summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTLS
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibTLS')
-rw-r--r--Userland/Libraries/LibTLS/ClientHandshake.cpp10
-rw-r--r--Userland/Libraries/LibTLS/Record.cpp16
-rw-r--r--Userland/Libraries/LibTLS/Socket.cpp8
-rw-r--r--Userland/Libraries/LibTLS/TLSv12.cpp12
4 files changed, 23 insertions, 23 deletions
diff --git a/Userland/Libraries/LibTLS/ClientHandshake.cpp b/Userland/Libraries/LibTLS/ClientHandshake.cpp
index 60498e7366..39f2193a8e 100644
--- a/Userland/Libraries/LibTLS/ClientHandshake.cpp
+++ b/Userland/Libraries/LibTLS/ClientHandshake.cpp
@@ -112,7 +112,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
return (i8)Error::NoCommonCipher;
}
m_context.cipher = cipher;
- dbgln<TLS_DEBUG>("Cipher: {}", (u16)cipher);
+ dbgln_if(TLS_DEBUG, "Cipher: {}", (u16)cipher);
// The handshake hash function is _always_ SHA256
m_context.handshake_hash.initialize(Crypto::Hash::HashKind::SHA256);
@@ -146,7 +146,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
u16 extension_length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(res));
res += 2;
- dbgln<TLS_DEBUG>("extension {} with length {}", (u16)extension_type, extension_length);
+ dbgln_if(TLS_DEBUG, "extension {} with length {}", (u16)extension_type, extension_length);
if (extension_length) {
if (buffer.size() - res < extension_length) {
@@ -218,12 +218,12 @@ ssize_t TLSv12::handle_finished(ReadonlyBytes buffer, WritePacketStage& write_pa
u32 size = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2];
if (size < 12) {
- dbgln<TLS_DEBUG>("finished packet smaller than minimum size: {}", size);
+ dbgln_if(TLS_DEBUG, "finished packet smaller than minimum size: {}", size);
return (i8)Error::BrokenPacket;
}
if (size < buffer.size() - index) {
- dbgln<TLS_DEBUG>("not enough data after length: {} > {}", size, buffer.size() - index);
+ dbgln_if(TLS_DEBUG, "not enough data after length: {} > {}", size, buffer.size() - index);
return (i8)Error::NeedMoreData;
}
@@ -324,7 +324,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
auto type = buffer[0];
auto write_packets { WritePacketStage::Initial };
size_t payload_size = buffer[1] * 0x10000 + buffer[2] * 0x100 + buffer[3] + 3;
- dbgln<TLS_DEBUG>("payload size: {} buffer length: {}", payload_size, buffer_length);
+ dbgln_if(TLS_DEBUG, "payload size: {} buffer length: {}", payload_size, buffer_length);
if (payload_size + 1 > buffer_length)
return (i8)Error::NeedMoreData;
diff --git a/Userland/Libraries/LibTLS/Record.cpp b/Userland/Libraries/LibTLS/Record.cpp
index be3e136681..4bdf6f0e9b 100644
--- a/Userland/Libraries/LibTLS/Record.cpp
+++ b/Userland/Libraries/LibTLS/Record.cpp
@@ -39,12 +39,12 @@ void TLSv12::write_packet(ByteBuffer& packet)
m_context.tls_buffer.append(packet.data(), packet.size());
if (m_context.connection_status > ConnectionStatus::Disconnected) {
if (!m_has_scheduled_write_flush) {
- dbgln<TLS_DEBUG>("Scheduling write of {}", m_context.tls_buffer.size());
+ dbgln_if(TLS_DEBUG, "Scheduling write of {}", m_context.tls_buffer.size());
deferred_invoke([this](auto&) { write_into_socket(); });
m_has_scheduled_write_flush = true;
} else {
// multiple packet are available, let's flush some out
- dbgln<TLS_DEBUG>("Flushing scheduled write of {}", m_context.tls_buffer.size());
+ dbgln_if(TLS_DEBUG, "Flushing scheduled write of {}", m_context.tls_buffer.size());
write_into_socket();
// the deferred invoke is still in place
m_has_scheduled_write_flush = true;
@@ -230,7 +230,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
size_t header_size = res;
ssize_t payload_res = 0;
- dbgln<TLS_DEBUG>("buffer size: {}", buffer.size());
+ dbgln_if(TLS_DEBUG, "buffer size: {}", buffer.size());
if (buffer.size() < 5) {
return (i8)Error::NeedMoreData;
@@ -249,15 +249,15 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
buffer_position += 2;
auto length = AK::convert_between_host_and_network_endian(*(const u16*)buffer.offset_pointer(buffer_position));
- dbgln<TLS_DEBUG>("record length: {} at offset: {}", length, buffer_position);
+ dbgln_if(TLS_DEBUG, "record length: {} at offset: {}", length, buffer_position);
buffer_position += 2;
if (buffer_position + length > buffer.size()) {
- dbgln<TLS_DEBUG>("record length more than what we have: {}", buffer.size());
+ dbgln_if(TLS_DEBUG, "record length more than what we have: {}", buffer.size());
return (i8)Error::NeedMoreData;
}
- dbgln<TLS_DEBUG>("message type: {}, length: {}", (u8)type, length);
+ dbgln_if(TLS_DEBUG, "message type: {}, length: {}", (u8)type, length);
auto plain = buffer.slice(buffer_position, buffer.size() - buffer_position);
ByteBuffer decrypted;
@@ -389,7 +389,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
write_packet(packet);
} else {
- dbgln<TLS_DEBUG>("application data message of size {}", plain.size());
+ dbgln_if(TLS_DEBUG, "application data message of size {}", plain.size());
m_context.application_buffer.append(plain.data(), plain.size());
}
@@ -414,7 +414,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
}
break;
case MessageType::Alert:
- dbgln<TLS_DEBUG>("alert message of length {}", length);
+ dbgln_if(TLS_DEBUG, "alert message of length {}", length);
if (length >= 2) {
if constexpr (TLS_DEBUG)
print_buffer(plain);
diff --git a/Userland/Libraries/LibTLS/Socket.cpp b/Userland/Libraries/LibTLS/Socket.cpp
index a8757cfb1b..3022b5e17d 100644
--- a/Userland/Libraries/LibTLS/Socket.cpp
+++ b/Userland/Libraries/LibTLS/Socket.cpp
@@ -174,7 +174,7 @@ void TLSv12::read_from_socket()
void TLSv12::write_into_socket()
{
- dbgln<TLS_DEBUG>("Flushing cached records: {} established? {}", m_context.tls_buffer.size(), is_established());
+ dbgln_if(TLS_DEBUG, "Flushing cached records: {} established? {}", m_context.tls_buffer.size(), is_established());
m_has_scheduled_write_flush = false;
if (!check_connection_state(false))
@@ -199,7 +199,7 @@ bool TLSv12::check_connection_state(bool read)
m_context.connection_finished = true;
}
if (m_context.critical_error) {
- dbgln<TLS_DEBUG>("CRITICAL ERROR {} :(", m_context.critical_error);
+ dbgln_if(TLS_DEBUG, "CRITICAL ERROR {} :(", m_context.critical_error);
if (on_tls_error)
on_tls_error((AlertDescription)m_context.critical_error);
@@ -211,7 +211,7 @@ bool TLSv12::check_connection_state(bool read)
on_tls_finished();
}
if (m_context.tls_buffer.size()) {
- dbgln<TLS_DEBUG>("connection closed without finishing data transfer, {} bytes still in buffer and {} bytes in application buffer",
+ dbgln_if(TLS_DEBUG, "connection closed without finishing data transfer, {} bytes still in buffer and {} bytes in application buffer",
m_context.tls_buffer.size(),
m_context.application_buffer.size());
} else {
@@ -247,7 +247,7 @@ bool TLSv12::flush()
}
if (m_context.send_retries++ == 10) {
// drop the records, we can't send
- dbgln<TLS_DEBUG>("Dropping {} bytes worth of TLS records as max retries has been reached", write_buffer().size());
+ dbgln_if(TLS_DEBUG, "Dropping {} bytes worth of TLS records as max retries has been reached", write_buffer().size());
write_buffer().clear();
m_context.send_retries = 0;
}
diff --git a/Userland/Libraries/LibTLS/TLSv12.cpp b/Userland/Libraries/LibTLS/TLSv12.cpp
index b94f6d47b0..4162028950 100644
--- a/Userland/Libraries/LibTLS/TLSv12.cpp
+++ b/Userland/Libraries/LibTLS/TLSv12.cpp
@@ -406,7 +406,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8*
hash.initialize(Crypto::Hash::HashKind::SHA512);
break;
default:
- dbgln<TLS_DEBUG>("Unsupported hash mode {}", (u32)cert.key_algorithm);
+ dbgln_if(TLS_DEBUG, "Unsupported hash mode {}", (u32)cert.key_algorithm);
// fallback to md5, it will fail later
hash.initialize(Crypto::Hash::HashKind::MD5);
break;
@@ -436,7 +436,7 @@ Optional<Certificate> TLSv12::parse_asn1(ReadonlyBytes buffer, bool) const
_parse_asn1(m_context, cert, buffer.data(), buffer.size(), 1, fields, nullptr, 0, nullptr, nullptr);
- dbgln<TLS_DEBUG>("Certificate issued for {} by {}", cert.subject, cert.issuer_subject);
+ dbgln_if(TLS_DEBUG, "Certificate issued for {} by {}", cert.subject, cert.issuer_subject);
return cert;
}
@@ -454,7 +454,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
u32 certificate_total_length = buffer[0] * 0x10000 + buffer[1] * 0x100 + buffer[2];
- dbgln<TLS_DEBUG>("total length: {}", certificate_total_length);
+ dbgln_if(TLS_DEBUG, "total length: {}", certificate_total_length);
if (certificate_total_length <= 4)
return 3 * certificate_total_length;
@@ -549,7 +549,7 @@ void TLSv12::consume(ReadonlyBytes record)
return;
}
- dbgln<TLS_DEBUG>("Consuming {} bytes", record.size());
+ dbgln_if(TLS_DEBUG, "Consuming {} bytes", record.size());
m_context.message_buffer.append(record.data(), record.size());
@@ -559,12 +559,12 @@ void TLSv12::consume(ReadonlyBytes record)
size_t size_offset { 3 }; // read the common record header
size_t header_size { 5 };
- dbgln<TLS_DEBUG>("message buffer length {}", buffer_length);
+ dbgln_if(TLS_DEBUG, "message buffer length {}", buffer_length);
while (buffer_length >= 5) {
auto length = AK::convert_between_host_and_network_endian(*(u16*)m_context.message_buffer.offset_pointer(index + size_offset)) + header_size;
if (length > buffer_length) {
- dbgln<TLS_DEBUG>("Need more data: {} > {}", length, buffer_length);
+ dbgln_if(TLS_DEBUG, "Need more data: {} > {}", length, buffer_length);
break;
}
auto consumed = handle_message(m_context.message_buffer.bytes().slice(index, length));