diff options
author | Jack Lloyd <[email protected]> | 2018-06-05 17:55:03 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-06-05 17:55:03 -0400 |
commit | c0cdcb3164d379851a995cd2b3d51944888d90df (patch) | |
tree | aff2479b03bf6aab292450d1b47847ff34b22b7a /src/tests/test_bigint.cpp | |
parent | b67c70c2e307049512a1e153e555a16314923e90 (diff) |
Fix a bug in Barrett reduction
-x*n % n would reduce to n instead of zero.
Also some small optimizations and cleanups.
Diffstat (limited to 'src/tests/test_bigint.cpp')
-rw-r--r-- | src/tests/test_bigint.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp index b62fa307d..8074a4f3b 100644 --- a/src/tests/test_bigint.cpp +++ b/src/tests/test_bigint.cpp @@ -9,6 +9,7 @@ #if defined(BOTAN_HAS_NUMBERTHEORY) #include <botan/bigint.h> #include <botan/numthry.h> + #include <botan/reducer.h> #include <botan/pow_mod.h> #include <botan/parsing.h> #include "test_rng.h" @@ -398,6 +399,9 @@ class BigInt_Mod_Test final : public Text_Based_Test e %= b; result.test_eq("a %= b", e, c); + const Botan::Modular_Reducer mod_b(b); + 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)) { |