initialize length variables and process decrypt only when encrypts passes
@@ -589,9 +589,9 @@ void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
size_t input_size;
unsigned char *output_data = NULL;
size_t output_size = 0;
- size_t output_length;
+ size_t output_length = 0;
unsigned char *output_data2 = NULL;
- size_t output_length2;
+ size_t output_length2 = 0;
uint8_t nonce[16];
size_t nonce_length = 16;
size_t tag_length = 16;
@@ -629,6 +629,8 @@ void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
input_data, input_size, output_data,
output_size, &output_length ) == expected_result );
+ if( PSA_SUCCESS == expected_result )
+ {
output_data2 = mbedtls_calloc( 1, output_length );
TEST_ASSERT( output_data2 != NULL );
@@ -638,8 +640,7 @@ void aead_encrypt_decrypt( int key_type_arg, char * key_hex,
output_data, output_length - tag_length, output_data2,
output_length, &output_length2 ) == expected_result );
- if( PSA_SUCCESS == expected_result )
- {
+
TEST_ASSERT( memcmp( input_data, output_data2,
input_size ) == 0 );
}
