mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibTLS: Hide some debug spam, use more dbgln_if and if constexpr
The debug console was full of 'Update hash with message of size x'.
This commit is contained in:
parent
2f9321a0d4
commit
57c6264877
1 changed files with 15 additions and 20 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include <AK/Endian.h>
|
#include <AK/Endian.h>
|
||||||
#include <AK/MemoryStream.h>
|
#include <AK/MemoryStream.h>
|
||||||
#include <LibCore/Timer.h>
|
#include <LibCore/Timer.h>
|
||||||
#include <LibCrypto/ASN1/DER.h>
|
|
||||||
#include <LibCrypto/PK/Code/EMSA_PSS.h>
|
#include <LibCrypto/PK/Code/EMSA_PSS.h>
|
||||||
#include <LibTLS/TLSv12.h>
|
#include <LibTLS/TLSv12.h>
|
||||||
|
|
||||||
|
@ -192,7 +191,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
|
||||||
|
|
||||||
void TLSv12::update_hash(ReadonlyBytes message, size_t header_size)
|
void TLSv12::update_hash(ReadonlyBytes message, size_t header_size)
|
||||||
{
|
{
|
||||||
dbgln("Update hash with message of size {}", message.size());
|
dbgln_if(TLS_DEBUG, "Update hash with message of size {}", message.size());
|
||||||
m_context.handshake_hash.update(message.slice(header_size));
|
m_context.handshake_hash.update(message.slice(header_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,14 +200,14 @@ ByteBuffer TLSv12::hmac_message(const ReadonlyBytes& buf, const Optional<Readonl
|
||||||
u64 sequence_number = AK::convert_between_host_and_network_endian(local ? m_context.local_sequence_number : m_context.remote_sequence_number);
|
u64 sequence_number = AK::convert_between_host_and_network_endian(local ? m_context.local_sequence_number : m_context.remote_sequence_number);
|
||||||
ensure_hmac(mac_length, local);
|
ensure_hmac(mac_length, local);
|
||||||
auto& hmac = local ? *m_hmac_local : *m_hmac_remote;
|
auto& hmac = local ? *m_hmac_local : *m_hmac_remote;
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("========================= PACKET DATA ==========================");
|
dbgln("========================= PACKET DATA ==========================");
|
||||||
print_buffer((const u8*)&sequence_number, sizeof(u64));
|
print_buffer((const u8*)&sequence_number, sizeof(u64));
|
||||||
print_buffer(buf.data(), buf.size());
|
print_buffer(buf.data(), buf.size());
|
||||||
if (buf2.has_value())
|
if (buf2.has_value())
|
||||||
print_buffer(buf2.value().data(), buf2.value().size());
|
print_buffer(buf2.value().data(), buf2.value().size());
|
||||||
dbgln("========================= PACKET DATA ==========================");
|
dbgln("========================= PACKET DATA ==========================");
|
||||||
#endif
|
}
|
||||||
hmac.update((const u8*)&sequence_number, sizeof(u64));
|
hmac.update((const u8*)&sequence_number, sizeof(u64));
|
||||||
hmac.update(buf);
|
hmac.update(buf);
|
||||||
if (buf2.has_value() && buf2.value().size()) {
|
if (buf2.has_value() && buf2.value().size()) {
|
||||||
|
@ -345,10 +344,10 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
||||||
|
|
||||||
length = decrypted_span.size();
|
length = decrypted_span.size();
|
||||||
|
|
||||||
#if TLS_DEBUG
|
if constexpr (TLS_DEBUG) {
|
||||||
dbgln("Decrypted: ");
|
dbgln("Decrypted: ");
|
||||||
print_buffer(decrypted);
|
print_buffer(decrypted);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
auto mac_size = mac_length();
|
auto mac_size = mac_length();
|
||||||
if (length < mac_size) {
|
if (length < mac_size) {
|
||||||
|
@ -396,9 +395,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::Handshake:
|
case MessageType::Handshake:
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "tls handshake message");
|
||||||
dbgln("tls handshake message");
|
|
||||||
#endif
|
|
||||||
payload_res = handle_payload(plain);
|
payload_res = handle_payload(plain);
|
||||||
break;
|
break;
|
||||||
case MessageType::ChangeCipher:
|
case MessageType::ChangeCipher:
|
||||||
|
@ -407,9 +404,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
||||||
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
|
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
|
||||||
payload_res = (i8)Error::UnexpectedMessage;
|
payload_res = (i8)Error::UnexpectedMessage;
|
||||||
} else {
|
} else {
|
||||||
#if TLS_DEBUG
|
dbgln_if(TLS_DEBUG, "change cipher spec message");
|
||||||
dbgln("change cipher spec message");
|
|
||||||
#endif
|
|
||||||
m_context.cipher_spec_set = true;
|
m_context.cipher_spec_set = true;
|
||||||
m_context.remote_sequence_number = 0;
|
m_context.remote_sequence_number = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue