Botan 2.19.5 Crypto and TLS for C&

tls_session_key.h
Go to the documentation of this file.
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 const secure_vector<uint8_t>& client_aead_key() const { return m_c_aead; }
30
31 /**
32 * @return server AEAD key
33 */
34 const secure_vector<uint8_t>& server_aead_key() const { return m_s_aead; }
35
36 /**
37 * @return client nonce
38 */
39 const std::vector<uint8_t>& client_nonce() const { return m_c_nonce; }
40
41 /**
42 * @return server nonce
43 */
44 const std::vector<uint8_t>& server_nonce() const { return m_s_nonce; }
45
46 /**
47 * @return TLS master secret
48 */
49 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 {
53 return (side == Connection_Side::CLIENT) ? client_aead_key() : server_aead_key();
54 }
55
56 const std::vector<uint8_t>& nonce(Connection_Side side) const
57 {
58 return (side == Connection_Side::CLIENT) ? client_nonce() : server_nonce();
59 }
60
61 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
Botan::TLS::Handshake_State
Definition: tls_handshake_state.h:50
Botan::TLS::Session_Keys
Definition: tls_session_key.h:24
Botan::TLS::Session_Keys::server_aead_key
const secure_vector< uint8_t > & server_aead_key() const
Definition: tls_session_key.h:34
Botan::TLS::Session_Keys::server_nonce
const std::vector< uint8_t > & server_nonce() const
Definition: tls_session_key.h:44
Botan::TLS::Session_Keys::client_nonce
const std::vector< uint8_t > & client_nonce() const
Definition: tls_session_key.h:39
Botan::TLS::Session_Keys::nonce
const std::vector< uint8_t > & nonce(Connection_Side side) const
Definition: tls_session_key.h:56
Botan::TLS::Session_Keys::aead_key
const secure_vector< uint8_t > & aead_key(Connection_Side side) const
Definition: tls_session_key.h:51
Botan::TLS::Session_Keys::Session_Keys
Session_Keys()=default
Botan::TLS::Session_Keys::client_aead_key
const secure_vector< uint8_t > & client_aead_key() const
Definition: tls_session_key.h:29
Botan::TLS::Session_Keys::master_secret
const secure_vector< uint8_t > & master_secret() const
Definition: tls_session_key.h:49
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
Botan::TLS::Connection_Side
Connection_Side
Definition: tls_magic.h:32
Botan::TLS::CLIENT
@ CLIENT
Definition: tls_magic.h:32
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65