summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp')
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index 0dc61b6..5d0ee9a 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -38,7 +38,7 @@ static String escape(const String& s) {
SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const String& nonce) : ClientAuthenticator("SCRAM-SHA-1"), step(Initial), clientnonce(nonce) {
}
-ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
+boost::optional<ByteArray> SCRAMSHA1ClientAuthenticator::getResponse() const {
if (step == Initial) {
return getGS2Header() + getInitialBareClientMessage();
}
@@ -54,13 +54,16 @@ ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
return result;
}
else {
- return ByteArray();
+ return boost::optional<ByteArray>();
}
}
-bool SCRAMSHA1ClientAuthenticator::setChallenge(const ByteArray& challenge) {
+bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray>& challenge) {
if (step == Initial) {
- initialServerMessage = challenge;
+ if (!challenge) {
+ return false;
+ }
+ initialServerMessage = *challenge;
std::map<char, String> keys = parseMap(String(initialServerMessage.getData(), initialServerMessage.getSize()));
@@ -102,7 +105,7 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const ByteArray& challenge) {
else if (step == Proof) {
ByteArray result = ByteArray("v=") + ByteArray(Base64::encode(serverSignature));
step = Final;
- return challenge == result;
+ return challenge && challenge == result;
}
else {
return true;