Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

prf_tls.h
Go to the documentation of this file.
1 /*
2 * TLS v1.0 and v1.2 PRFs
3 * (C) 2004-2010 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_TLS_PRF_H__
9 #define BOTAN_TLS_PRF_H__
10
11 #include <botan/kdf.h>
12 #include <botan/mac.h>
13
14 namespace Botan {
15
16 /**
17 * PRF used in TLS 1.0/1.1
18 */
19 class BOTAN_DLL TLS_PRF final : public KDF
20 {
21 public:
22 std::string name() const override { return "TLS-PRF"; }
23
24 KDF* clone() const override { return new TLS_PRF; }
25
26 size_t kdf(uint8_t key[], size_t key_len,
27 const uint8_t secret[], size_t secret_len,
28 const uint8_t salt[], size_t salt_len,
29 const uint8_t label[], size_t label_len) const override;
30
31 TLS_PRF();
32 private:
33 std::unique_ptr<MessageAuthenticationCode> m_hmac_md5;
34 std::unique_ptr<MessageAuthenticationCode> m_hmac_sha1;
35 };
36
37 /**
38 * PRF used in TLS 1.2
39 */
40 class BOTAN_DLL TLS_12_PRF final : public KDF
41 {
42 public:
43 std::string name() const override { return "TLS-12-PRF(" + m_mac->name() + ")"; }
44
45 KDF* clone() const override { return new TLS_12_PRF(m_mac->clone()); }
46
47 size_t kdf(uint8_t key[], size_t key_len,
48 const uint8_t secret[], size_t secret_len,
49 const uint8_t salt[], size_t salt_len,
50 const uint8_t label[], size_t label_len) const override;
51
52 /**
53 * @param mac MAC algorithm to use
54 */
55 explicit TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {}
56 private:
57 std::unique_ptr<MessageAuthenticationCode> m_mac;
58 };
59
60 }
61
62 #endif
Botan::TLS_PRF::name
std::string name() const override
Definition: prf_tls.h:22
Botan::TLS_PRF
Definition: prf_tls.h:19
m_mac
std::unique_ptr< MessageAuthenticationCode > m_mac
Definition: fpe_fe1.cpp:88
Botan::TLS_PRF::clone
KDF * clone() const override
Definition: prf_tls.h:24
Botan::TLS_12_PRF::clone
KDF * clone() const override
Definition: prf_tls.h:45
Botan::MessageAuthenticationCode
Definition: mac.h:20
Botan::TLS_12_PRF::name
std::string name() const override
Definition: prf_tls.h:43
Botan::TLS_12_PRF::TLS_12_PRF
TLS_12_PRF(MessageAuthenticationCode *mac)
Definition: prf_tls.h:55
Botan
Definition: alg_id.cpp:13
Botan::TLS_12_PRF
Definition: prf_tls.h:40
Botan::KDF
Definition: kdf.h:20