summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-08-12 19:52:24 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-08-12 20:18:40 (GMT)
commit353e9d5cd422779888d21e3780a0cb8f299f0a93 (patch)
tree4b9235fe3d3abeec725a1a9c48950aa3adc21060 /Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
parent7917a635fb1cd67100391a0787942288481fc47b (diff)
downloadswift-contrib-353e9d5cd422779888d21e3780a0cb8f299f0a93.zip
swift-contrib-353e9d5cd422779888d21e3780a0cb8f299f0a93.tar.bz2
Don't hard-code HMAC block size.
Diffstat (limited to 'Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp')
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index bcd6c5d..7842b4f 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -12,8 +12,7 @@
#include <Swiften/StringCodecs/SHA1.h>
#include <Swiften/StringCodecs/Base64.h>
-#include <Swiften/StringCodecs/HMAC.h>
-#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/StringCodecs/HMAC_SHA1.h>
#include <Swiften/StringCodecs/PBKDF2.h>
#include <Swiften/IDN/StringPrep.h>
#include <Swiften/Base/Concat.h>
@@ -45,9 +44,9 @@ boost::optional<SafeByteArray> SCRAMSHA1ClientAuthenticator::getResponse() const
return createSafeByteArray(concat(getGS2Header(), getInitialBareClientMessage()));
}
else if (step == Proof) {
- ByteArray clientKey = HMAC<SHA1>()(saltedPassword, createByteArray("Client Key"));
+ ByteArray clientKey = HMAC_SHA1()(saltedPassword, createByteArray("Client Key"));
ByteArray storedKey = SHA1::getHash(clientKey);
- ByteArray clientSignature = HMAC<SHA1>()(createSafeByteArray(storedKey), authMessage);
+ ByteArray clientSignature = HMAC_SHA1()(createSafeByteArray(storedKey), authMessage);
ByteArray clientProof = clientKey;
for (unsigned int i = 0; i < clientProof.size(); ++i) {
clientProof[i] ^= clientSignature[i];
@@ -102,13 +101,13 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray>
// 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<HMAC_SHA1>(StringPrep::getPrepared(getPassword(), StringPrep::SASLPrep), salt, iterations);
}
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 = HMAC_SHA1()(saltedPassword, createByteArray("Server Key"));
+ serverSignature = HMAC_SHA1()(serverKey, authMessage);
step = Proof;
return true;