summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-20 09:07:35 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-20 09:07:35 (GMT)
commit88b282766104841d47f9878536605bc08ae4c599 (patch)
tree57406e965f588883b917e212fb93e93ac84f72cc
parent7a4fe54c26332c21cd95b01cc07bd74714d060ae (diff)
downloadtcl-88b282766104841d47f9878536605bc08ae4c599.zip
tcl-88b282766104841d47f9878536605bc08ae4c599.tar.gz
tcl-88b282766104841d47f9878536605bc08ae4c599.tar.bz2
Further astyle formatting of libtommath. No functional changes.
-rw-r--r--libtommath/bn_mp_2expt.c3
-rw-r--r--libtommath/bn_mp_abs.c3
-rw-r--r--libtommath/bn_mp_add_d.c3
-rw-r--r--libtommath/bn_mp_addmod.c3
-rw-r--r--libtommath/bn_mp_and.c3
-rw-r--r--libtommath/bn_mp_clamp.c3
-rw-r--r--libtommath/bn_mp_clear.c3
-rw-r--r--libtommath/bn_mp_cmp.c3
-rw-r--r--libtommath/bn_mp_copy.c3
-rw-r--r--libtommath/bn_mp_count_bits.c3
-rw-r--r--libtommath/bn_mp_div.c2
-rw-r--r--libtommath/bn_mp_div_3.c3
-rw-r--r--libtommath/bn_mp_div_d.c7
-rw-r--r--libtommath/bn_mp_dr_reduce.c3
-rw-r--r--libtommath/bn_mp_dr_setup.c3
-rw-r--r--libtommath/bn_mp_exch.c3
-rw-r--r--libtommath/bn_mp_export.c8
-rw-r--r--libtommath/bn_mp_exptmod_fast.c4
-rw-r--r--libtommath/bn_mp_exteuclid.c2
-rw-r--r--libtommath/bn_mp_get_int.c6
-rw-r--r--libtommath/bn_mp_get_long.c6
-rw-r--r--libtommath/bn_mp_get_long_long.c6
-rw-r--r--libtommath/bn_mp_import.c11
-rw-r--r--libtommath/bn_mp_is_square.c16
-rw-r--r--libtommath/bn_mp_mod.c3
-rw-r--r--libtommath/bn_mp_mod_2d.c3
-rw-r--r--libtommath/bn_mp_mod_d.c3
-rw-r--r--libtommath/bn_mp_montgomery_reduce.c3
-rw-r--r--libtommath/bn_mp_montgomery_setup.c3
-rw-r--r--libtommath/bn_mp_mul.c2
-rw-r--r--libtommath/bn_mp_mul_d.c7
-rw-r--r--libtommath/bn_mp_radix_size.c2
-rw-r--r--libtommath/bn_mp_rand.c3
-rw-r--r--libtommath/bn_mp_read_radix.c4
-rw-r--r--libtommath/bn_mp_sqr.c3
-rw-r--r--libtommath/bn_mp_sqrmod.c3
-rw-r--r--libtommath/bn_mp_sub.c3
-rw-r--r--libtommath/bn_mp_sub_d.c3
-rw-r--r--libtommath/bn_mp_submod.c3
-rw-r--r--libtommath/bn_mp_toom_sqr.c3
-rw-r--r--libtommath/bn_mp_toradix.c2
-rw-r--r--libtommath/bn_mp_toradix_n.c2
-rw-r--r--libtommath/bn_mp_xor.c3
-rw-r--r--libtommath/bn_reverse.c3
-rw-r--r--libtommath/bn_s_mp_add.c3
-rw-r--r--libtommath/bn_s_mp_exptmod.c6
-rw-r--r--libtommath/bn_s_mp_mul_high_digs.c3
-rw-r--r--libtommath/bn_s_mp_sqr.c4
-rw-r--r--libtommath/bn_s_mp_sub.c3
49 files changed, 78 insertions, 112 deletions
diff --git a/libtommath/bn_mp_2expt.c b/libtommath/bn_mp_2expt.c
index bdc868f..701144c 100644
--- a/libtommath/bn_mp_2expt.c
+++ b/libtommath/bn_mp_2expt.c
@@ -20,8 +20,7 @@
* Simple algorithm which zeroes the int, grows it then just sets one bit
* as required.
*/
-int
-mp_2expt(mp_int *a, int b)
+int mp_2expt(mp_int *a, int b)
{
int res;
diff --git a/libtommath/bn_mp_abs.c b/libtommath/bn_mp_abs.c
index 03904d2..9b6bcec 100644
--- a/libtommath/bn_mp_abs.c
+++ b/libtommath/bn_mp_abs.c
@@ -19,8 +19,7 @@
*
* Simple function copies the input and fixes the sign to positive
*/
-int
-mp_abs(const mp_int *a, mp_int *b)
+int mp_abs(const mp_int *a, mp_int *b)
{
int res;
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c
index 5270d27..e5ede1f 100644
--- a/libtommath/bn_mp_add_d.c
+++ b/libtommath/bn_mp_add_d.c
@@ -16,8 +16,7 @@
*/
/* single digit addition */
-int
-mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
+int mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
{
int res, ix, oldused;
mp_digit *tmpa, *tmpc, mu;
diff --git a/libtommath/bn_mp_addmod.c b/libtommath/bn_mp_addmod.c
index 5aee233..0d612c3 100644
--- a/libtommath/bn_mp_addmod.c
+++ b/libtommath/bn_mp_addmod.c
@@ -16,8 +16,7 @@
*/
/* d = a + b (mod c) */
-int
-mp_addmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d)
+int mp_addmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d)
{
int res;
mp_int t;
diff --git a/libtommath/bn_mp_and.c b/libtommath/bn_mp_and.c
index c6e8cf7..09ff772 100644
--- a/libtommath/bn_mp_and.c
+++ b/libtommath/bn_mp_and.c
@@ -16,8 +16,7 @@
*/
/* AND two ints together */
-int
-mp_and(const mp_int *a, const mp_int *b, mp_int *c)
+int mp_and(const mp_int *a, const mp_int *b, mp_int *c)
{
int res, ix, px;
mp_int t;
diff --git a/libtommath/bn_mp_clamp.c b/libtommath/bn_mp_clamp.c
index e5c8907..3853914 100644
--- a/libtommath/bn_mp_clamp.c
+++ b/libtommath/bn_mp_clamp.c
@@ -22,8 +22,7 @@
* Typically very fast. Also fixes the sign if there
* are no more leading digits
*/
-void
-mp_clamp(mp_int *a)
+void mp_clamp(mp_int *a)
{
/* decrease used while the most significant digit is
* zero.
diff --git a/libtommath/bn_mp_clear.c b/libtommath/bn_mp_clear.c
index eada2d7..fcf4d61 100644
--- a/libtommath/bn_mp_clear.c
+++ b/libtommath/bn_mp_clear.c
@@ -16,8 +16,7 @@
*/
/* clear one (frees) */
-void
-mp_clear(mp_int *a)
+void mp_clear(mp_int *a)
{
int i;
diff --git a/libtommath/bn_mp_cmp.c b/libtommath/bn_mp_cmp.c
index 37f616e..a33d483 100644
--- a/libtommath/bn_mp_cmp.c
+++ b/libtommath/bn_mp_cmp.c
@@ -16,8 +16,7 @@
*/
/* compare two ints (signed)*/
-int
-mp_cmp(const mp_int *a, const mp_int *b)
+int mp_cmp(const mp_int *a, const mp_int *b)
{
/* compare based on sign */
if (a->sign != b->sign) {
diff --git a/libtommath/bn_mp_copy.c b/libtommath/bn_mp_copy.c
index 0f31138..17816e8 100644
--- a/libtommath/bn_mp_copy.c
+++ b/libtommath/bn_mp_copy.c
@@ -16,8 +16,7 @@
*/
/* copy, b = a */
-int
-mp_copy(const mp_int *a, mp_int *b)
+int mp_copy(const mp_int *a, mp_int *b)
{
int res, n;
diff --git a/libtommath/bn_mp_count_bits.c b/libtommath/bn_mp_count_bits.c
index f2cd190..7424581 100644
--- a/libtommath/bn_mp_count_bits.c
+++ b/libtommath/bn_mp_count_bits.c
@@ -16,8 +16,7 @@
*/
/* returns the number of bits in an int */
-int
-mp_count_bits(const mp_int *a)
+int mp_count_bits(const mp_int *a)
{
int r;
mp_digit q;
diff --git a/libtommath/bn_mp_div.c b/libtommath/bn_mp_div.c
index 6bad443..dbfdc03 100644
--- a/libtommath/bn_mp_div.c
+++ b/libtommath/bn_mp_div.c
@@ -167,7 +167,7 @@ int mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
t = y.used - 1;
/* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */
- if ((res = mp_lshd(&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
+ if ((res = mp_lshd(&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
goto LBL_Y;
}
diff --git a/libtommath/bn_mp_div_3.c b/libtommath/bn_mp_div_3.c
index 8011965..9cc8caa 100644
--- a/libtommath/bn_mp_div_3.c
+++ b/libtommath/bn_mp_div_3.c
@@ -16,8 +16,7 @@
*/
/* divide by three (based on routine from MPI and the GMP manual) */
-int
-mp_div_3(const mp_int *a, mp_int *c, mp_digit *d)
+int 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 9997646..0e9dc95 100644
--- a/libtommath/bn_mp_div_d.c
+++ b/libtommath/bn_mp_div_d.c
@@ -19,10 +19,13 @@ static int s_is_power_of_two(mp_digit b, int *p)
{
int x;
- /* quick out - if (b & (b-1)) isn't zero, b isn't a power of two */
- if ((b == 0) || ((b & (b-1)) != 0)) {
+ /* fast return if no power of two */
+ if ((b & (b-1)) != 0) {
return 0;
}
+
+ /* This loops gives the wrong result for b==1,
+ * but this function is never called for those values. */
for (x = 1; x < DIGIT_BIT; x++) {
if (b == (((mp_digit)1)<<x)) {
*p = x;
diff --git a/libtommath/bn_mp_dr_reduce.c b/libtommath/bn_mp_dr_reduce.c
index 17ab289..1ccb669 100644
--- a/libtommath/bn_mp_dr_reduce.c
+++ b/libtommath/bn_mp_dr_reduce.c
@@ -29,8 +29,7 @@
*
* Input x must be in the range 0 <= x <= (n-1)**2
*/
-int
-mp_dr_reduce(mp_int *x, const mp_int *n, mp_digit k)
+int mp_dr_reduce(mp_int *x, const mp_int *n, mp_digit k)
{
int err, i, m;
mp_word r;
diff --git a/libtommath/bn_mp_dr_setup.c b/libtommath/bn_mp_dr_setup.c
index 5dff995..af0e213 100644
--- a/libtommath/bn_mp_dr_setup.c
+++ b/libtommath/bn_mp_dr_setup.c
@@ -21,8 +21,7 @@ void mp_dr_setup(const mp_int *a, mp_digit *d)
/* the casts are required if DIGIT_BIT is one less than
* the number of bits in a mp_digit [e.g. DIGIT_BIT==31]
*/
- *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) -
- ((mp_word)a->dp[0]));
+ *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) - ((mp_word)a->dp[0]));
}
#endif
diff --git a/libtommath/bn_mp_exch.c b/libtommath/bn_mp_exch.c
index a95560a..2bc635f 100644
--- a/libtommath/bn_mp_exch.c
+++ b/libtommath/bn_mp_exch.c
@@ -18,8 +18,7 @@
/* swap the elements of two integers, for cases where you can't simply swap the
* mp_int pointers around
*/
-void
-mp_exch(mp_int *a, mp_int *b)
+void mp_exch(mp_int *a, mp_int *b)
{
mp_int t;
diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c
index 43228a8..b69a4fb 100644
--- a/libtommath/bn_mp_export.c
+++ b/libtommath/bn_mp_export.c
@@ -53,11 +53,9 @@ int mp_export(void *rop, size_t *countp, int order, size_t size,
for (i = 0; i < count; ++i) {
for (j = 0; j < size; ++j) {
- unsigned char *byte = (
- (unsigned char *)rop +
- (((order == -1) ? i : ((count - 1) - i)) * size) +
- ((endian == -1) ? j : ((size - 1) - j))
- );
+ unsigned char *byte = (unsigned char *)rop +
+ (((order == -1) ? i : ((count - 1) - i)) * size) +
+ ((endian == -1) ? j : ((size - 1) - j));
if (j >= (size - nail_bytes)) {
*byte = 0;
diff --git a/libtommath/bn_mp_exptmod_fast.c b/libtommath/bn_mp_exptmod_fast.c
index 08c6bc3..4a188d0 100644
--- a/libtommath/bn_mp_exptmod_fast.c
+++ b/libtommath/bn_mp_exptmod_fast.c
@@ -24,9 +24,9 @@
*/
#ifdef MP_LOW_MEM
-#define TAB_SIZE 32
+# define TAB_SIZE 32
#else
-#define TAB_SIZE 256
+# define TAB_SIZE 256
#endif
int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
diff --git a/libtommath/bn_mp_exteuclid.c b/libtommath/bn_mp_exteuclid.c
index adaea86..08e5ff2 100644
--- a/libtommath/bn_mp_exteuclid.c
+++ b/libtommath/bn_mp_exteuclid.c
@@ -20,7 +20,7 @@
*/
int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
{
- mp_int u1,u2,u3,v1,v2,v3,t1,t2,t3,q,tmp;
+ mp_int u1, u2, u3, v1, v2, v3, t1, t2, t3, q, tmp;
int err;
if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) {
diff --git a/libtommath/bn_mp_get_int.c b/libtommath/bn_mp_get_int.c
index 5d26ce9..f4a347f 100644
--- a/libtommath/bn_mp_get_int.c
+++ b/libtommath/bn_mp_get_int.c
@@ -26,13 +26,13 @@ unsigned long mp_get_int(const mp_int *a)
}
/* get number of digits of the lsb we have to read */
- i = MIN(a->used,(int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+ i = MIN(a->used, (int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = DIGIT(a,i);
+ res = DIGIT(a, i);
while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a,i);
+ res = (res << DIGIT_BIT) | DIGIT(a, i);
}
/* force result to 32-bits always so it is consistent on non 32-bit platforms */
diff --git a/libtommath/bn_mp_get_long.c b/libtommath/bn_mp_get_long.c
index ea9ac43..3fc7c35 100644
--- a/libtommath/bn_mp_get_long.c
+++ b/libtommath/bn_mp_get_long.c
@@ -26,14 +26,14 @@ unsigned long mp_get_long(const mp_int *a)
}
/* get number of digits of the lsb we have to read */
- i = MIN(a->used,(int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+ i = MIN(a->used, (int)(((sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = DIGIT(a,i);
+ res = DIGIT(a, i);
#if (ULONG_MAX != 0xffffffffuL) || (DIGIT_BIT < 32)
while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a,i);
+ res = (res << DIGIT_BIT) | DIGIT(a, i);
}
#endif
return res;
diff --git a/libtommath/bn_mp_get_long_long.c b/libtommath/bn_mp_get_long_long.c
index 111b469..a363f60 100644
--- a/libtommath/bn_mp_get_long_long.c
+++ b/libtommath/bn_mp_get_long_long.c
@@ -26,14 +26,14 @@ Tcl_WideUInt mp_get_long_long(const mp_int *a)
}
/* get number of digits of the lsb we have to read */
- i = MIN(a->used,(int)(((sizeof(Tcl_WideUInt) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
+ i = MIN(a->used, (int)(((sizeof(Tcl_WideUInt) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1;
/* get most significant digit of result */
- res = DIGIT(a,i);
+ res = DIGIT(a, i);
#if DIGIT_BIT < 64
while (--i >= 0) {
- res = (res << DIGIT_BIT) | DIGIT(a,i);
+ res = (res << DIGIT_BIT) | DIGIT(a, i);
}
#endif
return res;
diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c
index 50bee2e..afd735e 100644
--- a/libtommath/bn_mp_import.c
+++ b/libtommath/bn_mp_import.c
@@ -46,14 +46,11 @@ int mp_import(mp_int *rop, size_t count, int order, size_t size,
for (i = 0; i < count; ++i) {
for (j = 0; j < (size - nail_bytes); ++j) {
- unsigned char byte = *(
- (unsigned char *)op +
- (((order == 1) ? i : ((count - 1) - i)) * size) +
- ((endian == 1) ? (j + nail_bytes) : (((size - 1) - j) - nail_bytes))
- );
+ unsigned char byte = *((unsigned char *)op +
+ (((order == 1) ? i : ((count - 1) - i)) * size) +
+ ((endian == 1) ? (j + nail_bytes) : (((size - 1) - j) - nail_bytes)));
- if (
- (result = mp_mul_2d(rop, ((j == 0) ? (8 - odd_nails) : 8), rop)) != MP_OKAY) {
+ if ((result = mp_mul_2d(rop, ((j == 0) ? (8 - odd_nails) : 8), rop)) != MP_OKAY) {
return result;
}
diff --git a/libtommath/bn_mp_is_square.c b/libtommath/bn_mp_is_square.c
index 4d8612f..dd5150e 100644
--- a/libtommath/bn_mp_is_square.c
+++ b/libtommath/bn_mp_is_square.c
@@ -38,7 +38,7 @@ static const char rem_105[105] = {
};
/* Store non-zero to ret if arg is square, and zero if not */
-int mp_is_square(const mp_int *arg,int *ret)
+int mp_is_square(const mp_int *arg, int *ret)
{
int res;
mp_digit c;
@@ -58,12 +58,12 @@ int mp_is_square(const mp_int *arg,int *ret)
}
/* First check mod 128 (suppose that DIGIT_BIT is at least 7) */
- if (rem_128[127 & DIGIT(arg,0)] == 1) {
+ if (rem_128[127 & DIGIT(arg, 0)] == 1) {
return MP_OKAY;
}
/* Next check mod 105 (3*5*7) */
- if ((res = mp_mod_d(arg,105,&c)) != MP_OKAY) {
+ if ((res = mp_mod_d(arg, 105, &c)) != MP_OKAY) {
return res;
}
if (rem_105[c] == 1) {
@@ -71,10 +71,10 @@ int mp_is_square(const mp_int *arg,int *ret)
}
- if ((res = mp_init_set_int(&t,11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
+ if ((res = mp_init_set_int(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
return res;
}
- if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) {
+ if ((res = mp_mod(arg, &t, &t)) != MP_OKAY) {
goto ERR;
}
r = mp_get_int(&t);
@@ -91,14 +91,14 @@ int mp_is_square(const mp_int *arg,int *ret)
if (((1L<<(r%31)) & 0x6DE2B848L) != 0L) goto ERR;
/* Final check - is sqr(sqrt(arg)) == arg ? */
- if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
+ if ((res = mp_sqrt(arg, &t)) != MP_OKAY) {
goto ERR;
}
- if ((res = mp_sqr(&t,&t)) != MP_OKAY) {
+ if ((res = mp_sqr(&t, &t)) != MP_OKAY) {
goto ERR;
}
- *ret = (mp_cmp_mag(&t,arg) == MP_EQ) ? MP_YES : MP_NO;
+ *ret = (mp_cmp_mag(&t, arg) == MP_EQ) ? MP_YES : MP_NO;
ERR:
mp_clear(&t);
return res;
diff --git a/libtommath/bn_mp_mod.c b/libtommath/bn_mp_mod.c
index a7525c0..64e73ea 100644
--- a/libtommath/bn_mp_mod.c
+++ b/libtommath/bn_mp_mod.c
@@ -16,8 +16,7 @@
*/
/* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */
-int
-mp_mod(const mp_int *a, const mp_int *b, mp_int *c)
+int mp_mod(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int t;
int res;
diff --git a/libtommath/bn_mp_mod_2d.c b/libtommath/bn_mp_mod_2d.c
index 31997d3..8e69757 100644
--- a/libtommath/bn_mp_mod_2d.c
+++ b/libtommath/bn_mp_mod_2d.c
@@ -16,8 +16,7 @@
*/
/* calc a value mod 2**b */
-int
-mp_mod_2d(const 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/libtommath/bn_mp_mod_d.c b/libtommath/bn_mp_mod_d.c
index 5217aa4..9a24e78 100644
--- a/libtommath/bn_mp_mod_d.c
+++ b/libtommath/bn_mp_mod_d.c
@@ -15,8 +15,7 @@
* Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
-int
-mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c)
+int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c)
{
return mp_div_d(a, b, NULL, c);
}
diff --git a/libtommath/bn_mp_montgomery_reduce.c b/libtommath/bn_mp_montgomery_reduce.c
index e9f6c1c..a38173e 100644
--- a/libtommath/bn_mp_montgomery_reduce.c
+++ b/libtommath/bn_mp_montgomery_reduce.c
@@ -16,8 +16,7 @@
*/
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
-int
-mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
+int mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
{
int ix, res, digs;
mp_digit mu;
diff --git a/libtommath/bn_mp_montgomery_setup.c b/libtommath/bn_mp_montgomery_setup.c
index 37069c3..685ba51 100644
--- a/libtommath/bn_mp_montgomery_setup.c
+++ b/libtommath/bn_mp_montgomery_setup.c
@@ -16,8 +16,7 @@
*/
/* setups the montgomery reduction stuff */
-int
-mp_montgomery_setup(const mp_int *n, mp_digit *rho)
+int mp_montgomery_setup(const mp_int *n, mp_digit *rho)
{
mp_digit x, b;
diff --git a/libtommath/bn_mp_mul.c b/libtommath/bn_mp_mul.c
index 6e7f956..71d523d 100644
--- a/libtommath/bn_mp_mul.c
+++ b/libtommath/bn_mp_mul.c
@@ -51,7 +51,7 @@ int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
#endif
{
#ifdef BN_S_MP_MUL_DIGS_C
- res = s_mp_mul(a, b, c); /* uses s_mp_mul_digs */
+ res = s_mp_mul(a, b, c); /* uses s_mp_mul_digs */
#else
res = MP_VAL;
#endif
diff --git a/libtommath/bn_mp_mul_d.c b/libtommath/bn_mp_mul_d.c
index 98b99c9..0f6d03e 100644
--- a/libtommath/bn_mp_mul_d.c
+++ b/libtommath/bn_mp_mul_d.c
@@ -16,8 +16,7 @@
*/
/* multiply by a digit */
-int
-mp_mul_d(const mp_int *a, mp_digit b, mp_int *c)
+int mp_mul_d(const mp_int *a, mp_digit b, mp_int *c)
{
mp_digit u, *tmpa, *tmpc;
mp_word r;
@@ -51,10 +50,10 @@ mp_mul_d(const mp_int *a, mp_digit b, mp_int *c)
r = (mp_word)u + ((mp_word)*tmpa++ * (mp_word)b);
/* mask off higher bits to get a single digit */
- *tmpc++ = (mp_digit)(r & ((mp_word) MP_MASK));
+ *tmpc++ = (mp_digit)(r & ((mp_word)MP_MASK));
/* send carry into next iteration */
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
+ u = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
}
/* store final carry [if any] and increment ix offset */
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c
index edcf618..29355cb 100644
--- a/libtommath/bn_mp_radix_size.c
+++ b/libtommath/bn_mp_radix_size.c
@@ -58,7 +58,7 @@ int mp_radix_size(const mp_int *a, int radix, int *size)
/* fetch out all of the digits */
while (mp_iszero(&t) == MP_NO) {
- if ((res = mp_div_d(&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
+ if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
mp_clear(&t);
return res;
}
diff --git a/libtommath/bn_mp_rand.c b/libtommath/bn_mp_rand.c
index 7ac01dc..92a9a97 100644
--- a/libtommath/bn_mp_rand.c
+++ b/libtommath/bn_mp_rand.c
@@ -41,8 +41,7 @@ static mp_digit s_gen_random(void)
return d;
}
-int
-mp_rand(mp_int *a, int digits)
+int mp_rand(mp_int *a, int digits)
{
int res;
mp_digit d;
diff --git a/libtommath/bn_mp_read_radix.c b/libtommath/bn_mp_read_radix.c
index 6e57ed5..bc31cc5 100644
--- a/libtommath/bn_mp_read_radix.c
+++ b/libtommath/bn_mp_read_radix.c
@@ -60,10 +60,10 @@ int mp_read_radix(mp_int *a, const char *str, int radix)
* to the number, otherwise exit the loop.
*/
if (y < radix) {
- if ((res = mp_mul_d(a, (mp_digit) radix, a)) != MP_OKAY) {
+ if ((res = mp_mul_d(a, (mp_digit)radix, a)) != MP_OKAY) {
return res;
}
- if ((res = mp_add_d(a, (mp_digit) y, a)) != MP_OKAY) {
+ if ((res = mp_add_d(a, (mp_digit)y, a)) != MP_OKAY) {
return res;
}
} else {
diff --git a/libtommath/bn_mp_sqr.c b/libtommath/bn_mp_sqr.c
index 0fd077c..2b71097 100644
--- a/libtommath/bn_mp_sqr.c
+++ b/libtommath/bn_mp_sqr.c
@@ -16,8 +16,7 @@
*/
/* computes b = a*a */
-int
-mp_sqr(const mp_int *a, mp_int *b)
+int mp_sqr(const mp_int *a, mp_int *b)
{
int res;
diff --git a/libtommath/bn_mp_sqrmod.c b/libtommath/bn_mp_sqrmod.c
index b8265fe..c3c7ec9 100644
--- a/libtommath/bn_mp_sqrmod.c
+++ b/libtommath/bn_mp_sqrmod.c
@@ -16,8 +16,7 @@
*/
/* c = a * a (mod b) */
-int
-mp_sqrmod(const mp_int *a, const mp_int *b, mp_int *c)
+int mp_sqrmod(const mp_int *a, const mp_int *b, mp_int *c)
{
int res;
mp_int t;
diff --git a/libtommath/bn_mp_sub.c b/libtommath/bn_mp_sub.c
index b865dbd..19cb65e 100644
--- a/libtommath/bn_mp_sub.c
+++ b/libtommath/bn_mp_sub.c
@@ -16,8 +16,7 @@
*/
/* high level subtraction (handles signs) */
-int
-mp_sub(const mp_int *a, const mp_int *b, mp_int *c)
+int mp_sub(const mp_int *a, const mp_int *b, mp_int *c)
{
int sa, sb, res;
diff --git a/libtommath/bn_mp_sub_d.c b/libtommath/bn_mp_sub_d.c
index e22c35c..4d66a90 100644
--- a/libtommath/bn_mp_sub_d.c
+++ b/libtommath/bn_mp_sub_d.c
@@ -16,8 +16,7 @@
*/
/* single digit subtraction */
-int
-mp_sub_d(const mp_int *a, mp_digit b, mp_int *c)
+int mp_sub_d(const mp_int *a, mp_digit b, mp_int *c)
{
mp_digit *tmpa, *tmpc, mu;
int res, ix, oldused;
diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c
index 9a45f6d..c4db397 100644
--- a/libtommath/bn_mp_submod.c
+++ b/libtommath/bn_mp_submod.c
@@ -16,8 +16,7 @@
*/
/* d = a - b (mod c) */
-int
-mp_submod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d)
+int mp_submod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d)
{
int res;
mp_int t;
diff --git a/libtommath/bn_mp_toom_sqr.c b/libtommath/bn_mp_toom_sqr.c
index 921d6a5..b985435 100644
--- a/libtommath/bn_mp_toom_sqr.c
+++ b/libtommath/bn_mp_toom_sqr.c
@@ -16,8 +16,7 @@
*/
/* squaring using Toom-Cook 3-way algorithm */
-int
-mp_toom_sqr(const mp_int *a, mp_int *b)
+int 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_toradix.c b/libtommath/bn_mp_toradix.c
index 79960f0..7dd6e4f 100644
--- a/libtommath/bn_mp_toradix.c
+++ b/libtommath/bn_mp_toradix.c
@@ -48,7 +48,7 @@ int mp_toradix(const mp_int *a, char *str, int radix)
digs = 0;
while (mp_iszero(&t) == MP_NO) {
- if ((res = mp_div_d(&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
+ if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
mp_clear(&t);
return res;
}
diff --git a/libtommath/bn_mp_toradix_n.c b/libtommath/bn_mp_toradix_n.c
index 5d766bd..ef885fc 100644
--- a/libtommath/bn_mp_toradix_n.c
+++ b/libtommath/bn_mp_toradix_n.c
@@ -61,7 +61,7 @@ int mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
/* no more room */
break;
}
- if ((res = mp_div_d(&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
+ if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
mp_clear(&t);
return res;
}
diff --git a/libtommath/bn_mp_xor.c b/libtommath/bn_mp_xor.c
index 91bcd02..9ebc53a 100644
--- a/libtommath/bn_mp_xor.c
+++ b/libtommath/bn_mp_xor.c
@@ -16,8 +16,7 @@
*/
/* XOR two ints together */
-int
-mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
+int mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
{
int res, ix, px;
mp_int t;
diff --git a/libtommath/bn_reverse.c b/libtommath/bn_reverse.c
index c3e7cf2..71e3d03 100644
--- a/libtommath/bn_reverse.c
+++ b/libtommath/bn_reverse.c
@@ -16,8 +16,7 @@
*/
/* reverse an array, used for radix code */
-void
-bn_reverse(unsigned char *s, int len)
+void bn_reverse(unsigned char *s, int len)
{
int ix, iy;
unsigned char t;
diff --git a/libtommath/bn_s_mp_add.c b/libtommath/bn_s_mp_add.c
index 415521f..2046722 100644
--- a/libtommath/bn_s_mp_add.c
+++ b/libtommath/bn_s_mp_add.c
@@ -16,8 +16,7 @@
*/
/* low level addition, based on HAC pp.594, Algorithm 14.7 */
-int
-s_mp_add(const mp_int *a, const mp_int *b, mp_int *c)
+int s_mp_add(const mp_int *a, const mp_int *b, mp_int *c)
{
const mp_int *x;
int olduse, res, min, max;
diff --git a/libtommath/bn_s_mp_exptmod.c b/libtommath/bn_s_mp_exptmod.c
index e73c12e..0d0145d 100644
--- a/libtommath/bn_s_mp_exptmod.c
+++ b/libtommath/bn_s_mp_exptmod.c
@@ -15,9 +15,9 @@
* Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/
#ifdef MP_LOW_MEM
-#define TAB_SIZE 32
+# define TAB_SIZE 32
#else
-#define TAB_SIZE 256
+# define TAB_SIZE 256
#endif
int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
@@ -152,7 +152,7 @@ int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, i
}
/* read next digit and reset the bitcnt */
buf = X->dp[digidx--];
- bitcnt = (int) DIGIT_BIT;
+ bitcnt = (int)DIGIT_BIT;
}
/* grab the next msb from the exponent */
diff --git a/libtommath/bn_s_mp_mul_high_digs.c b/libtommath/bn_s_mp_mul_high_digs.c
index 0a829b9..37c108e 100644
--- a/libtommath/bn_s_mp_mul_high_digs.c
+++ b/libtommath/bn_s_mp_mul_high_digs.c
@@ -18,8 +18,7 @@
/* multiplies |a| * |b| and does not compute the lower digs digits
* [meant to get the higher part of the product]
*/
-int
-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)
{
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 e07bf1c..aae06eb 100644
--- a/libtommath/bn_s_mp_sqr.c
+++ b/libtommath/bn_s_mp_sqr.c
@@ -38,10 +38,10 @@ int s_mp_sqr(const mp_int *a, mp_int *b)
((mp_word)a->dp[ix] * (mp_word)a->dp[ix]);
/* store lower part in result */
- t.dp[ix+ix] = (mp_digit)(r & ((mp_word) MP_MASK));
+ t.dp[ix+ix] = (mp_digit)(r & ((mp_word)MP_MASK));
/* get the carry */
- u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
+ u = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
/* left hand side of A[ix] * A[iy] */
tmpx = a->dp[ix];
diff --git a/libtommath/bn_s_mp_sub.c b/libtommath/bn_s_mp_sub.c
index 8373025..52b8096 100644
--- a/libtommath/bn_s_mp_sub.c
+++ b/libtommath/bn_s_mp_sub.c
@@ -16,8 +16,7 @@
*/
/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */
-int
-s_mp_sub(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)
{
int olduse, res, min, max;