Botan  1.11.17
Public Types | Public Member Functions | List of all members
Botan::TLS_PRF Class Reference

#include <prf_tls.h>

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

Public Types

typedef SCAN_Name Spec
 

Public Member Functions

KDFclone () const
 
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
 
 TLS_PRF ()
 

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 119 of file kdf.h.

Constructor & Destructor Documentation

Botan::TLS_PRF::TLS_PRF ( )

Definition at line 26 of file prf_tls.cpp.

26  :
27  m_hmac_md5(make_message_auth("HMAC(MD5)")),
28  m_hmac_sha1(make_message_auth("HMAC(SHA-1)"))
29  {
30  }
std::unique_ptr< MessageAuthenticationCode > make_message_auth(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:71

Member Function Documentation

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

Implements Botan::KDF.

Definition at line 24 of file prf_tls.h.

24 { return new TLS_PRF; }
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 41 of file kdf.h.

46  {
47  secure_vector<byte> key(key_len);
48  key.resize(kdf(&key[0], key.size(), secret, secret_len, salt, salt_len));
49  return key;
50  }
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 58 of file kdf.h.

61  {
62  return derive_key(key_len, &secret[0], secret.size(),
63  reinterpret_cast<const byte*>(salt.data()),
64  salt.length());
65  }
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:41
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 74 of file kdf.h.

77  {
78  return derive_key(key_len,
79  &secret[0], secret.size(),
80  &salt[0], salt.size());
81  }
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:41
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 90 of file kdf.h.

94  {
95  return derive_key(key_len,
96  &secret[0], secret.size(),
97  salt, salt_len);
98  }
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:41
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 107 of file kdf.h.

111  {
112  return derive_key(key_len, secret, secret_len,
113  reinterpret_cast<const byte*>(salt.data()),
114  salt.length());
115  }
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:41
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  }
uint8_t byte
Definition: types.h:31
std::string Botan::TLS_PRF::name ( ) const
inlinevirtual

Implements Botan::KDF.

Definition at line 22 of file prf_tls.h.

22 { return "TLS-PRF"; }

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