test_suite_pk: extend pk_copy_from_psa_builtin_fail() also to EC keys

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2024-03-11 10:41:00 +01:00
parent e095a67bb2
commit 7dc2bf2cb0
2 changed files with 11 additions and 6 deletions

View File

@ -1459,8 +1459,13 @@ pk_import_into_psa_opaque:PSA_KEY_TYPE_ECC_KEY_PAIR(MBEDTLS_TEST_PSA_ECC_ONE_FAM
Copy from PSA: use wrong parameters
pk_copy_from_psa_fail:
Copy from PSA: accelerated key only, not available as built-in
pk_copy_from_psa_builtin_fail:
Copy from PSA: RSA PKCS1V15 accelerated only, not available as built-in
depends_on:MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN:MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR_BASIC:!MBEDTLS_RSA_C
pk_copy_from_psa_builtin_fail:PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256)
Copy from PSA: EC SECP256R1 accelerated only, not available as built-in
depends_on:MBEDTLS_PSA_ACCEL_ECC_SECP_R1_256:MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_BASIC:MBEDTLS_PSA_ACCEL_ALG_ECDSA:!MBEDTLS_ECDSA_C:!MBEDTLS_ECP_DP_SECP256R1:MBEDTLS_PSA_ACCEL_ALG_SHA_256
pk_copy_from_psa_builtin_fail:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA(PSA_ALG_SHA_256)
Copy from PSA: valid EC (SECP_R1_256 + ECDSA + ANY_HASH)
depends_on:MBEDTLS_ECP_HAVE_SECP256R1:MBEDTLS_PK_CAN_ECDSA_SIGN:MBEDTLS_PK_CAN_ECDSA_VERIFY:MBEDTLS_MD_ALG_FOR_TEST

View File

@ -2352,8 +2352,8 @@ exit:
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_PSA_CRYPTO_C:MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN:MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR_BASIC:!MBEDTLS_RSA_C */
void pk_copy_from_psa_builtin_fail()
/* BEGIN_CASE depends_on:MBEDTLS_PSA_CRYPTO_C */
void pk_copy_from_psa_builtin_fail(int key_type, int key_alg)
{
mbedtls_pk_context pk_ctx;
mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT;
@ -2361,10 +2361,10 @@ void pk_copy_from_psa_builtin_fail()
mbedtls_pk_init(&pk_ctx);
PSA_INIT();
PSA_ASSERT(pk_psa_genkey_generic(PSA_KEY_TYPE_RSA_KEY_PAIR,
PSA_ASSERT(pk_psa_genkey_generic(key_type,
PSA_VENDOR_RSA_GENERATE_MIN_KEY_BITS,
PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_EXPORT,
PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256),
key_alg,
&key_id));
TEST_EQUAL(mbedtls_pk_copy_from_psa(key_id, &pk_ctx), MBEDTLS_ERR_PK_BAD_INPUT_DATA);
exit: