10#ifndef BOTAN_MP_CORE_OPS_H_
11#define BOTAN_MP_CORE_OPS_H_
13#include <botan/assert.h>
14#include <botan/types.h>
15#include <botan/internal/bit_ops.h>
16#include <botan/internal/ct_utils.h>
17#include <botan/internal/loadstor.h>
18#include <botan/internal/mem_utils.h>
19#include <botan/internal/mp_asmi.h>
36 for(
size_t i = 0; i != size; ++i) {
39 x[i] = mask.select(b, a);
40 y[i] = mask.select(a, b);
54 for(
size_t i = 0; i != size; ++i) {
55 x[i] =
word_add(x[i], y[i] & mask, &carry);
58 return (mask & carry);
66inline constexpr auto bigint_cnd_sub(W cnd, W x[],
const W y[],
size_t size) -> W {
71 for(
size_t i = 0; i != size; ++i) {
72 x[i] =
word_sub(x[i], y[i] & mask, &carry);
75 return (mask & carry);
87 W carry = mask.if_set_return(1);
88 for(
size_t i = 0; i != size; ++i) {
89 const W z =
word_add(~x[i],
static_cast<W
>(0), &carry);
90 x[i] = mask.select(z, x[i]);
98inline constexpr auto bigint_add2(W x[],
size_t x_size,
const W y[],
size_t y_size) -> W {
103 const size_t blocks = y_size - (y_size % 8);
105 for(
size_t i = 0; i != blocks; i += 8) {
109 for(
size_t i = blocks; i != y_size; ++i) {
110 x[i] =
word_add(x[i], y[i], &carry);
113 for(
size_t i = y_size; i != x_size; ++i) {
114 x[i] =
word_add(x[i],
static_cast<W
>(0), &carry);
124inline constexpr auto bigint_add3(W z[],
const W x[],
size_t x_size,
const W y[],
size_t y_size) -> W {
125 if(x_size < y_size) {
131 const size_t blocks = y_size - (y_size % 8);
133 for(
size_t i = 0; i != blocks; i += 8) {
134 carry =
word8_add3(z + i, x + i, y + i, carry);
137 for(
size_t i = blocks; i != y_size; ++i) {
138 z[i] =
word_add(x[i], y[i], &carry);
141 for(
size_t i = y_size; i != x_size; ++i) {
142 z[i] =
word_add(x[i],
static_cast<W
>(0), &carry);
152inline constexpr auto bigint_sub2(W x[],
size_t x_size,
const W y[],
size_t y_size) -> W {
157 const size_t blocks = y_size - (y_size % 8);
159 for(
size_t i = 0; i != blocks; i += 8) {
163 for(
size_t i = blocks; i != y_size; ++i) {
164 x[i] =
word_sub(x[i], y[i], &borrow);
167 for(
size_t i = y_size; i != x_size; ++i) {
168 x[i] =
word_sub(x[i],
static_cast<W
>(0), &borrow);
181 for(
size_t i = 0; i != y_size; ++i) {
182 x[i] =
word_sub(y[i], x[i], &borrow);
196inline constexpr auto bigint_sub3(W z[],
const W x[],
size_t x_size,
const W y[],
size_t y_size) -> W {
201 const size_t blocks = y_size - (y_size % 8);
203 for(
size_t i = 0; i != blocks; i += 8) {
204 borrow =
word8_sub3(z + i, x + i, y + i, borrow);
207 for(
size_t i = blocks; i != y_size; ++i) {
208 z[i] =
word_sub(x[i], y[i], &borrow);
211 for(
size_t i = y_size; i != x_size; ++i) {
212 z[i] =
word_sub(x[i],
static_cast<W
>(0), &borrow);
232 const size_t blocks = N - (N % 8);
234 for(
size_t i = 0; i != blocks; i += 8) {
235 borrow =
word8_sub3(z + i, x + i, p + i, borrow);
238 for(
size_t i = blocks; i != N; ++i) {
239 z[i] =
word_sub(x[i], p[i], &borrow);
242 borrow = (x0 - borrow) > x0;
257template <
size_t N, WordType W>
261 for(
size_t i = 0; i != N; ++i) {
262 z[i] =
word_sub(x[i], y[i], &borrow);
265 borrow = (x0 - borrow) > x0;
292 const size_t blocks = N - (N % 8);
294 for(
size_t i = 0; i != blocks; i += 8) {
295 borrow0 =
word8_sub3(ws0 + i, x + i, y + i, borrow0);
296 borrow1 =
word8_sub3(ws1 + i, y + i, x + i, borrow1);
299 for(
size_t i = blocks; i != N; ++i) {
300 ws0[i] =
word_sub(x[i], y[i], &borrow0);
301 ws1[i] =
word_sub(y[i], x[i], &borrow1);
313inline constexpr void bigint_shl1(W x[],
size_t x_size,
size_t x_words,
size_t shift) {
327 for(
size_t i = word_shift; i != x_size; ++i) {
329 x[i] = (w << bit_shift) | carry;
330 carry = carry_mask.if_set_return(w >>
carry_shift);
335inline constexpr void bigint_shr1(W x[],
size_t x_size,
size_t shift) {
339 const size_t top = x_size >= word_shift ? (x_size - word_shift) : 0;
351 for(
size_t i = 0; i != top; ++i) {
352 const W w = x[top - i - 1];
353 x[top - i - 1] = (w >> bit_shift) | carry;
354 carry = carry_mask.if_set_return(w <<
carry_shift);
359inline constexpr void bigint_shl2(W y[],
size_t y_size,
const W x[],
size_t x_size,
size_t shift) {
368 zeroize_buffer(y + word_shift + x_size, y_size - word_shift - x_size);
374 for(
size_t i = word_shift; i != x_size + word_shift + 1; ++i) {
376 y[i] = (w << bit_shift) | carry;
377 carry = carry_mask.if_set_return(w >>
carry_shift);
382inline constexpr void bigint_shr2(W y[],
size_t y_size,
const W x[],
size_t x_size,
size_t shift) {
385 const size_t new_size = x_size < word_shift ? 0 : (x_size - word_shift);
398 for(
size_t i = new_size; i > 0; --i) {
400 y[i - 1] = (w >> bit_shift) | carry;
401 carry = carry_mask.if_set_return(w <<
carry_shift);
409[[nodiscard]]
inline constexpr auto bigint_linmul2(W x[],
size_t x_size, W y) -> W {
412 for(
size_t i = 0; i != x_size; ++i) {
421 const size_t blocks = x_size - (x_size % 8);
425 for(
size_t i = 0; i != blocks; i += 8) {
429 for(
size_t i = blocks; i != x_size; ++i) {
443inline constexpr auto bigint_submul(W z[],
const W y[],
size_t N, W q) -> W {
447 for(
size_t i = 0; i != N; ++i) {
453 return mul_carry + borrow;
463inline constexpr int32_t
bigint_cmp(
const W x[],
size_t x_size,
const W y[],
size_t y_size) {
464 static_assert(
sizeof(W) >=
sizeof(uint32_t),
"Size assumption");
466 const W LT =
static_cast<W
>(-1);
470 const size_t common_elems = std::min(x_size, y_size);
474 for(
size_t i = 0; i != common_elems; i++) {
478 result = is_eq.select(result, is_lt.select(LT, GT));
481 if(x_size < y_size) {
483 for(
size_t i = x_size; i != y_size; i++) {
489 }
else if(y_size < x_size) {
491 for(
size_t i = y_size; i != x_size; i++) {
501 return static_cast<int32_t
>(result);
510inline constexpr auto bigint_ct_is_lt(
const W x[],
size_t x_size,
const W y[],
size_t y_size,
bool lt_or_equal =
false)
512 const size_t common_elems = std::min(x_size, y_size);
516 for(
size_t i = 0; i != common_elems; i++) {
519 is_lt = eq.select_mask(is_lt, lt);
522 if(x_size < y_size) {
524 for(
size_t i = x_size; i != y_size; i++) {
529 }
else if(y_size < x_size) {
531 for(
size_t i = y_size; i != x_size; i++) {
544 const size_t common_elems = std::min(x_size, y_size);
548 for(
size_t i = 0; i != common_elems; i++) {
549 diff |= (x[i] ^ y[i]);
553 if(x_size < y_size) {
554 for(
size_t i = x_size; i != y_size; i++) {
557 }
else if(y_size < x_size) {
558 for(
size_t i = y_size; i != x_size; i++) {
587 if constexpr(
sizeof(W) == 4) {
591 return static_cast<W
>(n / D);
593 if(!std::is_constant_evaluated()) {
594#if defined(BOTAN_MP_USE_X86_64_ASM)
599 :
"=a"(quotient),
"=d"(remainder)
603#elif !defined(BOTAN_BUILD_COMPILER_IS_CLANGCL)
614 return static_cast<W
>(n / D);
621 const W d9 = D >> 55;
622 const W d40 = (D >> 24) + 1;
623 const W d63 = (D >> 1) + d0;
626 const W v0 = ((W(1) << 19) - (W(3) << 8)) / d9;
627 const W v1 = (v0 << 11) - ((v0 * v0 * d40) >> 40) - 1;
628 const W v2 = (v1 << 13) + ((v1 * ((W(1) << 60) - v1 * d40)) >> 47);
630 const W e = W(0) - v2 * d63 + (v2 >> 1) * d0;
634 const W v3 = (v2 << 31) + (product_hi >> 1);
639 return v3 - D - product_hi;
655 W remainder =
static_cast<W
>(~D);
660 remainder =
static_cast<W
>((remainder << 1) | 1);
664 remainder -= sub.if_set_return(D);
665 quotient |= sub.if_set_return(1);
684class divide_precomp final {
689 const W norm_divisor = divisor << shift;
691 return divide_precomp(divisor, shift, norm_divisor,
reciprocal);
695 static constexpr divide_precomp
setup(W divisor) {
697 const W norm_divisor = divisor << shift;
699 return divide_precomp(divisor, shift, norm_divisor,
reciprocal);
705 const size_t shift = std::countl_zero(divisor);
706 return divide_precomp(divisor, shift, divisor << shift,
reciprocal);
721 const W q = div_2to1_max_d(n1, n0);
722 const W r =
static_cast<W
>(n0 + q);
723 return std::make_pair(q, r);
730 return std::make_pair(q, r);
757 n1 |= (n0 >> 1) >> (rshift - 1);
760 const auto [q, scaled_r] = div2by1_preinv(n1, n0, m_norm_divisor, m_reciprocal);
761 const W r = scaled_r >> m_shift;
762 return std::make_pair(q, r);
781 m_divisor(divisor), m_shift(shift), m_norm_divisor(norm_divisor), m_reciprocal(
reciprocal) {}
792 static constexpr std::pair<W, W> div2by1_preinv(W u1, W u0, W D, W v) {
803 q1 -= fix_down.if_set_return(1);
804 r += fix_down.if_set_return(D);
808 q1 += fix_up.if_set_return(1);
809 r -= fix_up.if_set_return(D);
812 return std::make_pair(q1, r);
819 static inline constexpr W div_2to1_max_d(W n1, W n0) {
847 const W s = n0 + n1 + 1;
877 for(
size_t i = 0; i != iter; ++i) {
887template <
size_t S, WordType W,
size_t N>
889 static_assert(N >= 1,
"Invalid input size");
890 static_assert(S > 0,
"Zero shift not supported");
891 static_assert(S < WordInfo<W>::bits,
"Shift too large");
895 for(
size_t i = N - 1; i != 0; --i) {
903template <
size_t S, WordType W,
size_t N>
905 static_assert(N >= 1,
"Invalid input size");
906 static_assert(S > 0,
"Zero shift not supported");
907 static_assert(S < WordInfo<W>::bits,
"Shift too large");
911 for(
size_t i = 0; i != N - 1; ++i) {
920template <WordType W,
size_t N>
923 const constexpr size_t C = N - 1;
929 const constexpr size_t S = (C + NPW - 1) / NPW;
931 static_assert(S > 0,
"Input too small");
933 const auto hex2int = [](
char c) -> int8_t {
934 if(c >=
'0' && c <=
'9') {
935 return static_cast<int8_t
>(c -
'0');
936 }
else if(c >=
'a' && c <=
'f') {
937 return static_cast<int8_t
>(c -
'a' + 10);
938 }
else if(c >=
'A' && c <=
'F') {
939 return static_cast<int8_t
>(c -
'A' + 10);
945 std::array<W, S> r = {0};
947 for(
size_t i = 0; i != C; ++i) {
948 const int8_t c = hex2int(s[i]);
980template <
size_t N, WordType W>
981constexpr inline void comba_mul(W z[2 * N],
const W x[N],
const W y[N]) {
982 if(!std::is_constant_evaluated()) {
983 if constexpr(std::same_as<W, word> && N == 4) {
986 if constexpr(std::same_as<W, word> && N == 6) {
989 if constexpr(std::same_as<W, word> && N == 7) {
992 if constexpr(std::same_as<W, word> && N == 8) {
995 if constexpr(std::same_as<W, word> && N == 9) {
998 if constexpr(std::same_as<W, word> && N == 16) {
1005 for(
size_t i = 0; i != 2 * N; ++i) {
1006 const size_t start = i + 1 < N ? 0 : i + 1 - N;
1007 const size_t end = std::min(N, i + 1);
1009 for(
size_t j = start; j != end; ++j) {
1010 accum.
mul(x[j], y[i - j]);
1016template <
size_t N, WordType W>
1018 if(!std::is_constant_evaluated()) {
1019 if constexpr(std::same_as<W, word> && N == 4) {
1022 if constexpr(std::same_as<W, word> && N == 6) {
1025 if constexpr(std::same_as<W, word> && N == 7) {
1028 if constexpr(std::same_as<W, word> && N == 8) {
1031 if constexpr(std::same_as<W, word> && N == 9) {
1034 if constexpr(std::same_as<W, word> && N == 16) {
1041 for(
size_t i = 0; i != 2 * N; ++i) {
1042 const size_t start = i + 1 < N ? 0 : i + 1 - N;
1043 const size_t end = std::min(N, i + 1);
1045 for(
size_t j = start; j != end; ++j) {
1046 accum.
mul(x[j], x[i - j]);
1069 word r[],
const word z[],
size_t z_size,
const word p[],
size_t p_size,
word p_dash,
word ws[]);
1087 word r[],
const word z[],
const word p[],
size_t p_size,
word p_dash,
word ws[],
size_t ws_size) {
1088 const size_t z_size = 2 * p_size;
1090 BOTAN_ARG_CHECK(ws_size >= p_size,
"Montgomery reduction workspace too small");
1094 }
else if(p_size == 6) {
1096 }
else if(p_size == 8) {
1098 }
else if(p_size == 12) {
1100 }
else if(p_size == 16) {
1102 }
else if(p_size == 24) {
1104 }
else if(p_size == 32) {
1136 word z[],
const word x[],
const word p[],
size_t p_size,
word p_dash,
word ws[],
size_t ws_size);
1164void bigint_sqr(
word z[],
size_t z_size,
const word x[],
size_t x_size,
size_t x_sw,
word workspace[],
size_t ws_size);
1176template <WordType W,
size_t N, W C>
1178 static_assert(N >= 2);
1180 std::array<W, N> hi = {};
1185 for(
size_t i = 0; i != N; ++i) {
1186 hi[i] =
word_madd3(z[i + N], C, z[i], &carry);
1191 carry_c[0] =
word_madd2(carry, C, &carry_c[1]);
1197 std::array<W, N> r = {};
1212#if defined(BOTAN_MP_USE_X86_64_ASM) && defined(__GNUC__) && !defined(__clang__)
1213 if constexpr(N == 4 && std::same_as<W, uint64_t>) {
1214 if(!std::is_constant_evaluated()) {
1216 movq 0(%[x]), %[borrow]
1217 subq %[p0], %[borrow]
1218 movq %[borrow], 0(%[r])
1219 movq 8(%[x]), %[borrow]
1221 movq %[borrow], 8(%[r])
1222 movq 16(%[x]), %[borrow]
1224 movq %[borrow], 16(%[r])
1225 movq 24(%[x]), %[borrow]
1227 movq %[borrow], 24(%[r])
1228 sbbq %[borrow],%[borrow]
1231 : [borrow] "=r"(borrow)
1232 : [x]
"r"(hi.data()), [p0]
"r"(
P0), [r]
"r"(r.data()),
"0"(borrow)
1235 borrow = (carry - borrow) > carry;
1243 for(
size_t i = 1; i != N; ++i) {
1247 borrow = (carry - borrow) > carry;
1254template <WordType W,
size_t N,
size_t L>
1256 static_assert(L <= WordInfo<W>::bytes * N);
1258 std::array<W, N> r = {};
1263 static_assert(full_words + (extra_bytes ? 1 : 0) <= N);
1265 for(
size_t i = 0; i != full_words; ++i) {
1266 r[i] =
load_be<W>(bytes.data(), full_words - 1 - i);
1269 if constexpr(extra_bytes > 0) {
1270 constexpr size_t shift = extra_bytes * 8;
1273 for(
size_t i = 0; i != extra_bytes; ++i) {
1275 r[0] |= (b0 << (8 * (extra_bytes - 1 - i)));
1283template <
size_t WindowBits,
typename W,
size_t N>
1285 static_assert(WindowBits >= 1 && WindowBits <= 7);
1287 constexpr uint8_t WindowMask =
static_cast<uint8_t
>(1 << WindowBits) - 1;
1289 constexpr size_t W_bits =
sizeof(W) * 8;
1290 const auto bit_shift = offset % W_bits;
1291 const auto word_offset = words.size() - 1 - (offset / W_bits);
1293 const bool single_byte_window = bit_shift <= (W_bits - WindowBits) || word_offset == 0;
1295 const auto w0 = words[word_offset];
1297 if(single_byte_window) {
1298 return (w0 >> bit_shift) & WindowMask;
1301 const auto w1 = words[word_offset - 1];
1302 const auto combined = ((w0 >> bit_shift) | (w1 << (W_bits - bit_shift)));
1303 return combined & WindowMask;
1312inline constexpr std::pair<size_t, CT::Choice>
booth_recode(
size_t x,
size_t window_bits) {
1314 const size_t neg_x = (
static_cast<size_t>(1) << (window_bits + 1)) - x - 1;
1315 size_t digit = sign.select(neg_x, x);
1316 digit = (digit >> 1) + (digit & 1);
1317 return {digit, sign.as_choice()};
1320template <
size_t WindowBits, std::
unsigned_
integral T>
1322 static_assert(WindowBits >= 1 && WindowBits <= 16);
1323 return booth_recode(
static_cast<size_t>(x), WindowBits);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
#define BOTAN_ARG_CHECK(expr, msg)
#define BOTAN_ASSERT(expr, assertion_made)
static constexpr Mask< T > is_gte(T x, T y)
static constexpr Mask< T > expand(T v)
static constexpr Mask< T > expand_top_bit(T v)
static constexpr Mask< T > is_equal(T x, T y)
static constexpr Mask< T > is_gt(T x, T y)
static constexpr Mask< T > is_lt(T x, T y)
static constexpr Mask< T > is_zero(T x)
constexpr W div_2to1(W n1, W n0) const
constexpr W mod_2to1(W n1, W n0) const
static constexpr divide_precomp setup_vartime(W divisor)
static constexpr divide_precomp setup(W divisor)
static constexpr divide_precomp setup_with_reciprocal(W divisor, W reciprocal)
constexpr std::pair< W, W > divmod_2to1_vartime(W n1, W n0) const
constexpr W reciprocal() const
constexpr std::pair< W, W > divmod_2to1_ct(W n1, W n0) const
constexpr void mul(W x, W y)
constexpr decltype(auto) driveby_unpoison(T &&v)
constexpr Mask< T > conditional_copy_mem(Mask< T > mask, T *dest, const T *if_set, const T *if_unset, size_t elems)
constexpr void unpoison(const T *p, size_t n)
constexpr Mask< T > conditional_assign_mem(T cnd, T *dest, const T *src, size_t elems)
constexpr void bigint_cnd_abs(W cnd, W x[], size_t size)
constexpr auto bigint_add2(W x[], size_t x_size, const W y[], size_t y_size) -> W
constexpr void bigint_linmul3(W z[], const W x[], size_t x_size, W y)
constexpr auto bigint_cnd_sub(W cnd, W x[], const W y[], size_t size) -> W
BOTAN_TEST_API void bigint_monty_mul(word z[], const word x[], const word y[], const word p[], size_t p_size, word p_dash, word ws[], size_t ws_size)
constexpr W reciprocal_word(W D)
constexpr auto bigint_add3(W z[], const W x[], size_t x_size, const W y[], size_t y_size) -> W
constexpr void bigint_cnd_swap(W cnd, W x[], W y[], size_t size)
constexpr auto word8_sub3(W z[8], const W x[8], const W y[8], W carry) -> W
constexpr auto bytes_to_words(std::span< const uint8_t, L > bytes)
constexpr W shift_left(std::array< W, N > &x)
constexpr auto word_sub(W x, W y, W *carry) -> W
constexpr auto word_add(W x, W y, W *carry) -> W
constexpr auto bigint_submul(W z[], const W y[], size_t N, W q) -> W
constexpr void comba_sqr(W z[2 *N], const W x[N])
constexpr uint64_t carry_shift(const donna128 &a, size_t shift)
BOTAN_FUZZER_API void basecase_sqr(word z[], size_t z_size, const word x[], size_t x_size)
constexpr size_t read_window_bits(std::span< const W, N > words, size_t offset)
void bigint_comba_sqr4(word z[8], const word x[4])
void bigint_comba_sqr6(word z[12], const word x[6])
constexpr void bigint_shr1(W x[], size_t x_size, size_t shift)
constexpr auto word8_add3(W z[8], const W x[8], const W y[8], W carry) -> W
constexpr std::pair< size_t, CT::Choice > booth_recode(size_t x, size_t window_bits)
BOTAN_FUZZER_API void bigint_monty_redc_6(word r[6], const word z[12], const word p[6], word p_dash, word ws[6])
constexpr void comba_mul(W z[2 *N], const W x[N], const W y[N])
constexpr auto word8_sub2(W x[8], const W y[8], W carry) -> W
void bigint_comba_sqr7(word z[14], const word x[7])
void bigint_comba_mul4(word z[8], const word x[4], const word y[4])
constexpr auto word_madd2(W a, W b, W *c) -> W
void bigint_sqr(word z[], size_t z_size, const word x[], size_t x_size, size_t x_sw, word workspace[], size_t ws_size)
void bigint_comba_mul16(word z[32], const word x[16], const word y[16])
BOTAN_FUZZER_API void bigint_monty_redc_24(word r[24], const word z[48], const word p[24], word p_dash, word ws[24])
constexpr auto bigint_sub3(W z[], const W x[], size_t x_size, const W y[], size_t y_size) -> W
constexpr auto monty_inverse(W a) -> W
BOTAN_FUZZER_API void bigint_monty_redc_generic(word r[], const word z[], size_t z_size, const word p[], size_t p_size, word p_dash, word ws[])
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 zeroize_buffer(T buf[], size_t n)
void bigint_comba_mul6(word z[12], const word x[6], const word y[6])
constexpr W reciprocal_word_ct(W D)
constexpr void bigint_shl1(W x[], size_t x_size, size_t x_words, size_t shift)
constexpr auto bigint_ct_is_eq(const W x[], size_t x_size, const W y[], size_t y_size) -> CT::Mask< W >
constexpr int32_t bigint_cmp(const W x[], size_t x_size, const W y[], size_t y_size)
BOTAN_FUZZER_API void bigint_monty_redc_4(word r[4], const word z[8], const word p[4], word p_dash, word ws[4])
void bigint_monty_redc_inplace(word z[], const word p[], size_t p_size, word p_dash, word ws[], size_t ws_size)
void bigint_monty_redc(word r[], const word z[], const word p[], size_t p_size, word p_dash, word ws[], size_t ws_size)
void bigint_comba_mul7(word z[14], const word x[7], const word y[7])
constexpr W bigint_cnd_add(W cnd, W x[], const W y[], size_t size)
void unchecked_copy_memory(T *out, const T *in, size_t n)
constexpr void bigint_monty_maybe_sub(size_t N, W z[], W x0, const W x[], const W p[])
void bigint_comba_mul9(word z[18], const word x[9], const word y[9])
BOTAN_FUZZER_API void bigint_monty_redc_12(word r[12], const word z[24], const word p[12], word p_dash, word ws[12])
BOTAN_TEST_API void bigint_monty_sqr(word z[], const word x[], const word p[], size_t p_size, word p_dash, word ws[], size_t ws_size)
BOTAN_FUZZER_API void bigint_monty_redc_16(word r[16], const word z[32], const word p[16], word p_dash, word ws[16])
constexpr void bigint_shr2(W y[], size_t y_size, const W x[], size_t x_size, size_t shift)
BOTAN_FORCE_INLINE constexpr size_t high_bit(T n)
void bigint_comba_mul24(word z[48], const word x[24], const word y[24])
constexpr auto bigint_sub_abs(W z[], const W x[], const W y[], size_t N, W ws[]) -> CT::Mask< W >
constexpr auto bigint_ct_is_lt(const W x[], size_t x_size, const W y[], size_t y_size, bool lt_or_equal=false) -> CT::Mask< W >
constexpr std::array< W, N > redc_crandall(std::span< const W, 2 *N > z)
constexpr auto word8_add2(W x[8], const W y[8], W carry) -> W
constexpr auto bigint_sub2(W x[], size_t x_size, const W y[], size_t y_size) -> W
void bigint_comba_sqr8(word z[16], const word x[8])
constexpr auto hex_to_words(const char(&s)[N])
void bigint_comba_sqr16(word z[32], const word x[16])
constexpr void bigint_shl2(W y[], size_t y_size, const W x[], size_t x_size, size_t shift)
constexpr void bigint_sub2_rev(W x[], const W y[], size_t y_size)
void bigint_comba_sqr9(word z[18], const word x[9])
constexpr auto word8_linmul3(W z[8], const W x[8], W y, W carry) -> W
BOTAN_FUZZER_API void basecase_mul(word z[], size_t z_size, const word x[], size_t x_size, const word y[], size_t y_size)
std::conditional_t< HasNative64BitRegisters, std::uint64_t, uint32_t > word
The native machine word, used as the limb type for multiprecision integers.
void bigint_comba_sqr24(word z[48], const word x[24])
void bigint_comba_mul8(word z[16], const word x[8], const word y[8])
BOTAN_FUZZER_API void bigint_monty_redc_8(word r[8], const word z[16], const word p[8], word p_dash, word ws[8])
constexpr auto load_be(ParamTs &&... params)
constexpr W shift_right(std::array< W, N > &x)
BOTAN_FUZZER_API void bigint_monty_redc_32(word r[32], const word z[64], const word p[32], word p_dash, word ws[32])
constexpr auto word_madd3(W a, W b, W c, W *d) -> W
constexpr auto bigint_linmul2(W x[], size_t x_size, W y) -> W