mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 02:15:40 +01:00
Add 'exit' label and variable initialization to relevant test suite functions
This commit is contained in:
parent
318d0fe844
commit
bd51b262d1
@ -36,6 +36,7 @@ void aes_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -69,6 +70,7 @@ void aes_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -106,6 +108,7 @@ void aes_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -143,6 +146,7 @@ void aes_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -177,6 +181,7 @@ void aes_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -211,6 +216,7 @@ void aes_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -244,6 +250,7 @@ void aes_encrypt_cfb8( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -277,6 +284,7 @@ void aes_decrypt_cfb8( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
aes_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -33,6 +33,7 @@ void arc4_crypt( char *hex_src_string, char *hex_key_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_hexstr, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
arc4_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -52,7 +52,7 @@ void base64_decode( char *src_string, char *dst_string, int result )
|
||||
void base64_encode_hex( char *src_hex, char *dst, int dst_buf_size,
|
||||
int result )
|
||||
{
|
||||
unsigned char *src, *res;
|
||||
unsigned char *src = NULL, *res = NULL;
|
||||
size_t len = dst_buf_size, src_len;
|
||||
|
||||
src = unhexify_alloc( src_hex, &src_len );
|
||||
@ -65,6 +65,7 @@ void base64_encode_hex( char *src_hex, char *dst, int dst_buf_size,
|
||||
TEST_ASSERT( memcmp( dst, res, len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
polarssl_free( src );
|
||||
polarssl_free( res );
|
||||
}
|
||||
@ -74,7 +75,7 @@ void base64_encode_hex( char *src_hex, char *dst, int dst_buf_size,
|
||||
void base64_decode_hex( char *src, char *dst_hex, int dst_buf_size,
|
||||
int result )
|
||||
{
|
||||
unsigned char *dst, *res;
|
||||
unsigned char *dst = NULL, *res = NULL;
|
||||
size_t len = dst_buf_size, dst_len;
|
||||
|
||||
dst = unhexify_alloc( dst_hex, &dst_len );
|
||||
@ -88,6 +89,7 @@ void base64_decode_hex( char *src, char *dst_hex, int dst_buf_size,
|
||||
TEST_ASSERT( memcmp( dst, res, len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
polarssl_free( dst );
|
||||
polarssl_free( res );
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ void blowfish_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -69,6 +70,7 @@ void blowfish_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -107,6 +109,7 @@ void blowfish_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -144,6 +147,7 @@ void blowfish_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -178,6 +182,7 @@ void blowfish_encrypt_cfb64( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -212,6 +217,7 @@ void blowfish_decrypt_cfb64( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -248,6 +254,7 @@ void blowfish_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
blowfish_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -36,6 +36,7 @@ void camellia_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -69,6 +70,7 @@ void camellia_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -106,6 +108,7 @@ void camellia_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -143,6 +146,7 @@ void camellia_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -177,6 +181,7 @@ void camellia_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -211,6 +216,7 @@ void camellia_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
camellia_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -27,6 +27,7 @@ void ccm_init( int cipher_id, int key_size, int result )
|
||||
ret = ccm_init( &ctx, cipher_id, key, key_size );
|
||||
TEST_ASSERT( ret == result );
|
||||
|
||||
exit:
|
||||
ccm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -64,6 +65,7 @@ void ccm_lengths( int msg_len, int iv_len, int add_len, int tag_len, int res )
|
||||
else
|
||||
TEST_ASSERT( decrypt_ret == res );
|
||||
|
||||
exit:
|
||||
ccm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -106,6 +108,7 @@ void ccm_encrypt_and_tag( int cipher_id,
|
||||
/* Check we didn't write past the end */
|
||||
TEST_ASSERT( msg[result_len] == 0 && msg[result_len + 1] == 0 );
|
||||
|
||||
exit:
|
||||
ccm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -171,6 +174,7 @@ void ccm_auth_decrypt( int cipher_id,
|
||||
/* Check we didn't write past the end (where the original tag is) */
|
||||
TEST_ASSERT( memcmp( msg + msg_len, tag, tag_len ) == 0 );
|
||||
|
||||
exit:
|
||||
ccm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -207,6 +207,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len,
|
||||
/*
|
||||
* Done
|
||||
*/
|
||||
exit:
|
||||
cipher_free( &ctx_dec );
|
||||
cipher_free( &ctx_enc );
|
||||
}
|
||||
@ -259,6 +260,7 @@ void enc_fail( int cipher_id, int pad_mode, int key_len,
|
||||
TEST_ASSERT( ret == cipher_finish( &ctx, encbuf + outlen, &outlen ) );
|
||||
|
||||
/* done */
|
||||
exit:
|
||||
cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -308,6 +310,7 @@ void dec_empty_buf()
|
||||
&ctx_dec, decbuf + outlen, &outlen ) );
|
||||
TEST_ASSERT( 0 == outlen );
|
||||
|
||||
exit:
|
||||
cipher_free( &ctx_dec );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -397,6 +400,7 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val,
|
||||
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
|
||||
exit:
|
||||
cipher_free( &ctx_dec );
|
||||
cipher_free( &ctx_enc );
|
||||
}
|
||||
@ -479,6 +483,7 @@ void decrypt_test_vec( int cipher_id, int pad_mode,
|
||||
TEST_ASSERT( 0 == memcmp( output, clear, clear_len ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -536,7 +541,7 @@ void auth_crypt_tv( int cipher_id, char *hex_key, char *hex_iv,
|
||||
if( strcmp( hex_clear, "FAIL" ) == 0 )
|
||||
{
|
||||
TEST_ASSERT( ret == POLARSSL_ERR_CIPHER_AUTH_FAILED );
|
||||
goto cleanup;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* otherwise, make sure it was decrypted properly */
|
||||
@ -566,7 +571,7 @@ void auth_crypt_tv( int cipher_id, char *hex_key, char *hex_iv,
|
||||
TEST_ASSERT( my_tag[tag_len + 1] == 0xFF );
|
||||
|
||||
|
||||
cleanup:
|
||||
exit:
|
||||
cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -616,6 +621,7 @@ void test_vec_ecb( int cipher_id, int operation, char *hex_key,
|
||||
TEST_ASSERT( 0 == memcmp( output, result,
|
||||
cipher_get_block_size( &ctx ) ) );
|
||||
|
||||
exit:
|
||||
cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -634,6 +640,7 @@ void set_padding( int cipher_id, int pad_mode, int ret )
|
||||
|
||||
TEST_ASSERT( ret == cipher_set_padding_mode( &ctx, pad_mode ) );
|
||||
|
||||
exit:
|
||||
cipher_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -46,6 +46,7 @@ void ctr_drbg_validate_pr( char *add_init_string, char *entropy_string,
|
||||
hexify( output_str, buf, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
ctr_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -82,6 +83,7 @@ void ctr_drbg_validate_nopr( char *add_init_string, char *entropy_string,
|
||||
hexify( output_str, buf, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
ctr_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -155,6 +157,7 @@ void ctr_drbg_entropy_usage( )
|
||||
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
|
||||
TEST_ASSERT( test_offset_idx - last_idx == 13 );
|
||||
|
||||
exit:
|
||||
ctr_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -168,6 +171,7 @@ void ctr_drbg_seed_file( char *path, int ret )
|
||||
TEST_ASSERT( ctr_drbg_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( ctr_drbg_update_seed_file( &ctx, path ) == ret );
|
||||
|
||||
exit:
|
||||
ctr_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -117,6 +117,7 @@ void debug_print_crt( int mode, char *crt_file, char *file, int line,
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -144,6 +145,7 @@ void debug_print_mpi( int mode, int radix, char *value, char *file, int line,
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &val );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -45,6 +45,7 @@ void des_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
des_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -74,6 +75,7 @@ void des_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
des_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -110,6 +112,7 @@ void des_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
des_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -146,6 +149,7 @@ void des_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
des_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -181,6 +185,7 @@ void des3_encrypt_ecb( int key_count, char *hex_key_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
des3_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -216,6 +221,7 @@ void des3_decrypt_ecb( int key_count, char *hex_key_string,
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
exit:
|
||||
des3_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -260,6 +266,7 @@ void des3_encrypt_cbc( int key_count, char *hex_key_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
des3_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -304,6 +311,7 @@ void des3_decrypt_cbc( int key_count, char *hex_key_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
des3_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -92,6 +92,7 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
TEST_ASSERT( sec_srv_len != 0 );
|
||||
TEST_ASSERT( memcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
|
||||
exit:
|
||||
dhm_free( &ctx_srv );
|
||||
dhm_free( &ctx_cli );
|
||||
}
|
||||
@ -115,6 +116,7 @@ void dhm_file( char *filename, char *p, char *g, int len )
|
||||
TEST_ASSERT( mpi_cmp_mpi( &ctx.P, &P ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &ctx.G, &G ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &P ); mpi_free( &G );
|
||||
dhm_free( &ctx );
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ void ecdh_primitive_random( int id )
|
||||
|
||||
TEST_ASSERT( mpi_cmp_mpi( &zA, &zB ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &qA ); ecp_point_free( &qB );
|
||||
mpi_free( &dA ); mpi_free( &dB );
|
||||
@ -114,6 +115,7 @@ void ecdh_primitive_testvec( int id, char *dA_str, char *xA_str, char *yA_str,
|
||||
TEST_ASSERT( ecdh_compute_shared( &grp, &zB, &qA, &dB, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &zB, &check ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &qA ); ecp_point_free( &qB );
|
||||
mpi_free( &dA ); mpi_free( &dB );
|
||||
@ -151,6 +153,7 @@ void ecdh_exchange( int id )
|
||||
TEST_ASSERT( ecdh_calc_secret( &cli, &len, buf, 1000, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &srv.z, &cli.z ) == 0 );
|
||||
|
||||
exit:
|
||||
ecdh_free( &srv );
|
||||
ecdh_free( &cli );
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ void ecdsa_prim_random( int id )
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( ecdsa_verify( &grp, buf, sizeof( buf ), &Q, &r, &s ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &Q );
|
||||
mpi_free( &d ); mpi_free( &r ); mpi_free( &s );
|
||||
@ -86,6 +87,7 @@ void ecdsa_prim_test_vectors( int id, char *d_str, char *xQ_str, char *yQ_str,
|
||||
|
||||
TEST_ASSERT( ecdsa_verify( &grp, hash, hlen, &Q, &r_check, &s_check ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &Q );
|
||||
mpi_free( &d ); mpi_free( &r ); mpi_free( &s );
|
||||
@ -123,6 +125,7 @@ void ecdsa_det_test_vectors( int id, char *d_str, int md_alg,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &r, &r_check ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &s, &s_check ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
mpi_free( &d ); mpi_free( &r ); mpi_free( &s );
|
||||
mpi_free( &r_check ); mpi_free( &s_check );
|
||||
@ -183,6 +186,7 @@ void ecdsa_write_read_random( int id )
|
||||
sig, sig_len ) != 0 );
|
||||
sig[sig_len - 1]--;
|
||||
|
||||
exit:
|
||||
ecdsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -215,6 +219,7 @@ void ecdsa_write_read_det_random( int id, int md_alg )
|
||||
TEST_ASSERT( ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
||||
sig, sig_len ) == 0 );
|
||||
|
||||
exit:
|
||||
ecdsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -71,6 +71,7 @@ void ecp_small_add( int a_zero, char *x_a, char *y_a, int b_zero, char *x_b,
|
||||
TEST_ASSERT( mpi_cmp_int( &C.Y, y_c ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &A ); ecp_point_free( &B ); ecp_point_free( &C );
|
||||
}
|
||||
@ -109,6 +110,7 @@ void ecp_small_sub( int a_zero, char *x_a, char *y_a, int b_zero, char *x_b,
|
||||
TEST_ASSERT( mpi_cmp_int( &C.Y, y_c ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &A ); ecp_point_free( &B ); ecp_point_free( &C );
|
||||
}
|
||||
@ -162,6 +164,7 @@ void ecp_small_mul( int m_str, int r_zero, int x_r, int y_r, int ret )
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &R );
|
||||
mpi_free( &m );
|
||||
@ -186,6 +189,7 @@ void ecp_small_check_pub( int x, int y, int z, int ret )
|
||||
|
||||
TEST_ASSERT( ecp_check_pubkey( &grp, &P ) == ret );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &P );
|
||||
}
|
||||
@ -207,6 +211,7 @@ void ecp_check_pub_mx( int grp_id, char *key_hex, int ret )
|
||||
|
||||
TEST_ASSERT( ecp_check_pubkey( &grp, &P ) == ret );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &P );
|
||||
}
|
||||
@ -260,6 +265,7 @@ void ecp_test_vect( int id, char *dA_str, char *xA_str, char *yA_str,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &R.Y, &yZ ) == 0 );
|
||||
TEST_ASSERT( ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp ); ecp_point_free( &R );
|
||||
mpi_free( &dA ); mpi_free( &xA ); mpi_free( &yA ); mpi_free( &dB );
|
||||
mpi_free( &xB ); mpi_free( &yB ); mpi_free( &xZ ); mpi_free( &yZ );
|
||||
@ -309,6 +315,7 @@ void ecp_test_vec_x( int id, char *dA_hex, char *xA_hex,
|
||||
TEST_ASSERT( ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &R.X, &xS ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp ); ecp_point_free( &R );
|
||||
mpi_free( &dA ); mpi_free( &xA );
|
||||
mpi_free( &dB ); mpi_free( &xB );
|
||||
@ -343,6 +350,7 @@ void ecp_fast_mod( int id, char *N_str )
|
||||
TEST_ASSERT( mpi_mod_mpi( &N, &N, &grp.P ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &N, &R ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &N ); mpi_free( &R );
|
||||
ecp_group_free( &grp );
|
||||
}
|
||||
@ -377,6 +385,7 @@ void ecp_write_binary( int id, char *x, char *y, char *z, int format,
|
||||
TEST_ASSERT( strcasecmp( (char *) str, out ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp ); ecp_point_free( &P );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -413,6 +422,7 @@ void ecp_read_binary( int id, char *input, char *x, char *y, char *z,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &P.Z, &Z ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp ); ecp_point_free( &P );
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z );
|
||||
}
|
||||
@ -452,6 +462,7 @@ void ecp_tls_read_point( int id, char *input, char *x, char *y, char *z,
|
||||
TEST_ASSERT( *vbuf == 0x00 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp ); ecp_point_free( &P );
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z );
|
||||
}
|
||||
@ -503,6 +514,7 @@ void ecp_tls_write_read_point( int id )
|
||||
TEST_ASSERT( ecp_is_zero( &pt ) );
|
||||
TEST_ASSERT( vbuf == buf + olen );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &pt );
|
||||
}
|
||||
@ -530,6 +542,7 @@ void ecp_tls_read_group( char *record, int result, int bits )
|
||||
TEST_ASSERT( *vbuf == 0x00 );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -559,6 +572,7 @@ void ecp_tls_write_read_group( int id )
|
||||
TEST_ASSERT( grp1.id == grp2.id );
|
||||
}
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp1 );
|
||||
ecp_group_free( &grp2 );
|
||||
}
|
||||
@ -578,6 +592,7 @@ void ecp_check_privkey( int id, char *key_hex, int ret )
|
||||
|
||||
TEST_ASSERT( ecp_check_privkey( &grp, &d ) == ret );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
mpi_free( &d );
|
||||
}
|
||||
@ -604,6 +619,7 @@ void ecp_gen_keypair( int id )
|
||||
TEST_ASSERT( ecp_check_pubkey( &grp, &Q ) == 0 );
|
||||
TEST_ASSERT( ecp_check_privkey( &grp, &d ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &Q );
|
||||
mpi_free( &d );
|
||||
@ -624,6 +640,7 @@ void ecp_gen_key( int id )
|
||||
TEST_ASSERT( ecp_check_pubkey( &key.grp, &key.Q ) == 0 );
|
||||
TEST_ASSERT( ecp_check_privkey( &key.grp, &key.d ) == 0 );
|
||||
|
||||
exit:
|
||||
ecp_keypair_free( &key );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -50,6 +50,7 @@ void entropy_seed_file( char *path, int ret )
|
||||
TEST_ASSERT( entropy_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( entropy_update_seed_file( &ctx, path ) == ret );
|
||||
|
||||
exit:
|
||||
entropy_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -72,6 +73,7 @@ void entropy_too_many_sources( )
|
||||
TEST_ASSERT( entropy_add_source( &ctx, entropy_dummy_source, NULL, 16 )
|
||||
== POLARSSL_ERR_ENTROPY_MAX_SOURCES );
|
||||
|
||||
exit:
|
||||
entropy_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -130,6 +132,7 @@ void entropy_source_fail( char *path )
|
||||
((void) path);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
entropy_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -159,6 +162,7 @@ void entropy_threshold( int threshold, int chunk_size, int result )
|
||||
TEST_ASSERT( ret == result );
|
||||
}
|
||||
|
||||
exit:
|
||||
entropy_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -51,6 +51,7 @@ void gcm_encrypt_and_tag( int cipher_id,
|
||||
TEST_ASSERT( strcmp( (char *) tag_str, hex_tag_string ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
gcm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -106,6 +107,7 @@ void gcm_decrypt_and_verify( int cipher_id,
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
gcm_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -101,6 +101,8 @@ void hmac_drbg_entropy_usage( int md_alg )
|
||||
last_len = entropy.len;
|
||||
TEST_ASSERT( hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
|
||||
TEST_ASSERT( (int) last_len - entropy.len == 13 );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -120,6 +122,7 @@ void hmac_drbg_seed_file( int md_alg, char *path, int ret )
|
||||
TEST_ASSERT( hmac_drbg_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( hmac_drbg_update_seed_file( &ctx, path ) == ret );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -147,6 +150,7 @@ void hmac_drbg_buf( int md_alg )
|
||||
for( i = 0; i < 30; i++ )
|
||||
TEST_ASSERT( hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -190,6 +194,8 @@ void hmac_drbg_no_reseed( int md_alg,
|
||||
add1, add1_len ) == 0 );
|
||||
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
|
||||
add2, add2_len ) == 0 );
|
||||
|
||||
/* clear for second run */
|
||||
hmac_drbg_free( &ctx );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
|
||||
@ -201,10 +207,10 @@ void hmac_drbg_no_reseed( int md_alg,
|
||||
add1, add1_len ) == 0 );
|
||||
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
|
||||
add2, add2_len ) == 0 );
|
||||
hmac_drbg_free( &ctx );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -246,10 +252,11 @@ void hmac_drbg_nopr( int md_alg,
|
||||
add2, add2_len ) == 0 );
|
||||
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
|
||||
add3, add3_len ) == 0 );
|
||||
hmac_drbg_free( &ctx );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -289,9 +296,11 @@ void hmac_drbg_pr( int md_alg,
|
||||
add1, add1_len ) == 0 );
|
||||
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
|
||||
add2, add2_len ) == 0 );
|
||||
hmac_drbg_free( &ctx );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
|
||||
|
||||
exit:
|
||||
hmac_drbg_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -58,6 +58,7 @@ void sha1_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
sha1_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -116,6 +117,7 @@ void sha224_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
sha256_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -174,6 +176,7 @@ void sha256_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
sha256_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -232,6 +235,7 @@ void sha384_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
sha512_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -290,6 +294,7 @@ void sha512_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
sha512_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -33,6 +33,9 @@ void md_process( )
|
||||
TEST_ASSERT( md_process( &ctx, buf ) == 0 );
|
||||
md_free( &ctx );
|
||||
}
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -198,11 +201,13 @@ void md_text_multi( char *text_md_name, char *text_src_string,
|
||||
TEST_ASSERT ( ctx.md_ctx != NULL );
|
||||
TEST_ASSERT ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
|
||||
TEST_ASSERT ( 0 == md_finish( &ctx, output ) );
|
||||
md_free( &ctx );
|
||||
|
||||
hexify( hash_str, output, md_get_size(md_info) );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -236,11 +241,13 @@ void md_hex_multi( char *text_md_name, char *hex_src_string,
|
||||
TEST_ASSERT ( ctx.md_ctx != NULL );
|
||||
TEST_ASSERT ( 0 == md_update( &ctx, src_str, src_len ) );
|
||||
TEST_ASSERT ( 0 == md_finish( &ctx, output ) );
|
||||
md_free( &ctx );
|
||||
|
||||
hexify( hash_str, output, md_get_size(md_info) );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -320,10 +327,12 @@ void md_hmac_multi( char *text_md_name, int trunc_size, char *hex_key_string,
|
||||
TEST_ASSERT ( 0 == md_hmac_reset( &ctx ) );
|
||||
TEST_ASSERT ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
|
||||
TEST_ASSERT ( 0 == md_hmac_finish( &ctx, output ) );
|
||||
md_free( &ctx );
|
||||
|
||||
hexify( hash_str, output, md_get_size(md_info) );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -139,6 +139,7 @@ void md2_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
md2_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -197,6 +198,7 @@ void md4_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
md4_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -255,6 +257,7 @@ void md5_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
md5_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -313,6 +316,7 @@ void ripemd160_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
|
||||
hexify( hash_str, output, sizeof output );
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
||||
|
||||
exit:
|
||||
ripemd160_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -28,6 +28,7 @@ void mpi_read_write_string( int radix_X, char *input_X, int radix_A,
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -49,6 +50,7 @@ void mpi_read_binary( char *input_X, int radix_A, char *input_A )
|
||||
TEST_ASSERT( mpi_write_string( &X, radix_A, (char *) str, &len ) == 0 );
|
||||
TEST_ASSERT( strcmp( (char *) str, input_A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -81,6 +83,7 @@ void mpi_write_binary( int radix_X, char *input_X, char *input_A,
|
||||
TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -115,6 +118,7 @@ void mpi_read_file( int radix_X, char *input_file, char *input_A,
|
||||
TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -142,6 +146,7 @@ void mpi_write_file( int radix_X, char *input_X, int output_radix,
|
||||
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -154,6 +159,7 @@ void mpi_get_bit( int radix_X, char *input_X, int pos, int val )
|
||||
TEST_ASSERT( mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mpi_get_bit( &X, pos ) == val );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -170,6 +176,7 @@ void mpi_set_bit( int radix_X, char *input_X, int pos, int val, int radix_Y,
|
||||
TEST_ASSERT( mpi_set_bit( &X, pos, val ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -183,6 +190,7 @@ void mpi_lsb( int radix_X, char *input_X, int nr_bits )
|
||||
TEST_ASSERT( mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mpi_lsb( &X ) == (size_t) nr_bits );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -196,6 +204,7 @@ void mpi_msb( int radix_X, char *input_X, int nr_bits )
|
||||
TEST_ASSERT( mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mpi_msb( &X ) == (size_t) nr_bits );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -213,6 +222,7 @@ void mpi_gcd( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_gcd( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &A ); mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -226,6 +236,7 @@ void mpi_cmp_int( int input_X, int input_A, int result_CMP )
|
||||
TEST_ASSERT( mpi_lset( &X, input_X ) == 0);
|
||||
TEST_ASSERT( mpi_cmp_int( &X, input_A ) == result_CMP);
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -241,6 +252,7 @@ void mpi_cmp_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_read_string( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == input_A );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -256,6 +268,7 @@ void mpi_cmp_abs( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_read_string( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_abs( &X, &Y ) == input_A );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -275,6 +288,7 @@ void mpi_copy( int input_X, int input_A )
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Y, &A ) != 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -289,6 +303,7 @@ void mpi_copy_self( int input_X )
|
||||
TEST_ASSERT( mpi_copy( &X, &X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_int( &X, input_X ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -305,6 +320,7 @@ void mpi_shrink( int before, int used, int min, int after )
|
||||
TEST_ASSERT( mpi_shrink( &X, min ) == 0 );
|
||||
TEST_ASSERT( X.n == (size_t) after );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -328,6 +344,7 @@ void mpi_safe_cond_assign( int x_sign, char *x_str,
|
||||
TEST_ASSERT( mpi_safe_cond_assign( &X, &Y, 1 ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &XX );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -357,6 +374,7 @@ void mpi_safe_cond_swap( int x_sign, char *x_str,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Y, &XX ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &YY ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y );
|
||||
mpi_free( &XX ); mpi_free( &YY );
|
||||
}
|
||||
@ -377,6 +395,7 @@ void mpi_swap( int input_X, int input_Y )
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) != 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Y, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -394,6 +413,7 @@ void mpi_add_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_add_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -411,6 +431,7 @@ void mpi_add_abs( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_add_abs( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -428,6 +449,7 @@ void mpi_add_abs_add_first( int radix_X, char *input_X, int radix_Y,
|
||||
TEST_ASSERT( mpi_add_abs( &X, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -445,6 +467,7 @@ void mpi_add_abs_add_second( int radix_X, char *input_X, int radix_Y,
|
||||
TEST_ASSERT( mpi_add_abs( &Y, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Y, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -461,6 +484,7 @@ void mpi_add_int( int radix_X, char *input_X, int input_Y, int radix_A,
|
||||
TEST_ASSERT( mpi_add_int( &Z, &X, input_Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -478,6 +502,7 @@ void mpi_sub_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_sub_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -499,6 +524,7 @@ void mpi_sub_abs( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
if( res == 0 )
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -515,6 +541,7 @@ void mpi_sub_int( int radix_X, char *input_X, int input_Y, int radix_A,
|
||||
TEST_ASSERT( mpi_sub_int( &Z, &X, input_Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -532,6 +559,7 @@ void mpi_mul_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_mul_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -553,6 +581,7 @@ void mpi_mul_int( int radix_X, char *input_X, int input_Y, int radix_A,
|
||||
else
|
||||
TEST_ASSERT( "unknown operator" == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -579,6 +608,7 @@ void mpi_div_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &R, &B ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Q ); mpi_free( &R );
|
||||
mpi_free( &A ); mpi_free( &B );
|
||||
}
|
||||
@ -604,6 +634,7 @@ void mpi_div_int( int radix_X, char *input_X, int input_Y, int radix_A,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &R, &B ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Q ); mpi_free( &R ); mpi_free( &A );
|
||||
mpi_free( &B );
|
||||
}
|
||||
@ -627,6 +658,7 @@ void mpi_mod_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -648,6 +680,7 @@ void mpi_mod_int( int radix_X, char *input_X, int input_Y, int input_A,
|
||||
TEST_ASSERT( r == (t_uint) input_A );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -677,6 +710,7 @@ void mpi_exp_mod( int radix_A, char *input_A, int radix_E, char *input_E,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &X ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &A ); mpi_free( &E ); mpi_free( &N );
|
||||
mpi_free( &RR ); mpi_free( &Z ); mpi_free( &X );
|
||||
}
|
||||
@ -700,6 +734,7 @@ void mpi_inv_mod( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
TEST_ASSERT( mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -715,6 +750,7 @@ void mpi_is_prime( int radix_X, char *input_X, int div_result )
|
||||
res = mpi_is_prime( &X, rnd_std_rand, NULL );
|
||||
TEST_ASSERT( res == div_result );
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -745,6 +781,7 @@ void mpi_gen_prime( int bits, int safe, int ref_ret )
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -761,6 +798,7 @@ void mpi_shift_l( int radix_X, char *input_X, int shift_X, int radix_A,
|
||||
TEST_ASSERT( mpi_shift_l( &X, shift_X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -777,6 +815,7 @@ void mpi_shift_r( int radix_X, char *input_X, int shift_X, int radix_A,
|
||||
TEST_ASSERT( mpi_shift_r( &X, shift_X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -38,9 +38,11 @@ void pbkdf2_hmac( int hash, char *hex_password_string, char *hex_salt_string,
|
||||
TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
|
||||
TEST_ASSERT( pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len,
|
||||
it_cnt, key_len, key ) == 0 );
|
||||
md_free( &ctx );
|
||||
|
||||
hexify( dst_str, key, key_len );
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, result_key_string ) == 0 );
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -12,7 +12,7 @@
|
||||
void pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
|
||||
{
|
||||
unsigned char buf[5000];
|
||||
unsigned char *check_buf;
|
||||
unsigned char *check_buf = NULL;
|
||||
int ret;
|
||||
size_t buf_len, olen = 0, olen2 = 0;
|
||||
|
||||
@ -33,6 +33,8 @@ void pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
|
||||
TEST_ASSERT( olen > strlen( (char*) result_str ) );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
TEST_ASSERT( strncmp( (char *) check_buf, (char *) result_str, olen ) == 0 );
|
||||
|
||||
exit:
|
||||
polarssl_free( check_buf );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -75,6 +75,7 @@ void pk_utils( int type, int size, int len, char *name )
|
||||
TEST_ASSERT( pk_get_len( &pk ) == (unsigned) len );
|
||||
TEST_ASSERT( strcmp( pk_get_name( &pk), name ) == 0 );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -113,6 +114,7 @@ void pk_rsa_verify_test_vec( char *message_hex_string, int digest,
|
||||
TEST_ASSERT( pk_verify( &pk, digest, hash_result, 0,
|
||||
result_str, pk_get_len( &pk ) ) == result );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -178,6 +180,7 @@ void pk_rsa_verify_ext_test_vec( char *message_hex_string, int digest,
|
||||
digest, hash_result, hash_len,
|
||||
result_str, pk_get_len( &pk ) ) == result );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -209,6 +212,7 @@ void pk_ec_test_vec( int type, int id, char *key_str,
|
||||
TEST_ASSERT( pk_verify( &pk, POLARSSL_MD_NONE,
|
||||
hash, hash_len, sig, sig_len ) == ret );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -234,6 +238,7 @@ void pk_sign_verify( int type, int sign_ret, int verify_ret )
|
||||
TEST_ASSERT( pk_verify( &pk, POLARSSL_MD_NONE,
|
||||
hash, sizeof hash, sig, sig_len ) == verify_ret );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -274,6 +279,7 @@ void pk_rsa_encrypt_test_vec( char *message_hex, int mod,
|
||||
TEST_ASSERT( olen == res_len );
|
||||
TEST_ASSERT( memcmp( output, result, olen ) == 0 );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -338,6 +344,7 @@ void pk_rsa_decrypt_test_vec( char *cipher_hex, int mod,
|
||||
TEST_ASSERT( memcmp( output, clear, olen ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
pk_free( &pk );
|
||||
}
|
||||
@ -369,6 +376,7 @@ void pk_ec_nocrypt( int type )
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -442,6 +450,7 @@ void pk_rsa_alt( )
|
||||
hash, sizeof hash, sig, sig_len ) == ret );
|
||||
TEST_ASSERT( pk_debug( &alt, dbg_items ) == ret );
|
||||
|
||||
exit:
|
||||
rsa_free( &raw );
|
||||
pk_free( &rsa ); pk_free( &alt );
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char *input_N, int radix_E,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -101,6 +102,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char *input_P,
|
||||
TEST_ASSERT( strncasecmp( (char *) output_str, result_hex_str, strlen( result_hex_str ) ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
@ -164,6 +166,7 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char *input_P, int radix_Q,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
@ -201,6 +204,7 @@ void pkcs1_rsassa_pss_verify( int mod, int radix_N, char *input_N, int radix_E,
|
||||
|
||||
TEST_ASSERT( rsa_pkcs1_verify( &ctx, NULL, NULL, RSA_PUBLIC, digest, 0, hash_result, result_str ) == result );
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -257,6 +261,7 @@ void pkcs1_rsassa_pss_verify_ext( int mod,
|
||||
mgf_hash, salt_len,
|
||||
result_str ) == result_full );
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -39,10 +39,12 @@ void pbkdf2_hmac( int hash, char *hex_password_string,
|
||||
TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
|
||||
TEST_ASSERT( pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len,
|
||||
it_cnt, key_len, key ) == 0 );
|
||||
md_free( &ctx );
|
||||
|
||||
hexify( dst_str, key, key_len );
|
||||
TEST_ASSERT( strcmp( (char *) dst_str, result_key_string ) == 0 );
|
||||
|
||||
exit:
|
||||
md_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -52,7 +54,7 @@ void pkcs5_pbes2( int params_tag, char *params_hex, char *pw_hex,
|
||||
{
|
||||
int my_ret;
|
||||
asn1_buf params;
|
||||
unsigned char *my_out, *ref_out, *data, *pw;
|
||||
unsigned char *my_out = NULL, *ref_out = NULL, *data = NULL, *pw = NULL;
|
||||
size_t ref_out_len, data_len, pw_len;
|
||||
|
||||
params.tag = params_tag;
|
||||
@ -70,6 +72,7 @@ void pkcs5_pbes2( int params_tag, char *params_hex, char *pw_hex,
|
||||
if( ref_ret == 0 )
|
||||
TEST_ASSERT( memcmp( my_out, ref_out, ref_out_len ) == 0 );
|
||||
|
||||
exit:
|
||||
polarssl_free( params.p );
|
||||
polarssl_free( data );
|
||||
polarssl_free( pw );
|
||||
|
@ -33,6 +33,7 @@ void pk_parse_keyfile_rsa( char *key_file, char *password, int result )
|
||||
TEST_ASSERT( rsa_check_privkey( rsa ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
pk_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -57,6 +58,7 @@ void pk_parse_public_keyfile_rsa( char *key_file, int result )
|
||||
TEST_ASSERT( rsa_check_pubkey( rsa ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
pk_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -81,6 +83,7 @@ void pk_parse_public_keyfile_ec( char *key_file, int result )
|
||||
TEST_ASSERT( ecp_check_pubkey( &eckey->grp, &eckey->Q ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
pk_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -105,6 +108,7 @@ void pk_parse_keyfile_ec( char *key_file, char *password, int result )
|
||||
TEST_ASSERT( ecp_check_privkey( &eckey->grp, &eckey->d ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
pk_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -131,6 +135,7 @@ void pk_parse_key_rsa( char *key_data, char *result_str, int result )
|
||||
TEST_ASSERT( 1 );
|
||||
}
|
||||
|
||||
exit:
|
||||
pk_free( &pk );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -36,6 +36,7 @@ void pk_write_pubkey_check( char *key_file )
|
||||
TEST_ASSERT( ilen == strlen( (char *) buf ) );
|
||||
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
|
||||
|
||||
exit:
|
||||
pk_free( &key );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -67,6 +68,7 @@ void pk_write_key_check( char *key_file )
|
||||
TEST_ASSERT( ilen == strlen( (char *) buf ) );
|
||||
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
|
||||
|
||||
exit:
|
||||
pk_free( &key );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -69,6 +69,7 @@ void rsa_pkcs1_sign( char *message_hex_string, int padding_mode, int digest,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
@ -104,6 +105,7 @@ void rsa_pkcs1_verify( char *message_hex_string, int padding_mode, int digest,
|
||||
|
||||
TEST_ASSERT( rsa_pkcs1_verify( &ctx, NULL, NULL, RSA_PUBLIC, digest, 0, hash_result, result_str ) == result );
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -175,6 +177,7 @@ void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
@ -227,6 +230,7 @@ void rsa_pkcs1_verify_raw( char *message_hex_string, char *hash_result_string,
|
||||
TEST_ASSERT( ok == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -266,6 +270,7 @@ void rsa_pkcs1_encrypt( char *message_hex_string, int padding_mode, int mod,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -303,6 +308,7 @@ void rsa_pkcs1_encrypt_bad_rng( char *message_hex_string, int padding_mode,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -357,6 +363,7 @@ void rsa_pkcs1_decrypt( char *message_hex_string, int padding_mode, int mod,
|
||||
TEST_ASSERT( strncasecmp( (char *) output_str, result_hex_str, strlen( result_hex_str ) ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
@ -395,6 +402,7 @@ void rsa_public( char *message_hex_string, int mod, int radix_N, char *input_N,
|
||||
|
||||
/* And now with the copy */
|
||||
TEST_ASSERT( rsa_copy( &ctx2, &ctx ) == 0 );
|
||||
/* clear the original to be sure */
|
||||
rsa_free( &ctx );
|
||||
|
||||
TEST_ASSERT( rsa_check_pubkey( &ctx2 ) == 0 );
|
||||
@ -409,6 +417,8 @@ void rsa_public( char *message_hex_string, int mod, int radix_N, char *input_N,
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
rsa_free( &ctx2 );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -470,6 +480,7 @@ void rsa_private( char *message_hex_string, int mod, int radix_P, char *input_P,
|
||||
|
||||
/* And now one more time with the copy */
|
||||
TEST_ASSERT( rsa_copy( &ctx2, &ctx ) == 0 );
|
||||
/* clear the original to be sure */
|
||||
rsa_free( &ctx );
|
||||
|
||||
TEST_ASSERT( rsa_check_privkey( &ctx2 ) == 0 );
|
||||
@ -486,8 +497,9 @@ void rsa_private( char *message_hex_string, int mod, int radix_P, char *input_P,
|
||||
result_hex_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||
rsa_free( &ctx2 );
|
||||
rsa_free( &ctx ); rsa_free( &ctx2 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -520,6 +532,7 @@ void rsa_check_pubkey( int radix_N, char *input_N, int radix_E, char *input_E,
|
||||
|
||||
TEST_ASSERT( rsa_check_pubkey( &ctx ) == result );
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -572,6 +585,7 @@ void rsa_check_privkey( int mod, int radix_P, char *input_P, int radix_Q,
|
||||
|
||||
TEST_ASSERT( rsa_check_privkey( &ctx ) == result );
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -596,6 +610,7 @@ void rsa_gen_key( int nrbits, int exponent, int result)
|
||||
TEST_ASSERT( rsa_check_privkey( &ctx ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
rsa_free( &ctx );
|
||||
ctr_drbg_free( &ctr_drbg );
|
||||
entropy_free( &entropy );
|
||||
|
@ -45,12 +45,13 @@ void x509_cert_info( char *crt_file, char *result_str )
|
||||
TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
res = x509_crt_info( buf, 2000, "", &crt );
|
||||
|
||||
x509_crt_free( &crt );
|
||||
|
||||
TEST_ASSERT( res != -1 );
|
||||
TEST_ASSERT( res != -2 );
|
||||
|
||||
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -67,12 +68,13 @@ void x509_crl_info( char *crl_file, char *result_str )
|
||||
TEST_ASSERT( x509_crl_parse_file( &crl, crl_file ) == 0 );
|
||||
res = x509_crl_info( buf, 2000, "", &crl );
|
||||
|
||||
x509_crl_free( &crl );
|
||||
|
||||
TEST_ASSERT( res != -1 );
|
||||
TEST_ASSERT( res != -2 );
|
||||
|
||||
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
x509_crl_free( &crl );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -89,12 +91,13 @@ void x509_csr_info( char *csr_file, char *result_str )
|
||||
TEST_ASSERT( x509_csr_parse_file( &csr, csr_file ) == 0 );
|
||||
res = x509_csr_info( buf, 2000, "", &csr );
|
||||
|
||||
x509_csr_free( &csr );
|
||||
|
||||
TEST_ASSERT( res != -1 );
|
||||
TEST_ASSERT( res != -2 );
|
||||
|
||||
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
x509_csr_free( &csr );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -133,12 +136,13 @@ void x509_verify( char *crt_file, char *ca_file, char *crl_file,
|
||||
|
||||
res = x509_crt_verify( &crt, &ca, &crl, cn_name, &flags, f_vrfy, NULL );
|
||||
|
||||
TEST_ASSERT( res == ( result ) );
|
||||
TEST_ASSERT( flags == ( flags_result ) );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
x509_crt_free( &ca );
|
||||
x509_crl_free( &crl );
|
||||
|
||||
TEST_ASSERT( res == ( result ) );
|
||||
TEST_ASSERT( flags == ( flags_result ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -160,12 +164,13 @@ void x509_dn_gets( char *crt_file, char *entity, char *result_str )
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
x509_crt_free( &crt );
|
||||
|
||||
TEST_ASSERT( res != -1 );
|
||||
TEST_ASSERT( res != -2 );
|
||||
|
||||
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -185,6 +190,7 @@ void x509_time_expired( char *crt_file, char *entity, int result )
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -205,6 +211,7 @@ void x509_time_future( char *crt_file, char *entity, int result )
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -234,6 +241,7 @@ void x509parse_crt( char *crt_data, char *result_str, int result )
|
||||
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -263,6 +271,7 @@ void x509parse_crl( char *crl_data, char *result_str, int result )
|
||||
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
x509_crl_free( &crl );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -271,7 +280,7 @@ void x509parse_crl( char *crl_data, char *result_str, int result )
|
||||
void x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret )
|
||||
{
|
||||
x509_csr csr;
|
||||
unsigned char *csr_der;
|
||||
unsigned char *csr_der = NULL;
|
||||
char my_out[1000];
|
||||
size_t csr_der_len;
|
||||
int my_ret;
|
||||
@ -290,6 +299,7 @@ void x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret )
|
||||
TEST_ASSERT( strcmp( my_out, ref_out ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
x509_csr_free( &csr );
|
||||
polarssl_free( csr_der );
|
||||
}
|
||||
@ -312,6 +322,7 @@ void x509_crt_parse_path( char *crt_path, int ret, int nb_crt )
|
||||
|
||||
TEST_ASSERT( i == nb_crt );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &chain );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -378,6 +389,7 @@ void x509_check_key_usage( char *crt_file, int usage, int ret )
|
||||
|
||||
TEST_ASSERT( x509_crt_check_key_usage( &crt, usage ) == ret );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -397,6 +409,7 @@ void x509_check_extended_key_usage( char *crt_file, char *usage_hex, int ret )
|
||||
|
||||
TEST_ASSERT( x509_crt_check_extended_key_usage( &crt, oid, len ) == ret );
|
||||
|
||||
exit:
|
||||
x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
@ -428,6 +441,7 @@ void x509_parse_rsassa_pss_params( char *hex_params, int params_tag,
|
||||
TEST_ASSERT( my_salt_len == ref_salt_len );
|
||||
}
|
||||
|
||||
exit:
|
||||
polarssl_free( params.p );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -52,6 +52,7 @@ void x509_csr_check( char *key_file, char *cert_req_check_file,
|
||||
TEST_ASSERT( olen >= pem_len - 1 );
|
||||
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
||||
|
||||
exit:
|
||||
x509write_csr_free( &req );
|
||||
pk_free( &key );
|
||||
}
|
||||
@ -124,6 +125,7 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
||||
TEST_ASSERT( olen >= pem_len - 1 );
|
||||
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
||||
|
||||
exit:
|
||||
x509write_crt_free( &crt );
|
||||
pk_free( &issuer_key );
|
||||
pk_free( &subject_key );
|
||||
|
Loading…
Reference in New Issue
Block a user