/src/botan/src/lib/math/numbertheory/reducer.cpp
Line | Count | Source |
1 | | /* |
2 | | * Modular Reducer |
3 | | * (C) 1999-2011,2018,2025 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #include <botan/reducer.h> |
9 | | |
10 | | #include <botan/internal/divide.h> |
11 | | |
12 | | namespace Botan { |
13 | | |
14 | 0 | Modular_Reducer::Modular_Reducer(const BigInt& mod) : m_mod_words(mod.sig_words()) { |
15 | 0 | if(mod < 0) { |
16 | 0 | throw Invalid_Argument("Modular_Reducer: modulus must be positive"); |
17 | 0 | } |
18 | | |
19 | 0 | m_modulus = mod; |
20 | 0 | } |
21 | | |
22 | 0 | BigInt Modular_Reducer::reduce(const BigInt& x) const { |
23 | 0 | return ct_modulo(x, m_modulus); |
24 | 0 | } |
25 | | |
26 | | } // namespace Botan |