From 69998dd2c81d3f7130bf71e6e4fc955b46532c27 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 11 Jul 2009 19:15:20 +0000
Subject: [PATCH] - Made code compliant with ISO99
(no-declaration-after-statement)
---
tests/suites/test_suite_aes.function | 18 ++++++++++------
tests/suites/test_suite_arc4.function | 7 +++---
tests/suites/test_suite_camellia.function | 18 ++++++++++------
tests/suites/test_suite_des.function | 12 +++++++----
tests/suites/test_suite_dhm.function | 3 ++-
tests/suites/test_suite_hmac_shax.function | 25 +++++++++++++---------
tests/suites/test_suite_mdx.function | 15 +++++++------
tests/suites/test_suite_mpi.function | 18 ++++++++++------
tests/suites/test_suite_rsa.function | 12 +++++++----
tests/suites/test_suite_shax.function | 15 ++++++++-----
tests/suites/test_suite_x509parse.function | 15 ++++++++-----
11 files changed, 102 insertions(+), 56 deletions(-)
diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function
index f915010b9..3440202b4 100644
--- a/tests/suites/test_suite_aes.function
+++ b/tests/suites/test_suite_aes.function
@@ -10,13 +10,14 @@ aes_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
aes_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
aes_setkey_enc( &ctx, key_str, key_len * 8 );
@@ -35,13 +36,14 @@ aes_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
aes_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
aes_setkey_dec( &ctx, key_str, key_len * 8 );
@@ -61,6 +63,7 @@ aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
aes_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -68,7 +71,7 @@ aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -89,6 +92,7 @@ aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
aes_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -96,7 +100,7 @@ aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -118,6 +122,7 @@ aes_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char output[100];
aes_context ctx;
int iv_offset = 0;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -125,7 +130,7 @@ aes_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -147,6 +152,7 @@ aes_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char output[100];
aes_context ctx;
int iv_offset = 0;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -154,7 +160,7 @@ aes_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
diff --git a/tests/suites/test_suite_arc4.function b/tests/suites/test_suite_arc4.function
index d08295544..6c71cb232 100644
--- a/tests/suites/test_suite_arc4.function
+++ b/tests/suites/test_suite_arc4.function
@@ -8,15 +8,16 @@ arc4_crypt:hex_src_string:hex_key_string:hex_dst_string
unsigned char src_str[1000];
unsigned char key_str[1000];
unsigned char dst_str[2000];
+ int src_len, key_len;
+ arc4_context ctx;
memset(src_str, 0x00, 1000);
memset(key_str, 0x00, 1000);
memset(dst_str, 0x00, 2000);
- int src_len = unhexify( src_str, {hex_src_string} );
- int key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
- arc4_context ctx;
arc4_setup(&ctx, key_str, key_len);
arc4_crypt(&ctx, src_str, src_len);
hexify( dst_str, src_str, src_len );
diff --git a/tests/suites/test_suite_camellia.function b/tests/suites/test_suite_camellia.function
index 4670c79c7..7507feac8 100644
--- a/tests/suites/test_suite_camellia.function
+++ b/tests/suites/test_suite_camellia.function
@@ -10,13 +10,14 @@ camellia_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
camellia_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
camellia_setkey_enc( &ctx, key_str, key_len * 8 );
@@ -35,13 +36,14 @@ camellia_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
camellia_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
camellia_setkey_dec( &ctx, key_str, key_len * 8 );
@@ -61,6 +63,7 @@ camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
camellia_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -68,7 +71,7 @@ camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -89,6 +92,7 @@ camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
camellia_context ctx;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -96,7 +100,7 @@ camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -118,6 +122,7 @@ camellia_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri
unsigned char output[100];
camellia_context ctx;
int iv_offset = 0;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -125,7 +130,7 @@ camellia_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
@@ -147,6 +152,7 @@ camellia_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri
unsigned char output[100];
camellia_context ctx;
int iv_offset = 0;
+ int key_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -154,7 +160,7 @@ camellia_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_stri
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- int key_len = unhexify( key_str, {hex_key_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
unhexify( src_str, {hex_src_string} );
diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function
index 015ebc1a2..839fa97ea 100644
--- a/tests/suites/test_suite_des.function
+++ b/tests/suites/test_suite_des.function
@@ -61,6 +61,7 @@ des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
des_context ctx;
+ int src_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -70,7 +71,7 @@ des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
des_setkey_enc( &ctx, key_str );
des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output );
@@ -89,6 +90,7 @@ des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unsigned char dst_str[100];
unsigned char output[100];
des_context ctx;
+ int src_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -98,7 +100,7 @@ des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
des_setkey_dec( &ctx, key_str );
des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output );
@@ -179,6 +181,7 @@ des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s
unsigned char dst_str[100];
unsigned char output[100];
des3_context ctx;
+ int src_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -188,7 +191,7 @@ des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s
unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
if( {key_count} == 2 )
des3_set2key_enc( &ctx, key_str );
@@ -213,6 +216,7 @@ des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s
unsigned char dst_str[100];
unsigned char output[100];
des3_context ctx;
+ int src_len;
memset(key_str, 0x00, 100);
memset(iv_str, 0x00, 100);
@@ -222,7 +226,7 @@ des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_s
unhexify( key_str, {hex_key_string} );
unhexify( iv_str, {hex_iv_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
if( {key_count} == 2 )
des3_set2key_dec( &ctx, key_str );
diff --git a/tests/suites/test_suite_dhm.function b/tests/suites/test_suite_dhm.function
index d5c15c77d..c7c2b8c55 100644
--- a/tests/suites/test_suite_dhm.function
+++ b/tests/suites/test_suite_dhm.function
@@ -25,6 +25,7 @@ dhm_do_dhm:x_size:radix_P:input_P:radix_G:input_G
int pub_cli_len = 0;
int sec_srv_len = 1000;
int sec_cli_len = 1000;
+ int x_size;
memset( &ctx_srv, 0x00, sizeof( dhm_context ) );
memset( &ctx_cli, 0x00, sizeof( dhm_context ) );
@@ -35,7 +36,7 @@ dhm_do_dhm:x_size:radix_P:input_P:radix_G:input_G
TEST_ASSERT( mpi_read_string( &ctx_srv.P, {radix_P}, {input_P} ) == 0 );
TEST_ASSERT( mpi_read_string( &ctx_srv.G, {radix_G}, {input_G} ) == 0 );
- int x_size = mpi_size( &ctx_srv.P );
+ x_size = mpi_size( &ctx_srv.P );
TEST_ASSERT( dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &myrand, NULL ) == 0 );
ske[ske_len++] = 0;
diff --git a/tests/suites/test_suite_hmac_shax.function b/tests/suites/test_suite_hmac_shax.function
index 7b4a0dc96..d3e6f6ad0 100644
--- a/tests/suites/test_suite_hmac_shax.function
+++ b/tests/suites/test_suite_hmac_shax.function
@@ -11,14 +11,15 @@ sha1_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[41];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 41);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha1_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, 20 );
@@ -34,14 +35,15 @@ sha224_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[57];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 57);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
hexify( hash_str, output, 28 );
@@ -57,14 +59,15 @@ sha256_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[65];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 65);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
hexify( hash_str, output, 32 );
@@ -80,14 +83,15 @@ sha384_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[97];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 97);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
hexify( hash_str, output, 48 );
@@ -103,14 +107,15 @@ sha512_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[129];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 129);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
hexify( hash_str, output, 64 );
diff --git a/tests/suites/test_suite_mdx.function b/tests/suites/test_suite_mdx.function
index c810c5003..30ca36a0d 100644
--- a/tests/suites/test_suite_mdx.function
+++ b/tests/suites/test_suite_mdx.function
@@ -71,14 +71,15 @@ md2_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[33];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 33);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
md2_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, 16 );
@@ -94,14 +95,15 @@ md4_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[33];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 33);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
md4_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, 16 );
@@ -117,14 +119,15 @@ md5_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[33];
+ int key_len, src_len;
memset(src_str, 0x00, 10000);
memset(key_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 33);
- int key_len = unhexify( key_str, {hex_key_string} );
- int src_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, {hex_key_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
md5_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, 16 );
diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function
index c4ef3d191..52c5e413d 100644
--- a/tests/suites/test_suite_mpi.function
+++ b/tests/suites/test_suite_mpi.function
@@ -33,10 +33,11 @@ mpi_read_binary:input_X:radix_A:input_A
unsigned char str[1000];
unsigned char buf[1000];
int len = 1000;
+ int input_len;
mpi_init(&X, NULL);
- int input_len = unhexify( buf, {input_X} );
+ input_len = unhexify( buf, {input_X} );
TEST_ASSERT( mpi_read_binary( &X, buf, input_len ) == 0 );
TEST_ASSERT( mpi_write_string( &X, {radix_A}, (char *) str, &len ) == 0 );
@@ -50,6 +51,7 @@ mpi_write_binary:radix_X:input_X:input_A
mpi X;
unsigned char str[1000];
unsigned char buf[1000];
+ int buflen;
memset( buf, 0x00, 1000 );
memset( str, 0x00, 1000 );
@@ -58,7 +60,7 @@ mpi_write_binary:radix_X:input_X:input_A
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
- int buflen = mpi_size( &X );
+ buflen = mpi_size( &X );
TEST_ASSERT( mpi_write_binary( &X, buf, buflen ) == 0 );
hexify( str, buf, buflen );
@@ -73,17 +75,19 @@ mpi_read_file:radix_X:input_file:input_A
mpi X;
unsigned char str[1000];
unsigned char buf[1000];
+ int buflen;
+ FILE *file;
memset( buf, 0x00, 1000 );
memset( str, 0x00, 1000 );
mpi_init(&X, NULL);
- FILE *file = fopen( {input_file}, "r" );
+ file = fopen( {input_file}, "r" );
TEST_ASSERT( mpi_read_file( &X, {radix_X}, file ) == 0 );
fclose(file);
- int buflen = mpi_size( &X );
+ buflen = mpi_size( &X );
TEST_ASSERT( mpi_write_binary( &X, buf, buflen ) == 0 );
hexify( str, buf, buflen );
@@ -96,15 +100,17 @@ BEGIN_CASE
mpi_write_file:radix_X:input_X:output_radix:output_file
{
mpi X, Y;
+ FILE *file_out, *file_in;
+
mpi_init( &X, &Y, NULL );
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
- FILE *file_out = fopen( {output_file}, "w" );
+ file_out = fopen( {output_file}, "w" );
TEST_ASSERT( mpi_write_file( NULL, &X, {output_radix}, file_out ) == 0 );
fclose(file_out);
- FILE *file_in = fopen( {output_file}, "r" );
+ file_in = fopen( {output_file}, "r" );
TEST_ASSERT( mpi_read_file( &Y, {output_radix}, file_in ) == 0 );
fclose(file_in);
diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function
index 5e56ed5d4..7f94a6dba 100644
--- a/tests/suites/test_suite_rsa.function
+++ b/tests/suites/test_suite_rsa.function
@@ -14,6 +14,7 @@ rsa_pkcs1_sign:message_hex_string:digest:mod:radix_P:input_P:radix_Q:input_Q:rad
unsigned char output_str[1000];
rsa_context ctx;
mpi P1, Q1, H, G;
+ int msg_len;
mpi_init( &P1, &Q1, &H, &G, NULL );
rsa_init( &ctx, RSA_PKCS_V15, 0, NULL, NULL );
@@ -40,7 +41,7 @@ rsa_pkcs1_sign:message_hex_string:digest:mod:radix_P:input_P:radix_Q:input_Q:rad
TEST_ASSERT( rsa_check_privkey( &ctx ) == 0 );
- int msg_len = unhexify( message_str, {message_hex_string} );
+ msg_len = unhexify( message_str, {message_hex_string} );
if( {digest} == SIG_RSA_SHA1 )
sha1( message_str, msg_len, hash_result );
@@ -70,6 +71,7 @@ rsa_pkcs1_verify:message_hex_string:digest:mod:radix_N:input_N:radix_E:input_E:r
unsigned char hash_result[1000];
unsigned char result_str[1000];
rsa_context ctx;
+ int msg_len;
rsa_init( &ctx, RSA_PKCS_V15, 0, NULL, NULL );
memset( message_str, 0x00, 1000 );
@@ -82,7 +84,7 @@ rsa_pkcs1_verify:message_hex_string:digest:mod:radix_N:input_N:radix_E:input_E:r
TEST_ASSERT( rsa_check_pubkey( &ctx ) == 0 );
- int msg_len = unhexify( message_str, {message_hex_string} );
+ msg_len = unhexify( message_str, {message_hex_string} );
unhexify( result_str, {result_hex_str} );
if( {digest} == SIG_RSA_SHA1 )
@@ -110,6 +112,7 @@ rsa_pkcs1_encrypt:message_hex_string:mod:radix_N:input_N:radix_E:input_E:result_
unsigned char output[1000];
unsigned char output_str[1000];
rsa_context ctx;
+ int msg_len;
rsa_init( &ctx, RSA_PKCS_V15, 0, NULL, NULL );
memset( message_str, 0x00, 1000 );
@@ -123,7 +126,7 @@ rsa_pkcs1_encrypt:message_hex_string:mod:radix_N:input_N:radix_E:input_E:result_
TEST_ASSERT( rsa_check_pubkey( &ctx ) == 0 );
- int msg_len = unhexify( message_str, {message_hex_string} );
+ msg_len = unhexify( message_str, {message_hex_string} );
TEST_ASSERT( rsa_pkcs1_encrypt( &ctx, RSA_PUBLIC, msg_len, message_str, output ) == 0 );
@@ -142,6 +145,7 @@ rsa_pkcs1_decrypt:message_hex_string:mod:radix_P:input_P:radix_Q:input_Q:radix_N
unsigned char output_str[1000];
rsa_context ctx;
mpi P1, Q1, H, G;
+ int output_len;
mpi_init( &P1, &Q1, &H, &G, NULL );
rsa_init( &ctx, RSA_PKCS_V15, 0, NULL, NULL );
@@ -169,7 +173,7 @@ rsa_pkcs1_decrypt:message_hex_string:mod:radix_P:input_P:radix_Q:input_Q:radix_N
TEST_ASSERT( rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, {message_hex_string} );
- int output_len = 0;
+ output_len = 0;
TEST_ASSERT( rsa_pkcs1_decrypt( &ctx, RSA_PRIVATE, &output_len, message_str, output, 1000 ) == 0 );
diff --git a/tests/suites/test_suite_shax.function b/tests/suites/test_suite_shax.function
index a6b0fe6c5..13aff7ac8 100644
--- a/tests/suites/test_suite_shax.function
+++ b/tests/suites/test_suite_shax.function
@@ -10,12 +10,13 @@ sha1:hex_src_string:hex_hash_string
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[41];
+ int src_len;
memset(src_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 41);
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha1( src_str, src_len, output );
hexify( hash_str, output, 20 );
@@ -30,12 +31,13 @@ sha224:hex_src_string:hex_hash_string
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[57];
+ int src_len;
memset(src_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 57);
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha2( src_str, src_len, output, 1 );
hexify( hash_str, output, 28 );
@@ -50,12 +52,13 @@ sha256:hex_src_string:hex_hash_string
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[65];
+ int src_len;
memset(src_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 65);
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha2( src_str, src_len, output, 0 );
hexify( hash_str, output, 32 );
@@ -70,12 +73,13 @@ sha384:hex_src_string:hex_hash_string
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[97];
+ int src_len;
memset(src_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 97);
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha4( src_str, src_len, output, 1 );
hexify( hash_str, output, 48 );
@@ -90,12 +94,13 @@ sha512:hex_src_string:hex_hash_string
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[129];
+ int src_len;
memset(src_str, 0x00, 10000);
memset(hash_str, 0x00, 10000);
memset(output, 0x00, 129);
- int src_len = unhexify( src_str, {hex_src_string} );
+ src_len = unhexify( src_str, {hex_src_string} );
sha4( src_str, src_len, output, 0);
hexify( hash_str, output, 64 );
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index e9a0e19a7..c526cb720 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -7,12 +7,13 @@ x509_cert_info:crt_file:result_str
{
x509_cert crt;
char buf[2000];
+ int res;
memset( &crt, 0, sizeof( x509_cert ) );
memset( buf, 0, 2000 );
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
- int res = x509parse_cert_info( buf, 2000, "", &crt );
+ res = x509parse_cert_info( buf, 2000, "", &crt );
TEST_ASSERT( res != -1 );
TEST_ASSERT( res != -2 );
@@ -26,12 +27,13 @@ x509_crl_info:crl_file:result_str
{
x509_crl crl;
char buf[2000];
+ int res;
memset( &crl, 0, sizeof( x509_crl ) );
memset( buf, 0, 2000 );
TEST_ASSERT( x509parse_crlfile( &crl, {crl_file} ) == 0 );
- int res = x509parse_crl_info( buf, 2000, "", &crl );
+ res = x509parse_crl_info( buf, 2000, "", &crl );
TEST_ASSERT( res != -1 );
TEST_ASSERT( res != -2 );
@@ -47,6 +49,7 @@ x509_verify:crt_file:ca_file:crl_file:cn_name:result
x509_cert ca;
x509_crl crl;
int flags = 0;
+ int res;
memset( &crt, 0, sizeof( x509_cert ) );
memset( &ca, 0, sizeof( x509_cert ) );
@@ -56,7 +59,7 @@ x509_verify:crt_file:ca_file:crl_file:cn_name:result
TEST_ASSERT( x509parse_crtfile( &ca, {ca_file} ) == 0 );
TEST_ASSERT( x509parse_crlfile( &crl, {crl_file} ) == 0 );
- int res = x509parse_verify( &crt, &ca, &crl, {cn_name}, &flags );
+ res = x509parse_verify( &crt, &ca, &crl, {cn_name}, &flags );
if( res == 0 )
{
@@ -74,12 +77,13 @@ x509_dn_gets:crt_file:entity:result_str
{
x509_cert crt;
char buf[2000];
+ int res;
memset( &crt, 0, sizeof( x509_cert ) );
memset( buf, 0, 2000 );
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
- int res = x509parse_dn_gets( buf, 2000, &crt.{entity} );
+ res = x509parse_dn_gets( buf, 2000, &crt.{entity} );
TEST_ASSERT( res != -1 );
TEST_ASSERT( res != -2 );
@@ -104,10 +108,11 @@ BEGIN_CASE
x509parse_key:key_file:password:result
{
rsa_context rsa;
+ int res;
memset( &rsa, 0, sizeof( rsa_context ) );
- int res = x509parse_keyfile( &rsa, {key_file}, {password} );
+ res = x509parse_keyfile( &rsa, {key_file}, {password} );
TEST_ASSERT( res == {result} );