8#include <botan/reducer.h>
10#include <botan/internal/ct_utils.h>
11#include <botan/internal/divide.h>
12#include <botan/internal/mp_core.h>
77 throw Invalid_State(
"BigInt::sub_rev requires this is positive");
82 const size_t max_words = std::max(x_sw, y_sw);
83 ws.resize(std::max(x_sw, y_sw));
97 throw Invalid_State(
"Modular_Reducer arguments cannot alias");
99 if(m_mod_words == 0) {
105 if(x_sw > 2 * m_mod_words) {
119 t1.
mul(m_modulus, ws);
122 t1.
rev_sub(x.
_data(), std::min(x_sw, m_mod_words + 1), ws);
131 if(ws.size() < m_mod_words + 2) {
132 ws.resize(m_mod_words + 2);
135 ws[m_mod_words + 1] = t1_neg;
#define BOTAN_ARG_CHECK(expr, msg)
BigInt & rev_sub(const word y[], size_t y_words, secure_vector< word > &ws)
void grow_to(size_t n) const
void ct_reduce_below(const BigInt &mod, secure_vector< word > &ws, size_t bound)
BigInt & mul(const BigInt &y, secure_vector< word > &ws)
void cond_flip_sign(bool predicate)
static BigInt power_of_2(size_t n)
const word * _data() const
BigInt & add(const word y[], size_t y_words, Sign sign)
BigInt & square(secure_vector< word > &ws)
static Modular_Reducer for_public_modulus(const BigInt &m)
BigInt square(const BigInt &x) const
static Modular_Reducer for_secret_modulus(const BigInt &m)
BigInt reduce(const BigInt &x) const
#define BOTAN_MP_WORD_BITS
constexpr void bigint_cnd_swap(W cnd, W x[], W y[], size_t size)
BigInt ct_modulo(const BigInt &x, const BigInt &y)
BigInt ct_divide_pow2k(size_t k, const BigInt &y)
constexpr auto bigint_sub_abs(W z[], const W x[], const W y[], size_t N, W ws[]) -> CT::Mask< W >
std::vector< T, secure_allocator< T > > secure_vector
constexpr void clear_mem(T *ptr, size_t n)