diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-18 14:38:26 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-09-18 14:38:26 (GMT) |
commit | f75f76c9d479632f92d722036fdb45311338021f (patch) | |
tree | 10f652d15b7acb570ecce58ddcc42c714e6f39ce /libtommath | |
parent | f5ea63343e4245c7b8e5a0872e65c867e5e9d6f2 (diff) | |
download | tcl-f75f76c9d479632f92d722036fdb45311338021f.zip tcl-f75f76c9d479632f92d722036fdb45311338021f.tar.gz tcl-f75f76c9d479632f92d722036fdb45311338021f.tar.bz2 |
Finish libtommath's constification work. All done (hopefully). And make sure that C preprocessor directives have the '#' as first character on the line.
Diffstat (limited to 'libtommath')
-rw-r--r-- | libtommath/bn_fast_s_mp_mul_high_digs.c | 2 | ||||
-rw-r--r-- | libtommath/bn_mp_prime_fermat.c | 2 | ||||
-rw-r--r-- | libtommath/bn_mp_prime_is_divisible.c | 2 | ||||
-rw-r--r-- | libtommath/bn_mp_prime_is_prime.c | 2 | ||||
-rw-r--r-- | libtommath/bn_mp_prime_miller_rabin.c | 2 | ||||
-rw-r--r-- | libtommath/bn_s_mp_mul_high_digs.c | 2 | ||||
-rw-r--r-- | libtommath/tommath.h | 8 | ||||
-rw-r--r-- | libtommath/tommath_private.h | 8 |
8 files changed, 13 insertions, 15 deletions
diff --git a/libtommath/bn_fast_s_mp_mul_high_digs.c b/libtommath/bn_fast_s_mp_mul_high_digs.c index 588d80b..8b662ed 100644 --- a/libtommath/bn_fast_s_mp_mul_high_digs.c +++ b/libtommath/bn_fast_s_mp_mul_high_digs.c @@ -24,7 +24,7 @@ * * Based on Algorithm 14.12 on pp.595 of HAC. */ -int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs) +int fast_s_mp_mul_high_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_mp_prime_fermat.c b/libtommath/bn_mp_prime_fermat.c index 37ad6ec..9c15435 100644 --- a/libtommath/bn_mp_prime_fermat.c +++ b/libtommath/bn_mp_prime_fermat.c @@ -23,7 +23,7 @@ * * Sets result to 1 if the congruence holds, or zero otherwise. */ -int mp_prime_fermat(mp_int *a, mp_int *b, int *result) +int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result) { mp_int t; int err; diff --git a/libtommath/bn_mp_prime_is_divisible.c b/libtommath/bn_mp_prime_is_divisible.c index 92af330..c1e1158 100644 --- a/libtommath/bn_mp_prime_is_divisible.c +++ b/libtommath/bn_mp_prime_is_divisible.c @@ -20,7 +20,7 @@ * * sets result to 0 if not, 1 if yes */ -int mp_prime_is_divisible(mp_int *a, int *result) +int mp_prime_is_divisible(const mp_int *a, int *result) { int err, ix; mp_digit res; diff --git a/libtommath/bn_mp_prime_is_prime.c b/libtommath/bn_mp_prime_is_prime.c index 20a7d1f..e97712d 100644 --- a/libtommath/bn_mp_prime_is_prime.c +++ b/libtommath/bn_mp_prime_is_prime.c @@ -22,7 +22,7 @@ * * Sets result to 1 if probably prime, 0 otherwise */ -int mp_prime_is_prime(mp_int *a, int t, int *result) +int mp_prime_is_prime(const mp_int *a, int t, int *result) { mp_int b; int ix, err, res; diff --git a/libtommath/bn_mp_prime_miller_rabin.c b/libtommath/bn_mp_prime_miller_rabin.c index 917dc01..5de5f05 100644 --- a/libtommath/bn_mp_prime_miller_rabin.c +++ b/libtommath/bn_mp_prime_miller_rabin.c @@ -22,7 +22,7 @@ * Randomly the chance of error is no more than 1/4 and often * very much lower. */ -int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result) +int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) { mp_int n1, y, r; int s, j, err; diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c index 44d0d21..0a829b9 100644 --- a/libtommath/bn_s_mp_mul_high_digs.c +++ b/libtommath/bn_s_mp_mul_high_digs.c @@ -19,7 +19,7 @@ * [meant to get the higher part of the product] */ int -s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs) +s_mp_mul_high_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/tommath.h b/libtommath/tommath.h index 513b5b9..dee7ab5 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -464,17 +464,17 @@ int mp_exptmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d); extern const mp_digit ltm_prime_tab[PRIME_SIZE]; /* result=1 if a is divisible by one of the first PRIME_SIZE primes */ -int mp_prime_is_divisible(mp_int *a, int *result); +int mp_prime_is_divisible(const mp_int *a, int *result); /* performs one Fermat test of "a" using base "b". * Sets result to 0 if composite or 1 if probable prime */ -int mp_prime_fermat(mp_int *a, mp_int *b, int *result); +int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result); /* performs one Miller-Rabin test of "a" using base "b". * Sets result to 0 if composite or 1 if probable prime */ -int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result); +int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result); /* This gives [for a given bit size] the number of trials required * such that Miller-Rabin gives a prob of failure lower than 2^-96 @@ -488,7 +488,7 @@ int mp_prime_rabin_miller_trials(int size); * * Sets result to 1 if probably prime, 0 otherwise */ -int mp_prime_is_prime(mp_int *a, int t, int *result); +int mp_prime_is_prime(const mp_int *a, int t, int *result); /* finds the next prime after the number "a" using "t" trials * of Miller-Rabin. diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index 58846bf..be065cd 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -40,21 +40,19 @@ extern "C" { #endif /* define heap macros */ -#if 0 #ifndef XMALLOC /* default to libc stuff */ # define XMALLOC malloc # define XFREE free # define XREALLOC realloc # define XCALLOC calloc -#else +#elif 0 /* prototypes for our heap functions */ extern void *XMALLOC(size_t n); extern void *XREALLOC(void *p, size_t n); extern void *XCALLOC(size_t n, size_t s); extern void XFREE(void *p); #endif -#endif /* lowlevel functions, do not call! */ int s_mp_add(const mp_int *a, const mp_int *b, mp_int *c); @@ -62,8 +60,8 @@ 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(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_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); +int s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs); 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); |