`make astyle` + some manual adjustments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
diff --git a/bn_mp_get_bit.c b/bn_mp_get_bit.c
index e1e95f5..b124325 100644
--- a/bn_mp_get_bit.c
+++ b/bn_mp_get_bit.c
@@ -34,7 +34,7 @@ int mp_get_bit(const mp_int *a, int b)
* otherwise (limb >= a->used) would be true for a = 0
*/
- if(mp_iszero(a)) {
+ if (mp_iszero(a)) {
return MP_NO;
}
diff --git a/bn_mp_prime_frobenius_underwood.c b/bn_mp_prime_frobenius_underwood.c
index 8cabcb6..7e7c714 100644
--- a/bn_mp_prime_frobenius_underwood.c
+++ b/bn_mp_prime_frobenius_underwood.c
@@ -153,7 +153,9 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
* sz = temp
*/
if (a == 0) {
- if ((e = mp_mul_2(&sz,&T1z)) != MP_OKAY) { goto LBL_FU_ERR; }
+ if ((e = mp_mul_2(&sz,&T1z)) != MP_OKAY) {
+ goto LBL_FU_ERR;
+ }
} else {
if ((e = mp_mul_d(&sz, (mp_digit) ap2, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index 4ad3659..ee68adb 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -113,11 +113,11 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
goto LBL_B;
}
-/*
- * Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite
- * slow so if speed is an issue, define LTM_USE_FIPS_ONLY to use M-R tests with
- * bases 2, 3 and t random bases.
- */
+ /*
+ * Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite
+ * slow so if speed is an issue, define LTM_USE_FIPS_ONLY to use M-R tests with
+ * bases 2, 3 and t random bases.
+ */
#ifndef LTM_USE_FIPS_ONLY
if (t >= 0) {
/*
@@ -145,7 +145,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
#endif
/* run at least one Miller-Rabin test with a random base */
- if(t == 0) {
+ if (t == 0) {
t = 1;
}
@@ -192,23 +192,22 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
Sorenson, Jonathan; Webster, Jonathan (2015).
"Strong Pseudoprimes to Twelve Prime Bases".
*/
- /* 318665857834031151167461 */
+ /* 0x437ae92817f9fc85b7e5 = 318665857834031151167461 */
if ((err = mp_read_radix(&b, "437ae92817f9fc85b7e5", 16)) != MP_OKAY) {
goto LBL_B;
}
if (mp_cmp(a,&b) == MP_LT) {
p_max = 12;
- }
- else { /* 3317044064679887385961981 */
+ } else {
+ /* 0x2be6951adc5b22410a5fd = 3317044064679887385961981 */
if ((err = mp_read_radix(&b, "2be6951adc5b22410a5fd", 16)) != MP_OKAY) {
goto LBL_B;
}
if (mp_cmp(a,&b) == MP_LT) {
p_max = 13;
- }
- else {
+ } else {
err = MP_VAL;
goto LBL_B;
}
@@ -219,7 +218,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
p_max = t;
}
- if(p_max > PRIME_SIZE) {
+ if (p_max > PRIME_SIZE) {
err = MP_VAL;
goto LBL_B;
}
@@ -292,13 +291,13 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
* Reduce digit before casting because mp_digit might be bigger than
* an unsigned int and "mask" on the other side is most probably not.
*/
- fips_rand = (unsigned int) (b.dp[0] & (mp_digit) mask);
+ fips_rand = (unsigned int)(b.dp[0] & (mp_digit) mask);
#ifdef MP_8BIT
/*
* One 8-bit digit is too small, so concatenate two if the size of
* unsigned int allows for it.
*/
- if( (sizeof(unsigned int) * CHAR_BIT)/2 >= (sizeof(mp_digit) * CHAR_BIT) ) {
+ if ((sizeof(unsigned int) * CHAR_BIT)/2 >= (sizeof(mp_digit) * CHAR_BIT)) {
if ((err = mp_rand(&b, 1)) != MP_OKAY) {
goto LBL_B;
}
@@ -308,9 +307,9 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
}
#endif
/* Ceil, because small numbers have a right to live, too, */
- len = (int) ( (fips_rand + DIGIT_BIT) / DIGIT_BIT);
+ len = (int)((fips_rand + DIGIT_BIT) / DIGIT_BIT);
/* Unlikely. */
- if(len < 0){
+ if (len < 0) {
ix--;
continue;
}
@@ -322,7 +321,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
*/
#ifdef MP_8BIT
/* All "a" < 2^8 have been caught before */
- if(len == 1){
+ if (len == 1) {
len++;
}
#endif
diff --git a/bn_mp_prime_strong_lucas_selfridge.c b/bn_mp_prime_strong_lucas_selfridge.c
index 6558386..0be4915 100644
--- a/bn_mp_prime_strong_lucas_selfridge.c
+++ b/bn_mp_prime_strong_lucas_selfridge.c
@@ -118,7 +118,7 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
/* if 1 < GCD < N then N is composite with factor "D", and
Jacobi(D,N) is technically undefined (but often returned
as zero). */
- if ( mp_cmp_d(&gcd,1u) == MP_GT && mp_cmp(&gcd,a) == MP_LT) {
+ if ((mp_cmp_d(&gcd,1u) == MP_GT) && (mp_cmp(&gcd,a) == MP_LT)) {
goto LBL_LS_ERR;
}
if (Ds < 0) {
@@ -313,7 +313,7 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
if ((e = mp_div_2(&Uz,&Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
- if (Uz.sign == MP_NEG && mp_isodd(&Uz)) {
+ if ((Uz.sign == MP_NEG) && mp_isodd(&Uz)) {
if ((e = mp_sub_d(&Uz,1u,&Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
diff --git a/demo/demo.c b/demo/demo.c
index d8e52e8..b0ac10c 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -124,7 +124,7 @@ struct mp_kronecker_st {
int c[21];
};
static struct mp_kronecker_st kronecker[] = {
- /*-10, -9, -8, -7,-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10*/
+ /*-10, -9, -8, -7,-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10*/
{ -10, { 0, -1, 0, -1, 0, 0, 0, 1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 1, 0, 1, 0 } },
{ -9, { -1, 0, -1, 1, 0, -1, -1, 0, -1, -1, 0, 1, 1, 0, 1, 1, 0, -1, 1, 0, 1 } },
{ -8, { 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, 1, 0 } },
@@ -305,19 +305,17 @@ int main(void)
for (cnt = 0; cnt < (int)(sizeof(kronecker)/sizeof(kronecker[0])); ++cnt) {
k = kronecker[cnt].n;
if (k < 0) {
- mp_set_int(&a, (unsigned long) (-k));
- mp_neg(&a, &a);
- }
- else {
- mp_set_int(&a, (unsigned long) k);
+ mp_set_int(&a, (unsigned long)(-k));
+ mp_neg(&a, &a);
+ } else {
+ mp_set_int(&a, (unsigned long) k);
}
/* only test positive values of a */
for (m = -10; m <= 10; m++) {
if (m < 0) {
- mp_set_int(&b,(unsigned long) (-m));
+ mp_set_int(&b,(unsigned long)(-m));
mp_neg(&b, &b);
- }
- else {
+ } else {
mp_set_int(&b, (unsigned long) m);
}
if ((err = mp_kronecker(&a, &b, &i)) != MP_OKAY) {
@@ -676,7 +674,9 @@ int main(void)
/* strong Miller-Rabin pseudoprime to the first 200 primes (F. Arnault) */
puts("Testing mp_prime_is_prime() with Arnault's pseudoprime 803...901 \n");
- mp_read_radix(&a,"91xLNF3roobhzgTzoFIG6P13ZqhOVYSN60Fa7Cj2jVR1g0k89zdahO9/kAiRprpfO1VAp1aBHucLFV/qLKLFb+zonV7R2Vxp1K13ClwUXStpV0oxTNQVjwybmFb5NBEHImZ6V7P6+udRJuH8VbMEnS0H8/pSqQrg82OoQQ2fPpAk6G1hkjqoCv5s/Yr",64);
+ mp_read_radix(&a,
+ "91xLNF3roobhzgTzoFIG6P13ZqhOVYSN60Fa7Cj2jVR1g0k89zdahO9/kAiRprpfO1VAp1aBHucLFV/qLKLFb+zonV7R2Vxp1K13ClwUXStpV0oxTNQVjwybmFb5NBEHImZ6V7P6+udRJuH8VbMEnS0H8/pSqQrg82OoQQ2fPpAk6G1hkjqoCv5s/Yr",
+ 64);
mp_prime_is_prime(&a, 8, &cnt);
if (cnt == MP_YES) {
printf("Arnault's pseudoprime is not prime but mp_prime_is_prime says it is.\n");
diff --git a/demo/timing.c b/demo/timing.c
index 819cb5f..7a5da20 100644
--- a/demo/timing.c
+++ b/demo/timing.c
@@ -104,7 +104,7 @@ int main(void)
FILE *log, *logb, *logc, *logd;
mp_int a, b, c, d, e, f;
#ifdef LTM_TIMING_PRIME_IS_PRIME
- const char* name;
+ const char *name;
int m;
#endif
int n, cnt, ix, old_kara_m, old_kara_s, old_toom_m, old_toom_s;
@@ -130,7 +130,9 @@ int main(void)
for (m = 0; m < 2; ++m) {
if (m == 0) {
name = " Arnault";
- mp_read_radix(&a,"91xLNF3roobhzgTzoFIG6P13ZqhOVYSN60Fa7Cj2jVR1g0k89zdahO9/kAiRprpfO1VAp1aBHucLFV/qLKLFb+zonV7R2Vxp1K13ClwUXStpV0oxTNQVjwybmFb5NBEHImZ6V7P6+udRJuH8VbMEnS0H8/pSqQrg82OoQQ2fPpAk6G1hkjqoCv5s/Yr",64);
+ mp_read_radix(&a,
+ "91xLNF3roobhzgTzoFIG6P13ZqhOVYSN60Fa7Cj2jVR1g0k89zdahO9/kAiRprpfO1VAp1aBHucLFV/qLKLFb+zonV7R2Vxp1K13ClwUXStpV0oxTNQVjwybmFb5NBEHImZ6V7P6+udRJuH8VbMEnS0H8/pSqQrg82OoQQ2fPpAk6G1hkjqoCv5s/Yr",
+ 64);
} else {
name = "2^1119 + 53";
mp_set(&a,1u);
diff --git a/etc/2kprime.c b/etc/2kprime.c
index 829474a..bba3e62 100644
--- a/etc/2kprime.c
+++ b/etc/2kprime.c
@@ -37,7 +37,7 @@ top:
if ((clock() - t1) > CLOCKS_PER_SEC) {
printf(".");
fflush(stdout);
-/* sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC); */
+ /* sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC); */
t1 = clock();
}
diff --git a/mtest/mtest.c b/mtest/mtest.c
index 3492f73..06c9afb 100644
--- a/mtest/mtest.c
+++ b/mtest/mtest.c
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
rand_num2(&a);
rand_num2(&b);
rand_num2(&c);
-/* if (c.dp[0]&1) mp_add_d(&c, 1, &c); */
+ /* if (c.dp[0]&1) mp_add_d(&c, 1, &c); */
a.sign = b.sign = c.sign = 0;
mp_exptmod(&a, &b, &c, &d);
printf("expt\n");