mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 02:08:58 +00:00
LibCrypto: Fix a bug in big int addition
There was a bug when dealing with a carry when the addition result for the current word was UINT32_MAX. This commit also adds a regression test for the bug.
This commit is contained in:
parent
e0cf40518c
commit
2843dce498
Notes:
sideshowbarker
2024-07-19 07:05:53 +09:00
Author: https://github.com/itamar8910
Commit: 2843dce498
Pull-request: https://github.com/SerenityOS/serenity/pull/1661
Reviewed-by: https://github.com/Dexesttp
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
2 changed files with 9 additions and 1 deletions
|
@ -843,6 +843,14 @@ void bigint_addition_edgecases()
|
|||
FAIL(Incorrect Result);
|
||||
}
|
||||
}
|
||||
{
|
||||
I_TEST((BigInteger | Borrow with zero));
|
||||
Crypto::UnsignedBigInteger num1({ UINT32_MAX - 3, UINT32_MAX });
|
||||
Crypto::UnsignedBigInteger num2({ UINT32_MAX - 2, 0 });
|
||||
if (num1.add(num2).words() == Vector<u32> { 4294967289, 0, 1 }) {
|
||||
PASS;
|
||||
} else {
|
||||
FAIL(Incorrect Result);
|
||||
}
|
||||
|
||||
void bigint_subtraction()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue