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, ...@@ -303,21 +303,28 @@ rsa_generate_keypair(struct rsa_public_key *pub,
/* If we didn't have a given e, generate one now. */ /* If we didn't have a given e, generate one now. */
if (e_size) if (e_size)
for (;;) {
{ int retried = 0;
bignum_random_size(pub->e, e_size, for (;;)
random_ctx, random); {
bignum_random_size(pub->e, e_size,
random_ctx, random);
/* Make sure it's odd and that the most significant bit is /* Make sure it's odd and that the most significant bit is
* set */ * set */
mpz_setbit(pub->e, 0); mpz_setbit(pub->e, 0);
mpz_setbit(pub->e, e_size - 1); mpz_setbit(pub->e, e_size - 1);
/* Needs gmp-3, or inverse might be negative. */ /* Needs gmp-3, or inverse might be negative. */
if (mpz_invert(key->d, pub->e, phi)) if (mpz_invert(key->d, pub->e, phi))
break; break;
else if (progress) progress(progress_ctx, 'e');
} if (progress) progress(progress_ctx, 'e');
retried = 1;
}
if (retried && progress)
progress(progress_ctx, '\n');
}
else else
{ {
/* Must always succeed, as we already that e /* 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