From b465881b585596e3fb384212606bfc074446bb59 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Fri, 24 Mar 2017 10:17:02 +0100 Subject: [PATCH] fix "declaration-after-statement" warnings (tests only) --- testprof/pkcs_1_eme_test.c | 2 +- testprof/pkcs_1_emsa_test.c | 2 +- testprof/pkcs_1_oaep_test.c | 2 +- testprof/pkcs_1_pss_test.c | 2 +- testprof/rsa_test.c | 12 ++++++++---- testprof/x86_prof.c | 10 +++++----- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/testprof/pkcs_1_eme_test.c b/testprof/pkcs_1_eme_test.c index da1818d..2950b28 100644 --- a/testprof/pkcs_1_eme_test.c +++ b/testprof/pkcs_1_eme_test.c @@ -11,6 +11,7 @@ int pkcs_1_eme_test(void) int prng_idx = register_prng(&no_prng_desc); int hash_idx = find_hash("sha1"); unsigned int i; + unsigned int j; DO(prng_is_valid(prng_idx)); DO(hash_is_valid(hash_idx)); @@ -31,7 +32,6 @@ int pkcs_1_eme_test(void) DOX(mp_read_unsigned_bin(key->p, t->rsa.p, t->rsa.p_l), t->name); key->type = PK_PRIVATE; - unsigned int j; for (j = 0; j < sizeof(t->data)/sizeof(t->data[0]); ++j) { rsaData_t* s = &t->data[j]; unsigned char buf[256], obuf[256]; diff --git a/testprof/pkcs_1_emsa_test.c b/testprof/pkcs_1_emsa_test.c index c9941a8..e6d2cc2 100644 --- a/testprof/pkcs_1_emsa_test.c +++ b/testprof/pkcs_1_emsa_test.c @@ -10,6 +10,7 @@ int pkcs_1_emsa_test(void) { int hash_idx = find_hash("sha1"); unsigned int i; + unsigned int j; DO(hash_is_valid(hash_idx)); @@ -29,7 +30,6 @@ int pkcs_1_emsa_test(void) DOX(mp_read_unsigned_bin(key->p, t->rsa.p, t->rsa.p_l), t->name); key->type = PK_PRIVATE; - unsigned int j; for (j = 0; j < sizeof(t->data)/sizeof(t->data[0]); ++j) { rsaData_t* s = &t->data[j]; unsigned char buf[20], obuf[256]; diff --git a/testprof/pkcs_1_oaep_test.c b/testprof/pkcs_1_oaep_test.c index bb606cf..42a4dbd 100644 --- a/testprof/pkcs_1_oaep_test.c +++ b/testprof/pkcs_1_oaep_test.c @@ -11,6 +11,7 @@ int pkcs_1_oaep_test(void) int prng_idx = register_prng(&no_prng_desc); int hash_idx = find_hash("sha1"); unsigned int i; + unsigned int j; DO(prng_is_valid(prng_idx)); DO(hash_is_valid(hash_idx)); @@ -31,7 +32,6 @@ int pkcs_1_oaep_test(void) DOX(mp_read_unsigned_bin(key->p, t->rsa.p, t->rsa.p_l), t->name); key->type = PK_PRIVATE; - unsigned int j; for (j = 0; j < sizeof(t->data)/sizeof(t->data[0]); ++j) { rsaData_t* s = &t->data[j]; unsigned char buf[256], obuf[256]; diff --git a/testprof/pkcs_1_pss_test.c b/testprof/pkcs_1_pss_test.c index fe3a126..d3363d8 100644 --- a/testprof/pkcs_1_pss_test.c +++ b/testprof/pkcs_1_pss_test.c @@ -11,6 +11,7 @@ int pkcs_1_pss_test(void) int prng_idx = register_prng(&no_prng_desc); int hash_idx = find_hash("sha1"); unsigned int i; + unsigned int j; DO(prng_is_valid(prng_idx)); DO(hash_is_valid(hash_idx)); @@ -31,7 +32,6 @@ int pkcs_1_pss_test(void) DOX(mp_read_unsigned_bin(key->p, t->rsa.p, t->rsa.p_l), t->name); key->type = PK_PRIVATE; - unsigned int j; for (j = 0; j < sizeof(t->data)/sizeof(t->data[0]); ++j) { rsaData_t* s = &t->data[j]; unsigned char buf[20], obuf[256]; diff --git a/testprof/rsa_test.c b/testprof/rsa_test.c index 44272d8..c7f1dcb 100644 --- a/testprof/rsa_test.c +++ b/testprof/rsa_test.c @@ -200,6 +200,10 @@ int rsa_test(void) int hash_idx, prng_idx, stat, stat2, i, err; unsigned long rsa_msgsize, len, len2, len3, cnt, cnt2; static unsigned char lparam[] = { 0x01, 0x02, 0x03, 0x04 }; + void* dP; + unsigned char* p; + unsigned char* p2; + unsigned char* p3; if (rsa_compat_test() != 0) { return 1; @@ -388,7 +392,7 @@ for (cnt = 0; cnt < len; ) { /* verify with privKey but remove pointer to dP to test without CRT */ - void* dP = privKey.dP; + dP = privKey.dP; privKey.dP = NULL; /* change byte back to original */ in[0] ^= 1; @@ -470,9 +474,9 @@ for (cnt = 0; cnt < len; ) { * For all PS lengths: the result should not be valid */ - unsigned char* p = in; - unsigned char* p2 = out; - unsigned char* p3 = tmp; + p = in; + p2 = out; + p3 = tmp; for (i = 0; i < 9; ++i) { len = sizeof(in); len2 = sizeof(out); diff --git a/testprof/x86_prof.c b/testprof/x86_prof.c index fe203a0..751644e 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -526,16 +526,16 @@ int time_keysched(void) return 0; } +#ifdef LTC_ECB_MODE int time_cipher(void) { - fprintf(stderr, "\n\nECB Time Trials for the Symmetric Ciphers:\n"); -#ifdef LTC_ECB_MODE unsigned long x, y1; ulong64 t1, t2, c1, c2, a1, a2; symmetric_ECB ecb; unsigned char key[MAXBLOCKSIZE], pt[4096]; int err; + fprintf(stderr, "\n\nECB Time Trials for the Symmetric Ciphers:\n"); no_results = 0; for (x = 0; cipher_descriptor[x].name != NULL; x++) { ecb_start(x, key, cipher_descriptor[x].min_key_length, 0, &ecb); @@ -594,12 +594,12 @@ int time_cipher(void) #undef DO1 } tally_results(1); -#else - fprintf(stderr, "NOP"); -#endif return 0; } +#else +int time_cipher(void) { fprintf(stderr, "NO ECB\n"); return 0; } +#endif #ifdef LTC_CBC_MODE int time_cipher2(void)