Main Page Modules Data Structures File List Data Fields Globals Related Pages

# beecrypt/mp32barrett.h File Reference

Barrett modular reduction, header. More...

`#include "beecrypt.h"`
`#include "mp32number.h"`

Go to the source code of this file.

## Data Structures
struct | mp32barrett
## Functions
void | mp32bzero (mp32barrett *b)
| mp32bzero. More...
void | mp32binit (mp32barrett *b, uint32 size)
| Allocates the data words for an mp32barrett structure. More...
void | mp32bfree (mp32barrett *b)
| mp32bfree. More...
void | mp32bcopy (mp32barrett *b, const mp32barrett *copy)
void | mp32bset (mp32barrett *b, uint32 size, const uint32 *data)
| mp32bset. More...
void | mp32bsethex (mp32barrett *b, const char *hex)
void | mp32bsubone (const mp32barrett *b, uint32 *result)
| Copies (b-1) into result. More...
void | mp32bneg (const mp32barrett *b, const uint32 *xdata, uint32 *result)
| Computes the negative (modulo b) of x, where x must contain a value between 0 and b-1. More...
void | mp32bmu_w (mp32barrett *b, uint32 *wksp)
| Computes the Barrett 'mu' coefficient. More...
void | mp32brnd_w (const mp32barrett *b, randomGeneratorContext *rc, uint32 *result, uint32 *wksp)
| Generates a random number in the range 1 < r < b-1. More...
void | mp32brndodd_w (const mp32barrett *b, randomGeneratorContext *rc, uint32 *result, uint32 *wksp)
| Generates a random odd number in the range 1 < r < b-1. More...
void | mp32brndinv_w (const mp32barrett *b, randomGeneratorContext *rc, uint32 *result, uint32 *inverse, uint32 *wksp)
| Generates a random invertible (modulo b) in the range 1 < r < b-1. More...
void | mp32bmod_w (const mp32barrett *b, const uint32 *xdata, uint32 *result, uint32 *wksp)
| Computes the barrett modular reduction of a number x, which has twice the size of b. More...
void | mp32baddmod_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 ysize, const uint32 *ydata, uint32 *result, uint32 *wksp)
| Computes the sum (modulo b) of x and y. More...
void | mp32bsubmod_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 ysize, const uint32 *ydata, uint32 *result, uint32 *wksp)
| Computes the difference (modulo b) of x and y. More...
void | mp32bmulmod_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 ysize, const uint32 *ydata, uint32 *result, uint32 *wksp)
| Computes the product (modulo b) of x and y. More...
void | mp32bsqrmod_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 *result, uint32 *wksp)
| Computes the square (modulo b) of x. More...
void | mp32bpowmod_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 psize, const uint32 *pdata, uint32 *result, uint32 *wksp)
| mp32bpowmod_w needs workspace of 4*size+2 words. More...
void | mp32bpowmodsld_w (const mp32barrett *b, const uint32 *slide, uint32 psize, const uint32 *pdata, uint32 *result, uint32 *wksp)
void | mp32btwopowmod_w (const mp32barrett *b, uint32 psize, const uint32 *pdata, uint32 *result, uint32 *wksp)
| mp32btwopowmod_w needs workspace of (4*size+2) words. More...
int | mp32binv_w (const mp32barrett *b, uint32 xsize, const uint32 *xdata, uint32 *result, uint32 *wksp)
| Computes the inverse (modulo b) of x, and returns 1 if x was invertible. More...
int | mp32bpprime_w (const mp32barrett *b, randomGeneratorContext *rc, int t, uint32 *wksp)
| needs workspace of (7*size+2) words. More...
void | mp32bnrnd (const mp32barrett *b, randomGeneratorContext *rc, mp32number *result)
void | mp32bnmulmod (const mp32barrett *b, const mp32number *x, const mp32number *y, mp32number *result)
void | mp32bnsqrmod (const mp32barrett *b, const mp32number *x, mp32number *result)
void | mp32bnpowmod (const mp32barrett *b, const mp32number *x, const mp32number *pow, mp32number *y)
void | mp32bnpowmodsld (const mp32barrett *b, const uint32 *slide, const mp32number *pow, mp32number *y)

## Detailed Description

Barrett modular reduction, header.

Definition in file mp32barrett.h.

## Function Documentation

void mp32baddmod_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 | ysize,
|  | const uint32 * | ydata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the sum (modulo b) of x and y. needs a workspace of (4*size+2) words Definition at line 428 of file mp32barrett.c. Referenced by elgv1sign, and elgv3sign.

void mp32bcopy | ( | mp32barrett * | b,
|  | const mp32barrett * | copy
| ) |

| Definition at line 85 of file mp32barrett.c. Referenced by dldp_pCopy, rsakpCopy, and rsapkCopy.

void mp32bfree | ( | mp32barrett * | b | ) |

| mp32bfree. Definition at line 72 of file mp32barrett.c. References BEECRYPTAPI, and uint32. Referenced by dldp_pFree, mp32prndconone_w, mp32prndsafe_w, pgpFreeDig, rsakpFree, rsakpMake, and rsapkFree.

void mp32binit | ( | mp32barrett * | b,
|  | uint32 | size
| ) |

| Allocates the data words for an mp32barrett structure. will allocate 2*size+1 words Definition at line 55 of file mp32barrett.c. References BEECRYPTAPI, and uint32. Referenced by mp32prnd_w, mp32prndconone_w, and mp32prndsafe_w.

int mp32binv_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the inverse (modulo b) of x, and returns 1 if x was invertible. Definition at line 940 of file mp32barrett.c. Referenced by mp32brndinv_w, and rsakpMake.

void mp32bmod_w | ( | const mp32barrett * | b,
|  | const uint32 * | xdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the barrett modular reduction of a number x, which has twice the size of b. needs workspace of (2*size+2) words Definition at line 337 of file mp32barrett.c. Referenced by mp32baddmod_w, mp32bmulmod_w, mp32bnmulmod, mp32bnsqrmod, mp32bsqrmod_w, mp32bsubmod_w, and rsakpMake.

void mp32bmu_w | ( | mp32barrett * | b,
|  | uint32 * | wksp
| ) |

| Computes the Barrett 'mu' coefficient. needs workspace of (6*size+4) words Definition at line 232 of file mp32barrett.c. References uint32. Referenced by mp32bset, mp32bsethex, mp32prnd_w, mp32prndconone_w, and mp32prndsafe_w.

void mp32bmulmod_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 | ysize,
|  | const uint32 * | ydata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the product (modulo b) of x and y. needs a workspace of (4*size+2) words Definition at line 461 of file mp32barrett.c. Referenced by elgv1sign, elgv1vrfy, elgv3sign, elgv3vrfy, mp32bpowmodsld_w, mp32bslide_w, and rsapricrt.

void mp32bneg | ( | const mp32barrett * | b,
|  | const uint32 * | xdata,
|  | uint32 * | result
| ) |

| Computes the negative (modulo b) of x, where x must contain a value between 0 and b-1. Definition at line 414 of file mp32barrett.c.

void mp32bnmulmod | ( | const mp32barrett * | b,
|  | const mp32number * | x,
|  | const mp32number * | y,
|  | mp32number * | result
| ) |

| Note: Takes mp32number as parameter. Definition at line 1218 of file mp32barrett.c.

void mp32bnpowmod | ( | const mp32barrett * | b,
|  | const mp32number * | x,
|  | const mp32number * | pow,
|  | mp32number * | y
| ) |

| Note: Takes mp32number as parameter. Definition at line 1272 of file mp32barrett.c. Referenced by dldp_pPair, dldp_pPublic, and dlsvdp_pDHSecret.

void mp32bnpowmodsld | ( | const mp32barrett * | b,
|  | const uint32 * | slide,
|  | const mp32number * | pow,
|  | mp32number * | y
| ) |

| Note: Takes mp32number as parameter. Definition at line 1287 of file mp32barrett.c.

void mp32bnrnd | ( | const mp32barrett * | b,
|  | randomGeneratorContext * | rc,
|  | mp32number * | result
| ) |

| Note: Takes mp32number as parameter. Definition at line 1202 of file mp32barrett.c. Referenced by dldp_pPair, and dldp_pPrivate.

void mp32bnsqrmod | ( | const mp32barrett * | b,
|  | const mp32number * | x,
|  | mp32number * | result
| ) |

| Note: Takes mp32number as parameter. Definition at line 1245 of file mp32barrett.c.

void mp32bpowmod_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 | psize,
|  | const uint32 * | pdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| mp32bpowmod_w needs workspace of 4*size+2 words. Definition at line 566 of file mp32barrett.c. Referenced by dldp_pgonGenerator_w, dldp_pgoqGenerator_w, elgv1sign, elgv1vrfy, elgv3sign, elgv3vrfy, mp32bnpowmod, mp32pmilraba_w, rsapri, rsapricrt, and rsavrfy.

void mp32bpowmodsld_w | ( | const mp32barrett * | b,
|  | const uint32 * | slide,
|  | uint32 | psize,
|  | const uint32 * | pdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Definition at line 606 of file mp32barrett.c. Referenced by mp32bnpowmodsld, and mp32bpowmod_w.

int mp32bpprime_w | ( | const mp32barrett * | b,
|  | randomGeneratorContext * | rc,
|  | int | t,
|  | uint32 * | wksp
| ) |

| needs workspace of (7*size+2) words. Definition at line 1151 of file mp32barrett.c.

void mp32brnd_w | ( | const mp32barrett * | b,
|  | randomGeneratorContext * | rc,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Generates a random number in the range 1 < r < b-1. need workspace of (size) words Definition at line 259 of file mp32barrett.c. Referenced by dldp_pgonGenerator_w, dldp_pgoqGenerator_w, elgv3sign, mp32bnrnd, mp32brndinv_w, and mp32pmilrab_w.

void mp32brndinv_w | ( | const mp32barrett * | b,
|  | randomGeneratorContext * | rc,
|  | uint32 * | result,
|  | uint32 * | inverse,
|  | uint32 * | wksp
| ) |

| Generates a random invertible (modulo b) in the range 1 < r < b-1. needs workspace of (6*size+6) words Definition at line 318 of file mp32barrett.c. Referenced by elgv1sign.

void mp32brndodd_w | ( | const mp32barrett * | b,
|  | randomGeneratorContext * | rc,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Generates a random odd number in the range 1 < r < b-1. needs workspace of (size) words Definition at line 287 of file mp32barrett.c. Referenced by mp32brndinv_w.

void mp32bset | ( | mp32barrett * | b,
|  | uint32 | size,
|  | const uint32 * | data
| ) |

| mp32bset. Definition at line 129 of file mp32barrett.c. Referenced by dldp_pgonMake, dldp_pgonMakeSafe, dldp_pgoqMakeSafe, and rsakpMake.

void mp32bsethex | ( | mp32barrett * | b,
|  | const char * | hex
| ) |

| Definition at line 166 of file mp32barrett.c. References BEECRYPTAPI, and uint32. Referenced by pgpPrtPubkeyParams.

void mp32bsqrmod_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the square (modulo b) of x. needs a workspace of (4*size+2) words Definition at line 481 of file mp32barrett.c. Referenced by dldp_pgonGenerator_w, mp32bpowmodsld_w, mp32bslide_w, mp32btwopowmod_w, mp32pmilraba_w, and mp32pmilrabtwo_w.

void mp32bsubmod_w | ( | const mp32barrett * | b,
|  | uint32 | xsize,
|  | const uint32 * | xdata,
|  | uint32 | ysize,
|  | const uint32 * | ydata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| Computes the difference (modulo b) of x and y. needs a workspace of (4*size+2) words Definition at line 444 of file mp32barrett.c. Referenced by rsapricrt.

void mp32bsubone | ( | const mp32barrett * | b,
|  | uint32 * | result
| ) |

| Copies (b-1) into result. Definition at line 401 of file mp32barrett.c. Referenced by dldp_pgonMake, dldp_pgonMakeSafe, and rsakpMake.

void mp32btwopowmod_w | ( | const mp32barrett * | b,
|  | uint32 | psize,
|  | const uint32 * | pdata,
|  | uint32 * | result,
|  | uint32 * | wksp
| ) |

| mp32btwopowmod_w needs workspace of (4*size+2) words. Definition at line 711 of file mp32barrett.c. Referenced by mp32pmilrabtwo_w.

void mp32bzero | ( | mp32barrett * | b | ) |

| mp32bzero. Definition at line 43 of file mp32barrett.c. References BEECRYPTAPI. Referenced by dldp_pgoqMake, dldp_pgoqMakeSafe, dldp_pInit, mp32prndconone_w, mp32prndsafe_w, and rsakpMake.