mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:45:42 +01:00
exercise_key: support combined key agreement+derivation algorithms
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
8ddced5b1b
commit
9d3706fb7f
@ -623,15 +623,39 @@ static int exercise_key_agreement_key( mbedtls_svc_key_id_t key,
|
||||
psa_algorithm_t alg )
|
||||
{
|
||||
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
|
||||
unsigned char input[1];
|
||||
unsigned char output[1];
|
||||
int ok = 0;
|
||||
psa_algorithm_t kdf_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF( alg );
|
||||
|
||||
if( usage & PSA_KEY_USAGE_DERIVE )
|
||||
{
|
||||
/* We need two keys to exercise key agreement. Exercise the
|
||||
* private key against its own public key. */
|
||||
PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
|
||||
if( PSA_ALG_IS_TLS12_PRF( kdf_alg ) ||
|
||||
PSA_ALG_IS_TLS12_PSK_TO_MS( kdf_alg ) )
|
||||
{
|
||||
PSA_ASSERT( psa_key_derivation_input_bytes(
|
||||
&operation, PSA_KEY_DERIVATION_INPUT_SEED,
|
||||
input, sizeof( input ) ) );
|
||||
}
|
||||
|
||||
PSA_ASSERT( mbedtls_test_psa_key_agreement_with_self( &operation, key ) );
|
||||
|
||||
if( PSA_ALG_IS_TLS12_PRF( kdf_alg ) ||
|
||||
PSA_ALG_IS_TLS12_PSK_TO_MS( kdf_alg ) )
|
||||
{
|
||||
PSA_ASSERT( psa_key_derivation_input_bytes(
|
||||
&operation, PSA_KEY_DERIVATION_INPUT_LABEL,
|
||||
input, sizeof( input ) ) );
|
||||
}
|
||||
else if( PSA_ALG_IS_HKDF( kdf_alg ) )
|
||||
{
|
||||
PSA_ASSERT( psa_key_derivation_input_bytes(
|
||||
&operation, PSA_KEY_DERIVATION_INPUT_INFO,
|
||||
input, sizeof( input ) ) );
|
||||
}
|
||||
PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
|
||||
output,
|
||||
sizeof( output ) ) );
|
||||
|
Loading…
Reference in New Issue
Block a user