diff options
author | Jack Lloyd <[email protected]> | 2016-10-28 14:14:16 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-10-28 14:14:16 -0400 |
commit | 8863848ad3b21ad6e2cf626b75e991484be61a9f (patch) | |
tree | 342d79736b971a14413f07a952b349f19e49c9d2 /src/tests | |
parent | 9ad816a5d8d74105558640b2f37baec50d8b920f (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/tests')
-rw-r--r-- | src/tests/test_mac.cpp | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp index 43b19b14e..33972fabc 100644 --- a/src/tests/test_mac.cpp +++ b/src/tests/test_mac.cpp @@ -11,10 +11,6 @@ #include <botan/mac.h> #endif -#if defined(BOTAN_HAS_GMAC) - #include <botan/gmac.h> -#endif - namespace Botan_Tests { namespace { @@ -60,14 +56,7 @@ class Message_Auth_Tests : public Text_Based_Test result.test_eq(provider, mac->name(), algo); mac->set_key(key); - -#if defined(BOTAN_HAS_GMAC) - // GMAC needs to set an IV - if(Botan::GMAC* gmac = dynamic_cast<Botan::GMAC*>(mac.get())) - { - gmac->start(iv); - } -#endif + mac->start(iv); mac->update(input); @@ -80,13 +69,7 @@ class Message_Auth_Tests : public Text_Based_Test // do the same to test verify_mac() mac->set_key(key); -#if defined(BOTAN_HAS_GMAC) - // GMAC needs to set an IV - if(Botan::GMAC* gmac = dynamic_cast<Botan::GMAC*>(mac.get())) - { - gmac->start(iv); - } -#endif + mac->start(iv); mac->update(input); result.test_eq(provider + " correct mac", mac->verify_mac(expected.data(), expected.size()), true); @@ -94,13 +77,8 @@ class Message_Auth_Tests : public Text_Based_Test if(input.size() > 2) { mac->set_key(key); // Poly1305 requires the re-key -#if defined(BOTAN_HAS_GMAC) - // GMAC needs to set an IV - if(Botan::GMAC* gmac = dynamic_cast<Botan::GMAC*>(mac.get())) - { - gmac->start(iv); - } -#endif + mac->start(iv); + mac->update(input[0]); mac->update(&input[1], input.size() - 2); mac->update(input[input.size()-1]); @@ -109,13 +87,8 @@ class Message_Auth_Tests : public Text_Based_Test // do the same to test verify_mac() mac->set_key(key); -#if defined(BOTAN_HAS_GMAC) - // GMAC needs to set an IV - if(Botan::GMAC* gmac = dynamic_cast<Botan::GMAC*>(mac.get())) - { - gmac->start(iv); - } -#endif + mac->start(iv); + mac->update(input[ 0 ]); mac->update(&input[ 1 ], input.size() - 2); mac->update(input[ input.size() - 1 ]); |