Botan: Botan::SessionKeys Class Reference

Botan 1.10.17

Public Member Functions | List of all members
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< byte > | master_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.

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.

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 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::TLS_V10
Definition: tls_magic.h:25
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::SymmetricKey
OctetString SymmetricKey
Definition: symkey.h:147
Botan::block_size_of
size_t block_size_of(const std::string &name)
Definition: lookup.cpp:35
Botan::SSL_V3
Definition: tls_magic.h:24
Botan::have_block_cipher
bool have_block_cipher(const std::string &algo_spec)
Definition: lookup.h:235
Botan::TLS_V11
Definition: tls_magic.h:26
Botan::output_length_of
size_t output_length_of(const std::string &name)
Definition: lookup.cpp:51
Botan::InitializationVector
OctetString InitializationVector
Definition: symkey.h:152

## 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.

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

19 {
20 return c_cipher;
21 }

## ◆ client_iv()

InitializationVector Botan::SessionKeys::client_iv | ( |  | ) | const

Return the client cipher IV

Definition at line 50 of file tls_session_key.cpp.

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

51 {
52 return c_iv;
53 }

## ◆ 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.

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

35 {
36 return c_mac;
37 }

## ◆ 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.

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

27 {
28 return s_cipher;
29 }

## ◆ server_iv()

InitializationVector Botan::SessionKeys::server_iv | ( |  | ) | const

Return the server cipher IV

Definition at line 58 of file tls_session_key.cpp.

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

59 {
60 return s_iv;
61 }

## ◆ 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.

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

43 {
44 return s_mac;
45 }

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

- src/ssl/tls_session_key.h
- src/ssl/tls_session_key.cpp