2021-04-27 18:40:10 +00:00
|
|
|
/* BEGIN_HEADER */
|
|
|
|
|
|
|
|
#include "psa/crypto.h"
|
|
|
|
#include "test/psa_crypto_helpers.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* END_HEADER */
|
|
|
|
|
|
|
|
/* BEGIN_DEPENDENCIES
|
|
|
|
* depends_on:MBEDTLS_PSA_CRYPTO_C
|
|
|
|
* END_DEPENDENCIES
|
|
|
|
*/
|
|
|
|
|
2021-04-27 19:03:43 +00:00
|
|
|
/* BEGIN_CASE */
|
|
|
|
void hash_fail( int alg_arg, int expected_status_arg )
|
2021-04-27 18:40:10 +00:00
|
|
|
{
|
2021-04-27 19:03:43 +00:00
|
|
|
psa_status_t expected_status = expected_status_arg;
|
|
|
|
psa_algorithm_t alg = alg_arg;
|
|
|
|
psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT;
|
|
|
|
uint8_t input[1] = {'A'};
|
|
|
|
uint8_t output[PSA_HASH_MAX_SIZE] = {0};
|
|
|
|
size_t length = SIZE_MAX;
|
|
|
|
|
|
|
|
PSA_INIT( );
|
|
|
|
|
|
|
|
TEST_EQUAL( expected_status,
|
|
|
|
psa_hash_setup( &operation, alg ) );
|
|
|
|
TEST_EQUAL( expected_status,
|
|
|
|
psa_hash_compute( alg, input, sizeof( input ),
|
|
|
|
output, sizeof( output ), &length ) );
|
|
|
|
TEST_EQUAL( expected_status,
|
|
|
|
psa_hash_compare( alg, input, sizeof( input ),
|
|
|
|
output, sizeof( output ) ) );
|
|
|
|
|
|
|
|
exit:
|
|
|
|
psa_hash_abort( &operation );
|
|
|
|
PSA_DONE( );
|
2021-04-27 18:40:10 +00:00
|
|
|
}
|
|
|
|
/* END_CASE */
|