diff options
Diffstat (limited to 'Swiften/StringCodecs/UnitTest/HMACTest.cpp')
-rw-r--r-- | Swiften/StringCodecs/UnitTest/HMACTest.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Swiften/StringCodecs/UnitTest/HMACTest.cpp b/Swiften/StringCodecs/UnitTest/HMACTest.cpp index bdb0d96..75ae23e 100644 --- a/Swiften/StringCodecs/UnitTest/HMACTest.cpp +++ b/Swiften/StringCodecs/UnitTest/HMACTest.cpp @@ -11,21 +11,26 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/Base/ByteArray.h> -#include <Swiften/StringCodecs/HMAC.h> -#include <Swiften/StringCodecs/SHA1.h> +#include <Swiften/StringCodecs/HMAC_SHA1.h> using namespace Swift; class HMACTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(HMACTest); CPPUNIT_TEST(testGetResult); + CPPUNIT_TEST(testGetResult_KeyLongerThanBlockSize); CPPUNIT_TEST_SUITE_END(); public: void testGetResult() { - ByteArray result(HMAC<SHA1>()(createSafeByteArray("foo"), createByteArray("foobar"))); + ByteArray result(HMAC_SHA1()(createSafeByteArray("foo"), createByteArray("foobar"))); CPPUNIT_ASSERT_EQUAL(createByteArray("\xa4\xee\xba\x8e\x63\x3d\x77\x88\x69\xf5\x68\xd0\x5a\x1b\x3d\xc7\x2b\xfd\x4\xdd"), result); } + + void testGetResult_KeyLongerThanBlockSize() { + ByteArray result(HMAC_SHA1()(createSafeByteArray("---------|---------|---------|---------|---------|----------|---------|"), createByteArray("foobar"))); + CPPUNIT_ASSERT_EQUAL(createByteArray("\xd6""n""\x8f""P|1""\xd3"",""\x6"" ""\xb9\xe3""gg""\x8e\xcf"" ]+""\xa"), result); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(HMACTest); |