diff options
Diffstat (limited to 'Swiften/SASL')
-rw-r--r-- | Swiften/SASL/ClientAuthenticator.h | 3 | ||||
-rw-r--r-- | Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp | 18 | ||||
-rw-r--r-- | Swiften/SASL/DIGESTMD5ClientAuthenticator.h | 13 | ||||
-rw-r--r-- | Swiften/SASL/DIGESTMD5Properties.cpp | 8 | ||||
-rw-r--r-- | Swiften/SASL/DIGESTMD5Properties.h | 3 | ||||
-rw-r--r-- | Swiften/SASL/EXTERNALClientAuthenticator.cpp | 26 | ||||
-rw-r--r-- | Swiften/SASL/EXTERNALClientAuthenticator.h | 23 | ||||
-rw-r--r-- | Swiften/SASL/PLAINClientAuthenticator.h | 3 | ||||
-rw-r--r-- | Swiften/SASL/PLAINMessage.cpp | 6 | ||||
-rw-r--r-- | Swiften/SASL/PLAINMessage.h | 4 | ||||
-rw-r--r-- | Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp | 28 | ||||
-rw-r--r-- | Swiften/SASL/SCRAMSHA1ClientAuthenticator.h | 12 | ||||
-rw-r--r-- | Swiften/SASL/SConscript | 2 | ||||
-rw-r--r-- | Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp | 18 | ||||
-rw-r--r-- | Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp | 49 |
15 files changed, 144 insertions, 72 deletions
diff --git a/Swiften/SASL/ClientAuthenticator.h b/Swiften/SASL/ClientAuthenticator.h index 8710ac8..bc5b4f1 100644 --- a/Swiften/SASL/ClientAuthenticator.h +++ b/Swiften/SASL/ClientAuthenticator.h @@ -11,9 +11,10 @@ #include <vector> +#include <Swiften/Base/API.h> #include <Swiften/Base/SafeByteArray.h> #include <Swiften/Base/ByteArray.h> namespace Swift { - class ClientAuthenticator { + class SWIFTEN_API ClientAuthenticator { public: ClientAuthenticator(const std::string& name); diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp index 249a538..74cdb85 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -9,16 +9,12 @@ #include <cassert> -#include <Swiften/StringCodecs/MD5.h> #include <Swiften/StringCodecs/Hexify.h> #include <Swiften/Base/Concat.h> #include <Swiften/Base/Algorithm.h> +#include <Swiften/Crypto/CryptoProvider.h> namespace Swift { -DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { -} - -bool DIGESTMD5ClientAuthenticator::canBeUsed() { - return MD5::isAllowedForCrypto(); +DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce, CryptoProvider* crypto) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce), crypto(crypto) { } @@ -38,5 +34,5 @@ boost::optional<SafeByteArray> DIGESTMD5ClientAuthenticator::getResponse() const // Compute the response value ByteArray A1 = concat( - MD5::getHash( + crypto->getMD5Hash( concat(createSafeByteArray(getAuthenticationID().c_str()), createSafeByteArray(":"), createSafeByteArray(realm.c_str()), createSafeByteArray(":"), getPassword())), createByteArray(":"), createByteArray(*challenge.getValue("nonce")), createByteArray(":"), createByteArray(cnonce)); @@ -46,8 +42,8 @@ boost::optional<SafeByteArray> DIGESTMD5ClientAuthenticator::getResponse() const ByteArray A2 = createByteArray("AUTHENTICATE:" + digestURI); - std::string responseValue = Hexify::hexify(MD5::getHash(createByteArray( - Hexify::hexify(MD5::getHash(A1)) + ":" + std::string responseValue = Hexify::hexify(crypto->getMD5Hash(createByteArray( + Hexify::hexify(crypto->getMD5Hash(A1)) + ":" + *challenge.getValue("nonce") + ":" + nc + ":" + cnonce + ":" + qop + ":" - + Hexify::hexify(MD5::getHash(A2))))); + + Hexify::hexify(crypto->getMD5Hash(A2))))); diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h index 7ced962..d141401 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -11,4 +11,5 @@ #include <string> #include <vector> +#include <Swiften/Base/API.h> #include <Swiften/SASL/ClientAuthenticator.h> #include <Swiften/SASL/DIGESTMD5Properties.h> @@ -16,11 +17,12 @@ namespace Swift { - class DIGESTMD5ClientAuthenticator : public ClientAuthenticator { + class CryptoProvider; + + class SWIFTEN_API DIGESTMD5ClientAuthenticator : public ClientAuthenticator { public: - DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce); + DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce, CryptoProvider*); virtual boost::optional<SafeByteArray> getResponse() const; virtual bool setChallenge(const boost::optional<std::vector<unsigned char> >&); - static bool canBeUsed(); private: @@ -28,8 +30,9 @@ namespace Swift { Initial, Response, - Final, + Final } step; std::string host; std::string cnonce; + CryptoProvider* crypto; DIGESTMD5Properties challenge; }; diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp index 6d406e0..23a3476 100644 --- a/Swiften/SASL/DIGESTMD5Properties.cpp +++ b/Swiften/SASL/DIGESTMD5Properties.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -49,5 +49,5 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { ByteArray currentValue; for (size_t i = 0; i < data.size(); ++i) { - char c = data[i]; + char c = static_cast<char>(data[i]); if (inKey) { if (c == '=') { @@ -55,5 +55,5 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } else { - currentKey.push_back(c); + currentKey.push_back(static_cast<unsigned char>(c)); } } @@ -72,5 +72,5 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } else { - currentValue.push_back(c); + currentValue.push_back(static_cast<unsigned char>(c)); } } diff --git a/Swiften/SASL/DIGESTMD5Properties.h b/Swiften/SASL/DIGESTMD5Properties.h index ef87574..654208d 100644 --- a/Swiften/SASL/DIGESTMD5Properties.h +++ b/Swiften/SASL/DIGESTMD5Properties.h @@ -11,8 +11,9 @@ #include <string> +#include <Swiften/Base/API.h> #include <Swiften/Base/ByteArray.h> namespace Swift { - class DIGESTMD5Properties { + class SWIFTEN_API DIGESTMD5Properties { public: DIGESTMD5Properties(); diff --git a/Swiften/SASL/EXTERNALClientAuthenticator.cpp b/Swiften/SASL/EXTERNALClientAuthenticator.cpp new file mode 100644 index 0000000..a3016d1 --- /dev/null +++ b/Swiften/SASL/EXTERNALClientAuthenticator.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2012 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/SASL/EXTERNALClientAuthenticator.h> + +namespace Swift { + +EXTERNALClientAuthenticator::EXTERNALClientAuthenticator() : ClientAuthenticator("EXTERNAL"), finished(false) { +} + +boost::optional<SafeByteArray> EXTERNALClientAuthenticator::getResponse() const { + return boost::optional<SafeByteArray>(); +} + +bool EXTERNALClientAuthenticator::setChallenge(const boost::optional<ByteArray>&) { + if (finished) { + return false; + } + finished = true; + return true; +} + +} diff --git a/Swiften/SASL/EXTERNALClientAuthenticator.h b/Swiften/SASL/EXTERNALClientAuthenticator.h new file mode 100644 index 0000000..b986295 --- /dev/null +++ b/Swiften/SASL/EXTERNALClientAuthenticator.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2012 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <Swiften/SASL/ClientAuthenticator.h> +#include <Swiften/Base/ByteArray.h> + +namespace Swift { + class EXTERNALClientAuthenticator : public ClientAuthenticator { + public: + EXTERNALClientAuthenticator(); + + virtual boost::optional<SafeByteArray> getResponse() const; + virtual bool setChallenge(const boost::optional<ByteArray>&); + + private: + bool finished; + }; +} diff --git a/Swiften/SASL/PLAINClientAuthenticator.h b/Swiften/SASL/PLAINClientAuthenticator.h index 83e45c1..ad3a695 100644 --- a/Swiften/SASL/PLAINClientAuthenticator.h +++ b/Swiften/SASL/PLAINClientAuthenticator.h @@ -7,9 +7,10 @@ #pragma once +#include <Swiften/Base/API.h> #include <Swiften/SASL/ClientAuthenticator.h> #include <Swiften/Base/ByteArray.h> namespace Swift { - class PLAINClientAuthenticator : public ClientAuthenticator { + class SWIFTEN_API PLAINClientAuthenticator : public ClientAuthenticator { public: PLAINClientAuthenticator(); diff --git a/Swiften/SASL/PLAINMessage.cpp b/Swiften/SASL/PLAINMessage.cpp index 20ffea7..c43b446 100644 --- a/Swiften/SASL/PLAINMessage.cpp +++ b/Swiften/SASL/PLAINMessage.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -16,5 +16,5 @@ PLAINMessage::PLAINMessage(const SafeByteArray& value) { size_t i = 0; while (i < value.size() && value[i] != '\0') { - authzid += value[i]; + authzid += static_cast<char>(value[i]); ++i; } @@ -24,5 +24,5 @@ PLAINMessage::PLAINMessage(const SafeByteArray& value) { ++i; while (i < value.size() && value[i] != '\0') { - authcid += value[i]; + authcid += static_cast<char>(value[i]); ++i; } diff --git a/Swiften/SASL/PLAINMessage.h b/Swiften/SASL/PLAINMessage.h index 46ee8f7..3811b31 100644 --- a/Swiften/SASL/PLAINMessage.h +++ b/Swiften/SASL/PLAINMessage.h @@ -10,8 +10,10 @@ #include <string> + +#include <Swiften/Base/API.h> #include <Swiften/Base/SafeByteArray.h> namespace Swift { - class PLAINMessage { + class SWIFTEN_API PLAINMessage { public: PLAINMessage(const std::string& authcid, const SafeByteArray& password, const std::string& authzid = ""); diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp index 7842b4f..44fef76 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp @@ -11,9 +11,8 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/StringCodecs/SHA1.h> +#include <Swiften/Crypto/CryptoProvider.h> #include <Swiften/StringCodecs/Base64.h> -#include <Swiften/StringCodecs/HMAC_SHA1.h> #include <Swiften/StringCodecs/PBKDF2.h> -#include <Swiften/IDN/StringPrep.h> +#include <Swiften/IDN/IDNConverter.h> #include <Swiften/Base/Concat.h> @@ -37,5 +36,5 @@ static std::string escape(const std::string& s) { -SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding) { +SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding, IDNConverter* idnConverter, CryptoProvider* crypto) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding), idnConverter(idnConverter), crypto(crypto) { } @@ -45,7 +44,7 @@ boost::optional<SafeByteArray> SCRAMSHA1ClientAuthenticator::getResponse() const } else if (step == Proof) { - ByteArray clientKey = HMAC_SHA1()(saltedPassword, createByteArray("Client Key")); - ByteArray storedKey = SHA1::getHash(clientKey); - ByteArray clientSignature = HMAC_SHA1()(createSafeByteArray(storedKey), authMessage); + ByteArray clientKey = crypto->getHMACSHA1(saltedPassword, createByteArray("Client Key")); + ByteArray storedKey = crypto->getSHA1Hash(clientKey); + ByteArray clientSignature = crypto->getHMACSHA1(createSafeByteArray(storedKey), authMessage); ByteArray clientProof = clientKey; for (unsigned int i = 0; i < clientProof.size(); ++i) { @@ -95,18 +94,13 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray> } - ByteArray channelBindData; - if (useChannelBinding && tlsChannelBindingData) { - channelBindData = *tlsChannelBindingData; - } - // Compute all the values needed for the server signature try { - saltedPassword = PBKDF2::encode<HMAC_SHA1>(StringPrep::getPrepared(getPassword(), StringPrep::SASLPrep), salt, iterations); + saltedPassword = PBKDF2::encode(idnConverter->getStringPrepared(getPassword(), IDNConverter::SASLPrep), salt, iterations, crypto); } catch (const std::exception&) { } authMessage = concat(getInitialBareClientMessage(), createByteArray(","), initialServerMessage, createByteArray(","), getFinalMessageWithoutProof()); - ByteArray serverKey = HMAC_SHA1()(saltedPassword, createByteArray("Server Key")); - serverSignature = HMAC_SHA1()(serverKey, authMessage); + ByteArray serverKey = crypto->getHMACSHA1(saltedPassword, createByteArray("Server Key")); + serverSignature = crypto->getHMACSHA1(serverKey, authMessage); step = Proof; @@ -137,5 +131,5 @@ std::map<char, std::string> SCRAMSHA1ClientAuthenticator::parseMap(const std::st } else if (s[i] == ',') { - result[static_cast<size_t>(key)] = value; + result[key] = value; value = ""; expectKey = true; @@ -154,5 +148,5 @@ ByteArray SCRAMSHA1ClientAuthenticator::getInitialBareClientMessage() const { std::string authenticationID; try { - authenticationID = StringPrep::getPrepared(getAuthenticationID(), StringPrep::SASLPrep); + authenticationID = idnConverter->getStringPrepared(getAuthenticationID(), IDNConverter::SASLPrep); } catch (const std::exception&) { diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h index d140013..b713f9f 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -13,9 +13,13 @@ #include <Swiften/Base/ByteArray.h> #include <Swiften/SASL/ClientAuthenticator.h> +#include <Swiften/Base/API.h> namespace Swift { - class SCRAMSHA1ClientAuthenticator : public ClientAuthenticator { + class IDNConverter; + class CryptoProvider; + + class SWIFTEN_API SCRAMSHA1ClientAuthenticator : public ClientAuthenticator { public: - SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding = false); + SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding, IDNConverter*, CryptoProvider*); void setTLSChannelBindingData(const ByteArray& channelBindingData); @@ -44,4 +48,6 @@ namespace Swift { ByteArray serverSignature; bool useChannelBinding; + IDNConverter* idnConverter; + CryptoProvider* crypto; boost::optional<ByteArray> tlsChannelBindingData; }; diff --git a/Swiften/SASL/SConscript b/Swiften/SASL/SConscript index 085e49d..6509547 100644 --- a/Swiften/SASL/SConscript +++ b/Swiften/SASL/SConscript @@ -2,8 +2,8 @@ Import("swiften_env", "env") myenv = swiften_env.Clone() -myenv.MergeFlags(swiften_env["LIBIDN_FLAGS"]) objects = myenv.SwiftenObject([ "ClientAuthenticator.cpp", + "EXTERNALClientAuthenticator.cpp", "PLAINClientAuthenticator.cpp", "PLAINMessage.cpp", diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp index 38bab15..94bcd0a 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -13,4 +13,7 @@ #include <Swiften/Base/ByteArray.h> +#include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/Crypto/PlatformCryptoProvider.h> + using namespace Swift; @@ -24,6 +27,10 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { public: + void setUp() { + crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); + } + void testGetInitialResponse() { - DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh"); + DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get()); CPPUNIT_ASSERT(!testling.getResponse()); @@ -31,5 +38,5 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetResponse() { - DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh"); + DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -45,5 +52,5 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetResponse_WithAuthorizationID() { - DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh"); + DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), "myauthzid"); @@ -57,4 +64,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(createSafeByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response); } + + private: + boost::shared_ptr<CryptoProvider> crypto; }; diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp index f0ca01c..3341ad8 100644 --- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -12,4 +12,8 @@ #include <Swiften/SASL/SCRAMSHA1ClientAuthenticator.h> #include <Swiften/Base/ByteArray.h> +#include <Swiften/IDN/IDNConverter.h> +#include <Swiften/IDN/PlatformIDNConverter.h> +#include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/Crypto/PlatformCryptoProvider.h> using namespace Swift; @@ -40,8 +44,10 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { public: void setUp() { + idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create()); + crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); } void testGetInitialResponse() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH"); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -52,5 +58,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetInitialResponse_UsernameHasSpecialChars() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH"); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get()); testling.setCredentials(",us=,er=", createSafeByteArray("pass"), ""); @@ -61,5 +67,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetInitialResponse_WithAuthorizationID() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH"); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), "auth"); @@ -70,5 +76,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH"); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), "a=u,th"); @@ -79,5 +85,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get()); testling.setTLSChannelBindingData(createByteArray("xyza")); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -89,5 +95,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() { - SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true); + SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true, idnConverter.get(), crypto.get()); testling.setTLSChannelBindingData(createByteArray("xyza")); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -99,5 +105,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetFinalResponse() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); @@ -109,5 +115,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh", false); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setTLSChannelBindingData(createByteArray("xyza")); @@ -120,5 +126,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh", true); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", true, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setTLSChannelBindingData(createByteArray("xyza")); @@ -131,5 +137,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetFinalChallenge() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); @@ -141,5 +147,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -150,5 +156,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_InvalidClientNonce() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -159,5 +165,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_OnlyClientNonce() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -168,5 +174,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_InvalidIterations() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -177,5 +183,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_MissingIterations() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -186,5 +192,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_ZeroIterations() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -195,5 +201,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetChallenge_NegativeIterations() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); @@ -204,5 +210,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testSetFinalChallenge_InvalidChallenge() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); @@ -213,5 +219,5 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { void testGetResponseAfterFinalChallenge() { - SCRAMSHA1ClientAuthenticator testling("abcdefgh"); + SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get()); testling.setCredentials("user", createSafeByteArray("pass"), ""); testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); @@ -220,4 +226,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(!testling.getResponse()); } + + boost::shared_ptr<IDNConverter> idnConverter; + boost::shared_ptr<CryptoProvider> crypto; }; |