aboutsummaryrefslogtreecommitdiffstats
path: root/src/kdf
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-30 05:41:04 +0000
committerlloyd <[email protected]>2008-09-30 05:41:04 +0000
commit75ef07ee5378341adf054bd729232167c73e9e47 (patch)
tree7c84c43a431f0313b4f08b4267ff066650948bb0 /src/kdf
parentbc9e881d7c7a569664b5e753c12e4c8cbde06d2d (diff)
Remove lookup/libstate dependency on Lion, KDF1, KDF2, EMSA[1-4]
Diffstat (limited to 'src/kdf')
-rw-r--r--src/kdf/kdf1/kdf1.cpp13
-rw-r--r--src/kdf/kdf1/kdf1.h13
-rw-r--r--src/kdf/kdf2/kdf2.cpp12
-rw-r--r--src/kdf/kdf2/kdf2.h7
4 files changed, 14 insertions, 31 deletions
diff --git a/src/kdf/kdf1/kdf1.cpp b/src/kdf/kdf1/kdf1.cpp
index aac32db80..0ea375b30 100644
--- a/src/kdf/kdf1/kdf1.cpp
+++ b/src/kdf/kdf1/kdf1.cpp
@@ -4,8 +4,6 @@
*************************************************/
#include <botan/kdf1.h>
-#include <botan/lookup.h>
-#include <memory>
namespace Botan {
@@ -16,20 +14,9 @@ SecureVector<byte> KDF1::derive(u32bit,
const byte secret[], u32bit secret_len,
const byte P[], u32bit P_len) const
{
- std::auto_ptr<HashFunction> hash(get_hash(hash_name));
-
hash->update(secret, secret_len);
hash->update(P, P_len);
return hash->final();
}
-/*************************************************
-* KDF1 Constructor *
-*************************************************/
-KDF1::KDF1(const std::string& h_name) : hash_name(h_name)
- {
- if(!have_hash(hash_name))
- throw Algorithm_Not_Found(hash_name);
- }
-
}
diff --git a/src/kdf/kdf1/kdf1.h b/src/kdf/kdf1/kdf1.h
index 9aaa81d2b..6a4b0f113 100644
--- a/src/kdf/kdf1/kdf1.h
+++ b/src/kdf/kdf1/kdf1.h
@@ -7,6 +7,7 @@
#define BOTAN_KDF1_H__
#include <botan/kdf.h>
+#include <botan/base.h>
namespace Botan {
@@ -16,12 +17,16 @@ namespace Botan {
class BOTAN_DLL KDF1 : public KDF
{
public:
- SecureVector<byte> derive(u32bit, const byte[], u32bit,
- const byte[], u32bit) const;
+ SecureVector<byte> derive(u32bit,
+ const byte secret[], u32bit secret_len,
+ const byte P[], u32bit P_len) const;
- KDF1(const std::string&);
+ KDF1(HashFunction* h) : hash(h) {}
+ KDF1(const KDF1& other) : hash(other.hash->clone()) {}
+
+ ~KDF1() { delete hash; }
private:
- const std::string hash_name;
+ HashFunction* hash;
};
}
diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp
index fa975ccb9..fdeb09869 100644
--- a/src/kdf/kdf2/kdf2.cpp
+++ b/src/kdf/kdf2/kdf2.cpp
@@ -4,9 +4,7 @@
*************************************************/
#include <botan/kdf2.h>
-#include <botan/lookup.h>
#include <botan/loadstor.h>
-#include <memory>
namespace Botan {
@@ -20,7 +18,6 @@ SecureVector<byte> KDF2::derive(u32bit out_len,
SecureVector<byte> output;
u32bit counter = 1;
- std::auto_ptr<HashFunction> hash(get_hash(hash_name));
while(out_len && counter)
{
hash->update(secret, secret_len);
@@ -39,13 +36,4 @@ SecureVector<byte> KDF2::derive(u32bit out_len,
return output;
}
-/*************************************************
-* KDF2 Constructor *
-*************************************************/
-KDF2::KDF2(const std::string& h_name) : hash_name(h_name)
- {
- if(!have_hash(hash_name))
- throw Algorithm_Not_Found(hash_name);
- }
-
}
diff --git a/src/kdf/kdf2/kdf2.h b/src/kdf/kdf2/kdf2.h
index f3768f15f..33db36ad4 100644
--- a/src/kdf/kdf2/kdf2.h
+++ b/src/kdf/kdf2/kdf2.h
@@ -7,6 +7,7 @@
#define BOTAN_KDF2_H__
#include <botan/kdf.h>
+#include <botan/base.h>
namespace Botan {
@@ -19,9 +20,11 @@ class BOTAN_DLL KDF2 : public KDF
SecureVector<byte> derive(u32bit, const byte[], u32bit,
const byte[], u32bit) const;
- KDF2(const std::string&);
+ KDF2(HashFunction* h) : hash(h) {}
+ KDF2(const KDF2& other) : hash(other.hash->clone()) {}
+ ~KDF2() { delete hash; }
private:
- const std::string hash_name;
+ HashFunction* hash;
};
}