9 #include <botan/bigint.h>
10 #include <botan/divide.h>
11 #include <botan/internal/mp_core.h>
12 #include <botan/internal/bit_ops.h>
22 BigInt z(x.
sign(), std::max(x_sw, y_words) + 1);
24 if(x.
sign() == y_sign)
30 const int32_t relative_size =
bigint_sub_abs(z.mutable_data(), x.
data(), x_sw, y, y_words);
35 else if(relative_size == 0)
54 else if(y_sw == 1 && x_sw)
63 workspace.data(), workspace.size());
66 z.cond_flip_sign(x_sw > 0 && y_sw > 0 && x.
sign() != y.
sign());
165 remainder = (n.
word_at(0) & (mod - 1));
170 for(
size_t i = sw; i > 0; --i)
177 return mod - remainder;
186 const size_t shift_words = shift / BOTAN_MP_WORD_BITS,
187 shift_bits = shift % BOTAN_MP_WORD_BITS;
191 BigInt y(x.
sign(), x_sw + shift_words + (shift_bits ? 1 : 0));
201 const size_t shift_words = shift / BOTAN_MP_WORD_BITS;
202 const size_t shift_bits = shift % BOTAN_MP_WORD_BITS;
206 bigint_shr2(y.mutable_data(), x.
data(), x_sw, shift_words, shift_bits);
word word_at(size_t n) const
int operator<<(int fd, Pipe &pipe)
void vartime_divide(const BigInt &x, const BigInt &y_arg, BigInt &q_out, BigInt &r_out)
void bigint_shr2(word y[], const word x[], size_t x_size, size_t word_shift, size_t bit_shift)
BigInt operator/(const BigInt &x, const BigInt &y)
void bigint_linmul3(word z[], const word x[], size_t x_size, word y)
std::vector< T, secure_allocator< T >> secure_vector
CT::Mask< word > bigint_sub_abs(word z[], const word x[], const word y[], size_t N, word ws[])
constexpr bool is_power_of_2(T arg)
const word * data() const
void bigint_mul(word z[], size_t z_size, const word x[], size_t x_size, size_t x_sw, const word y[], size_t y_size, size_t y_sw, word workspace[], size_t ws_size)
void bigint_shl2(word y[], const word x[], size_t x_size, size_t word_shift, size_t bit_shift)
void ct_divide_u8(const BigInt &x, uint8_t y, BigInt &q_out, uint8_t &r_out)
BigInt operator*(const BigInt &x, const BigInt &y)
int operator>>(int fd, Pipe &pipe)
BigInt operator%(const BigInt &n, const BigInt &mod)
static BigInt add2(const BigInt &x, const word y[], size_t y_words, Sign y_sign)
void bigint_add3(word z[], const word x[], size_t x_size, const word y[], size_t y_size)
word bigint_modop(word n1, word n0, word d)