mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:47:34 +00:00
Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to easily find them later: awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in) do find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \; done # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list. awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
This commit is contained in:
parent
76f2918416
commit
1a3a0836c0
59 changed files with 475 additions and 459 deletions
|
@ -91,7 +91,7 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
|||
if (session_length && session_length <= 32) {
|
||||
memcpy(m_context.session_id, buffer.offset_pointer(res), session_length);
|
||||
m_context.session_id_size = session_length;
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Remote session ID:");
|
||||
print_buffer(ReadonlyBytes { m_context.session_id, session_length });
|
||||
#endif
|
||||
|
@ -228,7 +228,7 @@ ssize_t TLSv12::handle_finished(ReadonlyBytes buffer, WritePacketStage& write_pa
|
|||
}
|
||||
|
||||
// TODO: Compare Hashes
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("FIXME: handle_finished :: Check message validity");
|
||||
#endif
|
||||
m_context.connection_status = ConnectionStatus::Established;
|
||||
|
@ -276,7 +276,7 @@ void TLSv12::build_random(PacketBuilder& builder)
|
|||
}
|
||||
|
||||
auto& certificate = m_context.certificates[certificate_option.value()];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("PreMaster secret");
|
||||
print_buffer(m_context.premaster_key);
|
||||
#endif
|
||||
|
@ -287,7 +287,7 @@ void TLSv12::build_random(PacketBuilder& builder)
|
|||
auto outbuf = Bytes { out, rsa.output_size() };
|
||||
rsa.encrypt(m_context.premaster_key, outbuf);
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Encrypted: ");
|
||||
print_buffer(outbuf);
|
||||
#endif
|
||||
|
@ -305,7 +305,7 @@ void TLSv12::build_random(PacketBuilder& builder)
|
|||
ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
||||
{
|
||||
if (m_context.connection_status == ConnectionStatus::Established) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Renegotiation attempt ignored");
|
||||
#endif
|
||||
// FIXME: We should properly say "NoRenegotiation", but that causes a handshake failure
|
||||
|
@ -359,7 +359,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[2];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("server hello");
|
||||
#endif
|
||||
if (m_context.is_server) {
|
||||
|
@ -380,7 +380,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[4];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("certificate");
|
||||
#endif
|
||||
if (m_context.connection_status == ConnectionStatus::Negotiating) {
|
||||
|
@ -415,7 +415,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[5];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("server key exchange");
|
||||
#endif
|
||||
if (m_context.is_server) {
|
||||
|
@ -451,7 +451,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[7];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("server hello done");
|
||||
#endif
|
||||
if (m_context.is_server) {
|
||||
|
@ -470,7 +470,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[8];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("certificate verify");
|
||||
#endif
|
||||
if (m_context.connection_status == ConnectionStatus::KeyExchange) {
|
||||
|
@ -486,7 +486,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[9];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("client key exchange");
|
||||
#endif
|
||||
if (m_context.is_server) {
|
||||
|
@ -506,7 +506,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
}
|
||||
++m_context.handshake_messages[10];
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("finished");
|
||||
#endif
|
||||
payload_res = handle_finished(buffer.slice(1, payload_size), write_packets);
|
||||
|
@ -593,7 +593,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
break;
|
||||
case WritePacketStage::ClientHandshake:
|
||||
if (m_context.client_verified == VerificationNeeded) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> Client Certificate");
|
||||
#endif
|
||||
auto packet = build_certificate();
|
||||
|
@ -601,14 +601,14 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
m_context.client_verified = Verified;
|
||||
}
|
||||
{
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> Key exchange");
|
||||
#endif
|
||||
auto packet = build_client_key_exchange();
|
||||
write_packet(packet);
|
||||
}
|
||||
{
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> change cipher spec");
|
||||
#endif
|
||||
auto packet = build_change_cipher_spec();
|
||||
|
@ -617,7 +617,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
m_context.cipher_spec_set = 1;
|
||||
m_context.local_sequence_number = 0;
|
||||
{
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> client finished");
|
||||
#endif
|
||||
auto packet = build_finished();
|
||||
|
@ -633,14 +633,14 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
case WritePacketStage::Finished:
|
||||
// finished
|
||||
{
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> change cipher spec");
|
||||
#endif
|
||||
auto packet = build_change_cipher_spec();
|
||||
write_packet(packet);
|
||||
}
|
||||
{
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("> client finished");
|
||||
#endif
|
||||
auto packet = build_finished();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCrypto/ASN1/DER.h>
|
||||
#include <LibCrypto/PK/Code/EMSA_PSS.h>
|
||||
#include <LibTLS/TLSv12.h>
|
||||
|
@ -72,7 +73,7 @@ bool TLSv12::expand_key()
|
|||
auto server_iv = key + offset;
|
||||
offset += iv_size;
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("client key");
|
||||
print_buffer(client_key, key_size);
|
||||
dbgln("server key");
|
||||
|
@ -171,7 +172,7 @@ bool TLSv12::compute_master_secret(size_t length)
|
|||
ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) });
|
||||
|
||||
m_context.premaster_key.clear();
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("master key:");
|
||||
print_buffer(m_context.master_key);
|
||||
#endif
|
||||
|
@ -213,7 +214,7 @@ ByteBuffer TLSv12::build_certificate()
|
|||
builder.append((u8)HandshakeType::CertificateMessage);
|
||||
|
||||
if (!total_certificate_size) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("No certificates, sending empty certificate message");
|
||||
#endif
|
||||
builder.append_u24(certificate_vector_header_size);
|
||||
|
|
|
@ -200,7 +200,7 @@ 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);
|
||||
ensure_hmac(mac_length, local);
|
||||
auto& hmac = local ? *m_hmac_local : *m_hmac_remote;
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("========================= PACKET DATA ==========================");
|
||||
print_buffer((const u8*)&sequence_number, sizeof(u64));
|
||||
print_buffer(buf.data(), buf.size());
|
||||
|
@ -344,7 +344,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
|
||||
length = decrypted_span.size();
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Decrypted: ");
|
||||
print_buffer(decrypted);
|
||||
#endif
|
||||
|
@ -395,7 +395,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
}
|
||||
break;
|
||||
case MessageType::Handshake:
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("tls handshake message");
|
||||
#endif
|
||||
payload_res = handle_payload(plain);
|
||||
|
@ -406,7 +406,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
auto packet = build_alert(true, (u8)AlertDescription::UnexpectedMessage);
|
||||
payload_res = (i8)Error::UnexpectedMessage;
|
||||
} else {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("change cipher spec message");
|
||||
#endif
|
||||
m_context.cipher_spec_set = true;
|
||||
|
|
|
@ -77,7 +77,7 @@ String TLSv12::read_line(size_t max_size)
|
|||
bool TLSv12::write(ReadonlyBytes buffer)
|
||||
{
|
||||
if (m_context.connection_status != ConnectionStatus::Established) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("write request while not connected");
|
||||
#endif
|
||||
return false;
|
||||
|
@ -193,7 +193,7 @@ bool TLSv12::check_connection_state(bool read)
|
|||
{
|
||||
if (!Core::Socket::is_open() || !Core::Socket::is_connected() || Core::Socket::eof()) {
|
||||
// an abrupt closure (the server is a jerk)
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Socket not open, assuming abrupt closure");
|
||||
#endif
|
||||
m_context.connection_finished = true;
|
||||
|
@ -216,7 +216,7 @@ bool TLSv12::check_connection_state(bool read)
|
|||
m_context.application_buffer.size());
|
||||
} else {
|
||||
m_context.connection_finished = false;
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("FINISHED");
|
||||
#endif
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ bool TLSv12::flush()
|
|||
if (out_buffer_length == 0)
|
||||
return true;
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("SENDING...");
|
||||
print_buffer(out_buffer, out_buffer_length);
|
||||
#endif
|
||||
|
|
|
@ -208,7 +208,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8*
|
|||
size_t length = _get_asn1_length((const u8*)&buffer[position], size - position, octets);
|
||||
|
||||
if (octets > 4 || octets > size - position) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("could not read the certificate");
|
||||
#endif
|
||||
return position;
|
||||
|
@ -216,7 +216,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8*
|
|||
|
||||
position += octets;
|
||||
if (size - position < length) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("not enough data for sequence");
|
||||
#endif
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
@ -415,7 +415,7 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8*
|
|||
auto fingerprint = hash.digest();
|
||||
cert.fingerprint.grow(fingerprint.data_length());
|
||||
cert.fingerprint.overwrite(0, fingerprint.immutable_data(), fingerprint.data_length());
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("Certificate fingerprint:");
|
||||
print_buffer(cert.fingerprint);
|
||||
#endif
|
||||
|
@ -446,7 +446,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
|||
ssize_t res = 0;
|
||||
|
||||
if (buffer.size() < 3) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("not enough certificate header data");
|
||||
#endif
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
@ -462,7 +462,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
|||
res += 3;
|
||||
|
||||
if (certificate_total_length > buffer.size() - res) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("not enough data for claimed total cert length");
|
||||
#endif
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
@ -475,7 +475,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
|||
while (size > 0) {
|
||||
++index;
|
||||
if (buffer.size() - res < 3) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("not enough data for certificate length");
|
||||
#endif
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
@ -484,7 +484,7 @@ ssize_t TLSv12::handle_certificate(ReadonlyBytes buffer)
|
|||
res += 3;
|
||||
|
||||
if (buffer.size() - res < certificate_size) {
|
||||
#ifdef TLS_DEBUG
|
||||
#if TLS_DEBUG
|
||||
dbgln("not enough data for certificate body");
|
||||
#endif
|
||||
return (i8)Error::NeedMoreData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue