Commit 131d0d94 authored by Niels Möller's avatar Niels Möller
Browse files

(rsa_generate_keypair): Output a newline after a

non-empty line of 'e':s (bad e was chosen, try again).

Rev: src/nettle/rsa-keygen.c:1.2
parent ae7cfc81
......@@ -303,21 +303,28 @@ rsa_generate_keypair(struct rsa_public_key *pub,
/* If we didn't have a given e, generate one now. */
if (e_size)
for (;;)
{
bignum_random_size(pub->e, e_size,
random_ctx, random);
{
int retried = 0;
for (;;)
{
bignum_random_size(pub->e, e_size,
random_ctx, random);
/* Make sure it's odd and that the most significant bit is
* set */
mpz_setbit(pub->e, 0);
mpz_setbit(pub->e, e_size - 1);
/* Needs gmp-3, or inverse might be negative. */
if (mpz_invert(key->d, pub->e, phi))
break;
else if (progress) progress(progress_ctx, 'e');
}
/* Make sure it's odd and that the most significant bit is
* set */
mpz_setbit(pub->e, 0);
mpz_setbit(pub->e, e_size - 1);
/* Needs gmp-3, or inverse might be negative. */
if (mpz_invert(key->d, pub->e, phi))
break;
if (progress) progress(progress_ctx, 'e');
retried = 1;
}
if (retried && progress)
progress(progress_ctx, '\n');
}
else
{
/* Must always succeed, as we already that e
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment