summaryrefslogtreecommitdiffstats
path: root/libtommath
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-11 10:38:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-11 10:38:07 (GMT)
commitb9e8eecd80020e9dc1539f6f99f121472aff3126 (patch)
tree2e262a4602582231d8ffc8cfae0ed63eae88e24f /libtommath
parent72cd4c6a0763c30b3f3a4fceb1ed78ad63711cb5 (diff)
downloadtcl-b9e8eecd80020e9dc1539f6f99f121472aff3126.zip
tcl-b9e8eecd80020e9dc1539f6f99f121472aff3126.tar.gz
tcl-b9e8eecd80020e9dc1539f6f99f121472aff3126.tar.bz2
Many 'const' addtions in libtommath where it makes sense. To be submitted back to the libtommath guys.
Diffstat (limited to 'libtommath')
-rw-r--r--libtommath/bn_fast_s_mp_mul_digs.c2
-rw-r--r--libtommath/bn_fast_s_mp_sqr.c2
-rw-r--r--libtommath/bn_mp_add.c2
-rw-r--r--libtommath/bn_mp_and.c5
-rw-r--r--libtommath/bn_mp_div.c4
-rw-r--r--libtommath/bn_mp_div_3.c2
-rw-r--r--libtommath/bn_mp_div_d.c2
-rw-r--r--libtommath/bn_mp_expt_d.c2
-rw-r--r--libtommath/bn_mp_expt_d_ex.c2
-rw-r--r--libtommath/bn_mp_karatsuba_mul.c2
-rw-r--r--libtommath/bn_mp_karatsuba_sqr.c2
-rw-r--r--libtommath/bn_mp_mod.c2
-rw-r--r--libtommath/bn_mp_mul.c2
-rw-r--r--libtommath/bn_mp_mul_d.c2
-rw-r--r--libtommath/bn_mp_or.c5
-rw-r--r--libtommath/bn_mp_sqr.c2
-rw-r--r--libtommath/bn_mp_sqrt.c2
-rw-r--r--libtommath/bn_mp_sub.c2
-rw-r--r--libtommath/bn_mp_toom_mul.c2
-rw-r--r--libtommath/bn_mp_toom_sqr.c2
-rw-r--r--libtommath/bn_mp_xor.c5
-rw-r--r--libtommath/bn_s_mp_add.c4
-rw-r--r--libtommath/bn_s_mp_mul_digs.c2
-rw-r--r--libtommath/bn_s_mp_sqr.c2
-rw-r--r--libtommath/bn_s_mp_sub.c2
-rw-r--r--libtommath/tommath.h36
-rw-r--r--libtommath/tommath_private.h20
27 files changed, 61 insertions, 58 deletions
diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c
index a1015af..641b574 100644
--- a/libtommath/bn_fast_s_mp_mul_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_digs.c
@@ -31,7 +31,7 @@
* Based on Algorithm 14.12 on pp.595 of HAC.
*
*/
-int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
+int fast_s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs)
{
int olduse, res, pa, ix, iz;
mp_digit W[MP_WARRAY];
diff --git a/libtommath/bn_fast_s_mp_sqr.c b/libtommath/bn_fast_s_mp_sqr.c
index f435af9..282d303 100644
--- a/libtommath/bn_fast_s_mp_sqr.c
+++ b/libtommath/bn_fast_s_mp_sqr.c
@@ -25,7 +25,7 @@
After that loop you do the squares and add them in.
*/
-int fast_s_mp_sqr (mp_int * a, mp_int * b)
+int fast_s_mp_sqr (const mp_int * a, mp_int * b)
{
int olduse, res, pa, ix, iz;
mp_digit W[MP_WARRAY], *tmpx;
diff --git a/libtommath/bn_mp_add.c b/libtommath/bn_mp_add.c
index bdb166f..a68c02e 100644
--- a/libtommath/bn_mp_add.c
+++ b/libtommath/bn_mp_add.c
@@ -16,7 +16,7 @@
*/
/* high level addition (handles signs) */
-int mp_add (mp_int * a, mp_int * b, mp_int * c)
+int mp_add (const mp_int * a, const mp_int * b, mp_int * c)
{
int sa, sb, res;
diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c
index 53008a5..e90ab37 100644
--- a/libtommath/bn_mp_and.c
+++ b/libtommath/bn_mp_and.c
@@ -17,10 +17,11 @@
/* AND two ints together */
int
-mp_and (mp_int * a, mp_int * b, mp_int * c)
+mp_and (const mp_int * a, const mp_int * b, mp_int * c)
{
int res, ix, px;
- mp_int t, *x;
+ mp_int t;
+ const mp_int *x;
if (a->used > b->used) {
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c
index 0890e65..30b36b6 100644
--- a/libtommath/bn_mp_div.c
+++ b/libtommath/bn_mp_div.c
@@ -18,7 +18,7 @@
#ifdef BN_MP_DIV_SMALL
/* slower bit-bang division... also smaller */
-int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
+int mp_div(const mp_int * a, const mp_int * b, mp_int * c, mp_int * d)
{
mp_int ta, tb, tq, q;
int res, n, n2;
@@ -100,7 +100,7 @@ LBL_ERR:
* The overall algorithm is as described as
* 14.20 from HAC but fixed to treat these cases.
*/
-int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
+int mp_div (const mp_int * a, const mp_int * b, mp_int * c, mp_int * d)
{
mp_int q, x, y, t1, t2;
int res, n, t, i, norm, neg;
diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c
index e8504ea..5e75438 100644
--- a/libtommath/bn_mp_div_3.c
+++ b/libtommath/bn_mp_div_3.c
@@ -17,7 +17,7 @@
/* divide by three (based on routine from MPI and the GMP manual) */
int
-mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
+mp_div_3 (const mp_int * a, mp_int *c, mp_digit * d)
{
mp_int q;
mp_word w, t;
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c
index d1f2774..4767565 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -33,7 +33,7 @@ static int s_is_power_of_two(mp_digit b, int *p)
}
/* single digit division (based on routine from MPI) */
-int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
+int mp_div_d (const mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
{
mp_int q;
mp_word w;
diff --git a/libtommath/bn_mp_expt_d.c b/libtommath/bn_mp_expt_d.c
index a311926..ffa3b93 100644
--- a/libtommath/bn_mp_expt_d.c
+++ b/libtommath/bn_mp_expt_d.c
@@ -16,7 +16,7 @@
*/
/* wrapper function for mp_expt_d_ex() */
-int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
+int mp_expt_d (const mp_int * a, mp_digit b, mp_int * c)
{
return mp_expt_d_ex(a, b, c, 0);
}
diff --git a/libtommath/bn_mp_expt_d_ex.c b/libtommath/bn_mp_expt_d_ex.c
index c361b27..545d156 100644
--- a/libtommath/bn_mp_expt_d_ex.c
+++ b/libtommath/bn_mp_expt_d_ex.c
@@ -16,7 +16,7 @@
*/
/* calculate c = a**b using a square-multiply algorithm */
-int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
+int mp_expt_d_ex (const mp_int * a, mp_digit b, mp_int * c, int fast)
{
int res;
unsigned int x;
diff --git a/libtommath/bn_mp_karatsuba_mul.c b/libtommath/bn_mp_karatsuba_mul.c
index 4d982c7..1e6a42b 100644
--- a/libtommath/bn_mp_karatsuba_mul.c
+++ b/libtommath/bn_mp_karatsuba_mul.c
@@ -44,7 +44,7 @@
* 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 (const mp_int * a, const mp_int * b, mp_int * c)
{
mp_int x0, x1, y0, y1, t1, x0y0, x1y1;
int B, err;
diff --git a/libtommath/bn_mp_karatsuba_sqr.c b/libtommath/bn_mp_karatsuba_sqr.c
index 764e85a..90624d0 100644
--- a/libtommath/bn_mp_karatsuba_sqr.c
+++ b/libtommath/bn_mp_karatsuba_sqr.c
@@ -22,7 +22,7 @@
* is essentially the same algorithm but merely
* tuned to perform recursive squarings.
*/
-int mp_karatsuba_sqr (mp_int * a, mp_int * b)
+int mp_karatsuba_sqr (const mp_int * a, mp_int * b)
{
mp_int x0, x1, t1, t2, x0x0, x1x1;
int B, err;
diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c
index 06240a0..fff0f92 100644
--- a/libtommath/bn_mp_mod.c
+++ b/libtommath/bn_mp_mod.c
@@ -17,7 +17,7 @@
/* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */
int
-mp_mod (mp_int * a, mp_int * b, mp_int * c)
+mp_mod (const mp_int * a, const mp_int * b, mp_int * c)
{
mp_int t;
int res;
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index cc3b9c8..b8b85c8 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -16,7 +16,7 @@
*/
/* high level multiplication (handles sign) */
-int mp_mul (mp_int * a, mp_int * b, mp_int * c)
+int mp_mul (const mp_int * a, const mp_int * b, mp_int * c)
{
int res, neg;
neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c
index 6954ed3..266b082 100644
--- a/libtommath/bn_mp_mul_d.c
+++ b/libtommath/bn_mp_mul_d.c
@@ -17,7 +17,7 @@
/* multiply by a digit */
int
-mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
+mp_mul_d (const mp_int * a, mp_digit b, mp_int * c)
{
mp_digit u, *tmpa, *tmpc;
mp_word r;
diff --git a/libtommath/bn_mp_or.c b/libtommath/bn_mp_or.c
index b9775ce..afe8467 100644
--- a/libtommath/bn_mp_or.c
+++ b/libtommath/bn_mp_or.c
@@ -16,10 +16,11 @@
*/
/* OR two ints together */
-int mp_or (mp_int * a, mp_int * b, mp_int * c)
+int mp_or (const mp_int * a, const mp_int * b, mp_int * c)
{
int res, ix, px;
- mp_int t, *x;
+ mp_int t;
+ const mp_int *x;
if (a->used > b->used) {
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index ffe94e2..a61f506 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -17,7 +17,7 @@
/* computes b = a*a */
int
-mp_sqr (mp_int * a, mp_int * b)
+mp_sqr (const mp_int * a, mp_int * b)
{
int res;
diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c
index 775e85f..ce8bd0e 100644
--- a/libtommath/bn_mp_sqrt.c
+++ b/libtommath/bn_mp_sqrt.c
@@ -20,7 +20,7 @@
#endif
/* this function is less generic than mp_n_root, simpler and faster */
-int mp_sqrt(mp_int *arg, mp_int *ret)
+int mp_sqrt(const mp_int *arg, mp_int *ret)
{
int res;
mp_int t1,t2;
diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c
index 2f73faa..9ff03d5 100644
--- a/libtommath/bn_mp_sub.c
+++ b/libtommath/bn_mp_sub.c
@@ -17,7 +17,7 @@
/* high level subtraction (handles signs) */
int
-mp_sub (mp_int * a, mp_int * b, mp_int * c)
+mp_sub (const mp_int * a, const mp_int * b, mp_int * c)
{
int sa, sb, res;
diff --git a/libtommath/bn_mp_toom_mul.c b/libtommath/bn_mp_toom_mul.c
index 4a574fc..0bf940d 100644
--- a/libtommath/bn_mp_toom_mul.c
+++ b/libtommath/bn_mp_toom_mul.c
@@ -22,7 +22,7 @@
* only particularly useful on VERY large inputs
* (we're talking 1000s of digits here...).
*/
-int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
+int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int w0, w1, w2, w3, w4, tmp1, tmp2, a0, a1, a2, b0, b1, b2;
int res, B;
diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c
index 0a38192..842ae47 100644
--- a/libtommath/bn_mp_toom_sqr.c
+++ b/libtommath/bn_mp_toom_sqr.c
@@ -17,7 +17,7 @@
/* squaring using Toom-Cook 3-way algorithm */
int
-mp_toom_sqr(mp_int *a, mp_int *b)
+mp_toom_sqr(const mp_int *a, mp_int *b)
{
mp_int w0, w1, w2, w3, w4, tmp1, a0, a1, a2;
int res, B;
diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c
index f51fc8e..9f7b086 100644
--- a/libtommath/bn_mp_xor.c
+++ b/libtommath/bn_mp_xor.c
@@ -17,10 +17,11 @@
/* XOR two ints together */
int
-mp_xor (mp_int * a, mp_int * b, mp_int * c)
+mp_xor (const mp_int * a, const mp_int * b, mp_int * c)
{
int res, ix, px;
- mp_int t, *x;
+ mp_int t;
+ const mp_int *x;
if (a->used > b->used) {
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c
index 7a100e8..432e3b4 100644
--- a/libtommath/bn_s_mp_add.c
+++ b/libtommath/bn_s_mp_add.c
@@ -17,9 +17,9 @@
/* low level addition, based on HAC pp.594, Algorithm 14.7 */
int
-s_mp_add (mp_int * a, mp_int * b, mp_int * c)
+s_mp_add (const mp_int * a, const mp_int * b, mp_int * c)
{
- mp_int *x;
+ const mp_int *x;
int olduse, res, min, max;
/* find sizes, we let |a| <= |b| which means we have to sort
diff --git a/libtommath/bn_s_mp_mul_digs.c b/libtommath/bn_s_mp_mul_digs.c
index 8f1bf97..d32bf15 100644
--- a/libtommath/bn_s_mp_mul_digs.c
+++ b/libtommath/bn_s_mp_mul_digs.c
@@ -19,7 +19,7 @@
* HAC pp. 595, Algorithm 14.12 Modified so you can control how
* many digits of output are created.
*/
-int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
+int s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs)
{
mp_int t;
int res, pa, pb, ix, iy;
diff --git a/libtommath/bn_s_mp_sqr.c b/libtommath/bn_s_mp_sqr.c
index ac0e157..de6a3ea 100644
--- a/libtommath/bn_s_mp_sqr.c
+++ b/libtommath/bn_s_mp_sqr.c
@@ -16,7 +16,7 @@
*/
/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */
-int s_mp_sqr (mp_int * a, mp_int * b)
+int s_mp_sqr (const mp_int * a, mp_int * b)
{
mp_int t;
int res, ix, iy, pa;
diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c
index 8091f4a..7f49d66 100644
--- a/libtommath/bn_s_mp_sub.c
+++ b/libtommath/bn_s_mp_sub.c
@@ -17,7 +17,7 @@
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
int
-s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
+s_mp_sub (const mp_int * a, const mp_int * b, mp_int * c)
{
int olduse, res, min, max;
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index a8c9e21..b183b8a 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -288,13 +288,13 @@ int mp_rand(mp_int *a, int digits);
/* ---> binary operations <--- */
/* c = a XOR b */
-int mp_xor(mp_int *a, mp_int *b, mp_int *c);
+int mp_xor(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a OR b */
-int mp_or(mp_int *a, mp_int *b, mp_int *c);
+int mp_or(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a AND b */
-int mp_and(mp_int *a, mp_int *b, mp_int *c);
+int mp_and(const mp_int *a, const mp_int *b, mp_int *c);
/* ---> Basic arithmetic <--- */
@@ -302,7 +302,7 @@ int mp_and(mp_int *a, mp_int *b, mp_int *c);
int mp_neg(const mp_int *a, mp_int *b);
/* b = |a| */
-int mp_abs(mp_int *a, mp_int *b);
+int mp_abs(const mp_int *a, mp_int *b);
/* compare a to b */
int mp_cmp(const mp_int *a, const mp_int *b);
@@ -311,22 +311,22 @@ int mp_cmp(const mp_int *a, const mp_int *b);
int mp_cmp_mag(const mp_int *a, const mp_int *b);
/* c = a + b */
-int mp_add(mp_int *a, mp_int *b, mp_int *c);
+int mp_add(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a - b */
-int mp_sub(mp_int *a, mp_int *b, mp_int *c);
+int mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
/* c = a * b */
-int mp_mul(mp_int *a, mp_int *b, mp_int *c);
+int mp_mul(const mp_int *a, const mp_int *b, mp_int *c);
/* b = a*a */
-int mp_sqr(mp_int *a, mp_int *b);
+int mp_sqr(const mp_int *a, mp_int *b);
/* a/b => cb + d == a */
-int mp_div(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
+int mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d);
/* c = a mod b, 0 <= c < b */
-int mp_mod(mp_int *a, mp_int *b, mp_int *c);
+int mp_mod(const mp_int *a, const mp_int *b, mp_int *c);
/* ---> single digit functions <--- */
@@ -334,26 +334,26 @@ int mp_mod(mp_int *a, mp_int *b, mp_int *c);
int mp_cmp_d(const mp_int *a, mp_digit b);
/* c = a + b */
-int mp_add_d(mp_int *a, mp_digit b, mp_int *c);
+int mp_add_d(const mp_int *a, const mp_digit b, mp_int *c);
/* c = a - b */
int mp_sub_d(mp_int *a, mp_digit b, mp_int *c);
/* c = a * b */
-int mp_mul_d(mp_int *a, mp_digit b, mp_int *c);
+int mp_mul_d(const mp_int *a, mp_digit b, mp_int *c);
/* a/b => cb + d == a */
-int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
+int mp_div_d(const mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
/* a/3 => 3c + d == a */
-int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
+int mp_div_3(const mp_int *a, mp_int *c, mp_digit *d);
/* c = a**b */
-int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
-int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
+int mp_expt_d(const mp_int *a, const mp_digit b, mp_int *c);
+int mp_expt_d_ex (const mp_int * a, const mp_digit b, mp_int * c, int fast);
/* c = a mod b, 0 <= c < b */
-int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c);
+int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c);
/* ---> number theory <--- */
@@ -389,7 +389,7 @@ int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast);
/* special sqrt algo */
-int mp_sqrt(mp_int *arg, mp_int *ret);
+int mp_sqrt(const mp_int *arg, mp_int *ret);
/* special sqrt (mod prime) */
int mp_sqrtmod_prime(mp_int *arg, mp_int *prime, mp_int *ret);
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index 3217ee7..07607a8 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -57,19 +57,19 @@ extern "C" {
#endif
/* lowlevel functions, do not call! */
-int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
-int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
+int s_mp_add(const mp_int *a, const mp_int *b, mp_int *c);
+int s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
-int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
+int fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs);
+int s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs);
int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
-int fast_s_mp_sqr(mp_int *a, mp_int *b);
-int s_mp_sqr(mp_int *a, mp_int *b);
-int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
-int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
-int mp_karatsuba_sqr(mp_int *a, mp_int *b);
-int mp_toom_sqr(mp_int *a, mp_int *b);
+int fast_s_mp_sqr(const mp_int *a, mp_int *b);
+int s_mp_sqr(const mp_int *a, mp_int *b);
+int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c);
+int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c);
+int mp_karatsuba_sqr(const mp_int *a, mp_int *b);
+int mp_toom_sqr(const mp_int *a, mp_int *b);
int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
int fast_mp_montgomery_reduce(mp_int *x, mp_int *n, mp_digit rho);