9 #include <botan/hmac.h>
16 void HMAC::add_data(
const uint8_t input[],
size_t length)
18 m_hash->update(input, length);
24 void HMAC::final_result(uint8_t mac[])
27 m_hash->update(m_okey);
30 m_hash->update(m_ikey);
36 void HMAC::key_schedule(
const uint8_t key[],
size_t length)
40 m_ikey.resize(m_hash->hash_block_size());
41 m_okey.resize(m_hash->hash_block_size());
43 std::fill(m_ikey.begin(), m_ikey.end(), 0x36);
44 std::fill(m_okey.begin(), m_okey.end(), 0x5C);
46 if(length > m_hash->hash_block_size())
48 secure_vector<uint8_t> hmac_key = m_hash->process(key, length);
49 xor_buf(m_ikey, hmac_key, hmac_key.size());
50 xor_buf(m_okey, hmac_key, hmac_key.size());
58 m_hash->update(m_ikey);
76 return "HMAC(" + m_hash->name() +
")";
84 return new HMAC(m_hash->clone());
92 if(m_hash->hash_block_size() == 0)
void xor_buf(T out[], const T in[], size_t length)
MessageAuthenticationCode * clone() const override
void zap(std::vector< T, Alloc > &vec)
size_t output_length() const override
std::string name() const override
std::unique_ptr< HashFunction > m_hash