Botan

MPI Algorithms

License
Botan is released under the Simplified BSD License (see LICENSE.md)

pure void  bigint_add2(word* x, size_t x_size, in word* y, size_t y_size);

Two operand addition

Parameters
word* x the first operand (and output)
size_t x_size size of x
word* y the second operand
size_t y_size size of y (must be >= x_size)

pure void  bigint_add3(word* z, in word* x, size_t x_size, in word* y, size_t y_size);

Three operand addition


pure word  bigint_add2_nc(word* x, size_t x_size, in word* y, size_t y_size);

Two operand addition with carry out


pure word  bigint_add3_nc(word* z, in word* x, size_t x_size, in word* y, size_t y_size);

Three operand addition with carry out


pure word  bigint_sub2(word* x, size_t x_size, in word* y, size_t y_size);

Two operand subtraction


pure void  bigint_sub2_rev(word* x, in word* y, size_t y_size);

Two operand subtraction, x = y - x; assumes y >= x


pure word  bigint_sub3(word* z, in word* x, size_t x_size, in word* y, size_t y_size);

Three operand subtraction


pure void  bigint_monty_redc(word* z, in word* p, size_t p_size, word p_dash, word* ws);

Montgomery Reduction

Parameters
word* z integer to reduce, of size exactly 2*(p_size+1). Output is in the first p_size+1 words, higher words are set to zero.
word* p modulus
size_t p_size size of p
word p_dash Montgomery value
word* ws workspace array of at least 2*(p_size+1) words

pure int  bigint_cmp(in word* x, size_t x_size, in word* y, size_t y_size);

Compare x and y


pure word  bigint_divop(word n1, word n0, word d);

Compute ((n1<n0) / d


pure word  bigint_modop(word n1, word n0, word d);

Compute ((n1<n0) % d