mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-04 20:49:52 +00: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_algorithm_t alg )
|
||||||
{
|
{
|
||||||
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
|
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
|
||||||
|
unsigned char input[1];
|
||||||
unsigned char output[1];
|
unsigned char output[1];
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
psa_algorithm_t kdf_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF( alg );
|
||||||
|
|
||||||
if( usage & PSA_KEY_USAGE_DERIVE )
|
if( usage & PSA_KEY_USAGE_DERIVE )
|
||||||
{
|
{
|
||||||
/* We need two keys to exercise key agreement. Exercise the
|
/* We need two keys to exercise key agreement. Exercise the
|
||||||
* private key against its own public key. */
|
* private key against its own public key. */
|
||||||
PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
|
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 ) );
|
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,
|
PSA_ASSERT( psa_key_derivation_output_bytes( &operation,
|
||||||
output,
|
output,
|
||||||
sizeof( output ) ) );
|
sizeof( output ) ) );
|
||||||
|
|
Loading…
Reference in a new issue