10#include <botan/internal/mp_core.h>
12#include <botan/assert.h>
13#include <botan/exceptn.h>
14#include <botan/mem_ops.h>
15#include <botan/internal/ct_utils.h>
32 word r[],
const word z[],
size_t z_size,
const word p[],
size_t p_size,
word p_dash,
word ws[]) {
33 BOTAN_ARG_CHECK(z_size >= 2 * p_size && p_size > 0,
"Invalid sizes for bigint_monty_redc_generic");
41 for(
size_t i = 1; i != p_size; ++i) {
42 for(
size_t j = 0; j < i; ++j) {
43 accum.
mul(ws[j], p[i - j]);
50 for(
size_t i = 0; i != p_size - 1; ++i) {
51 for(
size_t j = i + 1; j != p_size; ++j) {
52 accum.
mul(ws[j], p[p_size + i - j]);
55 accum.
add(z[p_size + i]);
59 accum.
add(z[2 * p_size - 1]);
61 ws[p_size - 1] = accum.
extract();
#define BOTAN_ARG_CHECK(expr, msg)
constexpr W monty_step(W p0, W p_dash)
constexpr void mul(W x, W y)
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[])
constexpr void bigint_monty_maybe_sub(size_t N, W z[], W x0, const W x[], const W p[])
std::conditional_t< HasNative64BitRegisters, std::uint64_t, uint32_t > word