Botan  1.11.31
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 byte label[]=nullptr, size_t label_len=0) const
 
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const std::string &salt="", const std::string &label="") const
 
template<typename Alloc , typename Alloc2 , typename Alloc3 >
secure_vector< bytederive_key (size_t key_len, const std::vector< byte, Alloc > &secret, const std::vector< byte, Alloc2 > &salt, const std::vector< byte, Alloc3 > &label) const
 
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const byte salt[], size_t salt_len, const std::string &label="") const
 
secure_vector< bytederive_key (size_t key_len, const byte secret[], size_t secret_len, const std::string &salt="", const std::string &label="") 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 byte label[], size_t label_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 153 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 60 of file kdf.cpp.

Referenced by Botan::ECIES_KA_Params::create_kdf(), and Botan::get_kdf().

62  {
63  return std::unique_ptr<KDF>(make_a<KDF>(Botan::KDF::Spec(algo_spec), provider));
64  }
SCAN_Name Spec
Definition: kdf.h:153
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 byte  label[] = nullptr,
size_t  label_len = 0 
) 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
labelpurpose for the derived keying material
label_lensize of label in bytes

Definition at line 57 of file kdf.h.

64  {
65  secure_vector<byte> key(key_len);
66  key.resize(kdf(key.data(), key.size(), secret, secret_len, salt, salt_len, label, label_len));
67  return key;
68  }
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 byte label[], size_t label_len) const =0
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const std::string &  salt = "",
const std::string &  label = "" 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier
labelpurpose for the derived keying material

Definition at line 77 of file kdf.h.

81  {
82  return derive_key(key_len, secret.data(), secret.size(),
83  reinterpret_cast<const byte*>(salt.data()),
84  salt.length(),
85  reinterpret_cast<const byte*>(label.data()),
86  label.length());
87 
88  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len, const byte label[]=nullptr, size_t label_len=0) const
Definition: kdf.h:57
std::uint8_t byte
Definition: types.h:31
template<typename Alloc , typename Alloc2 , typename Alloc3 >
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const std::vector< byte, Alloc > &  secret,
const std::vector< byte, Alloc2 > &  salt,
const std::vector< byte, Alloc3 > &  label 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier
labelpurpose for the derived keying material

Definition at line 98 of file kdf.h.

102  {
103  return derive_key(key_len,
104  secret.data(), secret.size(),
105  salt.data(), salt.size(),
106  label.data(), label.size());
107  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len, const byte label[]=nullptr, size_t label_len=0) const
Definition: kdf.h:57
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const byte  salt[],
size_t  salt_len,
const std::string &  label = "" 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier
salt_lensize of salt in bytes
labelpurpose for the derived keying material

Definition at line 117 of file kdf.h.

122  {
123  return derive_key(key_len,
124  secret.data(), secret.size(),
125  salt, salt_len,
126  reinterpret_cast<const byte*>(label.data()),
127  label.size());
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 byte label[]=nullptr, size_t label_len=0) const
Definition: kdf.h:57
std::uint8_t byte
Definition: types.h:31
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const byte  secret[],
size_t  secret_len,
const std::string &  salt = "",
const std::string &  label = "" 
) const
inlineinherited

Derive a key

Parameters
key_lenthe desired output length in bytes
secretthe secret input
secret_lensize of secret in bytes
salta diversifier
labelpurpose for the derived keying material

Definition at line 138 of file kdf.h.

143  {
144  return derive_key(key_len, secret, secret_len,
145  reinterpret_cast<const byte*>(salt.data()),
146  salt.length(),
147  reinterpret_cast<const byte*>(label.data()),
148  label.length());
149  }
secure_vector< byte > derive_key(size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len, const byte label[]=nullptr, size_t label_len=0) const
Definition: kdf.h:57
std::uint8_t byte
Definition: types.h:31
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 byte  label[],
size_t  label_len 
) const
overridevirtual

Implements Botan::KDF.

Definition at line 74 of file prf_tls.cpp.

78  {
79  const size_t S1_len = (secret_len + 1) / 2,
80  S2_len = (secret_len + 1) / 2;
81  const byte* S1 = secret;
82  const byte* S2 = secret + (secret_len - S2_len);
83  secure_vector<byte> msg;
84 
85  msg.reserve(label_len + salt_len);
86  msg += std::make_pair(label, label_len);
87  msg += std::make_pair(salt, salt_len);
88 
89  P_hash(key, key_len, *m_hmac_md5, S1, S1_len, msg.data(), msg.size());
90  P_hash(key, key_len, *m_hmac_sha1, S2, S2_len, msg.data(), msg.size());
91  return key_len;
92  }
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 66 of file kdf.cpp.

67  {
68  return providers_of<KDF>(KDF::Spec(algo_spec));
69  }
SCAN_Name Spec
Definition: kdf.h:153

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