47#define MP_HWBITS (MP_WBITS >> 1)
48#define MP_WBYTES (MP_WBITS >> 3)
49#define MP_WNIBBLES (MP_WBITS >> 2)
52# define MP_WORDS_TO_BITS(x) ((x) << 6)
53# define MP_WORDS_TO_NIBBLES(x) ((x) << 4)
54# define MP_WORDS_TO_BYTES(x) ((x) << 3)
55# define MP_BITS_TO_WORDS(x) ((x) >> 6)
56# define MP_NIBBLES_TO_WORDS(x) ((x) >> 4)
57# define MP_BYTES_TO_WORDS(x) ((x) >> 3)
59# define MP_WORDS_TO_BITS(x) ((x) << 5)
60# define MP_WORDS_TO_NIBBLES(x) ((x) << 3)
61# define MP_WORDS_TO_BYTES(x) ((x) << 2)
62# define MP_BITS_TO_WORDS(x) ((x) >> 5)
63# define MP_NIBBLES_TO_WORDS(x) ((x) >> 3)
64# define MP_BYTES_TO_WORDS(x) ((x) >> 2)
69#define MP_MSBMASK (((mpw) 0x1) << (MP_WBITS-1))
70#define MP_LSBMASK ((mpw) 0x1)
71#define MP_ALLMASK ~((mpw) 0x0)
78# define mpcopy(size, dst, src) memcpy(dst, src, MP_WORDS_TO_BYTES(size))
85# define mpmove(size, dst, src) memmove(dst, src, MP_WORDS_TO_BYTES(size))
247int mpeqx(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
260int mpnex(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
274int mpgtx(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
288int mpltx(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
302int mpgex(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
316int mplex(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
327int mpcmpx(
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
669void mpmul(
mpw* result,
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw* ydata);
687void mpmod (
mpw* result,
size_t xsize,
const mpw* xdata,
size_t ysize,
const mpw*ydata,
mpw* wksp);
713int i2osp(
byte* osdata,
size_t ossize,
const mpw* idata,
size_t isize);
716int os2ip(
mpw* idata,
size_t isize,
const byte* osdata,
size_t ossize);
719int hs2ip(
mpw* idata,
size_t isize,
const char* hsdata,
size_t hssize);
BeeCrypt API, portability headers.
#define BEECRYPTAPI
Definition: api.h:52
uint64_t mpw
Definition: api.h:87
int mpgex(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if the first of two multi-precision integers of different size is greater than or...
int mpistwo(size_t size, const mpw *data)
This function tests if the value of a multi-precision integer is equal to two.
size_t mpnorm(size_t size, mpw *data)
mpw mppndiv(mpw xhi, mpw xlo, mpw y)
int mpaddx(size_t xsize, mpw *xdata, size_t ysize, const mpw *ydata)
This function adds two multi-precision integers of different size. The performed operation in pseudoc...
int mpmsbset(size_t size, const mpw *data)
This function tests if the most significant bit of a multi-precision integer is set.
void mpand(size_t size, mpw *xdata, const mpw *ydata)
This function computes the bit-wise AND of two multi-precision integers. Modifies xdata.
void mpfill(size_t size, mpw *data, mpw fill)
This function fills each word of a multi-precision integer with a given value.
void mpclrmsb(size_t size, mpw *data)
This function clears the most significant bit of a multi-precision integer.
size_t mprshiftlsz(size_t size, mpw *data)
int mpltx(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if the first of two multi-precision integers of different size is less than the s...
int os2ip(mpw *idata, size_t isize, const byte *osdata, size_t ossize)
int mpadd(size_t size, mpw *xdata, const mpw *ydata)
This function adds two multi-precision integers of equal size. The performed operation is in pseudoco...
size_t mpmszcnt(size_t size, const mpw *data)
int mpsub(size_t size, mpw *xdata, const mpw *ydata)
This function subtracts two multi-precision integers of equal size. The performed operation in pseudo...
size_t mplszcnt(size_t size, const mpw *data)
int mpsubw(size_t size, mpw *xdata, mpw y)
This function subtracts one word to a multi-precision integer. The performed operation in pseudocode:...
size_t mpsize(size_t size, const mpw *data)
This function returns the true size of a multi-precision integer, after stripping leading zero words.
void mpaddsqrtrc(size_t size, mpw *result, const mpw *data)
This function is used in the calculation of a multi-precision squaring.
void mpgcd_w(size_t size, const mpw *xdata, const mpw *ydata, mpw *result, mpw *wksp)
void mpneg(size_t size, mpw *data)
This function negates a multi-precision integer.
void mpxor(size_t size, mpw *xdata, const mpw *ydata)
This function computes the bit-wise XOR of two multi-precision integers. Modifies xdata.
mpw mpsetmul(size_t size, mpw *result, const mpw *data, mpw y)
This function performs a multi-precision multiply-setup.
int mpodd(size_t size, const mpw *data)
This functions tests if a multi-precision integer is odd.
int mpeqmone(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if multi-precision integer x is equal to y minus one.
int hs2ip(mpw *idata, size_t isize, const char *hsdata, size_t hssize)
void mpsqr(mpw *result, size_t size, const mpw *data)
This function computes a full multi-precision square.
int mplsbset(size_t size, const mpw *data)
This function tests if the leiast significant bit of a multi-precision integer is set.
int mpextgcd_w(size_t size, const mpw *xdata, const mpw *ydata, mpw *result, mpw *wksp)
void mpmod(mpw *result, size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata, mpw *wksp)
void mpsdivtwo(size_t size, mpw *data)
void mpdivtwo(size_t size, mpw *data)
void mpfprint(FILE *f, size_t size, const mpw *data)
void mpor(size_t size, mpw *xdata, const mpw *ydata)
This function computes the bit-wise OR of two multi-precision integers. Modifies xdata.
void mplshift(size_t size, mpw *data, size_t count)
void mpsetws(size_t size, mpw *xdata, size_t y)
This function sets the value of a multi-precision integer to the given word. The given value is copie...
int mpz(size_t size, const mpw *data)
This function tests if a multi-precision integer is zero.
void mpmul(mpw *result, size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function computes a full multi-precision product.
int mpeven(size_t size, const mpw *data)
This function tests if a multi-precision integer is even.
void mpsetmsb(size_t size, mpw *data)
This function sets the most significant bit of a multi-precision integer.
#define mpmove(size, dst, src)
Definition: mp.h:85
int mpnex(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if two multi-precision integers of different size are equal.
size_t mpbits(size_t size, const mpw *data)
This function returns the number of significant bits in a multi-precision integer.
int mpcmpx(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function performs a comparison of two multi-precision integers of the different size.
void mpprint(size_t size, const mpw *data)
void mpsetlsb(size_t size, mpw *data)
This function sets the least significant bit of a multi-precision integer.
int mpmultwo(size_t size, mpw *data)
void mprshift(size_t size, mpw *data, size_t count)
void mpfprintln(FILE *f, size_t size, const mpw *data)
int mpcmp(size_t size, const mpw *xdata, const mpw *ydata)
This function performs a comparison of two multi-precision integers of the same size.
void mpnot(size_t size, mpw *data)
This function flips all bits of a multi-precision integer.
int mpaddw(size_t size, mpw *xdata, mpw y)
This function adds one word to a multi-precision integer. The performed operation is in pseudocode: x...
void mpsetw(size_t size, mpw *xdata, mpw y)
This function sets the value of a multi-precision integer to the given word. The given value is copie...
int mplex(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if the first of two multi-precision integers of different size is less than or eq...
int mpnz(size_t size, const mpw *data)
This function tests if a multi-precision integer is not zero.
int mpge(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if the first of two multi-precision integers of the same size is greater than or ...
int mpgtx(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if the first of two multi-precision integers of different size is greater than th...
void mpprintln(size_t size, const mpw *data)
int mpgt(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if the first of two multi-precision integers of the same size is greater than the...
int mpne(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if two multi-precision integers of the same size differ.
int mpsubx(size_t xsize, mpw *xdata, size_t ysize, const mpw *ydata)
This function subtracts two multi-precision integers of different size. The performed operation in ps...
int mpeq(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if two multi-precision integers of the same size are equal.
int i2osp(byte *osdata, size_t ossize, const mpw *idata, size_t isize)
int mpisone(size_t size, const mpw *data)
This functions tests if the value of a multi-precision integer is equal to one.
void mpzero(size_t size, mpw *data)
This function zeroes a multi-precision integer of a given size.
int mpleone(size_t size, const mpw *data)
This function tests if the value of a multi-precision integer is less than or equal to one.
void mpndivmod(mpw *result, size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata, mpw *wksp)
int mplt(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if the first of two multi-precision integers of the same size is less than the se...
int mpeqx(size_t xsize, const mpw *xdata, size_t ysize, const mpw *ydata)
This function tests if two multi-precision integers of different size are equal.
mpw mpaddmul(size_t size, mpw *result, const mpw *data, mpw y)
This function performs a mult-precision multiply-accumulate.
void mpsetx(size_t xsize, mpw *xdata, size_t ysize, const mpw *ydata)
This function set the value of the first multi-precision integer to the second, truncating the most s...
int mple(size_t size, const mpw *xdata, const mpw *ydata)
This function tests if the first of two multi-precision integers of the same size is less than or equ...
void mpclrlsb(size_t size, mpw *data)
This function clears the least significant bit of a multi-precision integer.
#define mpcopy(size, dst, src)
Definition: mp.h:78
Multi-precision integer optimization definitions.