summaryrefslogtreecommitdiffstats
path: root/comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp')
-rw-r--r--comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp b/comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp
new file mode 100644
index 0000000000..3de261c55f
--- /dev/null
+++ b/comm/third_party/botan/src/lib/kdf/kdf1/kdf1.cpp
@@ -0,0 +1,33 @@
+/*
+* KDF1
+* (C) 1999-2007 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/kdf1.h>
+
+namespace Botan {
+
+size_t KDF1::kdf(uint8_t key[], size_t key_len,
+ const uint8_t secret[], size_t secret_len,
+ const uint8_t salt[], size_t salt_len,
+ const uint8_t label[], size_t label_len) const
+ {
+ m_hash->update(secret, secret_len);
+ m_hash->update(label, label_len);
+ m_hash->update(salt, salt_len);
+
+ if(key_len < m_hash->output_length())
+ {
+ secure_vector<uint8_t> v = m_hash->final();
+ copy_mem(key, v.data(), key_len);
+ return key_len;
+ }
+
+ m_hash->final(key);
+ // FIXME: returns truncated output
+ return m_hash->output_length();
+ }
+
+}