commit 2472be710f8518caab1f62999c50970b475f162f Author: Angel Yankov Date: Wed May 28 16:17:10 2025 +0300 Fix ElGamal side channel issue Index: cryptopp-CRYPTOPP_8_9_0/pubkey.h =================================================================== --- cryptopp-CRYPTOPP_8_9_0.orig/pubkey.h +++ cryptopp-CRYPTOPP_8_9_0/pubkey.h @@ -1855,7 +1855,14 @@ public: SecByteBlock derivedKey(encAlg.GetSymmetricKeyLength(encAlg.GetMaxSymmetricPlaintextLength(ciphertextLength))); derivAlg.Derive(params, derivedKey, derivedKey.size(), z, q, parameters); - return encAlg.SymmetricDecrypt(derivedKey, ciphertext, ciphertextLength, plaintext, parameters); + DecodingResult res = encAlg.SymmetricDecrypt(derivedKey, ciphertext, ciphertextLength, plaintext, parameters); + Element z2 = agreeAlg.AgreeWithStaticPrivateKey(params, q, true, key.GetPrivateExponent()); + if (z == z2) { + } else { + return DecodingResult(); + } + return res; + } catch (DL_BadElement &) {