diff options
Diffstat (limited to 'src/lib/tls/tls_channel.cpp')
-rw-r--r-- | src/lib/tls/tls_channel.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/tls/tls_channel.cpp b/src/lib/tls/tls_channel.cpp index c8fe407e2..cc7b7df6b 100644 --- a/src/lib/tls/tls_channel.cpp +++ b/src/lib/tls/tls_channel.cpp @@ -86,7 +86,7 @@ Connection_Sequence_Numbers& Channel::sequence_numbers() const return *m_sequence_numbers; } -std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(u16bit epoch) const +std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(uint16_t epoch) const { auto i = m_read_cipher_states.find(epoch); if(i == m_read_cipher_states.end()) @@ -94,7 +94,7 @@ std::shared_ptr<Connection_Cipher_State> Channel::read_cipher_state_epoch(u16bit return i->second; } -std::shared_ptr<Connection_Cipher_State> Channel::write_cipher_state_epoch(u16bit epoch) const +std::shared_ptr<Connection_Cipher_State> Channel::write_cipher_state_epoch(uint16_t epoch) const { auto i = m_write_cipher_states.find(epoch); if(i == m_write_cipher_states.end()) @@ -142,7 +142,7 @@ Handshake_State& Channel::create_handshake_state(Protocol_Version version) io.reset(new Datagram_Handshake_IO( std::bind(&Channel::send_record_under_epoch, this, _1, _2, _3), sequence_numbers(), - static_cast<u16bit>(m_policy.dtls_default_mtu()), + static_cast<uint16_t>(m_policy.dtls_default_mtu()), m_policy.dtls_initial_timeout(), m_policy.dtls_maximum_timeout())); } @@ -192,7 +192,7 @@ void Channel::change_cipher_spec_reader(Connection_Side side) sequence_numbers().new_read_cipher_state(); - const u16bit epoch = sequence_numbers().current_read_epoch(); + const uint16_t epoch = sequence_numbers().current_read_epoch(); BOTAN_ASSERT(m_read_cipher_states.count(epoch) == 0, "No read cipher state currently set for next epoch"); @@ -221,7 +221,7 @@ void Channel::change_cipher_spec_writer(Connection_Side side) sequence_numbers().new_write_cipher_state(); - const u16bit epoch = sequence_numbers().current_write_epoch(); + const uint16_t epoch = sequence_numbers().current_write_epoch(); BOTAN_ASSERT(m_write_cipher_states.count(epoch) == 0, "No write cipher state currently set for next epoch"); @@ -264,10 +264,10 @@ void Channel::activate_session() if(!m_active_state->version().is_datagram_protocol()) { // TLS is easy just remove all but the current state - const u16bit current_epoch = sequence_numbers().current_write_epoch(); + const uint16_t current_epoch = sequence_numbers().current_write_epoch(); const auto not_current_epoch = - [current_epoch](u16bit epoch) { return (epoch != current_epoch); }; + [current_epoch](uint16_t epoch) { return (epoch != current_epoch); }; map_remove_if(not_current_epoch, m_write_cipher_states); map_remove_if(not_current_epoch, m_read_cipher_states); @@ -276,19 +276,19 @@ void Channel::activate_session() callbacks().tls_session_activated(); } -size_t Channel::received_data(const std::vector<byte>& buf) +size_t Channel::received_data(const std::vector<uint8_t>& buf) { return this->received_data(buf.data(), buf.size()); } -size_t Channel::received_data(const byte input[], size_t input_size) +size_t Channel::received_data(const uint8_t input[], size_t input_size) { try { while(!is_closed() && input_size) { - secure_vector<byte> record_data; - u64bit record_sequence = 0; + secure_vector<uint8_t> record_data; + uint64_t record_sequence = 0; Record_Type record_type = NO_RECORD; Protocol_Version record_version; @@ -364,8 +364,8 @@ size_t Channel::received_data(const byte input[], size_t input_size) } } -void Channel::process_handshake_ccs(const secure_vector<byte>& record, - u64bit record_sequence, +void Channel::process_handshake_ccs(const secure_vector<uint8_t>& record, + uint64_t record_sequence, Record_Type record_type, Protocol_Version record_version) { @@ -382,7 +382,7 @@ void Channel::process_handshake_ccs(const secure_vector<byte>& record, */ sequence_numbers().read_accept(record_sequence); - const u16bit epoch = record_sequence >> 48; + const uint16_t epoch = record_sequence >> 48; if(epoch == sequence_numbers().current_read_epoch()) { @@ -427,7 +427,7 @@ void Channel::process_handshake_ccs(const secure_vector<byte>& record, } } -void Channel::process_application_data(u64bit seq_no, const secure_vector<byte>& record) +void Channel::process_application_data(uint64_t seq_no, const secure_vector<uint8_t>& record) { if(!active_state()) throw Unexpected_Message("Application data before handshake done"); @@ -441,7 +441,7 @@ void Channel::process_application_data(u64bit seq_no, const secure_vector<byte>& callbacks().tls_record_received(seq_no, record.data(), record.size()); } -void Channel::process_alert(const secure_vector<byte>& record) +void Channel::process_alert(const secure_vector<uint8_t>& record) { Alert alert_msg(record); @@ -466,8 +466,8 @@ void Channel::process_alert(const secure_vector<byte>& record) } -void Channel::write_record(Connection_Cipher_State* cipher_state, u16bit epoch, - byte record_type, const byte input[], size_t length) +void Channel::write_record(Connection_Cipher_State* cipher_state, uint16_t epoch, + uint8_t record_type, const uint8_t input[], size_t length) { BOTAN_ASSERT(m_pending_state || m_active_state, "Some connection state exists"); @@ -486,7 +486,7 @@ void Channel::write_record(Connection_Cipher_State* cipher_state, u16bit epoch, callbacks().tls_emit_data(m_writebuf.data(), m_writebuf.size()); } -void Channel::send_record_array(u16bit epoch, byte type, const byte input[], size_t length) +void Channel::send_record_array(uint16_t epoch, uint8_t type, const uint8_t input[], size_t length) { if(length == 0) return; @@ -523,19 +523,19 @@ void Channel::send_record_array(u16bit epoch, byte type, const byte input[], siz } } -void Channel::send_record(byte record_type, const std::vector<byte>& record) +void Channel::send_record(uint8_t record_type, const std::vector<uint8_t>& record) { send_record_array(sequence_numbers().current_write_epoch(), record_type, record.data(), record.size()); } -void Channel::send_record_under_epoch(u16bit epoch, byte record_type, - const std::vector<byte>& record) +void Channel::send_record_under_epoch(uint16_t epoch, uint8_t record_type, + const std::vector<uint8_t>& record) { send_record_array(epoch, record_type, record.data(), record.size()); } -void Channel::send(const byte buf[], size_t buf_size) +void Channel::send(const uint8_t buf[], size_t buf_size) { if(!is_active()) throw Exception("Data cannot be sent on inactive TLS connection"); @@ -546,7 +546,7 @@ void Channel::send(const byte buf[], size_t buf_size) void Channel::send(const std::string& string) { - this->send(reinterpret_cast<const byte*>(string.c_str()), string.size()); + this->send(reinterpret_cast<const uint8_t*>(string.c_str()), string.size()); } void Channel::send_alert(const Alert& alert) @@ -586,7 +586,7 @@ void Channel::secure_renegotiation_check(const Client_Hello* client_hello) if(secure_renegotiation) { - const std::vector<byte>& data = client_hello->renegotiation_info(); + const std::vector<uint8_t>& data = client_hello->renegotiation_info(); if(data != secure_renegotiation_data_for_client_hello()) throw TLS_Exception(Alert::HANDSHAKE_FAILURE, @@ -609,7 +609,7 @@ void Channel::secure_renegotiation_check(const Server_Hello* server_hello) if(secure_renegotiation) { - const std::vector<byte>& data = server_hello->renegotiation_info(); + const std::vector<uint8_t>& data = server_hello->renegotiation_info(); if(data != secure_renegotiation_data_for_server_hello()) throw TLS_Exception(Alert::HANDSHAKE_FAILURE, @@ -617,23 +617,23 @@ void Channel::secure_renegotiation_check(const Server_Hello* server_hello) } } -std::vector<byte> Channel::secure_renegotiation_data_for_client_hello() const +std::vector<uint8_t> Channel::secure_renegotiation_data_for_client_hello() const { if(auto active = active_state()) return active->client_finished()->verify_data(); - return std::vector<byte>(); + return std::vector<uint8_t>(); } -std::vector<byte> Channel::secure_renegotiation_data_for_server_hello() const +std::vector<uint8_t> Channel::secure_renegotiation_data_for_server_hello() const { if(auto active = active_state()) { - std::vector<byte> buf = active->client_finished()->verify_data(); + std::vector<uint8_t> buf = active->client_finished()->verify_data(); buf += active->server_finished()->verify_data(); return buf; } - return std::vector<byte>(); + return std::vector<uint8_t>(); } bool Channel::secure_renegotiation_supported() const @@ -656,10 +656,10 @@ SymmetricKey Channel::key_material_export(const std::string& label, { std::unique_ptr<KDF> prf(active->protocol_specific_prf()); - const secure_vector<byte>& master_secret = + const secure_vector<uint8_t>& master_secret = active->session_keys().master_secret(); - std::vector<byte> salt; + std::vector<uint8_t> salt; salt += active->client_hello()->random(); salt += active->server_hello()->random(); @@ -668,8 +668,8 @@ SymmetricKey Channel::key_material_export(const std::string& label, size_t context_size = context.length(); if(context_size > 0xFFFF) throw Exception("key_material_export context is too long"); - salt.push_back(get_byte(0, static_cast<u16bit>(context_size))); - salt.push_back(get_byte(1, static_cast<u16bit>(context_size))); + salt.push_back(get_byte(0, static_cast<uint16_t>(context_size))); + salt.push_back(get_byte(1, static_cast<uint16_t>(context_size))); salt += to_byte_vector(context); } |