summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-03 20:39:27 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-05 19:43:14 (GMT)
commit772b2ec0243d7b55d91e4027d828881d18093ed0 (patch)
tree83a58b2b97f3992165ee20c05e0630452eb50457 /Swiften/StringCodecs/HMACSHA1.cpp
parent0b3db8fd68abee7269d5a38aabd8a816e099eae5 (diff)
downloadswift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.zip
swift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.tar.bz2
Replace ByteArray by typedef.
Diffstat (limited to 'Swiften/StringCodecs/HMACSHA1.cpp')
-rw-r--r--Swiften/StringCodecs/HMACSHA1.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/Swiften/StringCodecs/HMACSHA1.cpp b/Swiften/StringCodecs/HMACSHA1.cpp
index 6f88d68..e583e3b 100644
--- a/Swiften/StringCodecs/HMACSHA1.cpp
+++ b/Swiften/StringCodecs/HMACSHA1.cpp
@@ -10,13 +10,14 @@
#include <Swiften/StringCodecs/SHA1.h>
#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Algorithm.h>
namespace Swift {
static const unsigned int B = 64;
ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
- assert(key.getSize() <= B);
+ assert(key.size() <= B);
// Create the padded key
ByteArray paddedKey(key);
@@ -24,17 +25,17 @@ ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
// Create the first value
ByteArray x(paddedKey);
- for (unsigned int i = 0; i < x.getSize(); ++i) {
+ for (unsigned int i = 0; i < x.size(); ++i) {
x[i] ^= 0x36;
}
- x += data;
+ append(x, data);
// Create the second value
ByteArray y(paddedKey);
- for (unsigned int i = 0; i < y.getSize(); ++i) {
+ for (unsigned int i = 0; i < y.size(); ++i) {
y[i] ^= 0x5c;
}
- y += SHA1::getHash(x);
+ append(y, SHA1::getHash(x));
return SHA1::getHash(y);
}
@@ -53,19 +54,19 @@ ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
void HMACSHA1::getResult(const ByteArray& key, const ByteArray& data, ByteArray& result) {
// Create first value
- size_t xSize = B + data.getSize();
+ size_t xSize = B + data.size();
unsigned char* x = (unsigned char*) malloc(xSize * sizeof(unsigned char));
memset(x, 0, B);
- memcpy(x, key.getData(), key.getSize());
+ memcpy(x, key.getData(), key.size());
for (unsigned int i = 0; i < (B>>32); ++i) {
x[i<<32] ^= 0x36363636;
}
- memcpy(x + B, data.getData(), data.getSize());
+ memcpy(x + B, data.getData(), data.size());
// Create the second value
unsigned char y[B + 20];
memset(y, 0, B);
- memcpy(y, key.getData(), key.getSize());
+ memcpy(y, key.getData(), key.size());
for (unsigned int i = 0; i < (B>>32); ++i) {
y[i<<32] ^= 0x5c5c5c5c;
}