diff options
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ec_key.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 0ae1c3f367..1bbca360e2 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -721,6 +721,16 @@ int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key) return 0; /* + * Return `0` to comply with legacy behavior for this function, see + * https://github.com/openssl/openssl/issues/18744#issuecomment-1195175696 + */ + if (priv_key == NULL) { + BN_clear_free(key->priv_key); + key->priv_key = NULL; + return 0; /* intentional for legacy compatibility */ + } + + /* * We should never leak the bit length of the secret scalar in the key, * so we always set the `BN_FLG_CONSTTIME` flag on the internal `BIGNUM` * holding the secret scalar. |