diff options
author | lloyd <[email protected]> | 2008-05-25 21:14:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-05-25 21:14:40 +0000 |
commit | 25609cd77358c4de86a9100dcd49b1d8ad07f19a (patch) | |
tree | c63ec72513883260e3124065dfd709b282a351eb /src | |
parent | 89e20a742ada5000c8a78fbbf0bf8bd3b13565eb (diff) |
Make the two parameters of Randpool (which underlying block cipher and MAC
to use) explicit arguments to the constructor instead of being hardcoded.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstate.cpp | 3 | ||||
-rw-r--r-- | src/randpool.cpp | 13 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/libstate.cpp b/src/libstate.cpp index b988625ce..7751216cb 100644 --- a/src/libstate.cpp +++ b/src/libstate.cpp @@ -273,7 +273,8 @@ void Library_State::initialize(const InitializerOptions& args, for(u32bit j = 0; j != sources.size(); ++j) add_entropy_source(sources[j]); - set_prng(new ANSI_X931_RNG("AES-256", new Randpool)); + set_prng(new ANSI_X931_RNG("AES-256", + new Randpool("AES-256", "HMAC(SHA-256)"))); if(args.seed_rng()) { diff --git a/src/randpool.cpp b/src/randpool.cpp index 46968eee1..be50ce2be 100644 --- a/src/randpool.cpp +++ b/src/randpool.cpp @@ -147,13 +147,12 @@ std::string Randpool::name() const /************************************************* * Randpool Constructor * *************************************************/ -Randpool::Randpool() : ITERATIONS_BEFORE_RESEED(8), POOL_BLOCKS(32) +Randpool::Randpool(const std::string& cipher_name, + const std::string& mac_name) : + ITERATIONS_BEFORE_RESEED(8), POOL_BLOCKS(32) { - const std::string CIPHER_NAME = "AES-256"; - const std::string MAC_NAME = "HMAC(SHA-256)"; - - cipher = get_block_cipher(CIPHER_NAME); - mac = get_mac(MAC_NAME); + cipher = get_block_cipher(cipher_name); + mac = get_mac(mac_name); const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE; const u32bit OUTPUT_LENGTH = mac->OUTPUT_LENGTH; @@ -165,7 +164,7 @@ Randpool::Randpool() : ITERATIONS_BEFORE_RESEED(8), POOL_BLOCKS(32) delete cipher; delete mac; throw Internal_Error("Randpool: Invalid algorithm combination " + - CIPHER_NAME + "/" + MAC_NAME); + cipher_name + "/" + mac_name); } buffer.create(BLOCK_SIZE); |