mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-28 00:35:21 +00:00
pk: improve mbedtls_pk_copy_from_psa()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
6f5f9f5ce8
commit
e095a67bb2
@ -1402,7 +1402,7 @@ int mbedtls_pk_copy_from_psa(mbedtls_svc_key_id_t key_id, mbedtls_pk_context *pk
|
||||
|
||||
status = psa_export_key(key_id, exp_key, sizeof(exp_key), &exp_key_len);
|
||||
if (status != PSA_SUCCESS) {
|
||||
ret = MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
ret = PSA_PK_TO_MBEDTLS_ERR(status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -1429,8 +1429,7 @@ int mbedtls_pk_copy_from_psa(mbedtls_svc_key_id_t key_id, mbedtls_pk_context *pk
|
||||
}
|
||||
|
||||
mbedtls_md_type_t md_type = MBEDTLS_MD_NONE;
|
||||
if ((PSA_ALG_GET_HASH(alg_type) != PSA_ALG_NONE) &&
|
||||
(PSA_ALG_GET_HASH(alg_type) != PSA_ALG_ANY_HASH)) {
|
||||
if (PSA_ALG_GET_HASH(alg_type) != PSA_ALG_ANY_HASH) {
|
||||
md_type = mbedtls_md_type_from_psa_alg(alg_type);
|
||||
}
|
||||
|
||||
|
@ -2340,7 +2340,7 @@ void pk_copy_from_psa_fail(void)
|
||||
/* Generate an EC key which cannot be exported. */
|
||||
PSA_ASSERT(pk_psa_genkey_generic(PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1), 256,
|
||||
0, PSA_ALG_NONE, &key_id));
|
||||
TEST_EQUAL(mbedtls_pk_copy_from_psa(key_id, &pk_ctx), MBEDTLS_ERR_PK_BAD_INPUT_DATA);
|
||||
TEST_EQUAL(mbedtls_pk_copy_from_psa(key_id, &pk_ctx), MBEDTLS_ERR_PK_TYPE_MISMATCH);
|
||||
psa_destroy_key(key_id);
|
||||
#endif /* MBEDTLS_PK_HAVE_ECC_KEYS && PSA_WANT_ECC_SECP_R1_256 &&
|
||||
PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE */
|
||||
|
Loading…
x
Reference in New Issue
Block a user