From 33bb3dca54ecef2599b756d27b66781e14d06ae3 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 30 Sep 2008 06:20:10 +0000 Subject: Remove lookup from Randpool, HMAC, CMAC, CBC-MAC, TLS-PRF, and PBKDF2 --- src/rng/randpool/randpool.cpp | 17 +++++++++-------- src/rng/randpool/randpool.h | 7 +++++-- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/rng/randpool') diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index 69ef3b9e7..d7d1763ec 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -4,7 +4,6 @@ *************************************************/ #include -#include #include #include #include @@ -180,13 +179,15 @@ std::string Randpool::name() const /************************************************* * Randpool Constructor * *************************************************/ -Randpool::Randpool(const std::string& cipher_name, - const std::string& mac_name) : - ITERATIONS_BEFORE_RESEED(128), POOL_BLOCKS(32) +Randpool::Randpool(BlockCipher* cipher_in, + MessageAuthenticationCode* mac_in, + u32bit pool_blocks, + u32bit iter_before_reseed) : + ITERATIONS_BEFORE_RESEED(iter_before_reseed), + POOL_BLOCKS(pool_blocks), + cipher(cipher_in), + mac(mac_in) { - 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; @@ -197,7 +198,7 @@ Randpool::Randpool(const std::string& cipher_name, delete cipher; delete mac; throw Internal_Error("Randpool: Invalid algorithm combination " + - cipher_name + "/" + mac_name); + cipher->name() + "/" + mac->name()); } buffer.create(BLOCK_SIZE); diff --git a/src/rng/randpool/randpool.h b/src/rng/randpool/randpool.h index b68dec765..16ffcefd6 100644 --- a/src/rng/randpool/randpool.h +++ b/src/rng/randpool/randpool.h @@ -27,13 +27,16 @@ class BOTAN_DLL Randpool : public RandomNumberGenerator void add_entropy_source(EntropySource*); void add_entropy(const byte[], u32bit); - Randpool(const std::string&, const std::string&); + Randpool(BlockCipher*, MessageAuthenticationCode*, + u32bit pool_blocks = 32, + u32bit iterations_before_reseed = 128); + ~Randpool(); private: void update_buffer(); void mix_pool(); - const u32bit ITERATIONS_BEFORE_RESEED, POOL_BLOCKS; + u32bit ITERATIONS_BEFORE_RESEED, POOL_BLOCKS; BlockCipher* cipher; MessageAuthenticationCode* mac; -- cgit v1.2.3