aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/mac/gmac
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-28 14:14:16 -0400
committerJack Lloyd <[email protected]>2016-10-28 14:14:16 -0400
commit8863848ad3b21ad6e2cf626b75e991484be61a9f (patch)
tree342d79736b971a14413f07a952b349f19e49c9d2 /src/lib/mac/gmac
parent9ad816a5d8d74105558640b2f37baec50d8b920f (diff)
Add MAC::start_msg, update GMAC
GMAC needs a per-message nonce specified with `start`, and other MACs are capable of using nonces (Skein-MAC, for instance) so move this API up to MAC class. Change GMAC::clone to clone the owned cipher.
Diffstat (limited to 'src/lib/mac/gmac')
-rw-r--r--src/lib/mac/gmac/gmac.cpp14
-rw-r--r--src/lib/mac/gmac/gmac.h4
2 files changed, 4 insertions, 14 deletions
diff --git a/src/lib/mac/gmac/gmac.cpp b/src/lib/mac/gmac/gmac.cpp
index 946e22cf0..4461cf370 100644
--- a/src/lib/mac/gmac/gmac.cpp
+++ b/src/lib/mac/gmac/gmac.cpp
@@ -64,17 +64,7 @@ void GMAC::key_schedule(const byte key[], size_t size)
m_cipher->encrypt(m_H_ad.data(), m_H.data());
}
-void GMAC::start(const std::vector<byte>& nonce)
- {
- start(nonce.data(), nonce.size());
- }
-
-void GMAC::start(const secure_vector<byte>& nonce)
- {
- start(nonce.data(), nonce.size());
- }
-
-void GMAC::start(const byte nonce[], size_t nonce_len)
+void GMAC::start_msg(const byte nonce[], size_t nonce_len)
{
secure_vector<byte> y0(GCM_BS);
@@ -118,6 +108,6 @@ void GMAC::final_result(byte mac[])
MessageAuthenticationCode* GMAC::clone() const
{
- return new GMAC(BlockCipher::create(m_cipher->name()).release());
+ return new GMAC(m_cipher->clone());
}
}
diff --git a/src/lib/mac/gmac/gmac.h b/src/lib/mac/gmac/gmac.h
index b651c2e11..b05c5451f 100644
--- a/src/lib/mac/gmac/gmac.h
+++ b/src/lib/mac/gmac/gmac.h
@@ -53,7 +53,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
*/
void start(const std::vector<byte>& nonce);
- Key_Length_Specification key_spec() const
+ Key_Length_Specification key_spec() const override
{
return m_cipher->key_spec();
}
@@ -71,7 +71,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode,
private:
void add_data(const byte[], size_t) override;
void final_result(byte[]) override;
- void start_msg(const byte nonce[], size_t nonce_len);
+ void start_msg(const byte nonce[], size_t nonce_len) override;
void key_schedule(const byte key[], size_t size) override;
static const size_t GCM_BS = 16;