improve indentation

This commit is contained in:
Francois Perrad 2018-12-26 08:47:47 +01:00
parent 5d090112af
commit 0f53ceb4cb
5 changed files with 55 additions and 55 deletions

View File

@ -28,7 +28,7 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c)
return MP_VAL;
}
return mp_kronecker(a,n,c);
return mp_kronecker(a, n, c);
}
#endif

View File

@ -116,7 +116,7 @@ int mp_kronecker(const mp_int *a, const mp_int *p, int *c)
}
}
if ((e = mp_copy(&a1,&r)) != MP_OKAY) {
if ((e = mp_copy(&a1, &r)) != MP_OKAY) {
goto LBL_KRON;
}
r.sign = MP_ZPOS;

View File

@ -35,14 +35,14 @@
#endif
int mp_prime_frobenius_underwood(const mp_int *N, int *result)
{
mp_int T1z,T2z,Np1z,sz,tz;
mp_int T1z, T2z, Np1z, sz, tz;
int a, ap2, length, i, j, isset;
int e;
*result = MP_NO;
if ((e = mp_init_multi(&T1z,&T2z,&Np1z,&sz,&tz, NULL)) != MP_OKAY) {
if ((e = mp_init_multi(&T1z, &T2z, &Np1z, &sz, &tz, NULL)) != MP_OKAY) {
return e;
}
@ -53,11 +53,11 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
continue;
}
/* (32764^2 - 4) < 2^31, no bigint for >MP_8BIT needed) */
if ((e = mp_set_long(&T1z,(unsigned long)a)) != MP_OKAY) {
if ((e = mp_set_long(&T1z, (unsigned long)a)) != MP_OKAY) {
goto LBL_FU_ERR;
}
if ((e = mp_sqr(&T1z,&T1z)) != MP_OKAY) {
if ((e = mp_sqr(&T1z, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
@ -88,7 +88,7 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
goto LBL_FU_ERR;
}
if ((e = mp_gcd(N,&T1z,&T1z)) != MP_OKAY) {
if ((e = mp_gcd(N, &T1z, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
@ -111,16 +111,16 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
* tz = ((tz-sz)*(tz+sz))%N;
* sz = temp;
*/
if ((e = mp_mul_2(&tz,&T2z)) != MP_OKAY) {
if ((e = mp_mul_2(&tz, &T2z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
/* a = 0 at about 50% of the cases (non-square and odd input) */
if (a != 0) {
if ((e = mp_mul_d(&sz,(mp_digit)a,&T1z)) != MP_OKAY) {
if ((e = mp_mul_d(&sz, (mp_digit)a, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
if ((e = mp_add(&T1z,&T2z,&T2z)) != MP_OKAY) {
if ((e = mp_add(&T1z, &T2z, &T2z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
}
@ -143,7 +143,7 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
if ((e = mp_mod(&T1z, N, &sz)) != MP_OKAY) {
goto LBL_FU_ERR;
}
if ((isset = mp_get_bit(&Np1z,i)) == MP_VAL) {
if ((isset = mp_get_bit(&Np1z, i)) == MP_VAL) {
e = isset;
goto LBL_FU_ERR;
}
@ -154,11 +154,11 @@ 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) {
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) {
if ((e = mp_mul_d(&sz, (mp_digit)ap2, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
}
@ -171,14 +171,14 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
if ((e = mp_sub(&T2z, &sz, &tz)) != MP_OKAY) {
goto LBL_FU_ERR;
}
mp_exch(&sz,&T1z);
mp_exch(&sz, &T1z);
}
}
if ((e = mp_set_long(&T1z, (unsigned long)((2 * a) + 5))) != MP_OKAY) {
goto LBL_FU_ERR;
}
if ((e = mp_mod(&T1z,N,&T1z)) != MP_OKAY) {
if ((e = mp_mod(&T1z, N, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
if ((mp_iszero(&sz) != MP_NO) && (mp_cmp(&tz, &T1z) == MP_EQ)) {
@ -187,7 +187,7 @@ int mp_prime_frobenius_underwood(const mp_int *N, int *result)
}
LBL_FU_ERR:
mp_clear_multi(&tz,&sz,&Np1z,&T2z,&T1z, NULL);
mp_clear_multi(&tz, &sz, &Np1z, &T2z, &T1z, NULL);
return e;
}

View File

@ -197,7 +197,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
goto LBL_B;
}
if (mp_cmp(a,&b) == MP_LT) {
if (mp_cmp(a, &b) == MP_LT) {
p_max = 12;
} else {
/* 0x2be6951adc5b22410a5fd = 3317044064679887385961981 */
@ -205,7 +205,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
goto LBL_B;
}
if (mp_cmp(a,&b) == MP_LT) {
if (mp_cmp(a, &b) == MP_LT) {
p_max = 13;
} else {
err = MP_VAL;
@ -224,7 +224,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
}
/* we did bases 2 and 3 already, skip them */
for (ix = 2; ix < p_max; ix++) {
mp_set(&b,ltm_prime_tab[ix]);
mp_set(&b, ltm_prime_tab[ix]);
if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {
goto LBL_B;
}

View File

@ -109,7 +109,7 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
for (;;) {
Ds = sign * D;
sign = -sign;
if ((e = mp_set_long(&Dz,(unsigned long) D)) != MP_OKAY) {
if ((e = mp_set_long(&Dz, (unsigned long)D)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_gcd(a, &Dz, &gcd)) != MP_OKAY) {
@ -205,14 +205,14 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
if (Q < 0) {
Q = -Q;
if ((e = mp_set_long(&Qmz, (unsigned long) Q)) != MP_OKAY) {
if ((e = mp_set_long(&Qmz, (unsigned long)Q)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Initializes calculation of Q^d */
if ((e = mp_set_long(&Qkdz, (unsigned long) Q)) != MP_OKAY) {
if ((e = mp_set_long(&Qkdz, (unsigned long)Q)) != MP_OKAY) {
goto LBL_LS_ERR;
}
Qmz.sign = MP_NEG;
@ -220,14 +220,14 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
Qkdz.sign = MP_NEG;
Q = -Q;
} else {
if ((e = mp_set_long(&Qmz, (unsigned long) Q)) != MP_OKAY) {
if ((e = mp_set_long(&Qmz, (unsigned long)Q)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Initializes calculation of Q^d */
if ((e = mp_set_long(&Qkdz, (unsigned long) Q)) != MP_OKAY) {
if ((e = mp_set_long(&Qkdz, (unsigned long)Q)) != MP_OKAY) {
goto LBL_LS_ERR;
}
}
@ -242,34 +242,34 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
* V_2m = V_m*V_m - 2*Q^m
*/
if ((e = mp_mul(&U2mz,&V2mz,&U2mz)) != MP_OKAY) {
if ((e = mp_mul(&U2mz, &V2mz, &U2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&U2mz,a,&U2mz)) != MP_OKAY) {
if ((e = mp_mod(&U2mz, a, &U2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_sqr(&V2mz,&V2mz)) != MP_OKAY) {
if ((e = mp_sqr(&V2mz, &V2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_sub(&V2mz,&Q2mz,&V2mz)) != MP_OKAY) {
if ((e = mp_sub(&V2mz, &Q2mz, &V2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&V2mz,a,&V2mz)) != MP_OKAY) {
if ((e = mp_mod(&V2mz, a, &V2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Must calculate powers of Q for use in V_2m, also for Q^d later */
if ((e = mp_sqr(&Qmz,&Qmz)) != MP_OKAY) {
if ((e = mp_sqr(&Qmz, &Qmz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* prevents overflow */ /* CZ still necessary without a fixed prealloc'd mem.? */
if ((e = mp_mod(&Qmz,a,&Qmz)) != MP_OKAY) {
if ((e = mp_mod(&Qmz, a, &Qmz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul_2(&Qmz,&Q2mz)) != MP_OKAY) {
if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((isset = mp_get_bit(&Dz,u)) == MP_VAL) {
if ((isset = mp_get_bit(&Dz, u)) == MP_VAL) {
e = isset;
goto LBL_LS_ERR;
}
@ -282,26 +282,26 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
* Be careful with division by 2 (mod N)!
*/
if ((e = mp_mul(&U2mz,&Vz,&T1z)) != MP_OKAY) {
if ((e = mp_mul(&U2mz, &Vz, &T1z)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul(&Uz,&V2mz,&T2z)) != MP_OKAY) {
if ((e = mp_mul(&Uz, &V2mz, &T2z)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul(&V2mz,&Vz,&T3z)) != MP_OKAY) {
if ((e = mp_mul(&V2mz, &Vz, &T3z)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul(&U2mz,&Uz,&T4z)) != MP_OKAY) {
if ((e = mp_mul(&U2mz, &Uz, &T4z)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = s_mp_mul_si(&T4z,(long)Ds,&T4z)) != MP_OKAY) {
if ((e = s_mp_mul_si(&T4z, (long)Ds, &T4z)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_add(&T1z,&T2z,&Uz)) != MP_OKAY) {
if ((e = mp_add(&T1z, &T2z, &Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if (mp_isodd(&Uz) != MP_NO) {
if ((e = mp_add(&Uz,a,&Uz)) != MP_OKAY) {
if ((e = mp_add(&Uz, a, &Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
}
@ -310,7 +310,7 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
* Thomas R. Nicely used GMP's mpz_fdiv_q_2exp().
* But mp_div_2() does not do so, it is truncating instead.
*/
if ((e = mp_div_2(&Uz,&Uz)) != MP_OKAY) {
if ((e = mp_div_2(&Uz, &Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((Uz.sign == MP_NEG) && (mp_isodd(&Uz) != MP_NO)) {
@ -318,15 +318,15 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
goto LBL_LS_ERR;
}
}
if ((e = mp_add(&T3z,&T4z,&Vz)) != MP_OKAY) {
if ((e = mp_add(&T3z, &T4z, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if (mp_isodd(&Vz) != MP_NO) {
if ((e = mp_add(&Vz,a,&Vz)) != MP_OKAY) {
if ((e = mp_add(&Vz, a, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
}
if ((e = mp_div_2(&Vz,&Vz)) != MP_OKAY) {
if ((e = mp_div_2(&Vz, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((Vz.sign == MP_NEG) && (mp_isodd(&Vz) != MP_NO)) {
@ -334,17 +334,17 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
goto LBL_LS_ERR;
}
}
if ((e = mp_mod(&Uz,a,&Uz)) != MP_OKAY) {
if ((e = mp_mod(&Uz, a, &Uz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&Vz,a,&Vz)) != MP_OKAY) {
if ((e = mp_mod(&Vz, a, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Calculating Q^d for later use */
if ((e = mp_mul(&Qkdz,&Qmz,&Qkdz)) != MP_OKAY) {
if ((e = mp_mul(&Qkdz, &Qmz, &Qkdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&Qkdz,a,&Qkdz)) != MP_OKAY) {
if ((e = mp_mod(&Qkdz, a, &Qkdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
}
@ -369,18 +369,18 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
Lucas pseudoprime. */
/* Initialize 2*Q^(d*2^r) for V_2m */
if ((e = mp_mul_2(&Qkdz,&Q2kdz)) != MP_OKAY) {
if ((e = mp_mul_2(&Qkdz, &Q2kdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
for (r = 1; r < s; r++) {
if ((e = mp_sqr(&Vz,&Vz)) != MP_OKAY) {
if ((e = mp_sqr(&Vz, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_sub(&Vz,&Q2kdz,&Vz)) != MP_OKAY) {
if ((e = mp_sub(&Vz, &Q2kdz, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&Vz,a,&Vz)) != MP_OKAY) {
if ((e = mp_mod(&Vz, a, &Vz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if (mp_iszero(&Vz) != MP_NO) {
@ -389,13 +389,13 @@ int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result)
}
/* Calculate Q^{d*2^r} for next r (final iteration irrelevant). */
if (r < (s - 1)) {
if ((e = mp_sqr(&Qkdz,&Qkdz)) != MP_OKAY) {
if ((e = mp_sqr(&Qkdz, &Qkdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mod(&Qkdz,a,&Qkdz)) != MP_OKAY) {
if ((e = mp_mod(&Qkdz, a, &Qkdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
if ((e = mp_mul_2(&Qkdz,&Q2kdz)) != MP_OKAY) {
if ((e = mp_mul_2(&Qkdz, &Q2kdz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
}