1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:18:12 +00:00

LibTLS: Compute the master secret in a single place

Before we were computing the master secret in the different
`build_*_pre_master_secret` methods, but this can be simplified to a
single call.
This commit is contained in:
Michiel Visser 2023-11-25 00:24:01 +01:00 committed by Ali Mohammad Pur
parent 0db6e0449e
commit 5ab64320b2

View file

@ -198,11 +198,6 @@ void TLSv12::build_rsa_pre_master_secret(PacketBuilder& builder)
print_buffer(outbuf);
}
if (!compute_master_secret_from_pre_master_secret(bytes)) {
dbgln("oh noes we could not derive a master key :(");
return;
}
builder.append_u24(outbuf.size() + 2);
builder.append((u16)outbuf.size());
builder.append(outbuf);
@ -245,11 +240,6 @@ void TLSv12::build_dhe_rsa_pre_master_secret(PacketBuilder& builder)
dbgln("premaster key: {:hex-dump}", (ReadonlyBytes)m_context.premaster_key);
}
if (!compute_master_secret_from_pre_master_secret(48)) {
dbgln("oh noes we could not derive a master key :(");
return;
}
builder.append_u24(dh_key_size + 2);
builder.append((u16)dh_key_size);
builder.append(dh_Yc_bytes);
@ -297,11 +287,6 @@ void TLSv12::build_ecdhe_rsa_pre_master_secret(PacketBuilder& builder)
dbgln("premaster key: {:hex-dump}", (ReadonlyBytes)m_context.premaster_key);
}
if (!compute_master_secret_from_pre_master_secret(48)) {
dbgln("oh noes we could not derive a master key :(");
return;
}
builder.append_u24(public_key.size() + 1);
builder.append((u8)public_key.size());
builder.append(public_key);
@ -414,6 +399,10 @@ ByteBuffer TLSv12::build_client_key_exchange()
update_packet(packet);
if (!compute_master_secret_from_pre_master_secret(48)) {
dbgln("oh noes we could not derive a master key :(");
}
return packet;
}