diff options
author | lloyd <[email protected]> | 2012-05-25 16:08:01 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-25 16:08:01 +0000 |
commit | dde0df62b9453f84d2abbe32a7e44e87487f7e80 (patch) | |
tree | 1431b1e1d8838b50564bbac40745152ecacbedd5 /src/mac/hmac | |
parent | fb6737d579cd0c205be509b5dae96ca95bd2563e (diff) |
Resize key arrays in HMAC and SSL3_MAC when the key is set.
Plus a few minor cleanups.
Diffstat (limited to 'src/mac/hmac')
-rw-r--r-- | src/mac/hmac/hmac.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mac/hmac/hmac.cpp b/src/mac/hmac/hmac.cpp index 61cb262d0..4b4ed2f70 100644 --- a/src/mac/hmac/hmac.cpp +++ b/src/mac/hmac/hmac.cpp @@ -37,6 +37,10 @@ void HMAC::final_result(byte mac[]) void HMAC::key_schedule(const byte key[], size_t length) { hash->clear(); + + i_key.resize(hash->hash_block_size()); + o_key.resize(hash->hash_block_size()); + std::fill(i_key.begin(), i_key.end(), 0x36); std::fill(o_key.begin(), o_key.end(), 0x5C); @@ -61,8 +65,8 @@ void HMAC::key_schedule(const byte key[], size_t length) void HMAC::clear() { hash->clear(); - zeroise(i_key); - zeroise(o_key); + i_key.clear(); + o_key.clear(); } /* @@ -88,9 +92,6 @@ HMAC::HMAC(HashFunction* hash_in) : hash(hash_in) { if(hash->hash_block_size() == 0) throw Invalid_Argument("HMAC cannot be used with " + hash->name()); - - i_key.resize(hash->hash_block_size()); - o_key.resize(hash->hash_block_size()); } } |