From 6bcfcf16bf6aef4f9ec267d8b86ae1bffd8deab9 Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 3 Sep 2018 07:37:38 +1000 Subject: [PATCH] Check the return from BN_sub() in BN_X931_generate_Xpq(). Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/7088) --- crypto/bn/bn_x931p.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index 2331b01943..a197cdc5f2 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -184,8 +184,10 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) for (i = 0; i < 1000; i++) { if (!BN_priv_rand(Xq, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY)) 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; } -- 2.25.1