diff options
Diffstat (limited to 'botan/src/kdf/kdf1')
-rw-r--r-- | botan/src/kdf/kdf1/info.txt | 14 | ||||
-rw-r--r-- | botan/src/kdf/kdf1/kdf1.cpp | 24 | ||||
-rw-r--r-- | botan/src/kdf/kdf1/kdf1.h | 36 |
3 files changed, 74 insertions, 0 deletions
diff --git a/botan/src/kdf/kdf1/info.txt b/botan/src/kdf/kdf1/info.txt new file mode 100644 index 0000000..ede1001 --- /dev/null +++ b/botan/src/kdf/kdf1/info.txt @@ -0,0 +1,14 @@ +realname "KDF1" + +define KDF1 + +load_on auto + +<add> +kdf1.h +kdf1.cpp +</add> + +<requires> +hash +</requires> diff --git a/botan/src/kdf/kdf1/kdf1.cpp b/botan/src/kdf/kdf1/kdf1.cpp new file mode 100644 index 0000000..539d9ed --- /dev/null +++ b/botan/src/kdf/kdf1/kdf1.cpp @@ -0,0 +1,24 @@ +/* +* KDF1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/kdf1.h> + +namespace Botan { + +/* +* KDF1 Key Derivation Mechanism +*/ +SecureVector<byte> KDF1::derive(u32bit, + const byte secret[], u32bit secret_len, + const byte P[], u32bit P_len) const + { + hash->update(secret, secret_len); + hash->update(P, P_len); + return hash->final(); + } + +} diff --git a/botan/src/kdf/kdf1/kdf1.h b/botan/src/kdf/kdf1/kdf1.h new file mode 100644 index 0000000..d657ccc --- /dev/null +++ b/botan/src/kdf/kdf1/kdf1.h @@ -0,0 +1,36 @@ +/* +* KDF1 +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_KDF1_H__ +#define BOTAN_KDF1_H__ + +#include <botan/kdf.h> +#include <botan/hash.h> + +namespace Botan { + +/* +* KDF1 +*/ +class BOTAN_DLL KDF1 : public KDF + { + public: + SecureVector<byte> derive(u32bit, + const byte secret[], u32bit secret_len, + const byte P[], u32bit P_len) const; + + KDF1(HashFunction* h) : hash(h) {} + KDF1(const KDF1& other) : KDF(), hash(other.hash->clone()) {} + + ~KDF1() { delete hash; } + private: + HashFunction* hash; + }; + +} + +#endif |