diff options
Diffstat (limited to 'Swiften/StringCodecs/HMACSHA1.cpp')
m--------- | Swiften | 0 | ||||
-rw-r--r-- | Swiften/StringCodecs/HMACSHA1.cpp | 39 |
2 files changed, 0 insertions, 39 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/StringCodecs/HMACSHA1.cpp b/Swiften/StringCodecs/HMACSHA1.cpp deleted file mode 100644 index f4066cb..0000000 --- a/Swiften/StringCodecs/HMACSHA1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Swiften/StringCodecs/HMACSHA1.h" - -#include <cassert> - -#include "Swiften/StringCodecs/SHA1.h" -#include "Swiften/Base/ByteArray.h" - -namespace Swift { - -static const unsigned int B = 64; - -ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) { - assert(key.getSize() <= B); - - // Create the padded key - ByteArray paddedKey(key); - paddedKey.resize(B); - for (unsigned int i = key.getSize(); i < paddedKey.getSize(); ++i) { - paddedKey[i] = 0x0; - } - - // Create the first value - ByteArray x(paddedKey); - for (unsigned int i = 0; i < x.getSize(); ++i) { - x[i] ^= 0x36; - } - x += data; - - // Create the second value - ByteArray y(paddedKey); - for (unsigned int i = 0; i < y.getSize(); ++i) { - y[i] ^= 0x5c; - } - y += SHA1::getHash(x); - - return SHA1::getHash(y); -} - -} |