aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/mac/hmac
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-26 20:31:30 -0400
committerJack Lloyd <[email protected]>2017-10-26 22:26:15 -0400
commite6d45052efedfe49e99adb6318aaf56e0a9e8d7b (patch)
treec6c3ccd3cff3d04285940bf1d518c809e0653947 /src/lib/mac/hmac
parent315b002ecf00f6b6bb0f0d5200d1f39a83527e8f (diff)
Add checks that keyed algorithms are actually keyed before use
Previously calling update or encrypt without calling set_key first would result in invalid outputs or else crashing.
Diffstat (limited to 'src/lib/mac/hmac')
-rw-r--r--src/lib/mac/hmac/hmac.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp
index 32f62f0c2..244946d88 100644
--- a/src/lib/mac/hmac/hmac.cpp
+++ b/src/lib/mac/hmac/hmac.cpp
@@ -15,6 +15,7 @@ namespace Botan {
*/
void HMAC::add_data(const uint8_t input[], size_t length)
{
+ verify_key_set(m_ikey.empty() == false);
m_hash->update(input, length);
}
@@ -23,6 +24,7 @@ void HMAC::add_data(const uint8_t input[], size_t length)
*/
void HMAC::final_result(uint8_t mac[])
{
+ verify_key_set(m_okey.empty() == false);
m_hash->final(mac);
m_hash->update(m_okey);
m_hash->update(mac, output_length());