mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-06-02 02:33:51 +08:00
Add Multipart Hash Compute fail tests
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
edb20865c7
commit
161ec5c368
@ -1852,6 +1852,7 @@ void hash_compute_fail( int alg_arg, data_t *input,
|
|||||||
uint8_t *output = NULL;
|
uint8_t *output = NULL;
|
||||||
size_t output_size = output_size_arg;
|
size_t output_size = output_size_arg;
|
||||||
size_t output_length = INVALID_EXPORT_LENGTH;
|
size_t output_length = INVALID_EXPORT_LENGTH;
|
||||||
|
psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT;
|
||||||
psa_status_t expected_status = expected_status_arg;
|
psa_status_t expected_status = expected_status_arg;
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
|
||||||
@ -1859,12 +1860,38 @@ void hash_compute_fail( int alg_arg, data_t *input,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
|
/* Hash Compute, one-shot */
|
||||||
status = psa_hash_compute( alg, input->x, input->len,
|
status = psa_hash_compute( alg, input->x, input->len,
|
||||||
output, output_size, &output_length );
|
output, output_size, &output_length );
|
||||||
TEST_EQUAL( status, expected_status );
|
TEST_EQUAL( status, expected_status );
|
||||||
TEST_ASSERT( output_length <= output_size );
|
TEST_ASSERT( output_length <= output_size );
|
||||||
|
|
||||||
|
/* Hash Compute, multi-part */
|
||||||
|
status = psa_hash_setup( &operation, alg );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
status = psa_hash_update( &operation, input->x, input->len );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
status = psa_hash_finish( &operation, output, output_size,
|
||||||
|
&output_length );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
TEST_ASSERT( output_length <= output_size );
|
||||||
|
else
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
PSA_ASSERT( psa_hash_abort( &operation ) );
|
||||||
mbedtls_free( output );
|
mbedtls_free( output );
|
||||||
PSA_DONE( );
|
PSA_DONE( );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user