OSSL_PARAM_BLD_push_BN_pad(): Allow NULL BIGNUM

This was supported previously and regressed
with commit 17898ec601

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21945)
This commit is contained in:
Tomas Mraz 2023-09-04 08:59:53 +02:00
parent 374945a9aa
commit 2ce79d97e3
1 changed files with 4 additions and 4 deletions

View File

@ -233,8 +233,8 @@ static int push_BN(OSSL_PARAM_BLD *bld, const char *key,
int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn)
{
if (BN_is_negative(bn))
return push_BN(bld, key, bn, bn == NULL ? 0 : BN_num_bytes(bn) + 1,
if (bn != NULL && BN_is_negative(bn))
return push_BN(bld, key, bn, BN_num_bytes(bn) + 1,
OSSL_PARAM_INTEGER);
return push_BN(bld, key, bn, bn == NULL ? 0 : BN_num_bytes(bn),
OSSL_PARAM_UNSIGNED_INTEGER);
@ -243,8 +243,8 @@ int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn, size_t sz)
{
if (BN_is_negative(bn))
return push_BN(bld, key, bn, bn == NULL ? 0 : BN_num_bytes(bn),
if (bn != NULL && BN_is_negative(bn))
return push_BN(bld, key, bn, BN_num_bytes(bn),
OSSL_PARAM_INTEGER);
return push_BN(bld, key, bn, sz, OSSL_PARAM_UNSIGNED_INTEGER);
}