Coverage Report

Created: 2020-06-30 13:58

/src/botan/build/include/botan/internal/tls_session_key.h
Line
Count
Source
1
/*
2
* TLS Session Key
3
* (C) 2004-2006,2011 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_TLS_SESSION_KEYS_H_
9
#define BOTAN_TLS_SESSION_KEYS_H_
10
11
#include <botan/secmem.h>
12
#include <botan/tls_magic.h>
13
14
namespace Botan {
15
16
namespace TLS {
17
18
class Handshake_State;
19
20
/**
21
* TLS Session Keys
22
*/
23
class Session_Keys final
24
   {
25
   public:
26
      /**
27
      * @return client AEAD key
28
      */
29
1.60k
      const secure_vector<uint8_t>& client_aead_key() const { return m_c_aead; }
30
31
      /**
32
      * @return server AEAD key
33
      */
34
1.07k
      const secure_vector<uint8_t>& server_aead_key() const { return m_s_aead; }
35
36
      /**
37
      * @return client nonce
38
      */
39
1.60k
      const std::vector<uint8_t>& client_nonce() const { return m_c_nonce; }
40
41
      /**
42
      * @return server nonce
43
      */
44
1.07k
      const std::vector<uint8_t>& server_nonce() const { return m_s_nonce; }
45
46
      /**
47
      * @return TLS master secret
48
      */
49
2.34k
      const secure_vector<uint8_t>& master_secret() const { return m_master_sec; }
50
51
      const secure_vector<uint8_t>& aead_key(Connection_Side side) const
52
2.67k
         {
53
2.67k
         return (side == Connection_Side::CLIENT) ? client_aead_key() : server_aead_key();
54
2.67k
         }
55
56
      const std::vector<uint8_t>& nonce(Connection_Side side) const
57
2.67k
         {
58
2.67k
         return (side == Connection_Side::CLIENT) ? client_nonce() : server_nonce();
59
2.67k
         }
60
61
47.5k
      Session_Keys() = default;
62
63
      /**
64
      * @param state state the handshake state
65
      * @param pre_master_secret the pre-master secret
66
      * @param resuming whether this TLS session is resumed
67
      */
68
      Session_Keys(const Handshake_State* state,
69
                   const secure_vector<uint8_t>& pre_master_secret,
70
                   bool resuming);
71
72
   private:
73
      secure_vector<uint8_t> m_master_sec;
74
      secure_vector<uint8_t> m_c_aead, m_s_aead;
75
      std::vector<uint8_t> m_c_nonce, m_s_nonce;
76
   };
77
78
}
79
80
}
81
82
#endif