Skip to content

Commit

Permalink
ossl_param_build_set_multi_key_bn(): Do not set NULL BIGNUMs
Browse files Browse the repository at this point in the history
This makes them zeroes otherwise
where NULLs actually mean the values aren't present.

Fixes #21935

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from #22334)

(cherry picked from commit 15a39e7)
  • Loading branch information
t8m committed Oct 18, 2023
1 parent 33e18be commit 100198f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crypto/param_build_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,22 @@ int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *params,
{
int i, sz = sk_BIGNUM_const_num(stk);
OSSL_PARAM *p;

const BIGNUM *bn;

if (bld != NULL) {
for (i = 0; i < sz && names[i] != NULL; ++i) {
if (!OSSL_PARAM_BLD_push_BN(bld, names[i],
sk_BIGNUM_const_value(stk, i)))
bn = sk_BIGNUM_const_value(stk, i);
if (bn != NULL && !OSSL_PARAM_BLD_push_BN(bld, names[i], bn))
return 0;
}
return 1;
}

for (i = 0; i < sz && names[i] != NULL; ++i) {
bn = sk_BIGNUM_const_value(stk, i);
p = OSSL_PARAM_locate(params, names[i]);
if (p != NULL) {
if (!OSSL_PARAM_set_BN(p, sk_BIGNUM_const_value(stk, i)))
if (p != NULL && bn != NULL) {
if (!OSSL_PARAM_set_BN(p, bn))
return 0;
}
}
Expand Down

0 comments on commit 100198f

Please sign in to comment.