length of secret exponent is needed only when we create one

This commit is contained in:
Bodo Möller
2001-07-27 22:45:19 +00:00
parent 1a76a85c93
commit 80a8d1406b

View File

@@ -132,10 +132,9 @@ static int generate_key(DH *dh)
} }
mont=(BN_MONT_CTX *)dh->method_mont_p; mont=(BN_MONT_CTX *)dh->method_mont_p;
l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
if (generate_new_key) if (generate_new_key)
{ {
l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
if (!BN_rand(priv_key, l, 0, 0)) goto err; if (!BN_rand(priv_key, l, 0, 0)) goto err;
} }
if (!dh->meth->bn_mod_exp(dh, pub_key,dh->g,priv_key,dh->p,&ctx,mont)) goto err; if (!dh->meth->bn_mod_exp(dh, pub_key,dh->g,priv_key,dh->p,&ctx,mont)) goto err;