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:
devgianlu 2025-04-25 21:28:00 +02:00 committed by Jelle Raaijmakers
parent 14387e5411
commit 5f1a30197c
Notes: github-actions[bot] 2025-04-28 10:06:55 +00:00
12 changed files with 34 additions and 109 deletions

View file

@ -68,7 +68,7 @@ void UnsignedBigIntegerAlgorithms::extended_GCD_without_allocation(
while (gcd < temp_1) {
add_into_accumulator_without_allocation(gcd, b);
}
subtract_without_allocation(gcd, temp_1, temp_r);
MUST(subtract_without_allocation(gcd, temp_1, temp_r));
gcd.set_to(temp_2);
// (old_s, s) := (s, old_s quotient × s)
@ -77,7 +77,7 @@ void UnsignedBigIntegerAlgorithms::extended_GCD_without_allocation(
while (x < temp_1) {
add_into_accumulator_without_allocation(x, b);
}
subtract_without_allocation(x, temp_1, temp_s);
MUST(subtract_without_allocation(x, temp_1, temp_s));
x.set_to(temp_2);
// (old_t, t) := (t, old_t quotient × t)
@ -86,7 +86,7 @@ void UnsignedBigIntegerAlgorithms::extended_GCD_without_allocation(
while (y < temp_1) {
add_into_accumulator_without_allocation(y, b);
}
subtract_without_allocation(y, temp_1, temp_t);
MUST(subtract_without_allocation(y, temp_1, temp_t));
y.set_to(temp_2);
}
}