39 { .
name =
"bigint_mod_multiply" };
43 { .
name =
"bigint_mod_multiply.multiply" };
47 { .
name =
"bigint_mod_multiply.rescale" };
51 { .
name =
"bigint_mod_multiply.subtract" };
62 unsigned int size,
int swap ) {
71 for ( i = 0 ; i <
size ; i++ ) {
72 xor = ( mask & ( first0[i] ^ second0[i] ) );
92 unsigned int size,
void *
tmp ) {
94 ( (
const void * ) multiplicand0 );
96 ( (
const void * ) multiplier0 );
98 ( (
const void * ) modulus0 );
100 ( (
void * ) result0 );
117 profile_stop ( &bigint_mod_multiply_multiply_profiler );
130 for ( i = 0 ; i <=
rotation ; i++ ) {
135 profile_stop ( &bigint_mod_multiply_subtract_profiler );
162 unsigned int size,
unsigned int exponent_size,
165 ( (
const void * ) base0 );
167 ( (
const void * ) modulus0 );
169 *exponent = ( (
const void * ) exponent0 );
171 ( (
void * ) result0 );
175 bigint_t ( exponent_size ) exponent;
176 uint8_t mod_multiply[mod_multiply_len];
180 memcpy ( &temp->base,
base, sizeof ( temp->base ) );
181 memcpy ( &temp->exponent, exponent, sizeof ( temp->exponent ) );
187 result, temp->mod_multiply );
191 &temp->base, temp->mod_multiply );
void bigint_mod_exp_raw(const bigint_element_t *base0, const bigint_element_t *modulus0, const bigint_element_t *exponent0, bigint_element_t *result0, unsigned int size, unsigned int exponent_size, void *tmp)
Perform modular exponentiation of big integers.
#define bigint_max_set_bit(value)
Find highest bit set in big integer.
#define bigint_ror(value)
Rotate big integer right.
void bigint_mod_multiply_raw(const bigint_element_t *multiplicand0, const bigint_element_t *multiplier0, const bigint_element_t *modulus0, bigint_element_t *result0, unsigned int size, void *tmp)
Perform modular multiplication of big integers.
#define bigint_grow(source, dest)
Grow big integer.
#define bigint_init(value, data, len)
Initialise big integer.
A data structure for storing profiling information.
#define bigint_is_zero(value)
Test if big integer is equal to zero.
static void profile_stop(struct profiler *profiler)
Stop profiling.
uint8_t multiplier
Port multiplier number.
static struct profiler bigint_mod_multiply_profiler __profiler
Modular multiplication overall profiler.
static u32 xor(u32 a, u32 b)
uint32_t start
Starting offset.
#define bigint_is_geq(value, reference)
Compare big integers.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define bigint_shrink(source, dest)
Shrink big integer.
uint32_t bigint_element_t
Element of a big integer.
static void profile_start(struct profiler *profiler)
Start profiling.
#define bigint_rol(value)
Rotate big integer left.
static unsigned int rotation
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void bigint_swap_raw(bigint_element_t *first0, bigint_element_t *second0, unsigned int size, int swap)
Conditionally swap big integers (in constant time)
#define bigint_mod_multiply(multiplicand, multiplier, modulus, result, tmp)
Perform modular multiplication of big integers.
#define bigint_mod_multiply_tmp_len(modulus)
Calculate temporary working space required for moduluar multiplication.
#define bigint_multiply(multiplicand, multiplier, result)
Multiply big integers.
uint8_t size
Entry size (in 32-bit words)
#define bigint_bit_is_set(value, bit)
Test if bit is set in big integer.
#define bigint_subtract(subtrahend, value)
Subtract big integers.
typedef bigint_t(X25519_SIZE) x25519_t
An X25519 unsigned big integer used in internal calculations.