diff options
author | Daniel Neus <[email protected]> | 2016-07-19 16:33:38 +0200 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-07-20 14:21:04 +0200 |
commit | b7005fdc0094cd77d83e982b2d9c586303a09b80 (patch) | |
tree | 6dc82baef1070ba0271c40665315e0d511260be9 /src/tests/test_mac.cpp | |
parent | 308c7d5eda678566edd26e9ab20edbe772f46363 (diff) |
fix SipHash::clear() and MAC test improvements
Fix for SipHash::clear() which does not clear the complete state.
Test additions:
- add a test for MessageAuthenticationCode::verify_mac()
- test MessageAuthenticationCode::clear()
Diffstat (limited to 'src/tests/test_mac.cpp')
-rw-r--r-- | src/tests/test_mac.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp index 8bc58e0e1..c7efb7f08 100644 --- a/src/tests/test_mac.cpp +++ b/src/tests/test_mac.cpp @@ -51,11 +51,21 @@ class Message_Auth_Tests : public Text_Based_Test result.test_eq(provider, mac->name(), algo); mac->set_key(key); - mac->update(input); result.test_eq(provider, "correct mac", mac->final(), expected); + // Test to make sure clear() resets what we need it to + mac->set_key( key ); + mac->update( "some discarded input"); + mac->clear(); + + // do the same to test verify_mac() + mac->set_key(key); + mac->update(input); + + result.test_eq(provider + " correct mac", mac->verify_mac(expected.data(), expected.size()), true); + if(input.size() > 2) { mac->set_key(key); // Poly1305 requires the re-key @@ -64,6 +74,14 @@ class Message_Auth_Tests : public Text_Based_Test mac->update(input[input.size()-1]); result.test_eq(provider, "split mac", mac->final(), expected); + + // do the same to test verify_mac() + mac->set_key(key); + mac->update(input[ 0 ]); + mac->update(&input[ 1 ], input.size() - 2); + mac->update(input[ input.size() - 1 ]); + + result.test_eq(provider + " split mac", mac->verify_mac(expected.data(), expected.size()), true); } } |