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>
51 throw Invalid_State(
"BigInt::sub_rev requires this is positive");
56 const size_t max_words = std::max(x_sw, y_sw);
57 ws.resize(std::max(x_sw, y_sw));
71 throw Invalid_State(
"Modular_Reducer arguments cannot alias");
73 if(m_mod_words == 0) {
79 if(x_sw > 2 * m_mod_words) {
93 t1.
mul(m_modulus, ws);
96 t1.
rev_sub(x.
_data(), std::min(x_sw, m_mod_words + 1), ws);
105 if(ws.size() < m_mod_words + 2) {
106 ws.resize(m_mod_words + 2);
109 ws[m_mod_words + 1] = t1_neg;
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)
const word * _data() const
BigInt & add(const word y[], size_t y_words, Sign sign)
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)
void ct_divide(const BigInt &x, const BigInt &y, BigInt &q_out, BigInt &r_out)
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)