aboutsummaryrefslogtreecommitdiffstats
path: root/src/kdf
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-10-08 15:39:22 +0000
committerlloyd <[email protected]>2008-10-08 15:39:22 +0000
commit60a47f9e5a095b0a1badb545233339aeaa353dbf (patch)
treeb5fafb725e651a47d4b6dde6a9d8a93d27bf1032 /src/kdf
parent8ffbc8cdb2ee4db93439721d95fc9f12c377d436 (diff)
Split kdf.h and kdf.cpp from core/ to kdf/kdf_base
Update dependencies as needed.
Diffstat (limited to 'src/kdf')
-rw-r--r--src/kdf/kdf1/info.txt4
-rw-r--r--src/kdf/kdf2/info.txt4
-rw-r--r--src/kdf/kdf_base/info.txt10
-rw-r--r--src/kdf/kdf_base/kdf.cpp66
-rw-r--r--src/kdf/kdf_base/kdf.h50
-rw-r--r--src/kdf/mgf1/info.txt4
-rw-r--r--src/kdf/ssl_prf/info.txt4
-rw-r--r--src/kdf/tls_prf/info.txt4
-rw-r--r--src/kdf/x942_prf/info.txt3
9 files changed, 148 insertions, 1 deletions
diff --git a/src/kdf/kdf1/info.txt b/src/kdf/kdf1/info.txt
index 65011907e..a4d2c36af 100644
--- a/src/kdf/kdf1/info.txt
+++ b/src/kdf/kdf1/info.txt
@@ -4,6 +4,10 @@ define KDF1
load_on auto
+<requires>
+kdf_base
+</requires>
+
<add>
kdf1.h
kdf1.cpp
diff --git a/src/kdf/kdf2/info.txt b/src/kdf/kdf2/info.txt
index 7fceffb18..46a88a392 100644
--- a/src/kdf/kdf2/info.txt
+++ b/src/kdf/kdf2/info.txt
@@ -4,6 +4,10 @@ define KDF2
load_on auto
+<requires>
+kdf_base
+</requires>
+
<add>
kdf2.cpp
kdf2.h
diff --git a/src/kdf/kdf_base/info.txt b/src/kdf/kdf_base/info.txt
new file mode 100644
index 000000000..fa5cca334
--- /dev/null
+++ b/src/kdf/kdf_base/info.txt
@@ -0,0 +1,10 @@
+realname "KDF Base Class"
+
+define KDF_BASE
+
+load_on auto
+
+<add>
+kdf.cpp
+kdf.h
+</add>
diff --git a/src/kdf/kdf_base/kdf.cpp b/src/kdf/kdf_base/kdf.cpp
new file mode 100644
index 000000000..a96f86e99
--- /dev/null
+++ b/src/kdf/kdf_base/kdf.cpp
@@ -0,0 +1,66 @@
+/*************************************************
+* KDF Base Class Source File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/kdf.h>
+
+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);
+ }
+
+}
diff --git a/src/kdf/kdf_base/kdf.h b/src/kdf/kdf_base/kdf.h
new file mode 100644
index 000000000..7d0c1866b
--- /dev/null
+++ b/src/kdf/kdf_base/kdf.h
@@ -0,0 +1,50 @@
+/*************************************************
+* KDF/MGF Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_KDF_BASE_H__
+#define BOTAN_KDF_BASE_H__
+
+#include <botan/secmem.h>
+#include <botan/types.h>
+
+namespace Botan {
+
+/*************************************************
+* Key Derivation Function *
+*************************************************/
+class BOTAN_DLL KDF
+ {
+ public:
+ SecureVector<byte> derive_key(u32bit, const MemoryRegion<byte>&,
+ const std::string& = "") const;
+ SecureVector<byte> derive_key(u32bit, const MemoryRegion<byte>&,
+ const MemoryRegion<byte>&) const;
+ SecureVector<byte> derive_key(u32bit, const MemoryRegion<byte>&,
+ const byte[], u32bit) const;
+
+ SecureVector<byte> derive_key(u32bit, const byte[], u32bit,
+ const std::string& = "") const;
+ SecureVector<byte> derive_key(u32bit, const byte[], u32bit,
+ const byte[], u32bit) const;
+
+ virtual ~KDF() {}
+ private:
+ virtual SecureVector<byte> derive(u32bit, const byte[], u32bit,
+ const byte[], u32bit) const = 0;
+ };
+
+/*************************************************
+* Mask Generation Function *
+*************************************************/
+class BOTAN_DLL MGF
+ {
+ public:
+ virtual void mask(const byte[], u32bit, byte[], u32bit) const = 0;
+ virtual ~MGF() {}
+ };
+
+}
+
+#endif
diff --git a/src/kdf/mgf1/info.txt b/src/kdf/mgf1/info.txt
index 2f704173d..1e91e8a9b 100644
--- a/src/kdf/mgf1/info.txt
+++ b/src/kdf/mgf1/info.txt
@@ -4,6 +4,10 @@ define MGF1
load_on dep
+<requires>
+kdf_base
+</requires>
+
<add>
mgf1.h
mgf1.cpp
diff --git a/src/kdf/ssl_prf/info.txt b/src/kdf/ssl_prf/info.txt
index c41b59b12..48796afaf 100644
--- a/src/kdf/ssl_prf/info.txt
+++ b/src/kdf/ssl_prf/info.txt
@@ -4,6 +4,10 @@ define SSL_V3_PRF
load_on auto
+<requires>
+kdf_base
+</requires>
+
<add>
prf_ssl3.h
prf_ssl3.cpp
diff --git a/src/kdf/tls_prf/info.txt b/src/kdf/tls_prf/info.txt
index 9f05f8729..a83b470ba 100644
--- a/src/kdf/tls_prf/info.txt
+++ b/src/kdf/tls_prf/info.txt
@@ -4,6 +4,10 @@ define TLS_V10_PRF
load_on auto
+<requires>
+kdf_base
+</requires>
+
<add>
prf_tls.h
prf_tls.cpp
diff --git a/src/kdf/x942_prf/info.txt b/src/kdf/x942_prf/info.txt
index 096745dce..e29c7bd9b 100644
--- a/src/kdf/x942_prf/info.txt
+++ b/src/kdf/x942_prf/info.txt
@@ -6,7 +6,8 @@ load_on auto
<requires>
core
-oid_lookup
+#kdf_base
+#oid_lookup
</requires>
<add>