diff options
author | Jack Lloyd <[email protected]> | 2020-03-08 07:51:50 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-03-08 07:51:50 -0400 |
commit | 9999cf59c604cef4bbebda3048c53732627fe851 (patch) | |
tree | e11ac9279920c8c3e3c7c20cc1ebee3a7457eefd /src/lib/math/bigint/bigint.cpp | |
parent | 5d74496ee51b8a2d1c418b0a66bddac6f0263749 (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.cpp | 2 |
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), |