Coverage Report

Created: 2020-06-30 13:58

/src/botan/build/include/botan/prf_tls.h
Line
Count
Source (jump to first uncovered line)
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
0
      std::string name() const override { return "TLS-PRF"; }
25
26
0
      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
0
         {}
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
0
      std::string name() const override { return "TLS-12-PRF(" + m_mac->name() + ")"; }
52
53
0
      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
16.7k
      explicit TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {}
64
   private:
65
      std::unique_ptr<MessageAuthenticationCode> m_mac;
66
   };
67
68
}
69
70
#endif