From 2ce79d97e338c8eaacf67ce2e1a1b0fb1c639f11 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Mon, 4 Sep 2023 08:59:53 +0200 Subject: OSSL_PARAM_BLD_push_BN_pad(): Allow NULL BIGNUM This was supported previously and regressed with commit 17898ec6011cc583c5af69ca8f25f5d165ff3e6a Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21945) --- crypto/param_build.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crypto') diff --git a/crypto/param_build.c b/crypto/param_build.c index 7604f9bd6c..def71f5718 100644 --- a/crypto/param_build.c +++ b/crypto/param_build.c @@ -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); } -- cgit v1.2.3