X-Git-Url: http://git.rot13.org/?p=bcm963xx.git;a=blobdiff_plain;f=userapps%2Fopensource%2Fsshd%2Flibtommath%2Fbn_mp_div_2d.c;h=cf103f2ba3f2b364b2d87ad940f6497e87044fe7;hp=18bf9042af8097f2b7798b1f7d1e54820de65002;hb=57a096f051259ceaefd5977f30d269884e1dd248;hpb=9887430fc6b7c0f8eb8e81de2bfe3bba12d8d4a1;ds=sidebyside diff --git a/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c b/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c index 18bf9042..cf103f2b 100755 --- a/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c +++ b/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c @@ -1,9 +1,11 @@ +#include +#ifdef BN_MP_DIV_2D_C /* LibTomMath, multiple-precision integer library -- Tom St Denis * - * LibTomMath is library that provides for multiple-precision + * LibTomMath is a library that provides multiple-precision * integer arithmetic as well as number theoretic functionality. * - * The library is designed directly after the MPI library by + * The library was designed directly after the MPI library by * Michael Fromberger but has been written from scratch with * additional optimizations in place. * @@ -12,11 +14,9 @@ * * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org */ -#include /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ -int -mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) +int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) { mp_digit D, r, rr; int x, res; @@ -58,11 +58,14 @@ mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) /* shift any bit count < DIGIT_BIT */ D = (mp_digit) (b % DIGIT_BIT); if (D != 0) { - register mp_digit *tmpc, mask; + register mp_digit *tmpc, mask, shift; /* mask */ mask = (((mp_digit)1) << D) - 1; + /* shift for lsb */ + shift = DIGIT_BIT - D; + /* alias */ tmpc = c->dp + (c->used - 1); @@ -73,7 +76,7 @@ mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) rr = *tmpc & mask; /* shift the current word and mix in the carry bits from the previous word */ - *tmpc = (*tmpc >> D) | (r << (DIGIT_BIT - D)); + *tmpc = (*tmpc >> D) | (r << shift); --tmpc; /* set the carry to the carry bits of the current word found above */ @@ -87,3 +90,4 @@ mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) mp_clear (&t); return MP_OKAY; } +#endif