Secure transformation of cryptographic protocols