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/ssl3mac | |
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/ssl3mac')
-rw-r--r-- | src/mac/ssl3mac/ssl3_mac.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mac/ssl3mac/ssl3_mac.cpp b/src/mac/ssl3mac/ssl3_mac.cpp index 8799c96a5..8979d1291 100644 --- a/src/mac/ssl3mac/ssl3_mac.cpp +++ b/src/mac/ssl3mac/ssl3_mac.cpp @@ -35,6 +35,14 @@ void SSL3_MAC::final_result(byte mac[]) void SSL3_MAC::key_schedule(const byte key[], size_t length) { hash->clear(); + + // Quirk to deal with specification bug + const size_t inner_hash_length = + (hash->name() == "SHA-160") ? 60 : hash->hash_block_size(); + + i_key.resize(inner_hash_length); + o_key.resize(inner_hash_length); + std::fill(i_key.begin(), i_key.end(), 0x36); std::fill(o_key.begin(), o_key.end(), 0x5C); @@ -50,8 +58,8 @@ void SSL3_MAC::key_schedule(const byte key[], size_t length) void SSL3_MAC::clear() { hash->clear(); - zeroise(i_key); - zeroise(o_key); + i_key.clear(); + o_key.clear(); } /* @@ -77,13 +85,6 @@ SSL3_MAC::SSL3_MAC(HashFunction* hash_in) : hash(hash_in) { if(hash->hash_block_size() == 0) throw Invalid_Argument("SSL3-MAC cannot be used with " + hash->name()); - - // Quirk to deal with specification bug - const size_t INNER_HASH_LENGTH = - (hash->name() == "SHA-160") ? 60 : hash->hash_block_size(); - - i_key.resize(INNER_HASH_LENGTH); - o_key.resize(INNER_HASH_LENGTH); } } |