Add test scenario

This commit is contained in:
mohammad1603 2018-05-09 02:26:51 -07:00 committed by itayzafrir
parent dad36fa855
commit bdd892aef5
2 changed files with 13 additions and 7 deletions

View file

@ -120,3 +120,6 @@ sign_fail:PSA_KEY_TYPE_ECC_KEYPAIR(PSA_KEY_TYPE_ECC_CURVE_NISTP256R1):"307802010
PSA verify ECDSA SECP256R1 SHA-256
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"
PSA AEAD Encrypt-Decrypt, first scenario
aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"0C0D0E0F101112131415161718191A1B1C1D1E":"000102030405060708090A0B"

View file

@ -577,7 +577,7 @@ exit:
/* BEGIN_CASE */
void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
int alg_arg, char * input_hex,
cahr* additional_data, int additional_data_length )
char * add_data )
{
int slot = 1;
psa_key_type_t key_type = key_type_arg;
@ -590,16 +590,20 @@ void aead_encrypt_decrypt( int key_type_arg, char *key_hex,
size_t output_length;
unsigned char *output_data2 = NULL;
size_t output_length2;
psa_status_t actual_status;
uint8_t nonce[16];
size_t nonce_length = 16;
size_t tag_length = 16;
unsigned char *additional_data = NULL;
size_t additional_data_length = 0;
size_t i = 0;
key_data = unhexify_alloc( key_hex, &key_size );
TEST_ASSERT( key_data != NULL );
input_data = unhexify_alloc( input_hex, &input_size );
TEST_ASSERT( input_data != NULL );
additional_data = unhexify_alloc( add_data, &additional_data_length );
TEST_ASSERT( input_data != NULL );
output_data = mbedtls_calloc( 1, input_size + tag_length );
TEST_ASSERT( output_data != NULL );
if( alg == PSA_ALG_CCM )
@ -607,7 +611,7 @@ void aead_encrypt_decrypt( int key_type_arg, char *key_hex,
nonce_length = 12;
}
for( int i = 0; i < nonce_length; ++nonce_length )
for( ; i < nonce_length; ++nonce_length )
nonce[i] = i;
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
@ -630,7 +634,7 @@ void aead_encrypt_decrypt( int key_type_arg, char *key_hex,
output_data, output_length - tag_length, output_data2,
output_length, &output_length2 ) == PSA_SUCCESS );
TEST_ASSERT( memcmp( input, output_data2,
TEST_ASSERT( memcmp( input_data, output_data2,
input_size ) == 0 );
@ -638,7 +642,6 @@ exit:
psa_destroy_key( slot );
mbedtls_free( key_data );
mbedtls_free( input_data );
mbedtls_free( signature );
mbedtls_psa_crypto_free( );
}
/* END_CASE */