aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint/bigint.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-03-08 07:51:50 -0400
committerJack Lloyd <[email protected]>2020-03-08 07:51:50 -0400
commit9999cf59c604cef4bbebda3048c53732627fe851 (patch)
treee11ac9279920c8c3e3c7c20cc1ebee3a7457eefd /src/lib/math/bigint/bigint.cpp
parent5d74496ee51b8a2d1c418b0a66bddac6f0263749 (diff)
Fix underflow bug in modular inverse
OSS-Fuzz 21115
Diffstat (limited to 'src/lib/math/bigint/bigint.cpp')
-rw-r--r--src/lib/math/bigint/bigint.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp
index fac82defa..96ca92b35 100644
--- a/src/lib/math/bigint/bigint.cpp
+++ b/src/lib/math/bigint/bigint.cpp
@@ -455,6 +455,8 @@ void BigInt::binary_decode(const uint8_t buf[], size_t length)
void BigInt::ct_cond_add(bool predicate, const BigInt& value)
{
+ if(this->is_negative() || value.is_negative())
+ throw Invalid_Argument("BigInt::ct_cond_add requires both values to be positive");
this->grow_to(1 + value.sig_words());
bigint_cnd_add(static_cast<word>(predicate),