summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDexesTTP <dexes.ttp@gmail.com>2021-05-14 09:46:41 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-14 11:36:39 +0200
commit36a56871c04e77b088847cf9d51becfd8c032904 (patch)
tree2d1739544ce68c384fc2ab8f0d1ab669f9f73002
parent4728f2af8064e76f499d2ae5a957afff6330eb30 (diff)
downloadserenity-36a56871c04e77b088847cf9d51becfd8c032904.zip
LibCrypto: Prevent a signed overflow during BigInt Modular Power
The algorithm isn't explicit about what type this needs to be. But this passes all of the tests, so that's probably fine.
-rw-r--r--Userland/Libraries/LibCrypto/BigInt/Algorithms/ModularPower.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCrypto/BigInt/Algorithms/ModularPower.cpp b/Userland/Libraries/LibCrypto/BigInt/Algorithms/ModularPower.cpp
index 15dca5a721..258f96b750 100644
--- a/Userland/Libraries/LibCrypto/BigInt/Algorithms/ModularPower.cpp
+++ b/Userland/Libraries/LibCrypto/BigInt/Algorithms/ModularPower.cpp
@@ -58,9 +58,9 @@ ALWAYS_INLINE static u32 inverse_wrapped(u32 value)
{
VERIFY(value & 1);
- i64 b = static_cast<i64>(value);
- i64 k0 = (2 - b);
- i64 t = (b - 1);
+ u64 b = static_cast<u64>(value);
+ u64 k0 = (2 - b);
+ u64 t = (b - 1);
size_t i = 1;
while (i < 32) {
t = t * t;