Cleaner test-memory cleanups

This commit is contained in:
Paul Bakker 2013-01-03 11:33:48 +01:00
parent 02303e8be4
commit 58ef6ec613
4 changed files with 37 additions and 0 deletions

View File

@ -39,6 +39,8 @@ debug_print_crt:crt_file:file:line:prefix:result_str
debug_print_crt( &ssl, 0, {file}, {line}, {prefix}, &crt);
TEST_ASSERT( strcmp( buffer.buf, {result_str} ) == 0 );
x509_free( &crt );
}
END_CASE

View File

@ -47,6 +47,8 @@ pkcs1_rsaes_oaep_encrypt:mod:radix_N:input_N:radix_E:input_E:hash:message_hex_st
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
}
rsa_free( &ctx );
}
END_CASE
@ -95,6 +97,7 @@ pkcs1_rsaes_oaep_decrypt:mod:radix_P:input_P:radix_Q:input_Q:radix_N:input_N:rad
}
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -190,6 +193,7 @@ pkcs1_rsassa_pss_sign:mod:radix_P:input_P:radix_Q:input_Q:radix_N:input_N:radix_
}
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -257,5 +261,7 @@ pkcs1_rsassa_pss_verify:mod:radix_N:input_N:radix_E:input_E:digest:hash:message_
}
TEST_ASSERT( rsa_pkcs1_verify( &ctx, RSA_PUBLIC, {digest}, 0, hash_result, result_str ) == {result} );
rsa_free( &ctx );
}
END_CASE

View File

@ -101,6 +101,7 @@ rsa_pkcs1_sign:message_hex_string:padding_mode:digest:mod:radix_P:input_P:radix_
}
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -168,6 +169,8 @@ rsa_pkcs1_verify:message_hex_string:padding_mode:digest:mod:radix_N:input_N:radi
}
TEST_ASSERT( rsa_pkcs1_verify( &ctx, RSA_PUBLIC, {digest}, 0, hash_result, result_str ) == {result} );
rsa_free( &ctx );
}
END_CASE
@ -218,6 +221,7 @@ rsa_pkcs1_sign_raw:message_hex_string:hash_result_string:padding_mode:mod:radix_
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -246,6 +250,8 @@ rsa_pkcs1_verify_raw:message_hex_string:hash_result_string:padding_mode:mod:radi
unhexify( result_str, {result_hex_str} );
TEST_ASSERT( rsa_pkcs1_verify( &ctx, RSA_PUBLIC, SIG_RSA_RAW, hash_len, hash_result, result_str ) == {correct} );
rsa_free( &ctx );
}
END_CASE
@ -281,6 +287,8 @@ rsa_pkcs1_encrypt:message_hex_string:padding_mode:mod:radix_N:input_N:radix_E:in
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
}
rsa_free( &ctx );
}
END_CASE
@ -313,6 +321,8 @@ rsa_pkcs1_encrypt_bad_rng:message_hex_string:padding_mode:mod:radix_N:input_N:ra
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
}
rsa_free( &ctx );
}
END_CASE
@ -362,6 +372,7 @@ rsa_pkcs1_decrypt:message_hex_string:padding_mode:mod:radix_P:input_P:radix_Q:in
}
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -393,6 +404,8 @@ rsa_public:message_hex_string:mod:radix_N:input_N:radix_E:input_E:result_hex_str
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
}
rsa_free( &ctx );
}
END_CASE
@ -440,6 +453,7 @@ rsa_private:message_hex_string:mod:radix_P:input_P:radix_Q:input_Q:radix_N:input
}
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
rsa_free( &ctx );
}
END_CASE
@ -470,6 +484,8 @@ rsa_check_pubkey:radix_N:input_N:radix_E:input_E:result
}
TEST_ASSERT( rsa_check_pubkey( &ctx ) == {result} );
rsa_free( &ctx );
}
END_CASE
@ -515,6 +531,8 @@ rsa_check_privkey:mod:radix_P:input_P:radix_Q:input_Q:radix_N:input_N:radix_E:in
}
TEST_ASSERT( rsa_check_privkey( &ctx ) == {result} );
rsa_free( &ctx );
}
END_CASE
@ -537,6 +555,8 @@ rsa_gen_key:nrbits:exponent:result
{
TEST_ASSERT( rsa_check_privkey( &ctx ) == 0 );
}
rsa_free( &ctx );
}
END_CASE

View File

@ -60,5 +60,14 @@ x509_cert_req_check:key_file:md_type:cert_req_check_file
TEST_ASSERT( memcmp( c, pem.buf, pem.buflen ) == 0 );
TEST_ASSERT( pem.buflen == (size_t) ret );
while( ( cur = req_name.next ) != NULL )
{
req_name.next = cur->next;
free( cur );
}
rsa_free( &rsa );
pem_free( &pem );
}
END_CASE