Adapt `rsa_import` tests to weakened semantics of `rsa_complete`
The tests now accept two result parameters, one for the expected result of the
completion call, and one for the expected result of the subsequent sanity
check.
diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function
index 87d15a8..9ee8ea1 100644
--- a/tests/suites/test_suite_rsa.function
+++ b/tests/suites/test_suite_rsa.function
@@ -831,7 +831,8 @@
int radix_E, char *input_E,
int successive,
int is_priv,
- int result )
+ int res_check,
+ int res_complete )
{
mbedtls_mpi N, P, Q, D, E;
mbedtls_rsa_context ctx;
@@ -916,17 +917,19 @@
have_E ? &E : NULL ) == 0 );
}
- TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == result );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == res_complete );
/* On expected success, perform some public and private
* key operations to check if the key is working properly. */
- if( result == 0 )
+ if( res_complete == 0 )
{
- TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
-
- /* Did we expect a full private key to be setup? */
if( is_priv )
- TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == res_check );
+ else
+ TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == res_check );
+
+ if( res_check != 0 )
+ goto exit;
buf_orig = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
buf_enc = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
@@ -1294,7 +1297,8 @@
char *input_D, char *input_E,
int successive,
int is_priv,
- int result )
+ int res_check,
+ int res_complete )
{
unsigned char bufN[1000];
unsigned char bufP[1000];
@@ -1380,17 +1384,19 @@
( lenE > 0 ) ? bufE : NULL, lenE ) == 0 );
}
- TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == result );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == res_complete );
/* On expected success, perform some public and private
* key operations to check if the key is working properly. */
- if( result == 0 )
+ if( res_complete == 0 )
{
- TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
-
- /* Did we expect a full private key to be setup? */
if( is_priv )
- TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == res_check );
+ else
+ TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == res_check );
+
+ if( res_check != 0 )
+ goto exit;
buf_orig = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
buf_enc = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );