Botan  1.11.26
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::TLS_PRF Class Referencefinal

#include <prf_tls.h>

Inheritance diagram for Botan::TLS_PRF:
Botan::KDF

Public Types

typedef SCAN_Name Spec
 

Public Member Functions

KDFclone () const override
 
secure_vector< bytederive_key (size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
 
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
 
template<typename Alloc , typename Alloc2 >
secure_vector< bytederive_key (size_t key_len, const std::vector< byte, Alloc > &secret, const std::vector< byte, Alloc2 > &salt) const
 
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const byte salt[], size_t salt_len) const
 
secure_vector< bytederive_key (size_t key_len, const byte secret[], size_t secret_len, const std::string &salt="") const
 
size_t kdf (byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const override
 
std::string name () const override
 
 TLS_PRF ()
 

Static Public Member Functions

static std::unique_ptr< KDFcreate (const std::string &algo_spec, const std::string &provider="")
 
static std::vector< std::string > providers (const std::string &algo_spec)
 

Detailed Description

PRF used in TLS 1.0/1.1

Definition at line 19 of file prf_tls.h.

Member Typedef Documentation

typedef SCAN_Name Botan::KDF::Spec
inherited

Definition at line 132 of file kdf.h.

Constructor & Destructor Documentation

Botan::TLS_PRF::TLS_PRF ( )

Definition at line 24 of file prf_tls.cpp.

References Botan::Buffered_Computation::final(), Botan::CT::min(), Botan::Buffered_Computation::process(), Botan::SymmetricAlgorithm::set_key(), Botan::ASN1::to_string(), Botan::Buffered_Computation::update(), and Botan::xor_buf().

24  :
25  m_hmac_md5(MessageAuthenticationCode::create("HMAC(MD5)")),
26  m_hmac_sha1(MessageAuthenticationCode::create("HMAC(SHA-1)"))
27  {
28  if(!m_hmac_md5 || !m_hmac_sha1)
29  throw Algorithm_Not_Found("TLS_PRF HMACs not available");
30  }
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:38

Member Function Documentation

KDF* Botan::TLS_PRF::clone ( ) const
inlineoverridevirtual

Implements Botan::KDF.

Definition at line 24 of file prf_tls.h.

24 { return new TLS_PRF; }
std::unique_ptr< KDF > Botan::KDF::create ( const std::string &  algo_spec,
const std::string &  provider = "" 
)
staticinherited

Create an instance based on a name Will return a null pointer if the algo/provider combination cannot be found. If provider is empty then best available is chosen.

Definition at line 48 of file kdf.cpp.

Referenced by Botan::get_kdf().

50  {
51  return std::unique_ptr<KDF>(make_a<KDF>(Botan::KDF::Spec(algo_spec), provider));
52  }
SCAN_Name Spec
Definition: kdf.h:132
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const byte  secret[],
size_t  secret_len,
const byte  salt[],
size_t  salt_len 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
secret_lensize of secret in bytes
salta diversifier
salt_lensize of salt in bytes

Definition at line 54 of file kdf.h.

59  {
60  secure_vector<byte> key(key_len);
61  key.resize(kdf(key.data(), key.size(), secret, secret_len, salt, salt_len));
62  return key;
63  }
virtual size_t kdf(byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const =0
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const std::string &  salt = "" 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier

Definition at line 71 of file kdf.h.

74  {
75  return derive_key(key_len, secret.data(), secret.size(),
76  reinterpret_cast<const byte*>(salt.data()),
77  salt.length());
78  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
Definition: kdf.h:54
std::uint8_t byte
Definition: types.h:31
template<typename Alloc , typename Alloc2 >
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const std::vector< byte, Alloc > &  secret,
const std::vector< byte, Alloc2 > &  salt 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier

Definition at line 87 of file kdf.h.

90  {
91  return derive_key(key_len,
92  secret.data(), secret.size(),
93  salt.data(), salt.size());
94  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
Definition: kdf.h:54
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const byte  salt[],
size_t  salt_len 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier
salt_lensize of salt in bytes

Definition at line 103 of file kdf.h.

107  {
108  return derive_key(key_len,
109  secret.data(), secret.size(),
110  salt, salt_len);
111  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
Definition: kdf.h:54
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const byte  secret[],
size_t  secret_len,
const std::string &  salt = "" 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
secret_lensize of secret in bytes
salta diversifier

Definition at line 120 of file kdf.h.

124  {
125  return derive_key(key_len, secret, secret_len,
126  reinterpret_cast<const byte*>(salt.data()),
127  salt.length());
128  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
Definition: kdf.h:54
size_t Botan::TLS_PRF::kdf ( byte  key[],
size_t  key_len,
const byte  secret[],
size_t  secret_len,
const byte  salt[],
size_t  salt_len 
) const
overridevirtual

Implements Botan::KDF.

Definition at line 74 of file prf_tls.cpp.

77  {
78  const size_t S1_len = (secret_len + 1) / 2,
79  S2_len = (secret_len + 1) / 2;
80  const byte* S1 = secret;
81  const byte* S2 = secret + (secret_len - S2_len);
82 
83  P_hash(key, key_len, *m_hmac_md5, S1, S1_len, salt, salt_len);
84  P_hash(key, key_len, *m_hmac_sha1, S2, S2_len, salt, salt_len);
85  return key_len;
86  }
std::uint8_t byte
Definition: types.h:31
std::string Botan::TLS_PRF::name ( ) const
inlineoverridevirtual

Implements Botan::KDF.

Definition at line 22 of file prf_tls.h.

22 { return "TLS-PRF"; }
std::vector< std::string > Botan::KDF::providers ( const std::string &  algo_spec)
staticinherited

Returns the list of available providers for this algorithm, empty if not available

Definition at line 54 of file kdf.cpp.

55  {
56  return providers_of<KDF>(KDF::Spec(algo_spec));
57  }
SCAN_Name Spec
Definition: kdf.h:132

The documentation for this class was generated from the following files: