Botan: Botan::TLS_PRF Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <prf_tls.h>`

Inheritance diagram for Botan::TLS_PRF:

## Public Member Functions
void | clear ()
KDF * | clone () const
SecureVector< byte > | derive (size_t key_len, const byte secret[], size_t secret_len, const byte seed[], size_t seed_len) const
SecureVector< byte > | derive_key (size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
SecureVector< byte > | derive_key (size_t key_len, const MemoryRegion< byte > &secret, const MemoryRegion< byte > &salt) const
SecureVector< byte > | derive_key (size_t key_len, const MemoryRegion< byte > &secret, const byte salt[], size_t salt_len) const
SecureVector< byte > | derive_key (size_t key_len, const byte secret[], size_t secret_len, const std::string &salt="") const
SecureVector< byte > | derive_key (size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
std::string | name () const
| TLS_PRF ()
| ~TLS_PRF ()

## Detailed Description

PRF used in TLS 1.0/1.1

Definition at line 20 of file prf_tls.h.

## Constructor & Destructor Documentation

Botan::TLS_PRF::TLS_PRF | ( |  | ) |

Definition at line 53 of file prf_tls.cpp.

54 {
55 hmac_md5 = new HMAC(new MD5);
56 hmac_sha1 = new HMAC(new SHA_160);
57 }

Botan::TLS_PRF::~TLS_PRF | ( |  | ) |

Definition at line 59 of file prf_tls.cpp.

60 {
61 delete hmac_md5;
62 delete hmac_sha1;
63 }

## Member Function Documentation

void Botan::KDF::clear | ( |  | ) |
| inlinevirtualinherited

Zeroize internal state

Implements Botan::Algorithm.

Definition at line 81 of file kdf.h.

81 {}

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

Implements Botan::KDF.

Definition at line 28 of file prf_tls.h.

28 { return new TLS_PRF; }
Botan::TLS_PRF::TLS_PRF
TLS_PRF()
Definition: prf_tls.cpp:53

SecureVector< byte > Botan::TLS_PRF::derive | ( | size_t | key_len,
|  | const byte | secret[],
|  | size_t | secret_len,
|  | const byte | seed[],
|  | size_t | seed_len
| ) |  | const
| virtual

Implements Botan::KDF.

Definition at line 68 of file prf_tls.cpp.

71 {
72 SecureVector<byte> output(key_len);
73
74 size_t S1_len = (secret_len + 1) / 2,
75 S2_len = (secret_len + 1) / 2;
76 const byte* S1 = secret;
77 const byte* S2 = secret + (secret_len - S2_len);
78
79 P_hash(output, hmac_md5, S1, S1_len, seed, seed_len);
80 P_hash(output, hmac_sha1, S2, S2_len, seed, seed_len);
81
82 return output;
83 }
Botan::byte
unsigned char byte
Definition: types.h:22

SecureVector< byte > Botan::KDF::derive_key | ( | size_t | key_len,
|  | const MemoryRegion< byte > & | secret,
|  | const std::string & | salt = `""`
| ) |  | const
| inherited

Derive a key

Parameters

  key_len | the desired output length in bytes
  secret | the secret input
  salt | a diversifier

Definition at line 15 of file kdf.cpp.

References Botan::MemoryRegion< T >::size().

Referenced by Botan::KDF::derive_key(), Botan::SessionKeys::master_secret(), Botan::Finished::verify(), Botan::DLIES_Decryptor::~DLIES_Decryptor(), and Botan::DLIES_Encryptor::~DLIES_Encryptor().

18 {
19 return derive_key(key_len, &secret[0], secret.size(),
20 reinterpret_cast<const byte*>(salt.data()),
21 salt.length());
22 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::KDF::derive_key
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition: kdf.cpp:15
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

SecureVector< byte > Botan::KDF::derive_key | ( | size_t | key_len,
|  | const MemoryRegion< byte > & | secret,
|  | const MemoryRegion< byte > & | salt
| ) |  | const
| inherited

Derive a key

Parameters

  key_len | the desired output length in bytes
  secret | the secret input
  salt | a diversifier

Definition at line 38 of file kdf.cpp.

References Botan::KDF::derive_key(), and Botan::MemoryRegion< T >::size().

41 {
42 return derive_key(key_len, &secret[0], secret.size(),
43 &salt[0], salt.size());
44 }
Botan::KDF::derive_key
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition: kdf.cpp:15
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

SecureVector< byte > Botan::KDF::derive_key | ( | size_t | key_len,
|  | const MemoryRegion< byte > & | secret,
|  | const byte | salt[],
|  | size_t | salt_len
| ) |  | const
| inherited

Derive a key

Parameters

  key_len | the desired output length in bytes
  secret | the secret input
  salt | a diversifier
  salt_len | size of salt in bytes

Definition at line 27 of file kdf.cpp.

References Botan::KDF::derive_key(), and Botan::MemoryRegion< T >::size().

30 {
31 return derive_key(key_len, &secret[0], secret.size(),
32 salt, salt_len);
33 }
Botan::KDF::derive_key
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition: kdf.cpp:15
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

SecureVector< byte > Botan::KDF::derive_key | ( | size_t | key_len,
|  | const byte | secret[],
|  | size_t | secret_len,
|  | const std::string & | salt = `""`
| ) |  | const
| inherited

Derive a key

Parameters

  key_len | the desired output length in bytes
  secret | the secret input
  secret_len | size of secret in bytes
  salt | a diversifier

Definition at line 49 of file kdf.cpp.

References Botan::KDF::derive_key().

52 {
53 return derive_key(key_len, secret, secret_len,
54 reinterpret_cast<const byte*>(salt.data()),
55 salt.length());
56 }
Botan::KDF::derive_key
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition: kdf.cpp:15

SecureVector< byte > Botan::KDF::derive_key | ( | size_t | key_len,
|  | const byte | secret[],
|  | size_t | secret_len,
|  | const byte | salt[],
|  | size_t | salt_len
| ) |  | const
| inherited

Derive a key

Parameters

  key_len | the desired output length in bytes
  secret | the secret input
  secret_len | size of secret in bytes
  salt | a diversifier
  salt_len | size of salt in bytes

Definition at line 61 of file kdf.cpp.

64 {
65 return derive(key_len, secret, secret_len, salt, salt_len);
66 }

std::string Botan::TLS_PRF::name | ( |  | ) | const
| inlinevirtual

Returns
  name of this algorithm

Implements Botan::Algorithm.

Definition at line 27 of file prf_tls.h.

27 { return "TLS-PRF"; }

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

- src/kdf/prf_tls/prf_tls.h
- src/kdf/prf_tls/prf_tls.cpp