summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_x931p.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_x931p.c')
-rw-r--r--src/lib/libcrypto/bn/bn_x931p.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/lib/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c
index fc8d4c3c49..89c86c1ff7 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.5 2014/06/12 15:49:28 deraadt Exp $ */ 1/* $OpenBSD: bn_x931p.c,v 1.6 2015/02/09 15:49:22 jsing 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 */
@@ -107,17 +107,21 @@ BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp,
107 return 0; 107 return 0;
108 108
109 BN_CTX_start(ctx); 109 BN_CTX_start(ctx);
110 if (!p1) 110 if (p1 != NULL) {
111 p1 = BN_CTX_get(ctx); 111 if ((p1 = BN_CTX_get(ctx)) == NULL)
112 112 goto err;
113 if (!p2) 113 }
114 p2 = BN_CTX_get(ctx); 114 if (p2 != NULL) {
115 115 if ((p2 = BN_CTX_get(ctx)) == NULL)
116 t = BN_CTX_get(ctx); 116 goto err;
117 117 }
118 p1p2 = BN_CTX_get(ctx);
119 118
120 pm1 = BN_CTX_get(ctx); 119 if ((t = BN_CTX_get(ctx)) == NULL)
120 goto err;
121 if ((p1p2 = BN_CTX_get(ctx)) == NULL)
122 goto err;
123 if ((pm1 = BN_CTX_get(ctx)) == NULL)
124 goto err;
121 125
122 if (!bn_x931_derive_pi(p1, Xp1, ctx, cb)) 126 if (!bn_x931_derive_pi(p1, Xp1, ctx, cb))
123 goto err; 127 goto err;
@@ -213,7 +217,8 @@ BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
213 return 0; 217 return 0;
214 218
215 BN_CTX_start(ctx); 219 BN_CTX_start(ctx);
216 t = BN_CTX_get(ctx); 220 if ((t = BN_CTX_get(ctx)) == NULL)
221 return 0;
217 222
218 for (i = 0; i < 1000; i++) { 223 for (i = 0; i < 1000; i++) {
219 if (!BN_rand(Xq, nbits, 1, 0)) 224 if (!BN_rand(Xq, nbits, 1, 0))
@@ -247,10 +252,14 @@ BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,
247 int ret = 0; 252 int ret = 0;
248 253
249 BN_CTX_start(ctx); 254 BN_CTX_start(ctx);
250 if (!Xp1) 255 if (Xp1 != NULL) {
251 Xp1 = BN_CTX_get(ctx); 256 if ((Xp1 = BN_CTX_get(ctx)) == NULL)
252 if (!Xp2) 257 goto error;
253 Xp2 = BN_CTX_get(ctx); 258 }
259 if (Xp2 != NULL) {
260 if ((Xp2 = BN_CTX_get(ctx)) == NULL)
261 goto error;
262 }
254 263
255 if (!BN_rand(Xp1, 101, 0, 0)) 264 if (!BN_rand(Xp1, 101, 0, 0))
256 goto error; 265 goto error;