Botan 1.10.17
Botan::SessionKeys Class Reference

#include <tls_session_key.h>

Public Member Functions

SymmetricKey client_cipher_key () const
InitializationVector client_iv () const
SymmetricKey client_mac_key () const
SecureVector< bytemaster_secret () const
SymmetricKey server_cipher_key () const
InitializationVector server_iv () const
SymmetricKey server_mac_key () const
 SessionKeys ()
 SessionKeys (const CipherSuite &, Version_Code, const MemoryRegion< byte > &, const MemoryRegion< byte > &, const MemoryRegion< byte > &)

Detailed Description

TLS Session Keys

Definition at line 20 of file tls_session_key.h.

Constructor & Destructor Documentation

◆ SessionKeys() [1/2]

Botan::SessionKeys::SessionKeys ( )
inline

Definition at line 34 of file tls_session_key.h.

34{}

◆ SessionKeys() [2/2]

Botan::SessionKeys::SessionKeys ( const CipherSuite & suite,
Version_Code version,
const MemoryRegion< byte > & pre_master_secret,
const MemoryRegion< byte > & c_random,
const MemoryRegion< byte > & s_random )

SessionKeys Constructor

Definition at line 129 of file tls_session_key.cpp.

133 {
134 if(version != SSL_V3 && version != TLS_V10 && version != TLS_V11)
135 throw Invalid_Argument("SessionKeys: Unknown version code");
136
137 const size_t mac_keylen = output_length_of(suite.mac_algo());
138 const size_t cipher_keylen = suite.cipher_keylen();
139
140 size_t cipher_ivlen = 0;
141 if(have_block_cipher(suite.cipher_algo()))
142 cipher_ivlen = block_size_of(suite.cipher_algo());
143
144 const size_t prf_gen = 2 * (mac_keylen + cipher_keylen + cipher_ivlen);
145
146 SymmetricKey keyblock = (version == SSL_V3) ?
147 ssl3_keygen(prf_gen, pre_master_secret, c_random, s_random) :
148 tls1_keygen(prf_gen, pre_master_secret, c_random, s_random);
149
150 const byte* key_data = keyblock.begin();
151
152 c_mac = SymmetricKey(key_data, mac_keylen);
153 key_data += mac_keylen;
154
155 s_mac = SymmetricKey(key_data, mac_keylen);
156 key_data += mac_keylen;
157
158 c_cipher = SymmetricKey(key_data, cipher_keylen);
159 key_data += cipher_keylen;
160
161 s_cipher = SymmetricKey(key_data, cipher_keylen);
162 key_data += cipher_keylen;
163
164 c_iv = InitializationVector(key_data, cipher_ivlen);
165 key_data += cipher_ivlen;
166
167 s_iv = InitializationVector(key_data, cipher_ivlen);
168 }
OctetString SymmetricKey
Definition symkey.h:147
std::invalid_argument Invalid_Argument
Definition exceptn.h:20
OctetString InitializationVector
Definition symkey.h:152
size_t output_length_of(const std::string &name)
Definition lookup.cpp:51
@ SSL_V3
Definition tls_magic.h:24
@ TLS_V10
Definition tls_magic.h:25
@ TLS_V11
Definition tls_magic.h:26
size_t block_size_of(const std::string &name)
Definition lookup.cpp:35
bool have_block_cipher(const std::string &algo_spec)
Definition lookup.h:235

References Botan::OctetString::begin(), Botan::block_size_of(), Botan::CipherSuite::cipher_algo(), Botan::CipherSuite::cipher_keylen(), Botan::have_block_cipher(), Botan::CipherSuite::mac_algo(), Botan::output_length_of(), Botan::SSL_V3, Botan::TLS_V10, and Botan::TLS_V11.

Member Function Documentation

◆ client_cipher_key()

SymmetricKey Botan::SessionKeys::client_cipher_key ( ) const

Return the client cipher key

Definition at line 18 of file tls_session_key.cpp.

19 {
20 return c_cipher;
21 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().

◆ client_iv()

InitializationVector Botan::SessionKeys::client_iv ( ) const

Return the client cipher IV

Definition at line 50 of file tls_session_key.cpp.

51 {
52 return c_iv;
53 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().

◆ client_mac_key()

SymmetricKey Botan::SessionKeys::client_mac_key ( ) const

Return the client MAC key

Definition at line 34 of file tls_session_key.cpp.

35 {
36 return c_mac;
37 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().

◆ master_secret()

SecureVector< byte > Botan::SessionKeys::master_secret ( ) const

Return the TLS master secret

Definition at line 66 of file tls_session_key.cpp.

67 {
68 return master_sec;
69 }

◆ server_cipher_key()

SymmetricKey Botan::SessionKeys::server_cipher_key ( ) const

Return the server cipher key

Definition at line 26 of file tls_session_key.cpp.

27 {
28 return s_cipher;
29 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().

◆ server_iv()

InitializationVector Botan::SessionKeys::server_iv ( ) const

Return the server cipher IV

Definition at line 58 of file tls_session_key.cpp.

59 {
60 return s_iv;
61 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().

◆ server_mac_key()

SymmetricKey Botan::SessionKeys::server_mac_key ( ) const

Return the server MAC key

Definition at line 42 of file tls_session_key.cpp.

43 {
44 return s_mac;
45 }

Referenced by Botan::Record_Reader::set_keys(), and Botan::Record_Writer::set_keys().


The documentation for this class was generated from the following files: