From a844b4b3703c86c6cbb260fc2f100be9380a82cd Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 15 Sep 2022 21:05:04 +0200 Subject: [PATCH] No need to use MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED in tests Initializing return status variables to CORRUPTION_DETECTED is a second line of defense in library code in case there's a code path where we forget to assign to the variable. This isn't useful in test code. In any case, here, we might as well define the variable at the point of use. This fixes a build error in configurations with MBEDTLS_ERROR_C and MBEDTLS_PSA_CRYPTO_C both disabled, because then mbedtls/error.h isn't included so MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED isn't defined. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_pkcs12.function | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/suites/test_suite_pkcs12.function b/tests/suites/test_suite_pkcs12.function index 34ef090ba1..06678a9d55 100644 --- a/tests/suites/test_suite_pkcs12.function +++ b/tests/suites/test_suite_pkcs12.function @@ -25,7 +25,6 @@ void pkcs12_derive_key( int md_type, int key_size_arg, data_t* expected_output, int expected_status ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char *output_data = NULL; unsigned char *password = NULL; @@ -46,15 +45,15 @@ void pkcs12_derive_key( int md_type, int key_size_arg, ASSERT_ALLOC( output_data, key_size ); - ret = mbedtls_pkcs12_derivation( output_data, - key_size, - password, - password_len, - salt, - salt_len, - md_type, - MBEDTLS_PKCS12_DERIVE_KEY, - iterations ); + int ret = mbedtls_pkcs12_derivation( output_data, + key_size, + password, + password_len, + salt, + salt_len, + md_type, + MBEDTLS_PKCS12_DERIVE_KEY, + iterations ); TEST_EQUAL( ret, expected_status );