diff --git a/src/math/gmp_desc.c b/src/math/gmp_desc.c index 464cd93..9904f30 100644 --- a/src/math/gmp_desc.c +++ b/src/math/gmp_desc.c @@ -18,7 +18,7 @@ #include static int init(void **a) -{ +{ LTC_ARGCHK(a != NULL); *a = XCALLOC(1, sizeof(__mpz_struct)); @@ -85,7 +85,7 @@ static int get_digit_count(void *a) LTC_ARGCHK(a != NULL); return mpz_size(a); } - + static int compare(void *a, void *b) { int ret; @@ -234,7 +234,7 @@ static int add(void *a, void *b, void *c) mpz_add(c, a, b); return CRYPT_OK; } - + static int addi(void *a, unsigned long b, void *c) { LTC_ARGCHK(a != NULL); @@ -321,10 +321,10 @@ static int modi(void *a, unsigned long b, unsigned long *c) { LTC_ARGCHK(a != NULL); LTC_ARGCHK(c != NULL); - + *c = mpz_fdiv_ui(a, b); return CRYPT_OK; -} +} /* gcd */ static int gcd(void *a, void *b, void *c) @@ -440,7 +440,7 @@ static int exptmod(void *a, void *b, void *c, void *d) LTC_ARGCHK(d != NULL); mpz_powm(d, a, b, c); return CRYPT_OK; -} +} static int isprime(void *a, int *b) { @@ -539,7 +539,7 @@ const ltc_math_descriptor gmp_desc = { #endif &addmod, &submod, - + &set_rand, }; diff --git a/src/math/ltm_desc.c b/src/math/ltm_desc.c index 2945a47..2760409 100644 --- a/src/math/ltm_desc.c +++ b/src/math/ltm_desc.c @@ -25,7 +25,7 @@ static const struct { }; /** - Convert a MPI error to a LTC error (Possibly the most powerful function ever! Oh wait... no) + Convert a MPI error to a LTC error (Possibly the most powerful function ever! Oh wait... no) @param err The error to convert @return The equivalent LTC error code or CRYPT_ERROR if none found */ @@ -34,7 +34,7 @@ static int mpi_to_ltc_error(int err) int x; for (x = 0; x < (int)(sizeof(mpi_to_ltc_codes)/sizeof(mpi_to_ltc_codes[0])); x++) { - if (err == mpi_to_ltc_codes[x].mpi_code) { + if (err == mpi_to_ltc_codes[x].mpi_code) { return mpi_to_ltc_codes[x].ltc_code; } } @@ -51,7 +51,7 @@ static int init(void **a) if (*a == NULL) { return CRYPT_MEM; } - + if ((err = mpi_to_ltc_error(mp_init(*a))) != CRYPT_OK) { XFREE(*a); } @@ -115,7 +115,7 @@ static int get_digit_count(void *a) A = a; return A->used; } - + static int compare(void *a, void *b) { int ret; @@ -211,7 +211,7 @@ static int add(void *a, void *b, void *c) LTC_ARGCHK(c != NULL); return mpi_to_ltc_error(mp_add(a, b, c)); } - + static int addi(void *a, unsigned long b, void *c) { LTC_ARGCHK(a != NULL); @@ -288,7 +288,7 @@ static int modi(void *a, unsigned long b, unsigned long *c) } *c = tmp; return CRYPT_OK; -} +} /* gcd */ static int gcd(void *a, void *b, void *c) @@ -398,7 +398,7 @@ static int exptmod(void *a, void *b, void *c, void *d) LTC_ARGCHK(c != NULL); LTC_ARGCHK(d != NULL); return mpi_to_ltc_error(mp_exptmod(a,b,c,d)); -} +} static int isprime(void *a, int *b) { @@ -460,7 +460,7 @@ const ltc_math_descriptor ltm_desc = { &mulmod, &sqrmod, &invmod, - + &montgomery_setup, &montgomery_normalization, &montgomery_reduce, @@ -472,7 +472,7 @@ const ltc_math_descriptor ltm_desc = { #ifdef LTC_MECC #ifdef LTC_MECC_FP <c_ecc_fp_mulmod, -#else +#else <c_ecc_mulmod, #endif <c_ecc_projective_add_point, @@ -499,7 +499,7 @@ const ltc_math_descriptor ltm_desc = { #endif &addmod, &submod, - + &set_rand, }; diff --git a/src/math/tfm_desc.c b/src/math/tfm_desc.c index 8218024..f75408d 100644 --- a/src/math/tfm_desc.c +++ b/src/math/tfm_desc.c @@ -25,7 +25,7 @@ static const struct { }; /** - Convert a tfm error to a LTC error (Possibly the most powerful function ever! Oh wait... no) + Convert a tfm error to a LTC error (Possibly the most powerful function ever! Oh wait... no) @param err The error to convert @return The equivalent LTC error code or CRYPT_ERROR if none found */ @@ -34,7 +34,7 @@ static int tfm_to_ltc_error(int err) int x; for (x = 0; x < (int)(sizeof(tfm_to_ltc_codes)/sizeof(tfm_to_ltc_codes[0])); x++) { - if (err == tfm_to_ltc_codes[x].tfm_code) { + if (err == tfm_to_ltc_codes[x].tfm_code) { return tfm_to_ltc_codes[x].ltc_code; } } @@ -114,7 +114,7 @@ static int get_digit_count(void *a) A = a; return A->used; } - + static int compare(void *a, void *b) { int ret; @@ -213,7 +213,7 @@ static int add(void *a, void *b, void *c) fp_add(a, b, c); return CRYPT_OK; } - + static int addi(void *a, unsigned long b, void *c) { LTC_ARGCHK(a != NULL); @@ -246,7 +246,7 @@ static int mul(void *a, void *b, void *c) LTC_ARGCHK(a != NULL); LTC_ARGCHK(b != NULL); LTC_ARGCHK(c != NULL); - fp_mul(a, b, c); + fp_mul(a, b, c); return CRYPT_OK; } @@ -297,7 +297,7 @@ static int modi(void *a, unsigned long b, unsigned long *c) } *c = tmp; return CRYPT_OK; -} +} /* gcd */ static int gcd(void *a, void *b, void *c) @@ -411,7 +411,7 @@ static int exptmod(void *a, void *b, void *c, void *d) LTC_ARGCHK(c != NULL); LTC_ARGCHK(d != NULL); return tfm_to_ltc_error(fp_exptmod(a,b,c,d)); -} +} static int isprime(void *a, int *b) { @@ -455,7 +455,7 @@ static int tfm_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulu if (fp_cmp(R->z, modulus) != FP_LT) { fp_sub(R->z, modulus, R->z); } - + /* &t2 = X - T1 */ fp_sub(R->x, &t1, &t2); if (fp_cmp_d(&t2, 0) == FP_LT) { @@ -514,7 +514,7 @@ static int tfm_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulu fp_add(R->x, modulus, R->x); } - /* Y = Y - X */ + /* Y = Y - X */ fp_sub(R->y, R->x, R->y); if (fp_cmp_d(R->y, 0) == FP_LT) { fp_add(R->y, modulus, R->y); @@ -527,7 +527,7 @@ static int tfm_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulu if (fp_cmp_d(R->y, 0) == FP_LT) { fp_add(R->y, modulus, R->y); } - + return CRYPT_OK; } @@ -543,8 +543,8 @@ static int tfm_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulu static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *Mp) { fp_int t1, t2, x, y, z; - fp_digit mp; - + fp_digit mp; + LTC_ARGCHK(P != NULL); LTC_ARGCHK(Q != NULL); LTC_ARGCHK(R != NULL); @@ -561,7 +561,7 @@ static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R /* should we dbl instead? */ fp_sub(modulus, Q->y, &t1); - if ( (fp_cmp(P->x, Q->x) == FP_EQ) && + if ( (fp_cmp(P->x, Q->x) == FP_EQ) && (Q->z != NULL && fp_cmp(P->z, Q->z) == FP_EQ) && (fp_cmp(P->y, Q->y) == FP_EQ || fp_cmp(P->y, &t1) == FP_EQ)) { return tfm_ecc_projective_dbl_point(P, R, modulus, Mp); @@ -654,7 +654,7 @@ static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R /* T1 = T1 * X */ fp_mul(&t1, &x, &t1); fp_montgomery_reduce(&t1, modulus, mp); - + /* X = Y*Y */ fp_sqr(&y, &x); fp_montgomery_reduce(&x, modulus, mp); @@ -668,7 +668,7 @@ static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R fp_sub(&t2, &x, &t2); if (fp_cmp_d(&t2, 0) == FP_LT) { fp_add(&t2, modulus, &t2); - } + } /* T2 = T2 - X */ fp_sub(&t2, &x, &t2); if (fp_cmp_d(&t2, 0) == FP_LT) { @@ -691,7 +691,7 @@ static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R fp_copy(&x, R->x); fp_copy(&y, R->y); fp_copy(&z, R->z); - + return CRYPT_OK; } @@ -786,7 +786,7 @@ const ltc_math_descriptor tfm_desc = { #endif &addmod, &submod, - + NULL, };