diff options
author | inoguchi <> | 2022-01-20 10:56:22 +0000 |
---|---|---|
committer | inoguchi <> | 2022-01-20 10:56:22 +0000 |
commit | 200c6c7f36f760bb809437722ecdf0a590a83b85 (patch) | |
tree | 12bac6114ff5c3089e6872fcf17c7878695f17d0 /src | |
parent | cd425e52a52e20b87cf9a7cd1d5ce5a75f86e3e4 (diff) | |
download | openbsd-200c6c7f36f760bb809437722ecdf0a590a83b85.tar.gz openbsd-200c6c7f36f760bb809437722ecdf0a590a83b85.tar.bz2 openbsd-200c6c7f36f760bb809437722ecdf0a590a83b85.zip |
Add and fix check for BN functions return value
ok jsing@ millert@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/bn_x931p.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c index a0a194aa34..7fc3b5c2ad 100644 --- a/src/lib/libcrypto/bn/bn_x931p.c +++ b/src/lib/libcrypto/bn/bn_x931p.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_x931p.c,v 1.12 2021/12/04 16:09:59 tb Exp $ */ | 1 | /* $OpenBSD: bn_x931p.c,v 1.13 2022/01/20 10:56:22 inoguchi Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2005. | 3 | * project 2005. |
4 | */ | 4 | */ |
@@ -139,13 +139,13 @@ BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, | |||
139 | 139 | ||
140 | /* First set p to value of Rp */ | 140 | /* First set p to value of Rp */ |
141 | 141 | ||
142 | if (!BN_mod_inverse_ct(p, p2, p1, ctx)) | 142 | if (BN_mod_inverse_ct(p, p2, p1, ctx) == NULL) |
143 | goto err; | 143 | goto err; |
144 | 144 | ||
145 | if (!BN_mul(p, p, p2, ctx)) | 145 | if (!BN_mul(p, p, p2, ctx)) |
146 | goto err; | 146 | goto err; |
147 | 147 | ||
148 | if (!BN_mod_inverse_ct(t, p1, p2, ctx)) | 148 | if (BN_mod_inverse_ct(t, p1, p2, ctx) == NULL) |
149 | goto err; | 149 | goto err; |
150 | 150 | ||
151 | if (!BN_mul(t, t, p1, ctx)) | 151 | if (!BN_mul(t, t, p1, ctx)) |
@@ -237,7 +237,8 @@ BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) | |||
237 | if (!BN_rand(Xq, nbits, 1, 0)) | 237 | if (!BN_rand(Xq, nbits, 1, 0)) |
238 | goto err; | 238 | goto err; |
239 | /* Check that |Xp - Xq| > 2^(nbits - 100) */ | 239 | /* Check that |Xp - Xq| > 2^(nbits - 100) */ |
240 | BN_sub(t, Xp, Xq); | 240 | if (!BN_sub(t, Xp, Xq)) |
241 | goto err; | ||
241 | if (BN_num_bits(t) > (nbits - 100)) | 242 | if (BN_num_bits(t) > (nbits - 100)) |
242 | break; | 243 | break; |
243 | } | 244 | } |