summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-22 17:20:19 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-22 17:20:19 (GMT)
commit2c4ea892d1da498e486ce48d80de0eee547375f2 (patch)
tree6c9497468f0f93071fb7e93e258b8c43684619bc /Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
parent497dd9b099e5810057ebcd8a3f6755819cfecdef (diff)
downloadswift-2c4ea892d1da498e486ce48d80de0eee547375f2.zip
swift-2c4ea892d1da498e486ce48d80de0eee547375f2.tar.bz2
Add support for authorization ID to SCRAM-SHA-1.
Diffstat (limited to 'Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp')
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index b55e5e4..8621b85 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -17,7 +17,7 @@ SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const String& nonce)
ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
if (step == Initial) {
- return "n,," + getInitialBareClientMessage();
+ return getGS2Header() + getInitialBareClientMessage();
}
else {
ByteArray clientKey = HMACSHA1::getResult(saltedPassword, "Client Key");
@@ -27,7 +27,7 @@ ByteArray SCRAMSHA1ClientAuthenticator::getResponse() const {
for (unsigned int i = 0; i < clientProof.getSize(); ++i) {
clientProof[i] ^= clientSignature[i];
}
- ByteArray result = ByteArray("c=biwsCg==,r=") + clientnonce + serverNonce + ",p=" + Base64::encode(clientProof);
+ ByteArray result = ByteArray("c=") + Base64::encode(getGS2Header()) + ",r=" + clientnonce + serverNonce + ",p=" + Base64::encode(clientProof);
return result;
}
}
@@ -66,7 +66,7 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const ByteArray& challenge) {
// Compute all the values needed for the server signature
saltedPassword = PBKDF2::encode(StringPrep::getPrepared(getPassword(), StringPrep::SASLPrep), salt, iterations);
- authMessage = getInitialBareClientMessage() + "," + initialServerMessage + "," + "c=biwsCg==," + "r=" + clientnonce + serverNonce;
+ authMessage = getInitialBareClientMessage() + "," + initialServerMessage + "," + "c=" + Base64::encode(getGS2Header()) + ",r=" + clientnonce + serverNonce;
ByteArray serverKey = HMACSHA1::getResult(saltedPassword, "Server Key");
serverSignature = HMACSHA1::getResult(serverKey, authMessage);
@@ -124,4 +124,8 @@ ByteArray SCRAMSHA1ClientAuthenticator::getInitialBareClientMessage() const {
return ByteArray(String("n=" + escapedAuthenticationID + ",r=" + clientnonce));
}
+ByteArray SCRAMSHA1ClientAuthenticator::getGS2Header() const {
+ return ByteArray("n,") + getAuthorizationID() + ",";
+}
+
}