summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorfullwaywang <fullwaywang@tencent.com>2023-06-21 15:00:06 +0800
committerPauli <pauli@openssl.org>2023-06-26 08:08:15 +1000
commit8d6ea2d2c3cfdb1f09898ee98362b057893e6f14 (patch)
tree63ee778e1dc156e949a5015c0eb481b848647bd9 /crypto
parenta6f46005413b49265aa91b2e00930a17b494df78 (diff)
Check for 0 modulus in BN_RECP_CTX_set.
The function BN_RECP_CTX_set did not check whether arg d is zero, in which case an early failure should be returned to the invoker. This is a similar fix to the cognate defect of CVE-2015-1794. Fixes #21111 CLA: trivial Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21255) (cherry picked from commit 43596b306b1fe06da3b1a99e07c0cf235898010d)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/bn/bn_recp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index 96a6b19ab0..aebe8a223b 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -44,7 +44,7 @@ void BN_RECP_CTX_free(BN_RECP_CTX *recp)
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
{
- if (!BN_copy(&(recp->N), d))
+ if (BN_is_zero(d) || !BN_copy(&(recp->N), d))
return 0;
BN_zero(&(recp->Nr));
recp->num_bits = BN_num_bits(d);