aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/kdf.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-29 19:09:22 +0000
committerlloyd <[email protected]>2008-09-29 19:09:22 +0000
commitee9965d3a59112d042df7569fde6a45302491499 (patch)
tree26ca5230867cdda27dde0100265ec3d5bb91ff7d /src/core/kdf.cpp
parent1371cecdcf42e1070512b888307871f81421469b (diff)
Move KDF, EME, and EMSA base classes from pubkey to core to remove a
false dependency on BigInt in the KDF/padding code.
Diffstat (limited to 'src/core/kdf.cpp')
-rw-r--r--src/core/kdf.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/core/kdf.cpp b/src/core/kdf.cpp
new file mode 100644
index 000000000..2d24d896c
--- /dev/null
+++ b/src/core/kdf.cpp
@@ -0,0 +1,70 @@
+/*************************************************
+* KDF Base Class Source File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/kdf.h>
+#include <botan/lookup.h>
+#include <botan/loadstor.h>
+#include <algorithm>
+#include <memory>
+
+namespace Botan {
+
+/*************************************************
+* Derive a key *
+*************************************************/
+SecureVector<byte> KDF::derive_key(u32bit key_len,
+ const MemoryRegion<byte>& secret,
+ const std::string& salt) const
+ {
+ return derive_key(key_len, secret, secret.size(),
+ reinterpret_cast<const byte*>(salt.data()),
+ salt.length());
+ }
+
+/*************************************************
+* Derive a key *
+*************************************************/
+SecureVector<byte> KDF::derive_key(u32bit key_len,
+ const MemoryRegion<byte>& secret,
+ const byte salt[], u32bit salt_len) const
+ {
+ return derive_key(key_len, secret.begin(), secret.size(),
+ salt, salt_len);
+ }
+
+/*************************************************
+* Derive a key *
+*************************************************/
+SecureVector<byte> KDF::derive_key(u32bit key_len,
+ const MemoryRegion<byte>& secret,
+ const MemoryRegion<byte>& salt) const
+ {
+ return derive_key(key_len, secret.begin(), secret.size(),
+ salt.begin(), salt.size());
+ }
+
+/*************************************************
+* Derive a key *
+*************************************************/
+SecureVector<byte> KDF::derive_key(u32bit key_len,
+ const byte secret[], u32bit secret_len,
+ const std::string& salt) const
+ {
+ return derive_key(key_len, secret, secret_len,
+ reinterpret_cast<const byte*>(salt.data()),
+ salt.length());
+ }
+
+/*************************************************
+* Derive a key *
+*************************************************/
+SecureVector<byte> KDF::derive_key(u32bit key_len,
+ const byte secret[], u32bit secret_len,
+ const byte salt[], u32bit salt_len) const
+ {
+ return derive(key_len, secret, secret_len, salt, salt_len);
+ }
+
+}