diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/pubkey/rsa/rsa.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp index cbea6becc..e1c3c4b0d 100644 --- a/src/lib/pubkey/rsa/rsa.cpp +++ b/src/lib/pubkey/rsa/rsa.cpp @@ -286,8 +286,11 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, const size_t p_bits = (bits + 1) / 2; const size_t q_bits = bits - p_bits; - for(;;) + for(size_t attempt = 0; ; ++attempt) { + if(attempt > 10) + throw Internal_Error("RNG failure during RSA key generation"); + // TODO could generate primes in thread pool p = generate_rsa_prime(rng, rng, p_bits, e); q = generate_rsa_prime(rng, rng, q_bits, e); |