From 97924625aa344acf1f8aa2087c5996f20641ce51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sat, 12 Mar 2011 15:33:13 +0100 Subject: Simplified HMAC-SHA1 a bit. diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h index 90a4907..d274663 100644 --- a/Swiften/Base/ByteArray.h +++ b/Swiften/Base/ByteArray.h @@ -63,6 +63,10 @@ namespace Swift { return data_.resize(size); } + void resize(size_t size, char c) { + return data_.resize(size, c); + } + friend ByteArray operator+(const ByteArray& a, const ByteArray&b) { ByteArray result(a); result.data_.insert(result.data_.end(), b.data_.begin(), b.data_.end()); diff --git a/Swiften/StringCodecs/HMACSHA1.cpp b/Swiften/StringCodecs/HMACSHA1.cpp index 4ce46fc..0cea08f 100644 --- a/Swiften/StringCodecs/HMACSHA1.cpp +++ b/Swiften/StringCodecs/HMACSHA1.cpp @@ -20,10 +20,7 @@ ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) { // Create the padded key ByteArray paddedKey(key); - paddedKey.resize(B); - for (unsigned int i = key.getSize(); i < paddedKey.getSize(); ++i) { - paddedKey[i] = 0x0; - } + paddedKey.resize(B, 0x0); // Create the first value ByteArray x(paddedKey); -- cgit v0.10.2-6-g49f6