diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-08-12 17:29:21 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-08-12 17:32:17 (GMT) |
commit | c6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c (patch) | |
tree | 5968399a0d1ae73c1f197630bef3a0960e8525b5 /Swiften/StringCodecs/UnitTest | |
parent | 08cfaa06859238449d6848df4e170ffb6dc605d3 (diff) | |
download | swift-contrib-c6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c.zip swift-contrib-c6ffcd27e94d2f90fd4a3bcb5d2d3c6550ead59c.tar.bz2 |
Refactored stringcodec functions to make them independent of hash algos.
Diffstat (limited to 'Swiften/StringCodecs/UnitTest')
-rw-r--r-- | Swiften/StringCodecs/UnitTest/HMACTest.cpp (renamed from Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp) | 11 | ||||
-rw-r--r-- | Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp | 8 |
2 files changed, 11 insertions, 8 deletions
diff --git a/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp b/Swiften/StringCodecs/UnitTest/HMACTest.cpp index d8cba42..bdb0d96 100644 --- a/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp +++ b/Swiften/StringCodecs/UnitTest/HMACTest.cpp @@ -11,20 +11,21 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/Base/ByteArray.h> -#include <Swiften/StringCodecs/HMACSHA1.h> +#include <Swiften/StringCodecs/HMAC.h> +#include <Swiften/StringCodecs/SHA1.h> using namespace Swift; -class HMACSHA1Test : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(HMACSHA1Test); +class HMACTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(HMACTest); CPPUNIT_TEST(testGetResult); CPPUNIT_TEST_SUITE_END(); public: void testGetResult() { - ByteArray result(HMACSHA1::getResult(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); } }; -CPPUNIT_TEST_SUITE_REGISTRATION(HMACSHA1Test); +CPPUNIT_TEST_SUITE_REGISTRATION(HMACTest); diff --git a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp b/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp index d0aacd3..377e5c9 100644 --- a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp +++ b/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp @@ -12,6 +12,8 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/StringCodecs/PBKDF2.h> +#include <Swiften/StringCodecs/HMAC.h> +#include <Swiften/StringCodecs/SHA1.h> using namespace Swift; @@ -24,19 +26,19 @@ class PBKDF2Test : public CppUnit::TestFixture { public: void testGetResult_I1() { - ByteArray result(PBKDF2::encode(createSafeByteArray("password"), createByteArray("salt"), 1)); + ByteArray result(PBKDF2::encode<HMAC<SHA1> >(createSafeByteArray("password"), createByteArray("salt"), 1)); CPPUNIT_ASSERT_EQUAL(createByteArray("\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"), result); } void testGetResult_I2() { - ByteArray result(PBKDF2::encode(createSafeByteArray("password"), createByteArray("salt"), 2)); + ByteArray result(PBKDF2::encode<HMAC<SHA1> >(createSafeByteArray("password"), createByteArray("salt"), 2)); CPPUNIT_ASSERT_EQUAL(createByteArray("\xea\x6c\x1\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"), result); } void testGetResult_I4096() { - ByteArray result(PBKDF2::encode(createSafeByteArray("password"), createByteArray("salt"), 4096)); + ByteArray result(PBKDF2::encode<HMAC<SHA1> >(createSafeByteArray("password"), createByteArray("salt"), 4096)); CPPUNIT_ASSERT_EQUAL(createByteArray("\x4b\x00\x79\x1\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1", 20), result); } |