From: Tomas Mraz Date: Mon, 4 Sep 2023 06:59:53 +0000 (+0200) Subject: OSSL_PARAM_BLD_push_BN_pad(): Allow NULL BIGNUM X-Git-Tag: openssl-3.2.0-alpha1~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ce79d97e338c8eaacf67ce2e1a1b0fb1c639f11;p=thirdparty%2Fopenssl.git 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) --- diff --git a/crypto/param_build.c b/crypto/param_build.c index 7604f9bd6ce..def71f5718d 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); }