From b6bdebde5e1f25a224d3b005fabfde5404dc6ea9 Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Tue, 8 Mar 2022 10:32:18 +0100 Subject: [PATCH] asymmetric_encrypt: handle forced output Signed-off-by: Przemek Stekiel --- ..._suite_psa_crypto_driver_wrappers.function | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function index 84672e2d4..74d6966d0 100644 --- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function +++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function @@ -2159,22 +2159,31 @@ void asymmetric_encrypt( int alg_arg, &output_length ), expected_status_encrypt ); if ( expected_status_encrypt == PSA_SUCCESS ) { - /* Perform sanity checks on the output */ -#if PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY - if( PSA_KEY_TYPE_IS_RSA( key_type ) ) + if( fake_output_encrypt->len > 0 ) { - if( ! sanity_check_rsa_encryption_result( - alg, modulus, private_exponent, - input_data, - output, output_length ) ) - goto exit; + TEST_EQUAL( fake_output_encrypt->len, output_length ); + ASSERT_COMPARE( fake_output_encrypt->x, fake_output_encrypt->len, + output, output_length ); } -#endif else { - (void) modulus; - (void) private_exponent; - TEST_ASSERT( ! "Encryption sanity checks not implemented for this key type" ); + /* Perform sanity checks on the output */ +#if PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + if( PSA_KEY_TYPE_IS_RSA( key_type ) ) + { + if( ! sanity_check_rsa_encryption_result( + alg, modulus, private_exponent, + input_data, + output, output_length ) ) + goto exit; + } + else +#endif + { + (void) modulus; + (void) private_exponent; + TEST_ASSERT( ! "Encryption sanity checks not implemented for this key type" ); + } } } exit: