asymmetric_encrypt: handle forced output

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2022-03-08 10:32:18 +01:00
parent d5e5c8b58d
commit b6bdebde5e

View file

@ -2158,6 +2158,14 @@ void asymmetric_encrypt( int alg_arg,
output, output_size, output, output_size,
&output_length ), expected_status_encrypt ); &output_length ), expected_status_encrypt );
if ( expected_status_encrypt == PSA_SUCCESS ) if ( expected_status_encrypt == PSA_SUCCESS )
{
if( fake_output_encrypt->len > 0 )
{
TEST_EQUAL( fake_output_encrypt->len, output_length );
ASSERT_COMPARE( fake_output_encrypt->x, fake_output_encrypt->len,
output, output_length );
}
else
{ {
/* Perform sanity checks on the output */ /* Perform sanity checks on the output */
#if PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY #if PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
@ -2169,14 +2177,15 @@ void asymmetric_encrypt( int alg_arg,
output, output_length ) ) output, output_length ) )
goto exit; goto exit;
} }
#endif
else else
#endif
{ {
(void) modulus; (void) modulus;
(void) private_exponent; (void) private_exponent;
TEST_ASSERT( ! "Encryption sanity checks not implemented for this key type" ); TEST_ASSERT( ! "Encryption sanity checks not implemented for this key type" );
} }
} }
}
exit: exit:
/* /*
* Key attributes may have been returned by psa_get_key_attributes() * Key attributes may have been returned by psa_get_key_attributes()