8 #include <botan/reducer.h> 9 #include <botan/internal/ct_utils.h> 10 #include <botan/internal/mp_core.h> 11 #include <botan/divide.h> 32 m_mu.
set_bit(2 * BOTAN_MP_WORD_BITS * m_mod_words);
53 throw Invalid_State(
"BigInt::sub_rev requires this is positive");
57 const size_t max_words = std::max(x_sw, y_sw);
58 ws.resize(std::max(x_sw, y_sw));
73 throw Invalid_State(
"Modular_Reducer arguments cannot alias");
79 if(x_sw > 2*m_mod_words)
88 t1 >>= (BOTAN_MP_WORD_BITS * (m_mod_words - 1));
91 t1 >>= (BOTAN_MP_WORD_BITS * (m_mod_words + 1));
94 t1.
mul(m_modulus, ws);
95 t1.
mask_bits(BOTAN_MP_WORD_BITS * (m_mod_words + 1));
97 t1.
rev_sub(x.
data(), std::min(x_sw, m_mod_words + 1), ws);
106 if(ws.size() < m_mod_words + 2)
107 ws.resize(m_mod_words + 2);
109 ws[m_mod_words + 1] = t1_neg;
void clear_mem(T *ptr, size_t n)
BigInt ct_modulo(const BigInt &x, const BigInt &y)
const word * data() const
CT::Mask< word > bigint_sub_abs(word z[], const word x[], const word y[], size_t N, word ws[])
void ct_divide(const BigInt &x, const BigInt &y, BigInt &q_out, BigInt &r_out)
void bigint_cnd_swap(word cnd, word x[], word y[], size_t size)
BigInt & add(const word y[], size_t y_words, Sign sign)
void cond_flip_sign(bool predicate)
void grow_to(size_t n) const
BigInt reduce(const BigInt &x) const
void ct_reduce_below(const BigInt &mod, secure_vector< word > &ws, size_t bound)
std::vector< T, secure_allocator< T > > secure_vector
BigInt & mul(const BigInt &y, secure_vector< word > &ws)
BigInt & rev_sub(const word y[], size_t y_words, secure_vector< word > &ws)