#include "tommath_private.h"
#ifdef BN_MP_LSHD_C
mp_err mp_lshd(mp_int *a, int b)
{
int x;
mp_err err;
mp_digit *top, *bottom;
if (b <= 0) {
return MP_OKAY;
}
if (MP_IS_ZERO(a)) {
return MP_OKAY;
}
if (a->alloc < (a->used + b)) {
if ((err = mp_grow(a, a->used + b)) != MP_OKAY) {
return err;
}
}
a->used += b;
top = a->dp + a->used - 1;
bottom = (a->dp + a->used - 1) - b;
* except the window goes the otherway around. Copying from
* the bottom to the top. see bn_mp_rshd.c for more info.
*/
for (x = a->used - 1; x >= b; x--) {
*top-- = *bottom--;
}
MP_ZERO_DIGITS(a->dp, b);
return MP_OKAY;
}
#endif