diff options
author | Jack Lloyd <[email protected]> | 2018-12-01 13:06:31 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-01 13:06:31 -0500 |
commit | be796a3f30d4bec1af7c0e6770a0397dca6ccd4a (patch) | |
tree | 0b2607f4193a899c4012e3072f4a71e9d17128e4 /src/tests/test_bigint.cpp | |
parent | 5cc1b897edf52a2037004bae28291c67c966c320 (diff) |
Correct a bug in BigInt::operator%(word)
If reducing a negative number modulo a power of 2, an incorrect
result would be returned. This only affected the versions taking
a single word as the modulo.
Diffstat (limited to 'src/tests/test_bigint.cpp')
-rw-r--r-- | src/tests/test_bigint.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp index 3870c5c6f..c7b95b89a 100644 --- a/src/tests/test_bigint.cpp +++ b/src/tests/test_bigint.cpp @@ -433,12 +433,15 @@ class BigInt_Mod_Test final : public Text_Based_Test result.test_eq("Barrett", mod_b.reduce(a), c); // if b fits into a Botan::word test %= operator for words - if(b.bytes() <= sizeof(Botan::word)) + if(b.sig_words() == 1) { - Botan::word b_word = b.word_at(0); + const Botan::word b_word = b.word_at(0); + e = a; e %= b_word; result.test_eq("a %= b (as word)", e, c); + + result.test_eq("a % b (as word)", a % b_word, c); } return result; |