diff options
Diffstat (limited to 'src/lib/mac')
-rw-r--r-- | src/lib/mac/hmac/hmac.cpp | 7 | ||||
-rw-r--r-- | src/lib/mac/siphash/siphash.cpp | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp index aeadf4520..32f62f0c2 100644 --- a/src/lib/mac/hmac/hmac.cpp +++ b/src/lib/mac/hmac/hmac.cpp @@ -40,8 +40,11 @@ void HMAC::key_schedule(const uint8_t key[], size_t length) m_ikey.resize(m_hash->hash_block_size()); m_okey.resize(m_hash->hash_block_size()); - std::fill(m_ikey.begin(), m_ikey.end(), 0x36); - std::fill(m_okey.begin(), m_okey.end(), 0x5C); + const uint8_t ipad = 0x36; + const uint8_t opad = 0x5C; + + std::fill(m_ikey.begin(), m_ikey.end(), ipad); + std::fill(m_okey.begin(), m_okey.end(), opad); if(length > m_hash->hash_block_size()) { diff --git a/src/lib/mac/siphash/siphash.cpp b/src/lib/mac/siphash/siphash.cpp index c6ef68889..54adcd5a5 100644 --- a/src/lib/mac/siphash/siphash.cpp +++ b/src/lib/mac/siphash/siphash.cpp @@ -39,7 +39,8 @@ void SipRounds(uint64_t M, secure_vector<uint64_t>& V, size_t r) void SipHash::add_data(const uint8_t input[], size_t length) { - m_words += length; + // SipHash counts the message length mod 256 + m_words += static_cast<uint8_t>(length); if(m_mbuf_pos) { |