1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:17:35 +00:00

LibCrypto: Fix bug in big int subtraction

A regression test was added to the suite.

This commit also generally simplifies the subtraction method.
This commit is contained in:
Itamar 2020-04-09 16:29:09 +03:00 committed by Andreas Kling
parent 0d2777752e
commit 709c691f38
2 changed files with 19 additions and 16 deletions

View file

@ -915,6 +915,15 @@ void bigint_subtraction()
// this test only verifies that we don't crash on an assertion
PASS;
}
{
I_TEST((BigInteger | Subtraction Regerssion 1));
auto num = Crypto::UnsignedBigInteger { 1 }.shift_left(256);
if (num.sub(1).words() == Vector<u32> { 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 0 }) {
PASS;
} else {
FAIL(Incorrect Result);
}
}
}
void bigint_multiplication()