version 1.17, 2001/06/23 15:12:18 |
version 1.17.2.1, 2002/03/07 17:37:46 |
|
|
if (cp != NULL || *prime == '\0') |
if (cp != NULL || *prime == '\0') |
goto fail; |
goto fail; |
|
|
dhg->g = BN_new(); |
if ((dhg->g = BN_new()) == NULL) |
dhg->p = BN_new(); |
fatal("parse_prime: BN_new failed"); |
|
if ((dhg->p = BN_new()) == NULL) |
|
fatal("parse_prime: BN_new failed"); |
if (BN_hex2bn(&dhg->g, gen) == 0) |
if (BN_hex2bn(&dhg->g, gen) == 0) |
goto failclean; |
goto failclean; |
|
|
|
|
return (1); |
return (1); |
|
|
failclean: |
failclean: |
BN_free(dhg->g); |
BN_clear_free(dhg->g); |
BN_free(dhg->p); |
BN_clear_free(dhg->p); |
fail: |
fail: |
error("Bad prime description in line %d", linenum); |
error("Bad prime description in line %d", linenum); |
return (0); |
return (0); |
|
|
linenum++; |
linenum++; |
if (!parse_prime(linenum, line, &dhg)) |
if (!parse_prime(linenum, line, &dhg)) |
continue; |
continue; |
BN_free(dhg.g); |
BN_clear_free(dhg.g); |
BN_free(dhg.p); |
BN_clear_free(dhg.p); |
|
|
if (dhg.size > max || dhg.size < min) |
if (dhg.size > max || dhg.size < min) |
continue; |
continue; |
|
|
if ((dhg.size > max || dhg.size < min) || |
if ((dhg.size > max || dhg.size < min) || |
dhg.size != best || |
dhg.size != best || |
linenum++ != which) { |
linenum++ != which) { |
BN_free(dhg.g); |
BN_clear_free(dhg.g); |
BN_free(dhg.p); |
BN_clear_free(dhg.p); |
continue; |
continue; |
} |
} |
break; |
break; |
|
|
BN_num_bits(dh->p), 2*need); |
BN_num_bits(dh->p), 2*need); |
do { |
do { |
if (dh->priv_key != NULL) |
if (dh->priv_key != NULL) |
BN_free(dh->priv_key); |
BN_clear_free(dh->priv_key); |
dh->priv_key = BN_new(); |
if ((dh->priv_key = BN_new()) == NULL) |
if (dh->priv_key == NULL) |
|
fatal("dh_gen_key: BN_new failed"); |
fatal("dh_gen_key: BN_new failed"); |
/* generate a 2*need bits random private exponent */ |
/* generate a 2*need bits random private exponent */ |
if (!BN_rand(dh->priv_key, 2*need, 0, 0)) |
if (!BN_rand(dh->priv_key, 2*need, 0, 0)) |
|
|
{ |
{ |
DH *dh; |
DH *dh; |
|
|
dh = DH_new(); |
if ((dh = DH_new()) == NULL) |
if (dh == NULL) |
fatal("dh_new_group_asc: DH_new"); |
fatal("DH_new"); |
|
|
|
if (BN_hex2bn(&dh->p, modulus) == 0) |
if (BN_hex2bn(&dh->p, modulus) == 0) |
fatal("BN_hex2bn p"); |
fatal("BN_hex2bn p"); |
|
|
{ |
{ |
DH *dh; |
DH *dh; |
|
|
dh = DH_new(); |
if ((dh = DH_new()) == NULL) |
if (dh == NULL) |
fatal("dh_new_group: DH_new"); |
fatal("DH_new"); |
|
dh->p = modulus; |
dh->p = modulus; |
dh->g = gen; |
dh->g = gen; |
|
|