Erase temporary buffer in EVP_PKEY_get_bn_param()
authorAnatolii Lishchynskyi <iamnotacake@protonmail.com>
Wed, 29 Mar 2023 14:16:48 +0000 (17:16 +0300)
committerTomas Mraz <tomas@openssl.org>
Tue, 4 Apr 2023 10:05:25 +0000 (12:05 +0200)
commit34e4a962bca998cc2d6eb4be721153fbde2f4c35
tree52b850846d2cb9f365992d8760c0e4b5b900b3e5
parent540c2d175d3c7c28bb969a74f6fe0396f0addc1a
Erase temporary buffer in EVP_PKEY_get_bn_param()

Function EVP_PKEY_get_bn_param() uses temporary buffer (on stack or
heap allocated) to store serialized bignum, but after deserializing it
into BIGNUM*, the buffer is not erased and may contain sensitive data.

This change makes sure the buffer is erased if it was successfully
filled before. Unfortunately, it does not distinguish between public and
private key components, and will always erase the buffer.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20639)
crypto/evp/p_lib.c