projects
/
bcm963xx.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git]
/
userapps
/
opensource
/
sshd
/
libtommath
/
bn_mp_div_2d.c
diff --git
a/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c
b/userapps/opensource/sshd/libtommath/bn_mp_div_2d.c
index
18bf904
..
cf103f2
100755
(executable)
--- 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 <tommath.h>
+#ifdef BN_MP_DIV_2D_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
/* 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.
*
* integer arithmetic as well as number theoretic functionality.
*
- * The library
i
s designed directly after the MPI library by
+ * The library
wa
s designed directly after the MPI library by
* Michael Fromberger but has been written from scratch with
* additional optimizations in place.
*
* 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
*/
*
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
*/
-#include <tommath.h>
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
/* 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;
{
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) {
/* 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;
/* mask */
mask = (((mp_digit)1) << D) - 1;
+ /* shift for lsb */
+ shift = DIGIT_BIT - D;
+
/* alias */
tmpc = c->dp + (c->used - 1);
/* 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 */
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 */
--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;
}
mp_clear (&t);
return MP_OKAY;
}
+#endif