summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2018-09-03 07:37:38 +1000
committerPauli <paul.dale@oracle.com>2018-09-03 10:43:32 +1000
commit78ca7b7b319c7027310c56eaa05b8c295624a357 (patch)
treefcc6cfcb9a8e74c328cffa2a15f401bf0c0c8c41
parente24892ef83da5c363d39b52d0b459a26740b1ade (diff)
Check the return from BN_sub() in BN_X931_generate_Xpq().
Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7088) (cherry picked from commit 6bcfcf16bf6aef4f9ec267d8b86ae1bffd8deab9)
-rw-r--r--crypto/bn/bn_x931p.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c
index f444af3fea..116620a138 100644
--- a/crypto/bn/bn_x931p.c
+++ b/crypto/bn/bn_x931p.c
@@ -223,8 +223,10 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
for (i = 0; i < 1000; i++) {
if (!BN_rand(Xq, nbits, 1, 0))
goto err;
+
/* Check that |Xp - Xq| > 2^(nbits - 100) */
- BN_sub(t, Xp, Xq);
+ if (!BN_sub(t, Xp, Xq))
+ goto err;
if (BN_num_bits(t) > (nbits - 100))
break;
}