diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Crypto/UnitTest | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Crypto/UnitTest')
-rw-r--r-- | Swiften/Crypto/UnitTest/CryptoProviderTest.cpp | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp b/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp index 3e40ecf..d37e776 100644 --- a/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp +++ b/Swiften/Crypto/UnitTest/CryptoProviderTest.cpp @@ -26,123 +26,123 @@ using namespace Swift; template <typename CryptoProviderType> class CryptoProviderTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(CryptoProviderTest); + 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(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(testGetMD5Hash_Empty); + CPPUNIT_TEST(testGetMD5Hash_Alphabet); + CPPUNIT_TEST(testMD5Incremental); - CPPUNIT_TEST(testGetHMACSHA1); - CPPUNIT_TEST(testGetHMACSHA1_KeyLongerThanBlockSize); - - CPPUNIT_TEST_SUITE_END(); + CPPUNIT_TEST(testGetHMACSHA1); + CPPUNIT_TEST(testGetHMACSHA1_KeyLongerThanBlockSize); - public: - void setUp() { - provider = new CryptoProviderType(); - } + CPPUNIT_TEST_SUITE_END(); - void tearDown() { - delete provider; - } + public: + void setUp() { + provider = new CryptoProviderType(); + } - //////////////////////////////////////////////////////////// - // 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<")); + void tearDown() { + delete provider; + } - 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()); - } + //////////////////////////////////////////////////////////// + // SHA-1 + //////////////////////////////////////////////////////////// - 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<")); + 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()); - } + 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>()); + 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("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), sha->getHash()); - } + 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 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 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_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)); + 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); + } - 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())); + 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("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result); - } - - - //////////////////////////////////////////////////////////// - // MD5 - //////////////////////////////////////////////////////////// + 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 testGetMD5Hash_Empty() { - ByteArray result(provider->getMD5Hash(createByteArray(""))); + void testGetSHA1HashStatic_NoData() { + ByteArray result(provider->getSHA1Hash(ByteArray())); - CPPUNIT_ASSERT_EQUAL(createByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result); - } + 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); + } - 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); - } + //////////////////////////////////////////////////////////// + // MD5 + //////////////////////////////////////////////////////////// - void testMD5Incremental() { - boost::shared_ptr<Hash> testling = boost::shared_ptr<Hash>(provider->createMD5()); - testling->update(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); - testling->update(createByteArray("abcdefghijklmnopqrstuvwxyz0123456789")); + void testGetMD5Hash_Empty() { + ByteArray result(provider->getMD5Hash(createByteArray(""))); - ByteArray result = testling->getHash(); + CPPUNIT_ASSERT_EQUAL(createByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result); + } - CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 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); + } - //////////////////////////////////////////////////////////// - // HMAC-SHA1 - //////////////////////////////////////////////////////////// + void testMD5Incremental() { + boost::shared_ptr<Hash> testling = boost::shared_ptr<Hash>(provider->createMD5()); + testling->update(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); + testling->update(createByteArray("abcdefghijklmnopqrstuvwxyz0123456789")); - 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); - } + ByteArray result = testling->getHash(); - 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); - } + CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result); + } - private: - CryptoProviderType* provider; + + //////////////////////////////////////////////////////////// + // 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 |