Preventing flaws in cryptographic implementations