summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-10-30 16:48:45 (GMT)
committerSwift Review <review@swift.im>2015-11-09 14:45:17 (GMT)
commit9132d9c10942e98f34fb7f1edc3141f73f0f3649 (patch)
tree99d9a0e67a7db43f2b242beaa650f38bfdc3d3ed /Swiften/Crypto
parent8f55f01251b99d73291d4deb4311a0e0d1e9e06d (diff)
downloadswift-9132d9c10942e98f34fb7f1edc3141f73f0f3649.zip
swift-9132d9c10942e98f34fb7f1edc3141f73f0f3649.tar.bz2
Change Windows to Unix line endings
Test-Information: Still builds and tests pass. Change-Id: I040423ab6f6934610e336f3af22d174a685af66a
Diffstat (limited to 'Swiften/Crypto')
-rw-r--r--Swiften/Crypto/CryptoProvider.cpp28
-rw-r--r--Swiften/Crypto/Hash.cpp24
-rw-r--r--Swiften/Crypto/Hash.h44
-rw-r--r--Swiften/Crypto/PlatformCryptoProvider.cpp64
-rw-r--r--Swiften/Crypto/PlatformCryptoProvider.h34
-rw-r--r--Swiften/Crypto/UnitTest/CryptoProviderTest.cpp312
6 files changed, 253 insertions, 253 deletions
diff --git a/Swiften/Crypto/CryptoProvider.cpp b/Swiften/Crypto/CryptoProvider.cpp
index 9962b67..04b0b16 100644
--- a/Swiften/Crypto/CryptoProvider.cpp
+++ b/Swiften/Crypto/CryptoProvider.cpp
@@ -1,14 +1,14 @@
-/*
- * Copyright (c) 2013 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#include <Swiften/Crypto/CryptoProvider.h>
-
-#include <boost/shared_ptr.hpp>
-
-using namespace Swift;
-
-CryptoProvider::~CryptoProvider() {
-}
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Crypto/CryptoProvider.h>
+
+#include <boost/shared_ptr.hpp>
+
+using namespace Swift;
+
+CryptoProvider::~CryptoProvider() {
+}
diff --git a/Swiften/Crypto/Hash.cpp b/Swiften/Crypto/Hash.cpp
index d07346f..b945301 100644
--- a/Swiften/Crypto/Hash.cpp
+++ b/Swiften/Crypto/Hash.cpp
@@ -1,12 +1,12 @@
-/*
- * Copyright (c) 2013 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#include <Swiften/Crypto/Hash.h>
-
-using namespace Swift;
-
-Hash::~Hash() {
-}
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Crypto/Hash.h>
+
+using namespace Swift;
+
+Hash::~Hash() {
+}
diff --git a/Swiften/Crypto/Hash.h b/Swiften/Crypto/Hash.h
index c054e4e..f3a8937 100644
--- a/Swiften/Crypto/Hash.h
+++ b/Swiften/Crypto/Hash.h
@@ -1,25 +1,25 @@
-/*
+/*
* Copyright (c) 2013-2015 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#pragma once
-
-#include <vector>
-
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <vector>
+
#include <Swiften/Base/API.h>
-#include <Swiften/Base/ByteArray.h>
-#include <Swiften/Base/SafeByteArray.h>
-
-namespace Swift {
+#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/SafeByteArray.h>
+
+namespace Swift {
class SWIFTEN_API Hash {
- public:
- virtual ~Hash();
-
- virtual Hash& update(const ByteArray& data) = 0;
- virtual Hash& update(const SafeByteArray& data) = 0;
-
- virtual std::vector<unsigned char> getHash() = 0;
- };
-}
+ public:
+ virtual ~Hash();
+
+ virtual Hash& update(const ByteArray& data) = 0;
+ virtual Hash& update(const SafeByteArray& data) = 0;
+
+ virtual std::vector<unsigned char> getHash() = 0;
+ };
+}
diff --git a/Swiften/Crypto/PlatformCryptoProvider.cpp b/Swiften/Crypto/PlatformCryptoProvider.cpp
index f681da2..759909d 100644
--- a/Swiften/Crypto/PlatformCryptoProvider.cpp
+++ b/Swiften/Crypto/PlatformCryptoProvider.cpp
@@ -1,32 +1,32 @@
-/*
- * Copyright (c) 2013 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#include <Swiften/Crypto/PlatformCryptoProvider.h>
-
-#include <cassert>
-
-#include <Swiften/Base/Platform.h>
-#if defined(SWIFTEN_PLATFORM_WIN32)
-#include <Swiften/Crypto/WindowsCryptoProvider.h>
-#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER)
-#include <Swiften/Crypto/CommonCryptoCryptoProvider.h>
-#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER)
-#include <Swiften/Crypto/OpenSSLCryptoProvider.h>
-#endif
-
-using namespace Swift;
-
-CryptoProvider* PlatformCryptoProvider::create() {
-#if defined(SWIFTEN_PLATFORM_WIN32)
- return new WindowsCryptoProvider();
-#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER)
- return new CommonCryptoCryptoProvider();
-#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER)
- return new OpenSSLCryptoProvider();
-#endif
- assert(false);
- return NULL;
-}
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Crypto/PlatformCryptoProvider.h>
+
+#include <cassert>
+
+#include <Swiften/Base/Platform.h>
+#if defined(SWIFTEN_PLATFORM_WIN32)
+#include <Swiften/Crypto/WindowsCryptoProvider.h>
+#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER)
+#include <Swiften/Crypto/CommonCryptoCryptoProvider.h>
+#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER)
+#include <Swiften/Crypto/OpenSSLCryptoProvider.h>
+#endif
+
+using namespace Swift;
+
+CryptoProvider* PlatformCryptoProvider::create() {
+#if defined(SWIFTEN_PLATFORM_WIN32)
+ return new WindowsCryptoProvider();
+#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER)
+ return new CommonCryptoCryptoProvider();
+#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER)
+ return new OpenSSLCryptoProvider();
+#endif
+ assert(false);
+ return NULL;
+}
diff --git a/Swiften/Crypto/PlatformCryptoProvider.h b/Swiften/Crypto/PlatformCryptoProvider.h
index ddfe616..9584ab9 100644
--- a/Swiften/Crypto/PlatformCryptoProvider.h
+++ b/Swiften/Crypto/PlatformCryptoProvider.h
@@ -1,17 +1,17 @@
-/*
- * Copyright (c) 2013 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#pragma once
-
-#include <Swiften/Base/API.h>
-
-namespace Swift {
- class CryptoProvider;
-
- namespace PlatformCryptoProvider {
- SWIFTEN_API CryptoProvider* create();
- }
-}
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/API.h>
+
+namespace Swift {
+ class CryptoProvider;
+
+ namespace PlatformCryptoProvider {
+ SWIFTEN_API CryptoProvider* create();
+ }
+}
diff --git a/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp b/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp
index a53a0cf..3e40ecf 100644
--- a/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp
+++ b/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp
@@ -1,156 +1,156 @@
-/*
- * Copyright (c) 2010-2015 Isode Limited.
- * All rights reserved.
- * See the COPYING file for more information.
- */
-
-#include <Swiften/Base/ByteArray.h>
-#include <Swiften/Base/Platform.h>
-#include <QA/Checker/IO.h>
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-
-#ifdef SWIFTEN_PLATFORM_WIN32
-#include <Swiften/Crypto/WindowsCryptoProvider.h>
-#endif
-#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER
-#include <Swiften/Crypto/OpenSSLCryptoProvider.h>
-#endif
-#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER
-#include <Swiften/Crypto/CommonCryptoCryptoProvider.h>
-#endif
-#include <Swiften/Crypto/Hash.h>
-
-using namespace Swift;
-
-template <typename CryptoProviderType>
-class CryptoProviderTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(CryptoProviderTest);
-
- CPPUNIT_TEST(testGetSHA1Hash);
- CPPUNIT_TEST(testGetSHA1Hash_TwoUpdates);
- CPPUNIT_TEST(testGetSHA1Hash_NoData);
- CPPUNIT_TEST(testGetSHA1HashStatic);
- CPPUNIT_TEST(testGetSHA1HashStatic_Twice);
- CPPUNIT_TEST(testGetSHA1HashStatic_NoData);
-
- CPPUNIT_TEST(testGetMD5Hash_Empty);
- CPPUNIT_TEST(testGetMD5Hash_Alphabet);
- CPPUNIT_TEST(testMD5Incremental);
-
- CPPUNIT_TEST(testGetHMACSHA1);
- CPPUNIT_TEST(testGetHMACSHA1_KeyLongerThanBlockSize);
-
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- provider = new CryptoProviderType();
- }
-
- void tearDown() {
- delete provider;
- }
-
- ////////////////////////////////////////////////////////////
- // SHA-1
- ////////////////////////////////////////////////////////////
-
- void testGetSHA1Hash() {
- boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
- sha->update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha->getHash());
- }
-
- void testGetSHA1Hash_TwoUpdates() {
- boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
- sha->update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
- sha->update(createByteArray("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha->getHash());
- }
-
- void testGetSHA1Hash_NoData() {
- boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
- sha->update(std::vector<unsigned char>());
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), sha->getHash());
- }
-
- void testGetSHA1HashStatic() {
- ByteArray result(provider->getSHA1Hash(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<")));
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
- }
-
-
- void testGetSHA1HashStatic_Twice() {
- ByteArray input(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
- provider->getSHA1Hash(input);
- ByteArray result(provider->getSHA1Hash(input));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
- }
-
- void testGetSHA1HashStatic_NoData() {
- ByteArray result(provider->getSHA1Hash(ByteArray()));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result);
- }
-
-
- ////////////////////////////////////////////////////////////
- // MD5
- ////////////////////////////////////////////////////////////
-
- void testGetMD5Hash_Empty() {
- ByteArray result(provider->getMD5Hash(createByteArray("")));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result);
- }
-
- void testGetMD5Hash_Alphabet() {
- ByteArray result(provider->getMD5Hash(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")));
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
- }
-
- void testMD5Incremental() {
- boost::shared_ptr<Hash> testling = boost::shared_ptr<Hash>(provider->createMD5());
- testling->update(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
- testling->update(createByteArray("abcdefghijklmnopqrstuvwxyz0123456789"));
-
- ByteArray result = testling->getHash();
-
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
- }
-
-
- ////////////////////////////////////////////////////////////
- // HMAC-SHA1
- ////////////////////////////////////////////////////////////
-
- void testGetHMACSHA1() {
- ByteArray result(provider->getHMACSHA1(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 testGetHMACSHA1_KeyLongerThanBlockSize() {
- ByteArray result(provider->getHMACSHA1(createSafeByteArray("---------|---------|---------|---------|---------|----------|---------|"), createByteArray("foobar")));
- CPPUNIT_ASSERT_EQUAL(createByteArray("\xd6""n""\x8f""P|1""\xd3"",""\x6"" ""\xb9\xe3""gg""\x8e\xcf"" ]+""\xa"), result);
- }
-
- private:
- CryptoProviderType* provider;
-};
-
-#ifdef SWIFTEN_PLATFORM_WIN32
-CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<WindowsCryptoProvider>);
-#endif
-#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER
-CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<OpenSSLCryptoProvider>);
-#endif
-#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER
-CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<CommonCryptoCryptoProvider>);
-#endif
+/*
+ * Copyright (c) 2010-2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Platform.h>
+#include <QA/Checker/IO.h>
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#ifdef SWIFTEN_PLATFORM_WIN32
+#include <Swiften/Crypto/WindowsCryptoProvider.h>
+#endif
+#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER
+#include <Swiften/Crypto/OpenSSLCryptoProvider.h>
+#endif
+#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER
+#include <Swiften/Crypto/CommonCryptoCryptoProvider.h>
+#endif
+#include <Swiften/Crypto/Hash.h>
+
+using namespace Swift;
+
+template <typename CryptoProviderType>
+class CryptoProviderTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(CryptoProviderTest);
+
+ CPPUNIT_TEST(testGetSHA1Hash);
+ CPPUNIT_TEST(testGetSHA1Hash_TwoUpdates);
+ CPPUNIT_TEST(testGetSHA1Hash_NoData);
+ CPPUNIT_TEST(testGetSHA1HashStatic);
+ CPPUNIT_TEST(testGetSHA1HashStatic_Twice);
+ CPPUNIT_TEST(testGetSHA1HashStatic_NoData);
+
+ CPPUNIT_TEST(testGetMD5Hash_Empty);
+ CPPUNIT_TEST(testGetMD5Hash_Alphabet);
+ CPPUNIT_TEST(testMD5Incremental);
+
+ CPPUNIT_TEST(testGetHMACSHA1);
+ CPPUNIT_TEST(testGetHMACSHA1_KeyLongerThanBlockSize);
+
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ provider = new CryptoProviderType();
+ }
+
+ void tearDown() {
+ delete provider;
+ }
+
+ ////////////////////////////////////////////////////////////
+ // SHA-1
+ ////////////////////////////////////////////////////////////
+
+ void testGetSHA1Hash() {
+ boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
+ sha->update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha->getHash());
+ }
+
+ void testGetSHA1Hash_TwoUpdates() {
+ boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
+ sha->update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
+ sha->update(createByteArray("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha->getHash());
+ }
+
+ void testGetSHA1Hash_NoData() {
+ boost::shared_ptr<Hash> sha = boost::shared_ptr<Hash>(provider->createSHA1());
+ sha->update(std::vector<unsigned char>());
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), sha->getHash());
+ }
+
+ void testGetSHA1HashStatic() {
+ ByteArray result(provider->getSHA1Hash(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<")));
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
+ }
+
+
+ void testGetSHA1HashStatic_Twice() {
+ ByteArray input(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+ provider->getSHA1Hash(input);
+ ByteArray result(provider->getSHA1Hash(input));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
+ }
+
+ void testGetSHA1HashStatic_NoData() {
+ ByteArray result(provider->getSHA1Hash(ByteArray()));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result);
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ // MD5
+ ////////////////////////////////////////////////////////////
+
+ void testGetMD5Hash_Empty() {
+ ByteArray result(provider->getMD5Hash(createByteArray("")));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result);
+ }
+
+ void testGetMD5Hash_Alphabet() {
+ ByteArray result(provider->getMD5Hash(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")));
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
+ }
+
+ void testMD5Incremental() {
+ boost::shared_ptr<Hash> testling = boost::shared_ptr<Hash>(provider->createMD5());
+ testling->update(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
+ testling->update(createByteArray("abcdefghijklmnopqrstuvwxyz0123456789"));
+
+ ByteArray result = testling->getHash();
+
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ // HMAC-SHA1
+ ////////////////////////////////////////////////////////////
+
+ void testGetHMACSHA1() {
+ ByteArray result(provider->getHMACSHA1(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 testGetHMACSHA1_KeyLongerThanBlockSize() {
+ ByteArray result(provider->getHMACSHA1(createSafeByteArray("---------|---------|---------|---------|---------|----------|---------|"), createByteArray("foobar")));
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd6""n""\x8f""P|1""\xd3"",""\x6"" ""\xb9\xe3""gg""\x8e\xcf"" ]+""\xa"), result);
+ }
+
+ private:
+ CryptoProviderType* provider;
+};
+
+#ifdef SWIFTEN_PLATFORM_WIN32
+CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<WindowsCryptoProvider>);
+#endif
+#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER
+CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<OpenSSLCryptoProvider>);
+#endif
+#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER
+CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest<CommonCryptoCryptoProvider>);
+#endif