8 #include <botan/internal/tls_session_key.h>
9 #include <botan/internal/tls_handshake_state.h>
10 #include <botan/tls_messages.h>
27 const bool extended_master_secret = state->
server_hello()->supports_extended_master_secret();
29 const size_t prf_gen = 2 * (mac_keylen + cipher_keylen + cipher_nonce_bytes);
31 const uint8_t MASTER_SECRET_MAGIC[] = {
32 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74 };
34 const uint8_t EXT_MASTER_SECRET_MAGIC[] = {
35 0x65, 0x78, 0x74, 0x65, 0x6E, 0x64, 0x65, 0x64, 0x20,
36 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74 };
38 const uint8_t KEY_GEN_MAGIC[] = {
39 0x6B, 0x65, 0x79, 0x20, 0x65, 0x78, 0x70, 0x61, 0x6E, 0x73, 0x69, 0x6F, 0x6E };
46 m_master_sec = pre_master_secret;
52 if(extended_master_secret)
54 label += std::make_pair(EXT_MASTER_SECRET_MAGIC,
sizeof(EXT_MASTER_SECRET_MAGIC));
60 label += std::make_pair(MASTER_SECRET_MAGIC,
sizeof(MASTER_SECRET_MAGIC));
65 m_master_sec = prf->derive_key(48, pre_master_secret, salt, label);
70 label += std::make_pair(KEY_GEN_MAGIC,
sizeof(KEY_GEN_MAGIC));
74 SymmetricKey keyblock = prf->derive_key(prf_gen, m_master_sec, salt, label);
76 const uint8_t* key_data = keyblock.
begin();
79 key_data += mac_keylen;
82 key_data += mac_keylen;
85 key_data += cipher_keylen;
88 key_data += cipher_keylen;
91 key_data += cipher_nonce_bytes;
void server_hello(Server_Hello *server_hello)
OctetString InitializationVector
KDF * protocol_specific_prf() const
std::string prf_algo() const
size_t mac_keylen() const
std::vector< T, secure_allocator< T >> secure_vector
void client_hello(Client_Hello *client_hello)
secure_vector< uint8_t > final(Protocol_Version version, const std::string &mac_algo) const
size_t cipher_keylen() const
size_t nonce_bytes_from_handshake() const
const Ciphersuite & ciphersuite() const
const uint8_t * begin() const
Protocol_Version version() const