Skip to content

Commit

Permalink
Correct top for EC/DSA nonces if BN_DEBUG is on
Browse files Browse the repository at this point in the history
Otherwise following operations would bail out in bn_check_top().

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
(Merged from openssl#24265)

(cherry picked from commit a380ae8)
  • Loading branch information
t8m committed May 2, 2024
1 parent 1e602b4 commit b514513
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crypto/bn/bn_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ int ossl_bn_priv_rand_range_fixed_top(BIGNUM *r, const BIGNUM *range,
ossl_bn_mask_bits_fixed_top(r, n);
}
while (BN_ucmp(r, range) >= 0);
#ifdef BN_DEBUG
/* With BN_DEBUG on a fixed top number cannot be returned */
bn_correct_top(r);
#endif
}

return 1;
Expand Down Expand Up @@ -372,6 +376,10 @@ int ossl_bn_gen_dsa_nonce_fixed_top(BIGNUM *out, const BIGNUM *range,

if (BN_ucmp(out, range) < 0) {
ret = 1;
#ifdef BN_DEBUG
/* With BN_DEBUG on a fixed top number cannot be returned */
bn_correct_top(out);
#endif
goto end;
}
}
Expand Down

0 comments on commit b514513

Please sign in to comment.