Simplification of the tests
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
diff --git a/tests/include/test/macros.h b/tests/include/test/macros.h
index a8a01ce..df961aa 100644
--- a/tests/include/test/macros.h
+++ b/tests/include/test/macros.h
@@ -58,9 +58,6 @@
* It allows a library function to return a value and return an error
* code that can be tested.
*
- * This macro is not suitable for negative parameter validation tests,
- * as it assumes the test step will not create an error.
- *
* Failing the test means:
* - Mark this test case as failed.
* - Print a message identifying the failure.
diff --git a/tests/src/helpers.c b/tests/src/helpers.c
index ece0465..cac6d4c 100644
--- a/tests/src/helpers.c
+++ b/tests/src/helpers.c
@@ -204,15 +204,6 @@
return ret;
}
-void mbedtls_param_failed( const char *failure_condition,
- const char *file,
- int line )
-{
- (void) failure_condition;
- (void) file;
- (void) line;
-}
-
#if defined(MBEDTLS_TEST_HOOKS)
void mbedtls_test_err_add_check( int high, int low,
const char *file, int line )
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index 13d032c..491de6d 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -159,31 +159,6 @@
};
/**
- * \brief Execute the test function.
- *
- * This is a wrapper function around the test function execution
- * to allow the setjmp() call used to catch any calls to the
- * parameter failure callback, to be used. Calls to setjmp()
- * can invalidate the state of any local auto variables.
- *
- * \param fp Function pointer to the test function.
- * \param params Parameters to pass to the #TestWrapper_t wrapper function.
- *
- */
-void execute_function_ptr(TestWrapper_t fp, void **params)
-{
-#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
- mbedtls_test_enable_insecure_external_rng( );
-#endif
-
- fp( params );
-
-#if defined(MBEDTLS_TEST_MUTEX_USAGE)
- mbedtls_test_mutex_usage_check( );
-#endif /* MBEDTLS_TEST_MUTEX_USAGE */
-}
-
-/**
* \brief Dispatches test functions based on function index.
*
* \param func_idx Test function index.
@@ -203,7 +178,17 @@
{
fp = test_funcs[func_idx];
if ( fp )
- execute_function_ptr(fp, params);
+ {
+ #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
+ mbedtls_test_enable_insecure_external_rng( );
+ #endif
+
+ fp( params );
+
+ #if defined(MBEDTLS_TEST_MUTEX_USAGE)
+ mbedtls_test_mutex_usage_check( );
+ #endif /* MBEDTLS_TEST_MUTEX_USAGE */
+ }
else
ret = DISPATCH_UNSUPPORTED_SUITE;
}
diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function
index 2ef8f5f..674349f 100644
--- a/tests/suites/test_suite_cipher.function
+++ b/tests/suites/test_suite_cipher.function
@@ -213,15 +213,12 @@
mbedtls_cipher_context_t valid_ctx;
mbedtls_operation_t invalid_operation = 100;
- mbedtls_cipher_padding_t valid_mode = MBEDTLS_PADDING_ZEROS;
unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
int valid_size = sizeof(valid_buffer);
int valid_bitlen = valid_size * 8;
const mbedtls_cipher_info_t *valid_info = mbedtls_cipher_info_from_type(
*( mbedtls_cipher_list() ) );
- (void)valid_mode; /* In some configurations this is unused */
-
TEST_EQUAL(
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
mbedtls_cipher_setkey( &valid_ctx,
diff --git a/tests/suites/test_suite_rsa.data b/tests/suites/test_suite_rsa.data
index 2512ef2..cc5a047 100644
--- a/tests/suites/test_suite_rsa.data
+++ b/tests/suites/test_suite_rsa.data
@@ -1,3 +1,6 @@
+RSA parameter validation
+rsa_invalid_param:
+
RSA init-free-free
rsa_init_free:0
diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function
index 9cf2fcf..bc5036c 100644
--- a/tests/suites/test_suite_rsa.function
+++ b/tests/suites/test_suite_rsa.function
@@ -17,6 +17,25 @@
* END_DEPENDENCIES
*/
+/* BEGIN_CASE depends_on:NOT_DEFINED */
+void rsa_invalid_param( )
+{
+ mbedtls_rsa_context ctx;
+ const int valid_padding = MBEDTLS_RSA_PKCS_V21;
+ const int invalid_padding = 42;
+ unsigned char buf[42] = { 0 };
+ size_t olen;
+
+ TEST_INVALID_PARAM( mbedtls_rsa_init( &ctx, invalid_padding, 0 ) );
+
+ TEST_INVALID_PARAM( mbedtls_rsa_set_padding( &ctx,
+ invalid_padding, 0 ) );
+
+exit:
+ return;
+}
+/* END_CASE */
+
/* BEGIN_CASE */
void rsa_init_free( int reinit )
{