summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-04-26 20:07:58 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-04-27 11:02:06 (GMT)
commit5d8c328e236f57d7390d32f9ea7bd17a31e1e740 (patch)
treebebe606707a6b835fe3fd15e694d629b5e420947 /Swiften/StringCodecs/HMAC.h
parentaa131405927fc7f597ed06aff71abb0a30b59926 (diff)
downloadswift-5d8c328e236f57d7390d32f9ea7bd17a31e1e740.zip
swift-5d8c328e236f57d7390d32f9ea7bd17a31e1e740.tar.bz2
Removing third-party hash implementations.
Using library/platform implementation instead. Change-Id: I2457c2dad80e6fdda023a7f31c3906ff10fe09ed
Diffstat (limited to 'Swiften/StringCodecs/HMAC.h')
-rw-r--r--Swiften/StringCodecs/HMAC.h67
1 files changed, 0 insertions, 67 deletions
diff --git a/Swiften/StringCodecs/HMAC.h b/Swiften/StringCodecs/HMAC.h
deleted file mode 100644
index 8b02d88..0000000
--- a/Swiften/StringCodecs/HMAC.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <Swiften/Base/SafeByteArray.h>
-#include <Swiften/Base/ByteArray.h>
-#include <Swiften/Base/Algorithm.h>
-#include <cassert>
-
-namespace Swift {
- namespace HMAC_Detail {
- template<typename KeyType> struct KeyWrapper;
- template<> struct KeyWrapper<ByteArray> {
- ByteArray wrap(const ByteArray& hash) const {
- return hash;
- }
- };
- template<> struct KeyWrapper<SafeByteArray> {
- SafeByteArray wrap(const ByteArray& hash) const {
- return createSafeByteArray(hash);
- }
- };
-
- template<typename Hash, typename KeyType, int BlockSize>
- static ByteArray getHMAC(const KeyType& key, const ByteArray& data) {
- Hash hash;
-
- // Create the padded key
- KeyType paddedKey(key.size() <= BlockSize ? key : KeyWrapper<KeyType>().wrap(hash(key)));
- paddedKey.resize(BlockSize, 0x0);
-
- // Create the first value
- KeyType x(paddedKey);
- for (unsigned int i = 0; i < x.size(); ++i) {
- x[i] ^= 0x36;
- }
- append(x, data);
-
- // Create the second value
- KeyType y(paddedKey);
- for (unsigned int i = 0; i < y.size(); ++i) {
- y[i] ^= 0x5c;
- }
- append(y, hash(x));
-
- return hash(y);
- }
- }
-
- template<typename Hash, int BlockSize>
- class HMAC {
- private:
-
- public:
- ByteArray operator()(const ByteArray& key, const ByteArray& data) const {
- return HMAC_Detail::getHMAC<Hash,ByteArray,BlockSize>(key, data);
- }
-
- ByteArray operator()(const SafeByteArray& key, const ByteArray& data) const {
- return HMAC_Detail::getHMAC<Hash,SafeByteArray,BlockSize>(key, data);
- }
- };
-}