mirror of
https://github.com/espressif/mbedtls.git
synced 2026-08-13 06:57:46 +00:00
test_suite_psa_crypto: Extended aead_multipart_state_test(2)
This patch adds psa_aead_decrypt_setup() & psa_aead_finish() path to the multipart_state_testing. Signed-off-by: Minos Galanakis <[email protected]>
This commit is contained in:
@@ -6516,6 +6516,34 @@ void aead_multipart_state_test(int key_type_arg, data_t *key_data,
|
||||
tag_buffer, tag_length,
|
||||
&tag_size),
|
||||
PSA_SUCCESS);
|
||||
|
||||
psa_aead_abort(&operation);
|
||||
/* For CCM, verifing without setting lengths must fail. */
|
||||
TEST_EQUAL(psa_aead_verify(&operation, final_data,
|
||||
finish_output_size,
|
||||
&output_part_length,
|
||||
tag_buffer,
|
||||
tag_length),
|
||||
PSA_ERROR_BAD_STATE);
|
||||
|
||||
PSA_ASSERT(psa_aead_decrypt_setup(&operation, key, alg));
|
||||
PSA_ASSERT(psa_aead_set_nonce(&operation, nonce->x, nonce->len));
|
||||
|
||||
PSA_ASSERT(psa_aead_set_lengths(&operation, additional_data->len,
|
||||
input_data->len));
|
||||
PSA_ASSERT(psa_aead_update_ad(&operation, additional_data->x,
|
||||
additional_data->len));
|
||||
PSA_ASSERT(psa_aead_update(&operation, input_data->x,
|
||||
input_data->len, output_data,
|
||||
output_size, &output_length));
|
||||
|
||||
/* Signature verification is expected fail, but after the checks for lengths */
|
||||
TEST_EQUAL(psa_aead_verify(&operation, final_data,
|
||||
finish_output_size,
|
||||
&output_part_length,
|
||||
tag_buffer,
|
||||
tag_length),
|
||||
PSA_ERROR_INVALID_SIGNATURE);
|
||||
} else {
|
||||
PSA_ASSERT(psa_aead_finish(&operation, final_data,
|
||||
finish_output_size,
|
||||
@@ -6611,6 +6639,34 @@ void aead_multipart_state_test(int key_type_arg, data_t *key_data,
|
||||
tag_buffer, tag_length,
|
||||
&tag_size),
|
||||
PSA_SUCCESS);
|
||||
|
||||
psa_aead_abort(&operation);
|
||||
/* For CCM, verifing without setting lengths must fail. */
|
||||
TEST_EQUAL(psa_aead_verify(&operation, final_data,
|
||||
finish_output_size,
|
||||
&output_part_length,
|
||||
tag_buffer,
|
||||
tag_length),
|
||||
PSA_ERROR_BAD_STATE);
|
||||
|
||||
PSA_ASSERT(psa_aead_decrypt_setup(&operation, key, alg));
|
||||
PSA_ASSERT(psa_aead_set_nonce(&operation, nonce->x, nonce->len));
|
||||
|
||||
PSA_ASSERT(psa_aead_set_lengths(&operation, additional_data->len,
|
||||
input_data->len));
|
||||
PSA_ASSERT(psa_aead_update_ad(&operation, additional_data->x,
|
||||
additional_data->len));
|
||||
PSA_ASSERT(psa_aead_update(&operation, input_data->x,
|
||||
input_data->len, output_data,
|
||||
output_size, &output_length));
|
||||
|
||||
/* Signature verification is expected fail, but after the checks for lengths */
|
||||
TEST_EQUAL(psa_aead_verify(&operation, final_data,
|
||||
finish_output_size,
|
||||
&output_part_length,
|
||||
tag_buffer,
|
||||
tag_length),
|
||||
PSA_ERROR_INVALID_SIGNATURE);
|
||||
} else {
|
||||
PSA_ASSERT(psa_aead_finish(&operation, final_data,
|
||||
finish_output_size,
|
||||
|
||||
Reference in New Issue
Block a user