aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kdf/kdf.h7
-rw-r--r--src/kdf/kdf1/kdf1.h3
-rw-r--r--src/kdf/kdf2/kdf2.h3
-rw-r--r--src/kdf/ssl_prf/prf_ssl3.h3
-rw-r--r--src/kdf/tls_prf/prf_tls.cpp3
-rw-r--r--src/kdf/tls_prf/prf_tls.h8
-rw-r--r--src/kdf/x942_prf/prf_x942.h5
7 files changed, 26 insertions, 6 deletions
diff --git a/src/kdf/kdf.h b/src/kdf/kdf.h
index 58d59d351..3ec912cfe 100644
--- a/src/kdf/kdf.h
+++ b/src/kdf/kdf.h
@@ -8,6 +8,7 @@
#ifndef BOTAN_KDF_BASE_H__
#define BOTAN_KDF_BASE_H__
+#include <botan/algo_base.h>
#include <botan/secmem.h>
#include <botan/types.h>
@@ -16,7 +17,7 @@ namespace Botan {
/**
* Key Derivation Function
*/
-class BOTAN_DLL KDF
+class BOTAN_DLL KDF : public Algorithm
{
public:
/**
@@ -77,7 +78,9 @@ class BOTAN_DLL KDF
const byte salt[],
size_t salt_len) const;
- virtual ~KDF() {}
+ void clear() {}
+
+ virtual KDF* clone() const = 0;
private:
virtual SecureVector<byte>
derive(size_t key_len,
diff --git a/src/kdf/kdf1/kdf1.h b/src/kdf/kdf1/kdf1.h
index fd950cd9b..f627235be 100644
--- a/src/kdf/kdf1/kdf1.h
+++ b/src/kdf/kdf1/kdf1.h
@@ -23,6 +23,9 @@ class BOTAN_DLL KDF1 : public KDF
const byte secret[], size_t secret_len,
const byte P[], size_t P_len) const;
+ std::string name() const { return "KDF1(" + hash->name() + ")"; }
+ KDF* clone() const { return new KDF1(hash->clone()); }
+
KDF1(HashFunction* h) : hash(h) {}
KDF1(const KDF1& other) : KDF(), hash(other.hash->clone()) {}
diff --git a/src/kdf/kdf2/kdf2.h b/src/kdf/kdf2/kdf2.h
index f2fd7630d..e85fe6d1c 100644
--- a/src/kdf/kdf2/kdf2.h
+++ b/src/kdf/kdf2/kdf2.h
@@ -22,6 +22,9 @@ class BOTAN_DLL KDF2 : public KDF
SecureVector<byte> derive(size_t, const byte[], size_t,
const byte[], size_t) const;
+ std::string name() const { return "KDF2(" + hash->name() + ")"; }
+ KDF* clone() const { return new KDF2(hash->clone()); }
+
KDF2(HashFunction* h) : hash(h) {}
KDF2(const KDF2& other) : KDF(), hash(other.hash->clone()) {}
~KDF2() { delete hash; }
diff --git a/src/kdf/ssl_prf/prf_ssl3.h b/src/kdf/ssl_prf/prf_ssl3.h
index 1340b149e..b07454be2 100644
--- a/src/kdf/ssl_prf/prf_ssl3.h
+++ b/src/kdf/ssl_prf/prf_ssl3.h
@@ -20,6 +20,9 @@ class BOTAN_DLL SSL3_PRF : public KDF
public:
SecureVector<byte> derive(size_t, const byte[], size_t,
const byte[], size_t) const;
+
+ std::string name() const { return "SSL3-PRF"; }
+ KDF* clone() const { return new SSL3_PRF; }
};
}
diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp
index 872997c28..2b57cdd25 100644
--- a/src/kdf/tls_prf/prf_tls.cpp
+++ b/src/kdf/tls_prf/prf_tls.cpp
@@ -85,9 +85,8 @@ SecureVector<byte> TLS_PRF::derive(size_t key_len,
/*
* TLS v1.2 PRF Constructor and Destructor
*/
-TLS_12_PRF::TLS_12_PRF(HashFunction* hash)
+TLS_12_PRF::TLS_12_PRF(MessageAuthenticationCode* mac) : hmac(mac)
{
- hmac = new HMAC(hash);
}
TLS_12_PRF::~TLS_12_PRF()
diff --git a/src/kdf/tls_prf/prf_tls.h b/src/kdf/tls_prf/prf_tls.h
index ee1b29df6..5237f17c0 100644
--- a/src/kdf/tls_prf/prf_tls.h
+++ b/src/kdf/tls_prf/prf_tls.h
@@ -24,6 +24,9 @@ class BOTAN_DLL TLS_PRF : public KDF
const byte secret[], size_t secret_len,
const byte seed[], size_t seed_len) const;
+ std::string name() const { return "TLS-PRF"; }
+ KDF* clone() const { return new TLS_PRF; }
+
TLS_PRF();
~TLS_PRF();
private:
@@ -41,7 +44,10 @@ class BOTAN_DLL TLS_12_PRF : public KDF
const byte secret[], size_t secret_len,
const byte seed[], size_t seed_len) const;
- TLS_12_PRF(HashFunction* hash);
+ std::string name() const { return "TLSv12-PRF(" + hmac->name() + ")"; }
+ KDF* clone() const { return new TLS_12_PRF(hmac->clone()); }
+
+ TLS_12_PRF(MessageAuthenticationCode* hmac);
~TLS_12_PRF();
private:
MessageAuthenticationCode* hmac;
diff --git a/src/kdf/x942_prf/prf_x942.h b/src/kdf/x942_prf/prf_x942.h
index 8efc6ea45..e6093eda6 100644
--- a/src/kdf/x942_prf/prf_x942.h
+++ b/src/kdf/x942_prf/prf_x942.h
@@ -21,7 +21,10 @@ class BOTAN_DLL X942_PRF : public KDF
SecureVector<byte> derive(size_t, const byte[], size_t,
const byte[], size_t) const;
- X942_PRF(const std::string&);
+ std::string name() const { return "X942_PRF(" + key_wrap_oid + ")"; }
+ KDF* clone() const { return new X942_PRF(key_wrap_oid); }
+
+ X942_PRF(const std::string& oid);
private:
std::string key_wrap_oid;
};