diff options
Diffstat (limited to 'src/kdf/kdf1')
-rw-r--r-- | src/kdf/kdf1/kdf1.cpp | 35 | ||||
-rw-r--r-- | src/kdf/kdf1/kdf1.h | 29 | ||||
-rw-r--r-- | src/kdf/kdf1/modinfo.txt | 10 |
3 files changed, 74 insertions, 0 deletions
diff --git a/src/kdf/kdf1/kdf1.cpp b/src/kdf/kdf1/kdf1.cpp new file mode 100644 index 000000000..aac32db80 --- /dev/null +++ b/src/kdf/kdf1/kdf1.cpp @@ -0,0 +1,35 @@ +/************************************************* +* KDF1 Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include <botan/kdf1.h> +#include <botan/lookup.h> +#include <memory> + +namespace Botan { + +/************************************************* +* KDF1 Key Derivation Mechanism * +*************************************************/ +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 new file mode 100644 index 000000000..ebc1979fc --- /dev/null +++ b/src/kdf/kdf1/kdf1.h @@ -0,0 +1,29 @@ +/************************************************* +* KDF1 Header File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_KDF1_H__ +#define BOTAN_KDF1_H__ + +#include <botan/pk_util.h> + +namespace Botan { + +/************************************************* +* KDF1 * +*************************************************/ +class BOTAN_DLL KDF1 : public KDF + { + public: + SecureVector<byte> derive(u32bit, const byte[], u32bit, + const byte[], u32bit) const; + + KDF1(const std::string&); + private: + const std::string hash_name; + }; + +} + +#endif diff --git a/src/kdf/kdf1/modinfo.txt b/src/kdf/kdf1/modinfo.txt new file mode 100644 index 000000000..802df67d0 --- /dev/null +++ b/src/kdf/kdf1/modinfo.txt @@ -0,0 +1,10 @@ +realname "KDF1" + +define KDF1 + +load_on auto + +<add> +kdf1.h +kdf1.cpp +</add> |