+#include <tommath.h>
+#ifdef BN_MP_KARATSUBA_MUL_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.
*
*
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
*/
-#include <tommath.h>
/* c = |a| * |b| using Karatsuba Multiplication using
* three half size multiplications
* Generally though the overhead of this method doesn't pay off
* until a certain size (N ~ 80) is reached.
*/
-int
-mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
+int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
{
mp_int x0, x1, y0, y1, t1, x0y0, x1y1;
int B, err;
B = MIN (a->used, b->used);
/* now divide in two */
- B = B / 2;
+ B = B >> 1;
/* init copy all the temps */
if (mp_init_size (&x0, B) != MP_OKAY)
goto X0Y0;
/* now shift the digits */
- x0.sign = x1.sign = a->sign;
- y0.sign = y1.sign = b->sign;
-
x0.used = y0.used = B;
x1.used = a->used - B;
y1.used = b->used - B;
ERR:
return err;
}
+#endif