Merge pull request #4 from thesamesam/develop
[libtompoly.git] / pb_rawsize.c
blob43ccc7690e05988bfea20f24420cb7c605e37271
1 /* LibTomPoly, Polynomial Basis Math -- Tom St Denis
2 *
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
12 #include <tompoly.h>
14 int pb_rawsize(pb_poly *a)
16 int x, y;
18 /* 2 bytes for # of coefficients */
19 y = 2;
21 /* characteristic */
22 y += 2 + mp_signed_bin_size(&(a->characteristic));
24 /* all of the terms */
25 for (x = 0; x < a->used; x++) {
26 y += 2 + mp_signed_bin_size(&(a->terms[x]));
29 return y;