Rename "generator" to "operation"
Generators are now key derivation operations.
Keep "random generator" intact.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 52c41e7..4c28b80 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -525,7 +525,7 @@
psa_key_usage_t usage,
psa_algorithm_t alg )
{
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
unsigned char label[16] = "This is a label.";
size_t label_length = sizeof( label );
unsigned char seed[16] = "abcdefghijklmnop";
@@ -536,15 +536,15 @@
{
if( PSA_ALG_IS_HKDF( alg ) )
{
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_SALT,
label,
label_length ) );
- PSA_ASSERT( psa_key_derivation_input_key( &generator,
+ PSA_ASSERT( psa_key_derivation_input_key( &operation,
PSA_KEY_DERIVATION_INPUT_SECRET,
handle ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_INFO,
seed,
seed_length ) );
@@ -552,16 +552,16 @@
else
{
// legacy
- PSA_ASSERT( psa_key_derivation( &generator,
+ PSA_ASSERT( psa_key_derivation( &operation,
handle, alg,
label, label_length,
seed, seed_length,
sizeof( output ) ) );
}
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output,
sizeof( output ) ) );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
}
return( 1 );
@@ -572,7 +572,7 @@
/* We need two keys to exercise key agreement. Exercise the
* private key against its own public key. */
-static psa_status_t key_agreement_with_self( psa_key_derivation_operation_t *generator,
+static psa_status_t key_agreement_with_self( psa_key_derivation_operation_t *operation,
psa_key_handle_t handle )
{
psa_key_type_t private_key_type;
@@ -596,7 +596,7 @@
public_key, public_key_length,
&public_key_length ) );
- status = psa_key_derivation_key_agreement( generator, PSA_KEY_DERIVATION_INPUT_SECRET, handle,
+ status = psa_key_derivation_key_agreement( operation, PSA_KEY_DERIVATION_INPUT_SECRET, handle,
public_key, public_key_length );
exit:
mbedtls_free( public_key );
@@ -664,7 +664,7 @@
psa_key_usage_t usage,
psa_algorithm_t alg )
{
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
unsigned char output[1];
int ok = 0;
@@ -672,12 +672,12 @@
{
/* We need two keys to exercise key agreement. Exercise the
* private key against its own public key. */
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( key_agreement_with_self( &generator, handle ) );
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( key_agreement_with_self( &operation, handle ) );
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output,
sizeof( output ) ) );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
}
ok = 1;
@@ -1844,7 +1844,7 @@
{
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_status_t status;
PSA_ASSERT( psa_crypto_init( ) );
@@ -1856,7 +1856,7 @@
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&handle ) );
- status = psa_key_derivation( &generator, handle,
+ status = psa_key_derivation( &operation, handle,
exercise_alg,
NULL, 0,
NULL, 0,
@@ -1868,7 +1868,7 @@
TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -1884,7 +1884,7 @@
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t key_type = key_type_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_status_t status;
PSA_ASSERT( psa_crypto_init( ) );
@@ -1896,8 +1896,8 @@
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&handle ) );
- PSA_ASSERT( psa_key_derivation_setup( &generator, exercise_alg ) );
- status = key_agreement_with_self( &generator, handle );
+ PSA_ASSERT( psa_key_derivation_setup( &operation, exercise_alg ) );
+ status = key_agreement_with_self( &operation, handle );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_DERIVE ) != 0 )
@@ -1906,7 +1906,7 @@
TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -1922,7 +1922,7 @@
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t key_type = key_type_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_status_t status;
PSA_ASSERT( psa_crypto_init( ) );
@@ -1943,7 +1943,7 @@
TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -4009,7 +4009,7 @@
memset( &zero, 0, sizeof( zero ) );
- /* A default generator should not be able to report its capacity. */
+ /* A default operation should not be able to report its capacity. */
TEST_EQUAL( psa_key_derivation_get_capacity( &func, &capacity ),
PSA_ERROR_BAD_STATE );
TEST_EQUAL( psa_key_derivation_get_capacity( &init, &capacity ),
@@ -4017,7 +4017,7 @@
TEST_EQUAL( psa_key_derivation_get_capacity( &zero, &capacity ),
PSA_ERROR_BAD_STATE );
- /* A default generator should be abortable without error. */
+ /* A default operation should be abortable without error. */
PSA_ASSERT( psa_key_derivation_abort(&func) );
PSA_ASSERT( psa_key_derivation_abort(&init) );
PSA_ASSERT( psa_key_derivation_abort(&zero) );
@@ -4038,7 +4038,7 @@
psa_algorithm_t alg = alg_arg;
size_t requested_capacity = requested_capacity_arg;
psa_status_t expected_status = expected_status_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
PSA_ASSERT( psa_crypto_init( ) );
@@ -4050,14 +4050,14 @@
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&handle ) );
- TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
+ TEST_EQUAL( psa_key_derivation( &operation, handle, alg,
salt->x, salt->len,
label->x, label->len,
requested_capacity ),
expected_status );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -4068,7 +4068,7 @@
{
psa_key_handle_t handle = 0;
size_t key_type = PSA_KEY_TYPE_DERIVE;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_algorithm_t alg = PSA_ALG_HKDF( PSA_ALG_SHA_256 );
uint8_t buffer[42];
size_t capacity = sizeof( buffer );
@@ -4088,25 +4088,25 @@
&handle ) );
/* valid key derivation */
- PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, handle, alg,
NULL, 0,
NULL, 0,
capacity ) );
- /* state of generator shouldn't allow additional generation */
- TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
+ /* state of operation shouldn't allow additional generation */
+ TEST_EQUAL( psa_key_derivation( &operation, handle, alg,
NULL, 0,
NULL, 0,
capacity ),
PSA_ERROR_BAD_STATE );
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator, buffer, capacity ) );
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation, buffer, capacity ) );
- TEST_EQUAL( psa_key_derivation_output_bytes( &generator, buffer, capacity ),
+ TEST_EQUAL( psa_key_derivation_output_bytes( &operation, buffer, capacity ),
PSA_ERROR_INSUFFICIENT_DATA );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -4118,24 +4118,24 @@
uint8_t output_buffer[16];
size_t buffer_size = 16;
size_t capacity = 0;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
- TEST_ASSERT( psa_key_derivation_output_bytes( &generator, output_buffer, buffer_size )
+ TEST_ASSERT( psa_key_derivation_output_bytes( &operation, output_buffer, buffer_size )
== PSA_ERROR_BAD_STATE );
- TEST_ASSERT( psa_key_derivation_get_capacity( &generator, &capacity )
+ TEST_ASSERT( psa_key_derivation_get_capacity( &operation, &capacity )
== PSA_ERROR_BAD_STATE );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
- TEST_ASSERT( psa_key_derivation_output_bytes( &generator, output_buffer, buffer_size )
+ TEST_ASSERT( psa_key_derivation_output_bytes( &operation, output_buffer, buffer_size )
== PSA_ERROR_BAD_STATE );
- TEST_ASSERT( psa_key_derivation_get_capacity( &generator, &capacity )
+ TEST_ASSERT( psa_key_derivation_get_capacity( &operation, &capacity )
== PSA_ERROR_BAD_STATE );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
}
/* END_CASE */
@@ -4151,7 +4151,7 @@
psa_key_handle_t handle = 0;
psa_algorithm_t alg = alg_arg;
size_t requested_capacity = requested_capacity_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
uint8_t *expected_outputs[2] =
{expected_output1->x, expected_output2->x};
size_t output_sizes[2] =
@@ -4184,28 +4184,28 @@
/* Extraction phase. */
if( PSA_ALG_IS_HKDF( alg ) )
{
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( psa_key_derivation_set_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( psa_key_derivation_set_capacity( &operation,
requested_capacity ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_SALT,
salt->x, salt->len ) );
- PSA_ASSERT( psa_key_derivation_input_key( &generator,
+ PSA_ASSERT( psa_key_derivation_input_key( &operation,
PSA_KEY_DERIVATION_INPUT_SECRET,
handle ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_INFO,
label->x, label->len ) );
}
else
{
// legacy
- PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, handle, alg,
salt->x, salt->len,
label->x, label->len,
requested_capacity ) );
}
- PSA_ASSERT( psa_key_derivation_get_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
¤t_capacity ) );
TEST_EQUAL( current_capacity, requested_capacity );
expected_capacity = requested_capacity;
@@ -4214,7 +4214,7 @@
for( i = 0; i < ARRAY_LENGTH( expected_outputs ); i++ )
{
/* Read some bytes. */
- status = psa_key_derivation_output_bytes( &generator,
+ status = psa_key_derivation_output_bytes( &operation,
output_buffer, output_sizes[i] );
if( expected_capacity == 0 && output_sizes[i] == 0 )
{
@@ -4236,17 +4236,17 @@
if( output_sizes[i] != 0 )
ASSERT_COMPARE( output_buffer, output_sizes[i],
expected_outputs[i], output_sizes[i] );
- /* Check the generator status. */
+ /* Check the operation status. */
expected_capacity -= output_sizes[i];
- PSA_ASSERT( psa_key_derivation_get_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
¤t_capacity ) );
TEST_EQUAL( expected_capacity, current_capacity );
}
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
exit:
mbedtls_free( output_buffer );
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -4262,7 +4262,7 @@
psa_key_handle_t handle = 0;
psa_algorithm_t alg = alg_arg;
size_t requested_capacity = requested_capacity_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
unsigned char output_buffer[16];
size_t expected_capacity = requested_capacity;
size_t current_capacity;
@@ -4280,28 +4280,28 @@
/* Extraction phase. */
if( PSA_ALG_IS_HKDF( alg ) )
{
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( psa_key_derivation_set_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( psa_key_derivation_set_capacity( &operation,
requested_capacity ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_SALT,
salt->x, salt->len ) );
- PSA_ASSERT( psa_key_derivation_input_key( &generator,
+ PSA_ASSERT( psa_key_derivation_input_key( &operation,
PSA_KEY_DERIVATION_INPUT_SECRET,
handle ) );
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_INFO,
label->x, label->len ) );
}
else
{
// legacy
- PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, handle, alg,
salt->x, salt->len,
label->x, label->len,
requested_capacity ) );
}
- PSA_ASSERT( psa_key_derivation_get_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
¤t_capacity ) );
TEST_EQUAL( current_capacity, expected_capacity );
@@ -4311,23 +4311,23 @@
size_t read_size = sizeof( output_buffer );
if( read_size > current_capacity )
read_size = current_capacity;
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output_buffer,
read_size ) );
expected_capacity -= read_size;
- PSA_ASSERT( psa_key_derivation_get_capacity( &generator,
+ PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
¤t_capacity ) );
TEST_EQUAL( current_capacity, expected_capacity );
}
- /* Check that the generator refuses to go over capacity. */
- TEST_EQUAL( psa_key_derivation_output_bytes( &generator, output_buffer, 1 ),
+ /* Check that the operation refuses to go over capacity. */
+ TEST_EQUAL( psa_key_derivation_output_bytes( &operation, output_buffer, 1 ),
PSA_ERROR_INSUFFICIENT_DATA );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
}
@@ -4351,7 +4351,7 @@
psa_key_usage_t derived_usage = derived_usage_arg;
psa_algorithm_t derived_alg = derived_alg_arg;
size_t capacity = PSA_BITS_TO_BYTES( derived_bits );
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -4364,7 +4364,7 @@
&base_handle ) );
/* Derive a key. */
- PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, base_handle, alg,
salt->x, salt->len,
label->x, label->len,
capacity ) );
@@ -4372,7 +4372,7 @@
psa_set_key_algorithm( &attributes, derived_alg );
psa_set_key_type( &attributes, derived_type );
psa_set_key_bits( &attributes, derived_bits );
- PSA_ASSERT( psa_key_derivation_output_key( &attributes, &generator,
+ PSA_ASSERT( psa_key_derivation_output_key( &attributes, &operation,
&derived_handle ) );
/* Test the key information */
@@ -4385,7 +4385,7 @@
goto exit;
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_reset_key_attributes( &got_attributes );
psa_destroy_key( base_handle );
psa_destroy_key( derived_handle );
@@ -4407,7 +4407,7 @@
size_t bytes1 = bytes1_arg;
size_t bytes2 = bytes2_arg;
size_t capacity = bytes1 + bytes2;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
uint8_t *output_buffer = NULL;
uint8_t *export_buffer = NULL;
psa_key_attributes_t base_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -4425,17 +4425,17 @@
&base_handle ) );
/* Derive some material and output it. */
- PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, base_handle, alg,
salt->x, salt->len,
label->x, label->len,
capacity ) );
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output_buffer,
capacity ) );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
/* Derive the same output again, but this time store it in key objects. */
- PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ PSA_ASSERT( psa_key_derivation( &operation, base_handle, alg,
salt->x, salt->len,
label->x, label->len,
capacity ) );
@@ -4443,7 +4443,7 @@
psa_set_key_algorithm( &derived_attributes, 0 );
psa_set_key_type( &derived_attributes, PSA_KEY_TYPE_RAW_DATA );
psa_set_key_bits( &derived_attributes, PSA_BYTES_TO_BITS( bytes1 ) );
- PSA_ASSERT( psa_key_derivation_output_key( &derived_attributes, &generator,
+ PSA_ASSERT( psa_key_derivation_output_key( &derived_attributes, &operation,
&derived_handle ) );
PSA_ASSERT( psa_export_key( derived_handle,
export_buffer, bytes1,
@@ -4451,7 +4451,7 @@
TEST_EQUAL( length, bytes1 );
PSA_ASSERT( psa_destroy_key( derived_handle ) );
psa_set_key_bits( &derived_attributes, PSA_BYTES_TO_BITS( bytes2 ) );
- PSA_ASSERT( psa_key_derivation_output_key( &derived_attributes, &generator,
+ PSA_ASSERT( psa_key_derivation_output_key( &derived_attributes, &operation,
&derived_handle ) );
PSA_ASSERT( psa_export_key( derived_handle,
export_buffer + bytes1, bytes2,
@@ -4465,7 +4465,7 @@
exit:
mbedtls_free( output_buffer );
mbedtls_free( export_buffer );
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( base_handle );
psa_destroy_key( derived_handle );
mbedtls_psa_crypto_free( );
@@ -4481,7 +4481,7 @@
psa_key_handle_t our_key = 0;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t expected_status = expected_status_arg;
psa_status_t status;
@@ -4499,10 +4499,10 @@
* Test cases that fail at the setup step should be changed to call
* key_derivation_setup instead, and this function should be renamed
* to key_agreement_fail. */
- status = psa_key_derivation_setup( &generator, alg );
+ status = psa_key_derivation_setup( &operation, alg );
if( status == PSA_SUCCESS )
{
- TEST_EQUAL( psa_key_derivation_key_agreement( &generator, PSA_KEY_DERIVATION_INPUT_SECRET,
+ TEST_EQUAL( psa_key_derivation_key_agreement( &operation, PSA_KEY_DERIVATION_INPUT_SECRET,
our_key,
peer_key_data->x, peer_key_data->len ),
expected_status );
@@ -4513,7 +4513,7 @@
}
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( our_key );
mbedtls_psa_crypto_free( );
}
@@ -4565,7 +4565,7 @@
psa_key_handle_t our_key = 0;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
size_t actual_capacity;
unsigned char output[16];
@@ -4579,37 +4579,37 @@
our_key_data->x, our_key_data->len,
&our_key ) );
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( psa_key_derivation_key_agreement( &generator, PSA_KEY_DERIVATION_INPUT_SECRET,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( psa_key_derivation_key_agreement( &operation, PSA_KEY_DERIVATION_INPUT_SECRET,
our_key,
peer_key_data->x, peer_key_data->len ) );
if( PSA_ALG_IS_HKDF( PSA_ALG_KEY_AGREEMENT_GET_KDF( alg ) ) )
{
/* The test data is for info="" */
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_INFO,
NULL, 0 ) );
}
/* Test the advertized capacity. */
PSA_ASSERT( psa_key_derivation_get_capacity(
- &generator, &actual_capacity ) );
+ &operation, &actual_capacity ) );
TEST_EQUAL( actual_capacity, (size_t) expected_capacity_arg );
/* Test the actual capacity by reading the output. */
while( actual_capacity > sizeof( output ) )
{
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output, sizeof( output ) ) );
actual_capacity -= sizeof( output );
}
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
output, actual_capacity ) );
- TEST_EQUAL( psa_key_derivation_output_bytes( &generator, output, 1 ),
+ TEST_EQUAL( psa_key_derivation_output_bytes( &operation, output, 1 ),
PSA_ERROR_INSUFFICIENT_DATA );
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( our_key );
mbedtls_psa_crypto_free( );
}
@@ -4624,7 +4624,7 @@
psa_key_handle_t our_key = 0;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
uint8_t *actual_output = NULL;
@@ -4640,26 +4640,26 @@
our_key_data->x, our_key_data->len,
&our_key ) );
- PSA_ASSERT( psa_key_derivation_setup( &generator, alg ) );
- PSA_ASSERT( psa_key_derivation_key_agreement( &generator, PSA_KEY_DERIVATION_INPUT_SECRET,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
+ PSA_ASSERT( psa_key_derivation_key_agreement( &operation, PSA_KEY_DERIVATION_INPUT_SECRET,
our_key,
peer_key_data->x, peer_key_data->len ) );
if( PSA_ALG_IS_HKDF( PSA_ALG_KEY_AGREEMENT_GET_KDF( alg ) ) )
{
/* The test data is for info="" */
- PSA_ASSERT( psa_key_derivation_input_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
PSA_KEY_DERIVATION_INPUT_INFO,
NULL, 0 ) );
}
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
actual_output,
expected_output1->len ) );
ASSERT_COMPARE( actual_output, expected_output1->len,
expected_output1->x, expected_output1->len );
if( expected_output2->len != 0 )
{
- PSA_ASSERT( psa_key_derivation_output_bytes( &generator,
+ PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
actual_output,
expected_output2->len ) );
ASSERT_COMPARE( actual_output, expected_output2->len,
@@ -4667,7 +4667,7 @@
}
exit:
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( our_key );
mbedtls_psa_crypto_free( );
mbedtls_free( actual_output );
@@ -4886,7 +4886,7 @@
size_t bits = bits_arg;
psa_key_usage_t usage_flags = usage_flags_arg;
psa_algorithm_t alg = alg_arg;
- psa_key_derivation_operation_t generator = PSA_KEY_DERIVATION_OPERATION_INIT;
+ psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
unsigned char *first_export = NULL;
unsigned char *second_export = NULL;
size_t export_size = PSA_KEY_EXPORT_MAX_SIZE( type, bits );
@@ -4933,16 +4933,16 @@
data->x, data->len,
&base_key ) );
/* Derive a key. */
- PSA_ASSERT( psa_key_derivation_setup( &generator, derive_alg ) );
- PSA_ASSERT( psa_key_derivation_input_key( &generator,
+ PSA_ASSERT( psa_key_derivation_setup( &operation, derive_alg ) );
+ PSA_ASSERT( psa_key_derivation_input_key( &operation,
PSA_KEY_DERIVATION_INPUT_SECRET,
base_key ) );
PSA_ASSERT( psa_key_derivation_input_bytes(
- &generator, PSA_KEY_DERIVATION_INPUT_INFO,
+ &operation, PSA_KEY_DERIVATION_INPUT_INFO,
NULL, 0 ) );
- PSA_ASSERT( psa_key_derivation_output_key( &attributes, &generator,
+ PSA_ASSERT( psa_key_derivation_output_key( &attributes, &operation,
&handle ) );
- PSA_ASSERT( psa_key_derivation_abort( &generator ) );
+ PSA_ASSERT( psa_key_derivation_abort( &operation ) );
PSA_ASSERT( psa_destroy_key( base_key ) );
base_key = 0;
}
@@ -4994,7 +4994,7 @@
psa_reset_key_attributes( &attributes );
mbedtls_free( first_export );
mbedtls_free( second_export );
- psa_key_derivation_abort( &generator );
+ psa_key_derivation_abort( &operation );
psa_destroy_key( base_key );
if( handle == 0 )
{