1 /* LibTomPoly, Polynomial Basis Math -- Tom St Denis
3 * LibTomPoly is a public domain library that provides
4 * polynomial basis arithmetic support. It relies on
5 * LibTomMath for large integer support.
7 * This library is free for all purposes without any
8 * express guarantee that it works.
10 * Tom St Denis, tomstdenis@iahu.ca, http://poly.libtomcrypt.org
16 int pb_init(pb_poly
*a
, mp_int
*characteristic
)
20 /* init characteristic */
21 if ((err
= mp_init_copy(&(a
->characteristic
), characteristic
)) != MP_OKAY
) {
25 /* now allocate an array of mp_ints */
26 if ((a
->terms
= calloc(PB_TERMS
, sizeof(mp_int
))) == NULL
) {
27 mp_clear(&(a
->characteristic
));
31 /* now initialize them all */
32 for (x
= 0; x
< PB_TERMS
; x
++) {
33 if ((err
= mp_init(&(a
->terms
[x
]))) != MP_OKAY
) {
35 for (y
= 0; y
< x
; y
++) {
36 mp_clear(&(a
->terms
[y
]));
39 mp_clear(&(a
->characteristic
));
44 /* set our parameters */