Update HmacTests: add Sha1HmacTest
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "Hash/Md5.hpp"
|
||||
#include "Hash/Sha1.hpp"
|
||||
#include "Mac/Hmac.hpp"
|
||||
|
||||
using namespace Chaos::Mac::Hmac;
|
||||
using namespace Chaos::Hash::Md5;
|
||||
using namespace Chaos::Hash::Sha1;
|
||||
|
||||
TEST(HmacTests, RfcTest)
|
||||
{
|
||||
@@ -51,6 +53,28 @@ TEST(HmacTests, RfcTest)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HmacTests, Sha1HmacTest)
|
||||
{
|
||||
struct Helper
|
||||
{
|
||||
std::string operator()(const char * key, const char * data) const
|
||||
{
|
||||
Hmac<Sha1Hasher> hmac(key, key + strlen(key));
|
||||
hmac.Update(data, data + strlen(data));
|
||||
return hmac.Finish().ToHexString();
|
||||
}
|
||||
};
|
||||
|
||||
Helper hmacSha1;
|
||||
|
||||
{
|
||||
const char * key = "Two Generals'";
|
||||
const char * data = "Attack at dawn.";
|
||||
|
||||
ASSERT_EQ("20ccda1c4de0e206f3a47056f2abd40f731ff3db", hmacSha1(key, data));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HmacTests, LongKeyTest)
|
||||
{
|
||||
struct Helper
|
||||
|
||||
Reference in New Issue
Block a user