aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac/ssl3mac/ssl3_mac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mac/ssl3mac/ssl3_mac.cpp')
-rw-r--r--src/mac/ssl3mac/ssl3_mac.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mac/ssl3mac/ssl3_mac.cpp b/src/mac/ssl3mac/ssl3_mac.cpp
index a07622eb3..8979d1291 100644
--- a/src/mac/ssl3mac/ssl3_mac.cpp
+++ b/src/mac/ssl3mac/ssl3_mac.cpp
@@ -35,11 +35,20 @@ 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);
- i_key.copy(key, length);
- o_key.copy(key, length);
+ copy_mem(&i_key[0], key, length);
+ copy_mem(&o_key[0], key, length);
+
hash->update(i_key);
}
@@ -49,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();
}
/*
@@ -76,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);
}
}