summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp')
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index 5e6179f..5dc924e 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -36,7 +36,7 @@ ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
if (step == Initial) {
return getGS2Header() + getInitialBareClientMessage();
}
- else {
+ else if (step == Proof) {
ByteArray clientKey = HMACSHA1::getResult(saltedPassword, "Client Key");
ByteArray storedKey = SHA1::getHash(clientKey);
ByteArray clientSignature = HMACSHA1::getResult(storedKey, authMessage);
@@ -47,6 +47,9 @@ ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
ByteArray result = ByteArray("c=") + Base64::encode(getGS2Header()) + ",r=" + clientnonce + serverNonce + ",p=" + Base64::encode(clientProof);
return result;
}
+ else {
+ return ByteArray();
+ }
}
bool SCRAMSHA1ClientAuthenticator::setChallenge(const ByteArray& challenge) {
@@ -90,10 +93,14 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const ByteArray& challenge) {
step = Proof;
return true;
}
- else {
+ else if (step == Proof) {
ByteArray result = ByteArray("v=") + ByteArray(Base64::encode(serverSignature));
+ step = Final;
return challenge == result;
}
+ else {
+ return true;
+ }
}
std::map<char, String> SCRAMSHA1ClientAuthenticator::parseMap(const String& s) {