diff --git a/bn_mp_cmp.c b/bn_mp_cmp.c index 9047060..a505746 100644 --- a/bn_mp_cmp.c +++ b/bn_mp_cmp.c @@ -16,7 +16,7 @@ */ /* compare two ints (signed)*/ -int mp_cmp(mp_int *a, mp_int *b) +int mp_cmp(const mp_int *a, mp_int *b) { /* compare based on sign */ if (a->sign != b->sign) { diff --git a/bn_mp_cmp_d.c b/bn_mp_cmp_d.c index 27a546d..576a073 100644 --- a/bn_mp_cmp_d.c +++ b/bn_mp_cmp_d.c @@ -16,7 +16,7 @@ */ /* compare a digit */ -int mp_cmp_d(mp_int *a, mp_digit b) +int mp_cmp_d(const mp_int *a, mp_digit b) { /* compare based on sign */ if (a->sign == MP_NEG) { diff --git a/bn_mp_cmp_mag.c b/bn_mp_cmp_mag.c index ca2bc88..0066ca0 100644 --- a/bn_mp_cmp_mag.c +++ b/bn_mp_cmp_mag.c @@ -16,7 +16,7 @@ */ /* compare maginitude of two ints (unsigned) */ -int mp_cmp_mag(mp_int *a, mp_int *b) +int mp_cmp_mag(const mp_int *a, mp_int *b) { int n; mp_digit *tmpa, *tmpb; diff --git a/bn_mp_cnt_lsb.c b/bn_mp_cnt_lsb.c index 7273655..9a94d3d 100644 --- a/bn_mp_cnt_lsb.c +++ b/bn_mp_cnt_lsb.c @@ -20,7 +20,7 @@ static const int lnz[16] = { }; /* Counts the number of lsbs which are zero before the first zero bit */ -int mp_cnt_lsb(mp_int *a) +int mp_cnt_lsb(const mp_int *a) { int x; mp_digit q, qq; diff --git a/bn_mp_copy.c b/bn_mp_copy.c index bed03b2..17816e8 100644 --- a/bn_mp_copy.c +++ b/bn_mp_copy.c @@ -16,7 +16,7 @@ */ /* copy, b = a */ -int mp_copy(mp_int *a, mp_int *b) +int mp_copy(const mp_int *a, mp_int *b) { int res, n; diff --git a/bn_mp_count_bits.c b/bn_mp_count_bits.c index dea364f..7424581 100644 --- a/bn_mp_count_bits.c +++ b/bn_mp_count_bits.c @@ -16,7 +16,7 @@ */ /* returns the number of bits in an int */ -int mp_count_bits(mp_int *a) +int mp_count_bits(const mp_int *a) { int r; mp_digit q; diff --git a/bn_mp_div_2d.c b/bn_mp_div_2d.c index d6723ee..eae3498 100644 --- a/bn_mp_div_2d.c +++ b/bn_mp_div_2d.c @@ -16,7 +16,7 @@ */ /* 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(const mp_int *a, int b, mp_int *c, mp_int *d) { mp_digit D, r, rr; int x, res; diff --git a/bn_mp_init_copy.c b/bn_mp_init_copy.c index c711e06..5681015 100644 --- a/bn_mp_init_copy.c +++ b/bn_mp_init_copy.c @@ -16,7 +16,7 @@ */ /* creates "a" then copies b into it */ -int mp_init_copy(mp_int *a, mp_int *b) +int mp_init_copy(mp_int *a, const mp_int *b) { int res; diff --git a/bn_mp_mod_2d.c b/bn_mp_mod_2d.c index 59270b9..8e69757 100644 --- a/bn_mp_mod_2d.c +++ b/bn_mp_mod_2d.c @@ -16,7 +16,7 @@ */ /* calc a value mod 2**b */ -int mp_mod_2d(mp_int *a, int b, mp_int *c) +int mp_mod_2d(const mp_int *a, int b, mp_int *c) { int x, res; diff --git a/bn_mp_mul_2d.c b/bn_mp_mul_2d.c index b3d92a9..4938e57 100644 --- a/bn_mp_mul_2d.c +++ b/bn_mp_mul_2d.c @@ -16,7 +16,7 @@ */ /* shift left by a certain bit count */ -int mp_mul_2d(mp_int *a, int b, mp_int *c) +int mp_mul_2d(const mp_int *a, int b, mp_int *c) { mp_digit d; int res; diff --git a/bn_mp_neg.c b/bn_mp_neg.c index b30d044..75f8bbd 100644 --- a/bn_mp_neg.c +++ b/bn_mp_neg.c @@ -16,7 +16,7 @@ */ /* b = -a */ -int mp_neg(mp_int *a, mp_int *b) +int mp_neg(const mp_int *a, mp_int *b) { int res; if (a != b) { diff --git a/bn_mp_radix_size.c b/bn_mp_radix_size.c index a6e2f04..29355cb 100644 --- a/bn_mp_radix_size.c +++ b/bn_mp_radix_size.c @@ -16,7 +16,7 @@ */ /* returns size of ASCII reprensentation */ -int mp_radix_size(mp_int *a, int radix, int *size) +int mp_radix_size(const mp_int *a, int radix, int *size) { int res, digs; mp_int t; diff --git a/tommath.h b/tommath.h index 2aaea5b..3f49767 100644 --- a/tommath.h +++ b/tommath.h @@ -238,10 +238,10 @@ int mp_init_set(mp_int *a, mp_digit b); int mp_init_set_int(mp_int *a, unsigned long b); /* copy, b = a */ -int mp_copy(mp_int *a, mp_int *b); +int mp_copy(const mp_int *a, mp_int *b); /* inits and copies, a = b */ -int mp_init_copy(mp_int *a, mp_int *b); +int mp_init_copy(mp_int *a, const mp_int *b); /* trim unused digits */ void mp_clamp(mp_int *a); @@ -261,25 +261,25 @@ void mp_rshd(mp_int *a, int b); int mp_lshd(mp_int *a, int b); /* c = a / 2**b, implemented as c = a >> b */ -int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d); +int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d); /* b = a/2 */ int mp_div_2(mp_int *a, mp_int *b); /* c = a * 2**b, implemented as c = a << b */ -int mp_mul_2d(mp_int *a, int b, mp_int *c); +int mp_mul_2d(const mp_int *a, int b, mp_int *c); /* b = a*2 */ int mp_mul_2(mp_int *a, mp_int *b); /* c = a mod 2**b */ -int mp_mod_2d(mp_int *a, int b, mp_int *c); +int mp_mod_2d(const mp_int *a, int b, mp_int *c); /* computes a = 2**b */ int mp_2expt(mp_int *a, int b); /* Counts the number of lsbs which are zero before the first zero bit */ -int mp_cnt_lsb(mp_int *a); +int mp_cnt_lsb(const mp_int *a); /* I Love Earth! */ @@ -299,16 +299,16 @@ int mp_and(mp_int *a, mp_int *b, mp_int *c); /* ---> Basic arithmetic <--- */ /* b = -a */ -int mp_neg(mp_int *a, mp_int *b); +int mp_neg(const mp_int *a, mp_int *b); /* b = |a| */ int mp_abs(mp_int *a, mp_int *b); /* compare a to b */ -int mp_cmp(mp_int *a, mp_int *b); +int mp_cmp(const mp_int *a, const mp_int *b); /* compare |a| to |b| */ -int mp_cmp_mag(mp_int *a, 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); @@ -331,7 +331,7 @@ int mp_mod(mp_int *a, mp_int *b, mp_int *c); /* ---> single digit functions <--- */ /* compare against a single digit */ -int mp_cmp_d(mp_int *a, mp_digit b); +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); @@ -524,7 +524,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style); int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat); /* ---> radix conversion <--- */ -int mp_count_bits(mp_int *a); +int mp_count_bits(const mp_int *a); int mp_unsigned_bin_size(mp_int *a); int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); @@ -539,7 +539,7 @@ int mp_to_signed_bin_n(mp_int *a, unsigned char *b, unsigned long *outlen); int mp_read_radix(mp_int *a, const char *str, int radix); int mp_toradix(mp_int *a, char *str, int radix); int mp_toradix_n(mp_int *a, char *str, int radix, int maxlen); -int mp_radix_size(mp_int *a, int radix, int *size); +int mp_radix_size(const mp_int *a, int radix, int *size); #ifndef LTM_NO_FILE int mp_fread(mp_int *a, int radix, FILE *stream);