191
* Shift A by COUNT limbs to the right
192
* This is used only within the MPI library
195
_gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count )
198
mpi_size_t n = a->nlimbs;
206
for( i = 0; i < n - count; i++ )
192
214
* Shift A by N bits to the right.
277
299
* This is used only within the MPI library
280
_gcry_mpi_lshift_limbs( gcry_mpi_t a, unsigned int count )
289
RESIZE_IF_NEEDED( a, n+count );
292
for( i = n-1; i >= 0; i-- )
294
for(i=0; i < count; i++ )
301
* Shift A by COUNT limbs to the right
302
* This is used only within the MPI library
305
_gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count )
308
mpi_size_t n = a->nlimbs;
316
for( i = 0; i < n - count; i++ )
302
_gcry_mpi_lshift_limbs (gcry_mpi_t a, unsigned int count)
311
RESIZE_IF_NEEDED (a, n+count);
314
for (i = n-1; i >= 0; i--)
316
for (i=0; i < count; i++ )
323
* Shift A by N bits to the left.
326
gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
328
unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
329
unsigned int nbits = (n%BITS_PER_MPI_LIMB);
332
return; /* In-place shift with an amount of zero. */
337
unsigned int alimbs = a->nlimbs;
341
RESIZE_IF_NEEDED (x, alimbs+nlimbs+1);
344
MPN_COPY (xp, ap, alimbs);
350
if (nlimbs && !nbits)
352
/* Shift a full number of limbs. */
353
_gcry_mpi_lshift_limbs (x, nlimbs);
357
/* We use a very dump approach: Shift left by the number of
358
limbs plus one and than fix it up by an rshift. */
359
_gcry_mpi_lshift_limbs (x, nlimbs+1);
360
gcry_mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits);
363
MPN_NORMALIZE (x->d, x->nlimbs);