/src/botan/build/include/internal/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::TLS { |
15 | | |
16 | | class Handshake_State; |
17 | | |
18 | | /** |
19 | | * TLS Session Keys |
20 | | */ |
21 | | class Session_Keys final { |
22 | | public: |
23 | | /** |
24 | | * @return client AEAD key |
25 | | */ |
26 | 306 | const secure_vector<uint8_t>& client_aead_key() const { return m_c_aead; } |
27 | | |
28 | | /** |
29 | | * @return server AEAD key |
30 | | */ |
31 | 82 | const secure_vector<uint8_t>& server_aead_key() const { return m_s_aead; } |
32 | | |
33 | | /** |
34 | | * @return client nonce |
35 | | */ |
36 | 306 | const std::vector<uint8_t>& client_nonce() const { return m_c_nonce; } |
37 | | |
38 | | /** |
39 | | * @return server nonce |
40 | | */ |
41 | 82 | const std::vector<uint8_t>& server_nonce() const { return m_s_nonce; } |
42 | | |
43 | | /** |
44 | | * @return TLS master secret |
45 | | */ |
46 | 246 | const secure_vector<uint8_t>& master_secret() const { return m_master_sec; } |
47 | | |
48 | 388 | const secure_vector<uint8_t>& aead_key(Connection_Side side) const { |
49 | 388 | return (side == Connection_Side::Client) ? client_aead_key() : server_aead_key(); |
50 | 388 | } |
51 | | |
52 | 388 | const std::vector<uint8_t>& nonce(Connection_Side side) const { |
53 | 388 | return (side == Connection_Side::Client) ? client_nonce() : server_nonce(); |
54 | 388 | } |
55 | | |
56 | 26.0k | Session_Keys() = default; |
57 | | |
58 | | /** |
59 | | * @param state state the handshake state |
60 | | * @param pre_master_secret the pre-master secret |
61 | | * @param resuming whether this TLS session is resumed |
62 | | */ |
63 | | Session_Keys(const Handshake_State* state, const secure_vector<uint8_t>& pre_master_secret, bool resuming); |
64 | | |
65 | | private: |
66 | | secure_vector<uint8_t> m_master_sec; |
67 | | secure_vector<uint8_t> m_c_aead, m_s_aead; |
68 | | std::vector<uint8_t> m_c_nonce, m_s_nonce; |
69 | | }; |
70 | | |
71 | | } // namespace Botan::TLS |
72 | | |
73 | | #endif |