Botan  2.4.0
Crypto and TLS for C++11
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_PUBLIC_API(2,0) 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_PUBLIC_API(2,0) 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
std::string name() const override
Definition: prf_tls.h:22
KDF * clone() const override
Definition: prf_tls.h:24
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
KDF * clone() const override
Definition: prf_tls.h:45
std::string name() const override
Definition: prf_tls.h:43
TLS_12_PRF(MessageAuthenticationCode *mac)
Definition: prf_tls.h:55
size_t salt_len
Definition: x509_obj.cpp:25
Definition: alg_id.cpp:13
Definition: kdf.h:20