mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 21:05:39 +01:00
- Made code compliant with ISO99 (no-declaration-after-statement)
This commit is contained in:
parent
765687985a
commit
69998dd2c8
@ -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} );
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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} );
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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} );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user