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
15 int pb_copy(pb_poly
*src
, pb_poly
*dest
)
19 /* avoid trivial copies */
24 /* grow dest as required */
25 if (dest
->alloc
< src
->used
) {
26 if ((err
= pb_grow(dest
, src
->used
)) != MP_OKAY
) {
31 /* set the characteristic */
32 if ((err
= mp_copy(&(src
->characteristic
), &(dest
->characteristic
))) != MP_OKAY
) {
37 for (x
= 0; x
< src
->used
; x
++) {
38 if ((err
= mp_copy(&(src
->terms
[x
]), &(dest
->terms
[x
]))) != MP_OKAY
) {
43 /* zero excess digits */
44 for (x
= src
->used
; x
< dest
->used
; x
++) {
45 mp_zero(&(dest
->terms
[x
]));
47 dest
->used
= src
->used
;