aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-06-01 14:34:07 +0000
committerlloyd <[email protected]>2012-06-01 14:34:07 +0000
commitf0baffd392e08344c968e8697c66978e1a61baeb (patch)
tree0e644c06c124afac3ba28136ecbb7a0266c0c9cf
parenta597c5ac36f012f76814fcfc1523d956871c0c0c (diff)
Missing source file from d8021f3e5aa8812a2843d6afd27bbe56d04af734
-rw-r--r--src/pbkdf/pbkdf.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/pbkdf/pbkdf.cpp b/src/pbkdf/pbkdf.cpp
new file mode 100644
index 000000000..8f29295f3
--- /dev/null
+++ b/src/pbkdf/pbkdf.cpp
@@ -0,0 +1,44 @@
+/*
+* PBKDF
+* (C) 2012 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/pbkdf.h>
+#include <botan/internal/assert.h>
+
+namespace Botan {
+
+OctetString PBKDF::derive_key(size_t output_len,
+ const std::string& passphrase,
+ const byte salt[], size_t salt_len,
+ size_t iterations) const
+ {
+ if(iterations == 0)
+ throw std::invalid_argument(name() + ": Invalid iteration count");
+
+ auto derived = key_derivation(output_len, passphrase,
+ salt, salt_len, iterations,
+ std::chrono::milliseconds(0));
+
+ BOTAN_ASSERT(derived.first == iterations,
+ "PBKDF used the correct number of iterations");
+
+ return derived.second;
+ }
+
+OctetString PBKDF::derive_key(size_t output_len,
+ const std::string& passphrase,
+ const byte salt[], size_t salt_len,
+ std::chrono::milliseconds ms,
+ size_t& iterations) const
+ {
+ auto derived = key_derivation(output_len, passphrase, salt, salt_len, 0, ms);
+
+ iterations = derived.first;
+
+ return derived.second;
+ }
+
+}