diff options
author | lloyd <[email protected]> | 2015-01-11 04:15:03 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-11 04:15:03 +0000 |
commit | b07e980986bd62ecaa951140dbe2c472bbd60d3b (patch) | |
tree | bb39a25c5e79448ac1886407561e8c31980501c2 /src/tests/test_mac.cpp | |
parent | 582e1cea2cb13c5d9d40610ff4566921f934ba27 (diff) |
Add SipHash
Diffstat (limited to 'src/tests/test_mac.cpp')
-rw-r--r-- | src/tests/test_mac.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp index 45092d4f3..8be57afbe 100644 --- a/src/tests/test_mac.cpp +++ b/src/tests/test_mac.cpp @@ -45,16 +45,36 @@ size_t mac_test(const std::string& algo, std::unique_ptr<MessageAuthenticationCode> mac(proto->clone()); + const std::vector<byte> in = hex_decode(in_hex); + const std::vector<byte> exp = hex_decode(out_hex); + mac->set_key(hex_decode(key_hex)); - mac->update(hex_decode(in_hex)); - auto h = mac->final(); + mac->update(in); + + const std::vector<byte> out = unlock(mac->final()); - if(h != hex_decode_locked(out_hex)) + if(out != exp) { - std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex << "\n"; + std::cout << algo << " " << provider << " got " << hex_encode(out) << " != " << hex_encode(exp) << "\n"; ++fails; } + + if(in.size() > 2) + { + mac->set_key(hex_decode(key_hex)); + mac->update(in[0]); + mac->update(&in[1], in.size() - 2); + mac->update(in[in.size()-1]); + + const std::vector<byte> out2 = unlock(mac->final()); + + if(out2 != exp) + { + std::cout << algo << " " << provider << " got " << hex_encode(out2) << " != " << hex_encode(exp) << "\n"; + ++fails; + } + } } return fails; |