1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:57:45 +00:00

Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr

Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
This commit is contained in:
Sam Atkins 2022-01-20 17:47:39 +00:00 committed by Andreas Kling
parent 140f1d9e55
commit 45cf40653a
79 changed files with 202 additions and 274 deletions

View file

@ -193,7 +193,7 @@ void TLSv12::build_rsa_pre_master_secret(PacketBuilder& builder)
}
auto premaster_key_result = ByteBuffer::copy(random_bytes, bytes);
if (!premaster_key_result.has_value()) {
if (premaster_key_result.is_error()) {
dbgln("RSA premaster key generation failed, not enough memory");
return;
}
@ -245,7 +245,7 @@ void TLSv12::build_dhe_rsa_pre_master_secret(PacketBuilder& builder)
auto dh_random = Crypto::NumberTheory::random_number(0, dh_p);
auto dh_Yc = Crypto::NumberTheory::ModularPower(dh_g, dh_random, dh_p);
auto dh_Yc_bytes_result = ByteBuffer::create_uninitialized(dh_key_size);
if (!dh_Yc_bytes_result.has_value()) {
if (dh_Yc_bytes_result.is_error()) {
dbgln("Failed to build DHE_RSA premaster secret: not enough memory");
return;
}
@ -254,7 +254,7 @@ void TLSv12::build_dhe_rsa_pre_master_secret(PacketBuilder& builder)
auto premaster_key = Crypto::NumberTheory::ModularPower(dh_Ys, dh_random, dh_p);
auto premaster_key_result = ByteBuffer::create_uninitialized(dh_key_size);
if (!premaster_key_result.has_value()) {
if (premaster_key_result.is_error()) {
dbgln("Failed to build DHE_RSA premaster secret: not enough memory");
return;
}