From 9132d9c10942e98f34fb7f1edc3141f73f0f3649 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Fri, 30 Oct 2015 17:48:45 +0100 Subject: Change Windows to Unix line endings Test-Information: Still builds and tests pass. Change-Id: I040423ab6f6934610e336f3af22d174a685af66a 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 - -#include - -using namespace Swift; - -CryptoProvider::~CryptoProvider() { -} +/* + * Copyright (c) 2013 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include + +#include + +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 - -using namespace Swift; - -Hash::~Hash() { -} +/* + * Copyright (c) 2013 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include + +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 - + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include + #include -#include -#include - -namespace Swift { +#include +#include + +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 getHash() = 0; - }; -} + public: + virtual ~Hash(); + + virtual Hash& update(const ByteArray& data) = 0; + virtual Hash& update(const SafeByteArray& data) = 0; + + virtual std::vector 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 - -#include - -#include -#if defined(SWIFTEN_PLATFORM_WIN32) -#include -#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER) -#include -#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER) -#include -#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 + +#include + +#include +#if defined(SWIFTEN_PLATFORM_WIN32) +#include +#elif defined(HAVE_COMMONCRYPTO_CRYPTO_PROVIDER) +#include +#elif defined(HAVE_OPENSSL_CRYPTO_PROVIDER) +#include +#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 - -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 + +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 -#include -#include - -#include -#include - -#ifdef SWIFTEN_PLATFORM_WIN32 -#include -#endif -#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER -#include -#endif -#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER -#include -#endif -#include - -using namespace Swift; - -template -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 sha = boost::shared_ptr(provider->createSHA1()); - sha->update(createByteArray("client/pc//Exodus 0.9.1getHash()); - } - - void testGetSHA1Hash_TwoUpdates() { - boost::shared_ptr sha = boost::shared_ptr(provider->createSHA1()); - sha->update(createByteArray("client/pc//Exodus 0.9.1update(createByteArray("http://jabber.org/protocol/disco#infogetHash()); - } - - void testGetSHA1Hash_NoData() { - boost::shared_ptr sha = boost::shared_ptr(provider->createSHA1()); - sha->update(std::vector()); - - 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.1getSHA1Hash(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 testling = boost::shared_ptr(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); -#endif -#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER -CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest); -#endif -#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER -CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest); -#endif +/* + * Copyright (c) 2010-2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include +#include +#include + +#include +#include + +#ifdef SWIFTEN_PLATFORM_WIN32 +#include +#endif +#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER +#include +#endif +#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER +#include +#endif +#include + +using namespace Swift; + +template +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 sha = boost::shared_ptr(provider->createSHA1()); + sha->update(createByteArray("client/pc//Exodus 0.9.1getHash()); + } + + void testGetSHA1Hash_TwoUpdates() { + boost::shared_ptr sha = boost::shared_ptr(provider->createSHA1()); + sha->update(createByteArray("client/pc//Exodus 0.9.1update(createByteArray("http://jabber.org/protocol/disco#infogetHash()); + } + + void testGetSHA1Hash_NoData() { + boost::shared_ptr sha = boost::shared_ptr(provider->createSHA1()); + sha->update(std::vector()); + + 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.1getSHA1Hash(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 testling = boost::shared_ptr(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); +#endif +#ifdef HAVE_OPENSSL_CRYPTO_PROVIDER +CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest); +#endif +#ifdef HAVE_COMMONCRYPTO_CRYPTO_PROVIDER +CPPUNIT_TEST_SUITE_REGISTRATION(CryptoProviderTest); +#endif -- cgit v0.10.2-6-g49f6