summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/pk/ecc
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2020-06-10 23:01:33 +0800
committerMatt Johnston <matt@ucc.asn.au>2020-06-10 23:01:33 +0800
commit615885be01188e433cf931e2f7f85394fdc31c5d (patch)
treefae717f5964faafb98d6469a963f084f7d31622e /libtomcrypt/src/pk/ecc
parent6b823d617c8e2999767ad00232652b234a1048bc (diff)
Fix whitespace changes vs upstream libtomcrypt
Diffstat (limited to 'libtomcrypt/src/pk/ecc')
-rw-r--r--libtomcrypt/src/pk/ecc/ecc_sign_hash.c46
-rw-r--r--libtomcrypt/src/pk/ecc/ecc_verify_hash.c16
-rw-r--r--libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c10
3 files changed, 36 insertions, 36 deletions
diff --git a/libtomcrypt/src/pk/ecc/ecc_sign_hash.c b/libtomcrypt/src/pk/ecc/ecc_sign_hash.c
index d285dac..5f6f57f 100644
--- a/libtomcrypt/src/pk/ecc/ecc_sign_hash.c
+++ b/libtomcrypt/src/pk/ecc/ecc_sign_hash.c
@@ -14,10 +14,10 @@
/**
@file ecc_sign_hash.c
ECC Crypto, Tom St Denis
-*/
+*/
static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
- unsigned char *out, unsigned long *outlen,
+ unsigned char *out, unsigned long *outlen,
prng_state *prng, int wprng, ecc_key *key, int sigformat)
{
ecc_key pubkey;
@@ -35,21 +35,21 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
if (key->type != PK_PRIVATE) {
return CRYPT_PK_NOT_PRIVATE;
}
-
+
/* is the IDX valid ? */
if (ltc_ecc_is_valid_idx(key->idx) != 1) {
return CRYPT_PK_INVALID_TYPE;
}
-
+
if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
return err;
}
/* init the bignums */
- if ((err = mp_init_multi(&r, &s, &p, &e, NULL)) != CRYPT_OK) {
+ if ((err = mp_init_multi(&r, &s, &p, &e, NULL)) != CRYPT_OK) {
return err;
}
- if ((err = mp_read_radix(p, (char *)key->dp->order, 16)) != CRYPT_OK) { goto errnokey; }
+ if ((err = mp_read_radix(p, (char *)key->dp->order, 16)) != CRYPT_OK) { goto errnokey; }
/* get the hash and load it as a bignum into 'e' */
pbits = mp_count_bits(p);
@@ -77,21 +77,21 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
}
/* find r = x1 mod n */
- if ((err = mp_mod(pubkey.pubkey.x, p, r)) != CRYPT_OK) { goto error; }
+ if ((err = mp_mod(pubkey.pubkey.x, p, r)) != CRYPT_OK) { goto error; }
if (mp_iszero(r) == LTC_MP_YES) {
ecc_free(&pubkey);
- } else {
- /* find s = (e + xr)/k */
- if ((err = mp_invmod(pubkey.k, p, pubkey.k)) != CRYPT_OK) { goto error; } /* k = 1/k */
- if ((err = mp_mulmod(key->k, r, p, s)) != CRYPT_OK) { goto error; } /* s = xr */
- if ((err = mp_add(e, s, s)) != CRYPT_OK) { goto error; } /* s = e + xr */
- if ((err = mp_mod(s, p, s)) != CRYPT_OK) { goto error; } /* s = e + xr */
- if ((err = mp_mulmod(s, pubkey.k, p, s)) != CRYPT_OK) { goto error; } /* s = (e + xr)/k */
- ecc_free(&pubkey);
- if (mp_iszero(s) == LTC_MP_NO) {
- break;
- }
+ } else {
+ /* find s = (e + xr)/k */
+ if ((err = mp_invmod(pubkey.k, p, pubkey.k)) != CRYPT_OK) { goto error; } /* k = 1/k */
+ if ((err = mp_mulmod(key->k, r, p, s)) != CRYPT_OK) { goto error; } /* s = xr */
+ if ((err = mp_add(e, s, s)) != CRYPT_OK) { goto error; } /* s = e + xr */
+ if ((err = mp_mod(s, p, s)) != CRYPT_OK) { goto error; } /* s = e + xr */
+ if ((err = mp_mulmod(s, pubkey.k, p, s)) != CRYPT_OK) { goto error; } /* s = (e + xr)/k */
+ ecc_free(&pubkey);
+ if (mp_iszero(s) == LTC_MP_NO) {
+ break;
+ }
}
} while (--max_iterations > 0);
@@ -112,17 +112,17 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen,
}
else {
/* store as ASN.1 SEQUENCE { r, s -- integer } */
- err = der_encode_sequence_multi(out, outlen,
- LTC_ASN1_INTEGER, 1UL, r,
- LTC_ASN1_INTEGER, 1UL, s,
- LTC_ASN1_EOL, 0UL, NULL);
+ err = der_encode_sequence_multi(out, outlen,
+ LTC_ASN1_INTEGER, 1UL, r,
+ LTC_ASN1_INTEGER, 1UL, s,
+ LTC_ASN1_EOL, 0UL, NULL);
}
goto errnokey;
error:
ecc_free(&pubkey);
errnokey:
mp_clear_multi(r, s, p, e, NULL);
- return err;
+ return err;
}
/**
diff --git a/libtomcrypt/src/pk/ecc/ecc_verify_hash.c b/libtomcrypt/src/pk/ecc/ecc_verify_hash.c
index 7aa5f52..bc4f84f 100644
--- a/libtomcrypt/src/pk/ecc/ecc_verify_hash.c
+++ b/libtomcrypt/src/pk/ecc/ecc_verify_hash.c
@@ -14,10 +14,10 @@
/**
@file ecc_verify_hash.c
ECC Crypto, Tom St Denis
-*/
+*/
static int _ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
- const unsigned char *hash, unsigned long hashlen,
+ const unsigned char *hash, unsigned long hashlen,
int *stat, ecc_key *key, int sigformat)
{
ecc_point *mG, *mQ;
@@ -66,9 +66,9 @@ static int _ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
}
else {
/* ASN.1 format */
- if ((err = der_decode_sequence_multi(sig, siglen,
- LTC_ASN1_INTEGER, 1UL, r,
- LTC_ASN1_INTEGER, 1UL, s,
+ if ((err = der_decode_sequence_multi(sig, siglen,
+ LTC_ASN1_INTEGER, 1UL, r,
+ LTC_ASN1_INTEGER, 1UL, s,
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { goto error; }
}
@@ -125,13 +125,13 @@ static int _ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
if (ltc_mp.ecc_mul2add == NULL) {
if ((err = ltc_mp.ecc_ptmul(u1, mG, mG, m, 0)) != CRYPT_OK) { goto error; }
if ((err = ltc_mp.ecc_ptmul(u2, mQ, mQ, m, 0)) != CRYPT_OK) { goto error; }
-
+
/* find the montgomery mp */
if ((err = mp_montgomery_setup(m, &mp)) != CRYPT_OK) { goto error; }
/* add them */
if ((err = ltc_mp.ecc_ptadd(mQ, mG, mG, m, mp)) != CRYPT_OK) { goto error; }
-
+
/* reduce */
if ((err = ltc_mp.ecc_map(mG, m, mp)) != CRYPT_OK) { goto error; }
} else {
@@ -153,7 +153,7 @@ error:
ltc_ecc_del_point(mG);
ltc_ecc_del_point(mQ);
mp_clear_multi(r, s, v, w, u1, u2, p, e, m, NULL);
- if (mp != NULL) {
+ if (mp != NULL) {
mp_montgomery_free(mp);
}
return err;
diff --git a/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c b/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c
index ca5c9d9..ab26ede 100644
--- a/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c
+++ b/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c
@@ -17,7 +17,7 @@
/**
@file ltc_ecc_mulmod_timing.c
ECC Crypto, Tom St Denis
-*/
+*/
#ifdef LTC_MECC
@@ -59,8 +59,8 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map)
return err;
}
- /* alloc ram for window temps */
- for (i = 0; i < 3; i++) {
+ /* alloc ram for window temps */
+ for (i = 0; i < 3; i++) {
M[i] = ltc_ecc_new_point();
if (M[i] == NULL) {
for (j = 0; j < i; j++) {
@@ -70,7 +70,7 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map)
mp_montgomery_free(mp);
return CRYPT_MEM;
}
- }
+ }
/* make a copy of G incase R==G */
tG = ltc_ecc_new_point();
@@ -82,7 +82,7 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map)
if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK) { goto done; }
mp_clear(mu);
mu = NULL;
-
+
/* calc the M tab */
/* M[0] == G */
if ((err = mp_copy(tG->x, M[0]->x)) != CRYPT_OK) { goto done; }