mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-23 23:05:05 +00:00
tests fix
This commit is contained in:
parent
16864af80b
commit
3205a6592b
|
@ -1425,7 +1425,6 @@ psa_status_t psa_encrypt_generate_iv(psa_cipher_operation_t *operation,
|
||||||
}
|
}
|
||||||
|
|
||||||
*iv_length = operation->iv_size;
|
*iv_length = operation->iv_size;
|
||||||
|
|
||||||
return psa_encrypt_set_iv( operation, iv, *iv_length);
|
return psa_encrypt_set_iv( operation, iv, *iv_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,16 +1475,13 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
|
||||||
size_t *output_length)
|
size_t *output_length)
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE;
|
int ret = MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE;
|
||||||
|
|
||||||
if ( output_size < operation->block_size )
|
|
||||||
return ( PSA_ERROR_BUFFER_TOO_SMALL );
|
|
||||||
|
|
||||||
if( ! operation->key_set )
|
if( ! operation->key_set )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
return( PSA_ERROR_BAD_STATE );
|
||||||
if( ! operation->iv_set )
|
if( ! operation->iv_set )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
return( PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
ret = mbedtls_cipher_finish( &operation->ctx.cipher, output,
|
ret = mbedtls_cipher_finish( &operation->ctx.cipher, output,
|
||||||
output_length );
|
output_length );
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,9 +107,8 @@ key_lifetime_set_fail:1:PSA_KEY_LIFETIME_PERSISTENT+1:PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
|
||||||
PSA Symmetric encryption: AES-128
|
PSA Symmetric encryption: AES-128
|
||||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||||
cipher_test_positive:PSA_ALG_CBC_BASE:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411"
|
cipher_test_positive:PSA_ALG_CBC_BASE:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172a"
|
||||||
|
|
||||||
PSA Symmetric encryption/decryption: AES-128
|
PSA Symmetric encryption/decryption: AES-128
|
||||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
|
||||||
cipher_test_verify_output:PSA_ALG_CBC_BASE:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411"
|
cipher_test_verify_output:PSA_ALG_CBC_BASE:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172a"
|
||||||
|
|
||||||
|
|
|
@ -542,11 +542,12 @@ void cipher_test_positive( int alg_arg, int key_type_arg,
|
||||||
size_t iv_length = 0;
|
size_t iv_length = 0;
|
||||||
unsigned char *input = NULL;
|
unsigned char *input = NULL;
|
||||||
size_t input_size = 0;
|
size_t input_size = 0;
|
||||||
unsigned char *output = NULL;
|
unsigned char *output ;
|
||||||
size_t output_size = 0;
|
size_t output_size = 0;
|
||||||
size_t output_length = 0;
|
size_t output_length = 0;
|
||||||
psa_cipher_operation_t operation;
|
psa_cipher_operation_t operation;
|
||||||
|
|
||||||
|
|
||||||
key = unhexify_alloc( key_hex, &key_size );
|
key = unhexify_alloc( key_hex, &key_size );
|
||||||
TEST_ASSERT( key != NULL );
|
TEST_ASSERT( key != NULL );
|
||||||
|
|
||||||
|
@ -558,20 +559,19 @@ void cipher_test_positive( int alg_arg, int key_type_arg,
|
||||||
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
||||||
key, key_size ) == PSA_SUCCESS );
|
key, key_size ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_decrypt_setup( &operation, key_slot, alg ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_encrypt_setup( &operation, key_slot, alg ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_encrypt_generate_iv( &operation, iv,
|
TEST_ASSERT( psa_encrypt_generate_iv( &operation, iv,
|
||||||
iv_size, &iv_length) == PSA_SUCCESS );
|
iv_size, &iv_length) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_encrypt_set_iv( &operation, iv,
|
output_size = input_size;
|
||||||
iv_length) == PSA_SUCCESS );
|
output = mbedtls_calloc(0, output_size);
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_update( &operation, input, input_size,
|
TEST_ASSERT( psa_cipher_update( &operation, input, input_size,
|
||||||
output, output_size,
|
output, output_size,
|
||||||
&output_length) == PSA_SUCCESS );
|
&output_length) == PSA_SUCCESS );
|
||||||
|
TEST_ASSERT( psa_cipher_finish( &operation, output + output_length,
|
||||||
TEST_ASSERT( psa_cipher_finish( &operation, output + output_length,
|
output_size,
|
||||||
output_size - output_length,
|
|
||||||
&output_length) == PSA_SUCCESS );
|
&output_length) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
|
||||||
|
@ -599,10 +599,10 @@ void cipher_test_verify_output( int alg_arg, int key_type_arg,
|
||||||
size_t iv_length = 0;
|
size_t iv_length = 0;
|
||||||
unsigned char *input = NULL;
|
unsigned char *input = NULL;
|
||||||
size_t input_size = 0;
|
size_t input_size = 0;
|
||||||
unsigned char *output1 = NULL;
|
unsigned char *output1;
|
||||||
size_t output1_size = 0;
|
size_t output1_size = 0;
|
||||||
size_t output1_length = 0;
|
size_t output1_length = 0;
|
||||||
unsigned char *output2 = NULL;
|
unsigned char *output2;
|
||||||
size_t output2_size = 0;
|
size_t output2_size = 0;
|
||||||
size_t output2_length = 0;
|
size_t output2_length = 0;
|
||||||
size_t tmp_output_length = 0;
|
size_t tmp_output_length = 0;
|
||||||
|
@ -620,39 +620,37 @@ void cipher_test_verify_output( int alg_arg, int key_type_arg,
|
||||||
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
||||||
key, key_size ) == PSA_SUCCESS );
|
key, key_size ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_decrypt_setup( &operation1, key_slot, alg ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_encrypt_setup( &operation1, key_slot, alg ) == PSA_SUCCESS );
|
||||||
|
TEST_ASSERT( psa_decrypt_setup( &operation2, key_slot, alg ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_encrypt_generate_iv( &operation1, iv,
|
TEST_ASSERT( psa_encrypt_generate_iv( &operation1, iv,
|
||||||
iv_size, &iv_length) == PSA_SUCCESS );
|
iv_size, &iv_length) == PSA_SUCCESS );
|
||||||
|
output1_size = input_size;
|
||||||
TEST_ASSERT( psa_encrypt_set_iv( &operation1, iv,
|
output1 = mbedtls_calloc(0, output1_size);
|
||||||
iv_length) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_update( &operation1, input, input_size,
|
TEST_ASSERT( psa_cipher_update( &operation1, input, input_size,
|
||||||
output1, output1_size,
|
output1, output1_size,
|
||||||
&output1_length) == PSA_SUCCESS );
|
&output1_length) == PSA_SUCCESS );
|
||||||
|
TEST_ASSERT( psa_cipher_finish( &operation1, output1 + output1_length,
|
||||||
TEST_ASSERT( psa_cipher_finish( &operation1, output1 + output1_length,
|
|
||||||
output1_size - output1_length,
|
output1_size - output1_length,
|
||||||
&tmp_output_length) == PSA_SUCCESS );
|
&tmp_output_length) == PSA_SUCCESS );
|
||||||
|
|
||||||
output1_length += tmp_output_length;
|
output1_length += tmp_output_length;
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_decrypt_setup( &operation2, key_slot, alg ) == PSA_SUCCESS );
|
output2_size = output1_length;
|
||||||
|
output2 = mbedtls_calloc(0, output2_size);
|
||||||
|
|
||||||
TEST_ASSERT( psa_encrypt_set_iv( &operation2, iv,
|
TEST_ASSERT( psa_encrypt_set_iv( &operation2, iv,
|
||||||
iv_length) == PSA_SUCCESS );
|
iv_length) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_update( &operation2, output1, output1_length,
|
TEST_ASSERT( psa_cipher_update( &operation2, output1, output1_length,
|
||||||
output2, output2_size, &output2_length) == PSA_SUCCESS );
|
output2, output2_size, &output2_length) == PSA_SUCCESS );
|
||||||
tmp_output_length = 0;
|
tmp_output_length = 0;
|
||||||
TEST_ASSERT( psa_cipher_finish( &operation2, output2 + output2_length,
|
TEST_ASSERT( psa_cipher_finish( &operation2, output2 + output2_length,
|
||||||
output2_size - output2_length,
|
output2_size - output2_length,
|
||||||
&tmp_output_length) == PSA_SUCCESS );
|
&tmp_output_length) == PSA_SUCCESS );
|
||||||
|
|
||||||
output2_length += tmp_output_length;
|
output2_length += tmp_output_length;
|
||||||
|
|
||||||
TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue