12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <tommath.h>
- #ifdef BN_MP_LSHD_C
- int mp_lshd (mp_int * a, int b)
- {
- int x, res;
-
- if (b <= 0) {
- return MP_OKAY;
- }
-
- if (a->alloc < a->used + b) {
- if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
- return res;
- }
- }
- {
- register mp_digit *top, *bottom;
-
- a->used += b;
-
- top = a->dp + a->used - 1;
-
- bottom = a->dp + a->used - 1 - b;
-
- for (x = a->used - 1; x >= b; x--) {
- *top-- = *bottom--;
- }
-
- top = a->dp;
- for (x = 0; x < b; x++) {
- *top++ = 0;
- }
- }
- return MP_OKAY;
- }
- #endif
|