mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +00:00
LibCrypto: Add a += operation to UnsignedBigIntegerAlgorithms
This new operation is immediately used in several existing algorithms.
This commit is contained in:
parent
f4e6f58cc6
commit
5071989545
Notes:
sideshowbarker
2024-07-18 18:13:44 +09:00
Author: https://github.com/Dexesttp
Commit: 5071989545
Pull-request: https://github.com/SerenityOS/serenity/pull/7067
Reviewed-by: https://github.com/alimpfard
10 changed files with 151 additions and 47 deletions
|
@ -16,7 +16,6 @@ void UnsignedBigIntegerAlgorithms::modular_inverse_without_allocation(
|
|||
UnsignedBigInteger& temp_2,
|
||||
UnsignedBigInteger& temp_3,
|
||||
UnsignedBigInteger& temp_4,
|
||||
UnsignedBigInteger& temp_plus,
|
||||
UnsignedBigInteger& temp_minus,
|
||||
UnsignedBigInteger& temp_quotient,
|
||||
UnsignedBigInteger& temp_d,
|
||||
|
@ -30,8 +29,7 @@ void UnsignedBigIntegerAlgorithms::modular_inverse_without_allocation(
|
|||
temp_u.set_to(a);
|
||||
if (a.words()[0] % 2 == 0) {
|
||||
// u += b
|
||||
add_without_allocation(temp_u, b, temp_plus);
|
||||
temp_u.set_to(temp_plus);
|
||||
add_into_accumulator_without_allocation(temp_u, b);
|
||||
}
|
||||
|
||||
temp_v.set_to(b);
|
||||
|
@ -47,14 +45,12 @@ void UnsignedBigIntegerAlgorithms::modular_inverse_without_allocation(
|
|||
temp_u.set_to(temp_minus);
|
||||
|
||||
// d += x
|
||||
add_without_allocation(temp_d, temp_x, temp_plus);
|
||||
temp_d.set_to(temp_plus);
|
||||
add_into_accumulator_without_allocation(temp_d, temp_x);
|
||||
|
||||
while (temp_u.words()[0] % 2 == 0) {
|
||||
if (temp_d.words()[0] % 2 == 1) {
|
||||
// d += b
|
||||
add_without_allocation(temp_d, b, temp_plus);
|
||||
temp_d.set_to(temp_plus);
|
||||
add_into_accumulator_without_allocation(temp_d, b);
|
||||
}
|
||||
|
||||
// u /= 2
|
||||
|
@ -72,14 +68,12 @@ void UnsignedBigIntegerAlgorithms::modular_inverse_without_allocation(
|
|||
temp_v.set_to(temp_minus);
|
||||
|
||||
// x += d
|
||||
add_without_allocation(temp_x, temp_d, temp_plus);
|
||||
temp_x.set_to(temp_plus);
|
||||
add_into_accumulator_without_allocation(temp_x, temp_d);
|
||||
|
||||
while (temp_v.words()[0] % 2 == 0) {
|
||||
if (temp_x.words()[0] % 2 == 1) {
|
||||
// x += b
|
||||
add_without_allocation(temp_x, b, temp_plus);
|
||||
temp_x.set_to(temp_plus);
|
||||
add_into_accumulator_without_allocation(temp_x, b);
|
||||
}
|
||||
|
||||
// v /= 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue