Coverage Report

Created: 2020-11-21 08:34

/src/botan/build/include/botan/internal/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
namespace Botan {
15
16
/**
17
* PRF used in TLS 1.0/1.1
18
*/
19
class TLS_PRF final : public KDF
20
   {
21
   public:
22
0
      std::string name() const override { return "TLS-PRF"; }
23
24
0
      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(std::unique_ptr<MessageAuthenticationCode> hmac_md5,
32
              std::unique_ptr<MessageAuthenticationCode> hmac_sha1) :
33
         m_hmac_md5(std::move(hmac_md5)),
34
         m_hmac_sha1(std::move(hmac_sha1))
35
0
         {}
36
37
      TLS_PRF();
38
   private:
39
      std::unique_ptr<MessageAuthenticationCode> m_hmac_md5;
40
      std::unique_ptr<MessageAuthenticationCode> m_hmac_sha1;
41
   };
42
43
/**
44
* PRF used in TLS 1.2
45
*/
46
class TLS_12_PRF final : public KDF
47
   {
48
   public:
49
0
      std::string name() const override { return "TLS-12-PRF(" + m_mac->name() + ")"; }
50
51
0
      KDF* clone() const override { return new TLS_12_PRF(m_mac->clone()); }
52
53
      size_t kdf(uint8_t key[], size_t key_len,
54
                 const uint8_t secret[], size_t secret_len,
55
                 const uint8_t salt[], size_t salt_len,
56
                 const uint8_t label[], size_t label_len) const override;
57
58
      /**
59
      * @param mac MAC algorithm to use
60
      */
61
17.6k
      explicit TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {}
62
   private:
63
      std::unique_ptr<MessageAuthenticationCode> m_mac;
64
   };
65
66
}
67
68
#endif