3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality.
8 * The library was designed directly after the MPI library by
9 * Michael Fromberger but has been written from scratch with
10 * additional optimizations in place.
12 * The library is free for all purposes without any express
15 * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
18 /* shift right a certain amount of digits */
19 void mp_rshd (mp_int
* a
, int b
)
23 /* if b <= 0 then ignore it */
28 /* if b > used then simply zero it and return */
35 register mp_digit
*bottom
, *top
;
37 /* shift the digits down */
42 /* top [offset into digits] */
45 /* this is implemented as a sliding window where
46 * the window is b-digits long and digits from
47 * the top of the window are copied to the bottom
51 b-2 | b-1 | b0 | b1 | b2 | ... | bb | ---->
53 \-------------------/ ---->
55 for (x
= 0; x
< (a
->used
- b
); x
++) {
59 /* zero the top digits */
60 for (; x
< a
->used
; x
++) {
65 /* remove excess digits */
70 /* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */
71 /* $Revision: 1.3 $ */
72 /* $Date: 2006/03/31 14:18:44 $ */