diff options
author | lloyd <[email protected]> | 2006-07-01 21:42:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-07-01 21:42:35 +0000 |
commit | 8b4e6498cb339ec33e0eb1ab8ad72724dc61523d (patch) | |
tree | 1b3dc42ea95bf05519c90d45d741dcf6dfaa3be5 /src/init_def.cpp | |
parent | 6601628f84f52535adec1f34fe46c5e7039770cc (diff) |
Just some small cleanups / variable renames
Diffstat (limited to 'src/init_def.cpp')
-rw-r--r-- | src/init_def.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/init_def.cpp b/src/init_def.cpp index 513454292..26e759120 100644 --- a/src/init_def.cpp +++ b/src/init_def.cpp @@ -65,22 +65,25 @@ void initialize(const std::string& arg_string) if(min_entropy != 0 && args.seed_rng()) { - u32bit total_bits = 0; + u32bit bits_so_far = 0; + for(u32bit j = 0; j != 4; ++j) { - total_bits += global_state().seed_prng(true, - min_entropy - total_bits); - if(total_bits >= min_entropy) + u32bit to_get = min_entropy - bits_so_far; + + bits_so_far += global_state().seed_prng(true, to_get); + + if(bits_so_far >= min_entropy) break; } - if(total_bits < min_entropy) + if(bits_so_far < min_entropy) throw PRNG_Unseeded("Unable to collect sufficient entropy"); } if(!FIPS140::passes_self_tests()) { - set_global_state(0); + deinitialize(); throw Self_Test_Failure("FIPS-140 startup tests"); } } |