Botan 2.13.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 BOTAN_FUTURE_INTERNAL_HEADER(prf_tls.h)
15
16 namespace Botan {
17
18 /**
19 * PRF used in TLS 1.0/1.1
20 */
21 class BOTAN_PUBLIC_API(2,0) TLS_PRF final : public KDF
22 {
23 public:
24 std::string name() const override { return "TLS-PRF"; }
25
26 KDF* clone() const override { return new TLS_PRF; }
27
28 size_t kdf(uint8_t key[], size_t key_len,
29 const uint8_t secret[], size_t secret_len,
30 const uint8_t salt[], size_t salt_len,
31 const uint8_t label[], size_t label_len) const override;
32
33 TLS_PRF(std::unique_ptr<MessageAuthenticationCode> hmac_md5,
34 std::unique_ptr<MessageAuthenticationCode> hmac_sha1) :
35 m_hmac_md5(std::move(hmac_md5)),
36 m_hmac_sha1(std::move(hmac_sha1))
37 {}
38
39 TLS_PRF();
40 private:
41 std::unique_ptr<MessageAuthenticationCode> m_hmac_md5;
42 std::unique_ptr<MessageAuthenticationCode> m_hmac_sha1;
43 };
44
45 /**
46 * PRF used in TLS 1.2
47 */
48 class BOTAN_PUBLIC_API(2,0) TLS_12_PRF final : public KDF
49 {
50 public:
51 std::string name() const override { return "TLS-12-PRF(" + m_mac->name() + ")"; }
52
53 KDF* clone() const override { return new TLS_12_PRF(m_mac->clone()); }
54
55 size_t kdf(uint8_t key[], size_t key_len,
56 const uint8_t secret[], size_t secret_len,
57 const uint8_t salt[], size_t salt_len,
58 const uint8_t label[], size_t label_len) const override;
59
60 /**
61 * @param mac MAC algorithm to use
62 */
63 explicit TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {}
64 private:
65 std::unique_ptr<MessageAuthenticationCode> m_mac;
66 };
67
68 }
69
70 #endif
Botan::TLS_PRF::name
std::string name() const override
Definition: prf_tls.h:24
Botan::TLS_PRF
Definition: prf_tls.h:21
Botan::TLS_PRF::clone
KDF * clone() const override
Definition: prf_tls.h:26
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
std
Definition: bigint.h:1135
Botan::TLS_12_PRF::clone
KDF * clone() const override
Definition: prf_tls.h:53
Botan::MessageAuthenticationCode
Definition: mac.h:21
Botan::TLS_PRF::TLS_PRF
TLS_PRF(std::unique_ptr< MessageAuthenticationCode > hmac_md5, std::unique_ptr< MessageAuthenticationCode > hmac_sha1)
Definition: prf_tls.h:33
Botan::TLS_12_PRF::name
std::string name() const override
Definition: prf_tls.h:51
Botan::TLS_12_PRF::TLS_12_PRF
TLS_12_PRF(MessageAuthenticationCode *mac)
Definition: prf_tls.h:63
salt_len
size_t salt_len
Definition: x509_obj.cpp:25
Botan
Definition: alg_id.cpp:13
Botan::TLS_12_PRF
Definition: prf_tls.h:48
Botan::KDF
Definition: kdf.h:20
Botan::KDF::kdf
virtual size_t kdf(uint8_t key[], size_t key_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const =0
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139