summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StringCodecs/PBKDF2.h')
-rw-r--r--Swiften/StringCodecs/PBKDF2.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/Swiften/StringCodecs/PBKDF2.h b/Swiften/StringCodecs/PBKDF2.h
index 0c04145..ae0bb17 100644
--- a/Swiften/StringCodecs/PBKDF2.h
+++ b/Swiften/StringCodecs/PBKDF2.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -8,18 +8,17 @@
#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/Base/Concat.h>
+#include <Swiften/Crypto/CryptoProvider.h>
namespace Swift {
class PBKDF2 {
public:
- template<typename PRF>
- static ByteArray encode(const SafeByteArray& password, const ByteArray& salt, int iterations) {
- PRF prf;
- ByteArray u = prf(password, concat(salt, createByteArray("\0\0\0\1", 4)));
+ static ByteArray encode(const SafeByteArray& password, const ByteArray& salt, int iterations, CryptoProvider* crypto) {
+ ByteArray u = crypto->getHMACSHA1(password, concat(salt, createByteArray("\0\0\0\1", 4)));
ByteArray result(u);
int i = 1;
while (i < iterations) {
- u = prf(password, u);
+ u = crypto->getHMACSHA1(password, u);
for (unsigned int j = 0; j < u.size(); ++j) {
result[j] ^= u[j];
}