Botan  1.11.12
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 Member Functions

KDFclone () const
 
secure_vector< bytederive (size_t key_len, const byte secret[], size_t secret_len, const byte seed[], size_t seed_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
 
secure_vector< bytederive_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 ()
 

Detailed Description

PRF used in TLS 1.0/1.1

Definition at line 19 of file prf_tls.h.

Constructor & Destructor Documentation

Botan::TLS_PRF::TLS_PRF ( )

Definition at line 62 of file prf_tls.cpp.

63  {
64  hmac_md5.reset(new HMAC(new MD5));
65  hmac_sha1.reset(new HMAC(new SHA_160));
66  }

Member Function Documentation

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

Implements Botan::KDF.

Definition at line 27 of file prf_tls.h.

27 { return new TLS_PRF; }
secure_vector< 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 71 of file prf_tls.cpp.

74  {
75  secure_vector<byte> output(key_len);
76 
77  size_t S1_len = (secret_len + 1) / 2,
78  S2_len = (secret_len + 1) / 2;
79  const byte* S1 = secret;
80  const byte* S2 = secret + (secret_len - S2_len);
81 
82  P_hash(output, *hmac_md5, S1, S1_len, seed, seed_len);
83  P_hash(output, *hmac_sha1, S2, S2_len, seed, seed_len);
84 
85  return output;
86  }
uint8_t byte
Definition: types.h:30
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 33 of file kdf.h.

36  {
37  return derive_key(key_len, &secret[0], secret.size(),
38  reinterpret_cast<const byte*>(salt.data()),
39  salt.length());
40  }
uint8_t byte
Definition: types.h:30
secure_vector< byte > derive_key(size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
Definition: kdf.h:33
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 49 of file kdf.h.

52  {
53  return derive_key(key_len,
54  &secret[0], secret.size(),
55  &salt[0], salt.size());
56  }
secure_vector< byte > derive_key(size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
Definition: kdf.h:33
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 65 of file kdf.h.

69  {
70  return derive_key(key_len,
71  &secret[0], secret.size(),
72  salt, salt_len);
73  }
secure_vector< byte > derive_key(size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
Definition: kdf.h:33
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 82 of file kdf.h.

86  {
87  return derive_key(key_len, secret, secret_len,
88  reinterpret_cast<const byte*>(salt.data()),
89  salt.length());
90  }
secure_vector< byte > derive_key(size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
Definition: kdf.h:33
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 100 of file kdf.h.

105  {
106  return derive(key_len, secret, secret_len, salt, salt_len);
107  }
std::string Botan::TLS_PRF::name ( ) const
inlinevirtual

Implements Botan::KDF.

Definition at line 26 of file prf_tls.h.

26 { return "TLS-PRF"; }

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