mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Keys may allow a second algorithm
Add a second permitted algorithm to key policies. This commit includes smoke tests that do not cover psa_copy_key.
This commit is contained in:
@ -516,6 +516,14 @@ PSA key policy: raw agreement, key only permits a KDF
|
||||
depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECDH_C
|
||||
raw_agreement_key_policy:PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP256R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_ALG_KEY_AGREEMENT(PSA_ALG_ECDH, PSA_ALG_HKDF(PSA_ALG_SHA_256))
|
||||
|
||||
PSA key policy algorithm2: CTR, CBC
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CTR:MBEDTLS_CIPHER_MODE_CBC_NOPAD
|
||||
key_policy_alg2:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:PSA_ALG_CBC_NO_PADDING
|
||||
|
||||
PSA key policy algorithm2: ECDH, ECDSA
|
||||
depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECDH_C:MBEDTLS_ECDSA_C
|
||||
key_policy_alg2:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP256R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY:PSA_ALG_ECDH:PSA_ALG_ECDSA_ANY
|
||||
|
||||
Copy key: raw, 0 bytes
|
||||
copy_success:PSA_KEY_USAGE_COPY:0:PSA_KEY_TYPE_RAW_DATA:"":1:-1:-1:PSA_KEY_USAGE_COPY:0
|
||||
|
||||
|
@ -1912,6 +1912,43 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void key_policy_alg2( int key_type_arg, data_t *key_data,
|
||||
int usage_arg, int alg_arg, int alg2_arg )
|
||||
{
|
||||
psa_key_handle_t handle = 0;
|
||||
psa_key_type_t key_type = key_type_arg;
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_usage_t usage = usage_arg;
|
||||
psa_algorithm_t alg = alg_arg;
|
||||
psa_algorithm_t alg2 = alg2_arg;
|
||||
|
||||
PSA_ASSERT( psa_crypto_init( ) );
|
||||
|
||||
psa_set_key_usage_flags( &attributes, usage );
|
||||
psa_set_key_algorithm( &attributes, alg );
|
||||
psa_set_key_enrollment_algorithm( &attributes, alg2 );
|
||||
psa_set_key_type( &attributes, key_type );
|
||||
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
||||
&handle ) );
|
||||
|
||||
PSA_ASSERT( psa_get_key_attributes( handle, &got_attributes ) );
|
||||
TEST_EQUAL( psa_get_key_usage_flags( &got_attributes ), usage );
|
||||
TEST_EQUAL( psa_get_key_algorithm( &got_attributes ), alg );
|
||||
TEST_EQUAL( psa_get_key_enrollment_algorithm( &got_attributes ), alg2 );
|
||||
|
||||
if( ! exercise_key( handle, usage, alg ) )
|
||||
goto exit;
|
||||
if( ! exercise_key( handle, usage, alg2 ) )
|
||||
goto exit;
|
||||
|
||||
exit:
|
||||
psa_destroy_key( handle );
|
||||
mbedtls_psa_crypto_free( );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void raw_agreement_key_policy( int policy_usage,
|
||||
int policy_alg,
|
||||
|
Reference in New Issue
Block a user