mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 12:35:40 +01:00
Add init-free tests for RSA
These tests are trivial except when compiling with MBEDTLS_THREADING_C and a mutex implementation that are picky about matching each mbedtls_mutex_init() with exactly one mbedtls_mutex_free(). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
7aba036154
commit
914afe1fdb
@ -1,6 +1,12 @@
|
||||
RSA parameter validation
|
||||
rsa_invalid_param:
|
||||
|
||||
RSA init-free-free
|
||||
rsa_init_free:0
|
||||
|
||||
RSA init-free-init-free
|
||||
rsa_init_free:1
|
||||
|
||||
RSA PKCS1 Verify v1.5 CAVS #1
|
||||
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
|
||||
# Good padding but wrong hash
|
||||
|
@ -466,6 +466,29 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void rsa_init_free( int reinit )
|
||||
{
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
/* Double free is not explicitly documented to work, but we rely on it
|
||||
* even inside the library so that you can call mbedtls_rsa_free()
|
||||
* unconditionally on an error path without checking whether it has
|
||||
* already been called in the success path. */
|
||||
|
||||
mbedtls_rsa_init( &ctx, 0, 0 );
|
||||
mbedtls_rsa_free( &ctx );
|
||||
|
||||
if( reinit )
|
||||
mbedtls_rsa_init( &ctx, 0, 0 );
|
||||
mbedtls_rsa_free( &ctx );
|
||||
|
||||
/* This test case always succeeds, functionally speaking. A plausible
|
||||
* bug might trigger an invalid pointer dereference or a memory leak. */
|
||||
goto exit;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
|
||||
int digest, int mod, int radix_P, char * input_P,
|
||||
|
Loading…
Reference in New Issue
Block a user