Merge pull request #4 from thesamesam/develop
[libtompoly.git] / pb_rshd.c
blob2662ab1ae11c04379655f3492f0cd8ac975c0eb2
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_rshd(pb_poly *a, int x)
16 int y;
18 if (x >= a->used) {
19 pb_zero(a);
20 return MP_OKAY;
23 if (x <= 0) {
24 return MP_OKAY;
27 for (y = x; y < a->used; y++) {
28 mp_exch(&(a->terms[y]), &(a->terms[y-x]));
31 for (y = a->used - x; y < a->used; y++) {
32 mp_zero(&(a->terms[y]));
34 a->used -= x;
36 return MP_OKAY;