|
@@ -53,7 +53,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|
|
dbgln("not enough data for version");
|
|
|
return (i8)Error::NeedMoreData;
|
|
|
}
|
|
|
- auto version = (Version)AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
|
|
|
+ auto version = static_cast<Version>(AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res))));
|
|
|
|
|
|
res += 2;
|
|
|
if (!supports_version(version))
|
|
@@ -84,7 +84,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|
|
dbgln("not enough data for cipher suite listing");
|
|
|
return (i8)Error::NeedMoreData;
|
|
|
}
|
|
|
- auto cipher = (CipherSuite)AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
|
|
|
+ auto cipher = static_cast<CipherSuite>(AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res))));
|
|
|
res += 2;
|
|
|
if (!supports_cipher(cipher)) {
|
|
|
m_context.cipher = CipherSuite::Invalid;
|
|
@@ -113,14 +113,14 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|
|
|
|
|
// Presence of extensions is determined by availability of bytes after compression_method
|
|
|
if (buffer.size() - res >= 2) {
|
|
|
- auto extensions_bytes_total = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res += 2));
|
|
|
+ auto extensions_bytes_total = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res += 2)));
|
|
|
dbgln_if(TLS_DEBUG, "Extensions bytes total: {}", extensions_bytes_total);
|
|
|
}
|
|
|
|
|
|
while (buffer.size() - res >= 4) {
|
|
|
- auto extension_type = (HandshakeExtension)AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
|
|
|
+ auto extension_type = (HandshakeExtension)AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res)));
|
|
|
res += 2;
|
|
|
- u16 extension_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
|
|
|
+ u16 extension_length = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res)));
|
|
|
res += 2;
|
|
|
|
|
|
dbgln_if(TLS_DEBUG, "Extension {} with length {}", (u16)extension_type, extension_length);
|
|
@@ -134,14 +134,14 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|
|
// ServerNameList total size
|
|
|
if (buffer.size() - res < 2)
|
|
|
return (i8)Error::NeedMoreData;
|
|
|
- auto sni_name_list_bytes = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res += 2));
|
|
|
+ auto sni_name_list_bytes = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res += 2)));
|
|
|
dbgln_if(TLS_DEBUG, "SNI: expecting ServerNameList of {} bytes", sni_name_list_bytes);
|
|
|
|
|
|
// Exactly one ServerName should be present
|
|
|
if (buffer.size() - res < 3)
|
|
|
return (i8)Error::NeedMoreData;
|
|
|
auto sni_name_type = (NameType)(*(const u8*)buffer.offset_pointer(res++));
|
|
|
- auto sni_name_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res += 2));
|
|
|
+ auto sni_name_length = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res += 2)));
|
|
|
|
|
|
if (sni_name_type != NameType::HostName)
|
|
|
return (i8)Error::NotUnderstood;
|
|
@@ -158,7 +158,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|
|
}
|
|
|
} else if (extension_type == HandshakeExtension::ApplicationLayerProtocolNegotiation && m_context.alpn.size()) {
|
|
|
if (buffer.size() - res > 2) {
|
|
|
- auto alpn_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
|
|
|
+ auto alpn_length = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res)));
|
|
|
if (alpn_length && alpn_length <= extension_length - 2) {
|
|
|
const u8* alpn = buffer.offset_pointer(res + 2);
|
|
|
size_t alpn_position = 0;
|