mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-23 06:41:15 +00:00
Convert derive_full test to the new KDF API
This commit is contained in:
parent
46d9fbc4a9
commit
47f27ed752
|
@ -4340,8 +4340,8 @@ exit:
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void derive_full( int alg_arg,
|
void derive_full( int alg_arg,
|
||||||
data_t *key_data,
|
data_t *key_data,
|
||||||
data_t *salt,
|
data_t *input1,
|
||||||
data_t *label,
|
data_t *input2,
|
||||||
int requested_capacity_arg )
|
int requested_capacity_arg )
|
||||||
{
|
{
|
||||||
psa_key_handle_t handle = 0;
|
psa_key_handle_t handle = 0;
|
||||||
|
@ -4362,33 +4362,41 @@ void derive_full( int alg_arg,
|
||||||
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
||||||
&handle ) );
|
&handle ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
|
||||||
|
PSA_ASSERT( psa_key_derivation_set_capacity( &operation,
|
||||||
|
requested_capacity ) );
|
||||||
|
|
||||||
/* Extraction phase. */
|
/* Extraction phase. */
|
||||||
if( PSA_ALG_IS_HKDF( alg ) )
|
if( PSA_ALG_IS_HKDF( alg ) )
|
||||||
{
|
{
|
||||||
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( &operation,
|
PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
|
||||||
PSA_KEY_DERIVATION_INPUT_SALT,
|
PSA_KEY_DERIVATION_INPUT_SALT,
|
||||||
salt->x, salt->len ) );
|
input1->x, input1->len ) );
|
||||||
PSA_ASSERT( psa_key_derivation_input_key( &operation,
|
PSA_ASSERT( psa_key_derivation_input_key( &operation,
|
||||||
PSA_KEY_DERIVATION_INPUT_SECRET,
|
PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||||
handle ) );
|
handle ) );
|
||||||
PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
|
PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
|
||||||
PSA_KEY_DERIVATION_INPUT_INFO,
|
PSA_KEY_DERIVATION_INPUT_INFO,
|
||||||
label->x, label->len ) );
|
input2->x, input2->len ) );
|
||||||
|
}
|
||||||
|
else if( PSA_ALG_IS_TLS12_PRF( alg ) ||
|
||||||
|
PSA_ALG_IS_TLS12_PSK_TO_MS( alg ) )
|
||||||
|
{
|
||||||
|
PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_SEED,
|
||||||
|
input1->x, input1->len ) );
|
||||||
|
PSA_ASSERT( psa_key_derivation_input_key( &operation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||||
|
handle ) );
|
||||||
|
PSA_ASSERT( psa_key_derivation_input_bytes( &operation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_LABEL,
|
||||||
|
input2->x, input2->len ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PSA_PRE_1_0_KEY_DERIVATION)
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// legacy
|
TEST_ASSERT( ! "Key derivation algorithm not supported" );
|
||||||
PSA_ASSERT( psa_key_derivation( &operation, handle, alg,
|
|
||||||
salt->x, salt->len,
|
|
||||||
label->x, label->len,
|
|
||||||
requested_capacity ) );
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
|
PSA_ASSERT( psa_key_derivation_get_capacity( &operation,
|
||||||
¤t_capacity ) );
|
¤t_capacity ) );
|
||||||
TEST_EQUAL( current_capacity, expected_capacity );
|
TEST_EQUAL( current_capacity, expected_capacity );
|
||||||
|
|
Loading…
Reference in a new issue