mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-12 12:05:29 +00:00
Add more test scenario for GCM and failure cases
This commit is contained in:
parent
5c8845f563
commit
f07db2e919
|
@ -121,5 +121,20 @@ PSA verify ECDSA SECP256R1 SHA-256
|
||||||
depends_on:MBEDTLS_PK_C:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
depends_on:MBEDTLS_PK_C:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||||
asymmetric_verify:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"3078020101042100ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3aa00a06082a8648ce3d030107a14403420004dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_SHA_256:"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":"304502206a3399f69421ffe1490377adf2ea1f117d81a63cf5bf22e918d51175eb259151022100ce95d7c26cc04e25503e2f7a1ec3573e3c2412534bb4a19b3a7811742f49f50f"
|
asymmetric_verify:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"3078020101042100ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3aa00a06082a8648ce3d030107a14403420004dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_SHA_256:"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":"304502206a3399f69421ffe1490377adf2ea1f117d81a63cf5bf22e918d51175eb259151022100ce95d7c26cc04e25503e2f7a1ec3573e3c2412534bb4a19b3a7811742f49f50f"
|
||||||
|
|
||||||
PSA AEAD Encrypt-Decrypt, first scenario
|
PSA AEAD Encrypt-Decrypt, AES CCM scenario 1
|
||||||
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B"
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES CCM scenario 2
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES GCM scenario 1
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, AES GCM scenario 2
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"EC46BB63B02520C33C49FD70":PSA_SUCCESS
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid key type
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_DES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"B96B49E21D621741632875DB7F6C9243D2D7C2":"EC46BB63B02520C33C49FD70":PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
|
||||||
|
PSA AEAD Encrypt-Decrypt, Fail Scenario - Invalid algorithm
|
||||||
|
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"B96B49E21D621741632875DB7F6C9243D2D7C2":"EC46BB63B02520C33C49FD70":PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
|
|
@ -577,7 +577,7 @@ exit:
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
||||||
int alg_arg, char * input_hex,
|
int alg_arg, char * input_hex,
|
||||||
char * add_data )
|
char * add_data, int expected_result )
|
||||||
{
|
{
|
||||||
int slot = 1;
|
int slot = 1;
|
||||||
psa_key_type_t key_type = key_type_arg;
|
psa_key_type_t key_type = key_type_arg;
|
||||||
|
@ -625,7 +625,7 @@ void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
||||||
nonce, nonce_length,
|
nonce, nonce_length,
|
||||||
additional_data, additional_data_length,
|
additional_data, additional_data_length,
|
||||||
input_data, input_size, output_data,
|
input_data, input_size, output_data,
|
||||||
output_size, &output_length ) == PSA_SUCCESS );
|
output_size, &output_length ) == ( psa_status_t )expected_result );
|
||||||
|
|
||||||
output_data2 = mbedtls_calloc( 1, output_length );
|
output_data2 = mbedtls_calloc( 1, output_length );
|
||||||
TEST_ASSERT( output_data2 != NULL );
|
TEST_ASSERT( output_data2 != NULL );
|
||||||
|
@ -634,16 +634,21 @@ void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
|
||||||
nonce, nonce_length,
|
nonce, nonce_length,
|
||||||
additional_data, additional_data_length,
|
additional_data, additional_data_length,
|
||||||
output_data, output_length - tag_length, output_data2,
|
output_data, output_length - tag_length, output_data2,
|
||||||
output_length, &output_length2 ) == PSA_SUCCESS );
|
output_length, &output_length2 ) == ( psa_status_t )expected_result );
|
||||||
|
|
||||||
|
if( expected_result == 0 )
|
||||||
|
{
|
||||||
TEST_ASSERT( memcmp( input_data, output_data2,
|
TEST_ASSERT( memcmp( input_data, output_data2,
|
||||||
input_size ) == 0 );
|
input_size ) == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
psa_destroy_key( slot );
|
psa_destroy_key( slot );
|
||||||
mbedtls_free( key_data );
|
mbedtls_free( key_data );
|
||||||
mbedtls_free( input_data );
|
mbedtls_free( input_data );
|
||||||
|
mbedtls_free( additional_data );
|
||||||
|
mbedtls_free( output_data );
|
||||||
mbedtls_psa_crypto_free( );
|
mbedtls_psa_crypto_free( );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
Loading…
Reference in a new issue