bn_x931p.c (302408) | bn_x931p.c (325337) |
---|---|
1/* bn_x931p.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 2005. 5 */ 6/* ==================================================================== 7 * Copyright (c) 2005 The OpenSSL Project. All rights reserved. 8 * --- 203 unchanged lines hidden (view full) --- 212 * - 1. By setting the top two bits we ensure that the lower bound is 213 * exceeded. 214 */ 215 if (!BN_rand(Xp, nbits, 1, 0)) 216 goto err; 217 218 BN_CTX_start(ctx); 219 t = BN_CTX_get(ctx); | 1/* bn_x931p.c */ 2/* 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 4 * 2005. 5 */ 6/* ==================================================================== 7 * Copyright (c) 2005 The OpenSSL Project. All rights reserved. 8 * --- 203 unchanged lines hidden (view full) --- 212 * - 1. By setting the top two bits we ensure that the lower bound is 213 * exceeded. 214 */ 215 if (!BN_rand(Xp, nbits, 1, 0)) 216 goto err; 217 218 BN_CTX_start(ctx); 219 t = BN_CTX_get(ctx); |
220 if (t == NULL) 221 goto err; |
|
220 221 for (i = 0; i < 1000; i++) { 222 if (!BN_rand(Xq, nbits, 1, 0)) 223 goto err; 224 /* Check that |Xp - Xq| > 2^(nbits - 100) */ 225 BN_sub(t, Xp, Xq); 226 if (BN_num_bits(t) > (nbits - 100)) 227 break; --- 22 unchanged lines hidden (view full) --- 250int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, 251 BIGNUM *Xp1, BIGNUM *Xp2, 252 const BIGNUM *Xp, 253 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) 254{ 255 int ret = 0; 256 257 BN_CTX_start(ctx); | 222 223 for (i = 0; i < 1000; i++) { 224 if (!BN_rand(Xq, nbits, 1, 0)) 225 goto err; 226 /* Check that |Xp - Xq| > 2^(nbits - 100) */ 227 BN_sub(t, Xp, Xq); 228 if (BN_num_bits(t) > (nbits - 100)) 229 break; --- 22 unchanged lines hidden (view full) --- 252int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, 253 BIGNUM *Xp1, BIGNUM *Xp2, 254 const BIGNUM *Xp, 255 const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) 256{ 257 int ret = 0; 258 259 BN_CTX_start(ctx); |
258 if (!Xp1) | 260 if (Xp1 == NULL) |
259 Xp1 = BN_CTX_get(ctx); | 261 Xp1 = BN_CTX_get(ctx); |
260 if (!Xp2) | 262 if (Xp2 == NULL) |
261 Xp2 = BN_CTX_get(ctx); | 263 Xp2 = BN_CTX_get(ctx); |
264 if (Xp1 == NULL || Xp2 == NULL) 265 goto error; |
|
262 263 if (!BN_rand(Xp1, 101, 0, 0)) 264 goto error; 265 if (!BN_rand(Xp2, 101, 0, 0)) 266 goto error; 267 if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb)) 268 goto error; 269 270 ret = 1; 271 272 error: 273 BN_CTX_end(ctx); 274 275 return ret; 276 277} | 266 267 if (!BN_rand(Xp1, 101, 0, 0)) 268 goto error; 269 if (!BN_rand(Xp2, 101, 0, 0)) 270 goto error; 271 if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb)) 272 goto error; 273 274 ret = 1; 275 276 error: 277 BN_CTX_end(ctx); 278 279 return ret; 280 281} |