mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-07 01:21:57 +00:00
LibCrypto: Remove the concept of invalid big integers
This concept is rarely used in codebase and very much error-prone if you forget to check it. Instead, make it so that operations that would produce invalid integers return an error instead.
This commit is contained in:
parent
14387e5411
commit
5f1a30197c
Notes:
github-actions[bot]
2025-04-28 10:06:55 +00:00
Author: https://github.com/devgianlu
Commit: 5f1a30197c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4482
Reviewed-by: https://github.com/gmta ✅
12 changed files with 34 additions and 109 deletions
|
@ -23,16 +23,6 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_or_without_allocation(
|
|||
UnsignedBigInteger const& right,
|
||||
UnsignedBigInteger& output)
|
||||
{
|
||||
// If either of the BigInts are invalid, the output is just the other one.
|
||||
if (left.is_invalid()) {
|
||||
output.set_to(right);
|
||||
return;
|
||||
}
|
||||
if (right.is_invalid()) {
|
||||
output.set_to(left);
|
||||
return;
|
||||
}
|
||||
|
||||
UnsignedBigInteger const *shorter, *longer;
|
||||
if (left.length() < right.length()) {
|
||||
shorter = &left;
|
||||
|
@ -62,16 +52,6 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_and_without_allocation(
|
|||
UnsignedBigInteger const& right,
|
||||
UnsignedBigInteger& output)
|
||||
{
|
||||
// If either of the BigInts are invalid, the output is just the other one.
|
||||
if (left.is_invalid()) {
|
||||
output.set_to(right);
|
||||
return;
|
||||
}
|
||||
if (right.is_invalid()) {
|
||||
output.set_to(left);
|
||||
return;
|
||||
}
|
||||
|
||||
UnsignedBigInteger const *shorter, *longer;
|
||||
if (left.length() < right.length()) {
|
||||
shorter = &left;
|
||||
|
@ -101,16 +81,6 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_xor_without_allocation(
|
|||
UnsignedBigInteger const& right,
|
||||
UnsignedBigInteger& output)
|
||||
{
|
||||
// If either of the BigInts are invalid, the output is just the other one.
|
||||
if (left.is_invalid()) {
|
||||
output.set_to(right);
|
||||
return;
|
||||
}
|
||||
if (right.is_invalid()) {
|
||||
output.set_to(left);
|
||||
return;
|
||||
}
|
||||
|
||||
UnsignedBigInteger const *shorter, *longer;
|
||||
if (left.length() < right.length()) {
|
||||
shorter = &left;
|
||||
|
@ -137,12 +107,6 @@ FLATTEN ErrorOr<void> UnsignedBigIntegerAlgorithms::bitwise_not_fill_to_one_base
|
|||
size_t index,
|
||||
UnsignedBigInteger& output)
|
||||
{
|
||||
// If the value is invalid, the output value is invalid as well.
|
||||
if (right.is_invalid()) {
|
||||
output.invalidate();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
output.set_to_0();
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue