Fix handling of ECC public keys under MBEDTLS_PK_USE_PSA_EC_DATA
The test code to construct test keys and the implementation had matching errors: both assumed that there was a PSA public key object. Fix this. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
591e83d139
commit
cb3b4cae0a
3 changed files with 8 additions and 12 deletions
14
library/pk.c
14
library/pk.c
|
@ -464,16 +464,12 @@ int mbedtls_pk_get_psa_attributes(const mbedtls_pk_context *pk,
|
|||
int sign_ok = (pk_type != MBEDTLS_PK_ECKEY_DH);
|
||||
int derive_ok = (pk_type != MBEDTLS_PK_ECDSA);
|
||||
#if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
|
||||
psa_key_attributes_t old_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
status = psa_get_key_attributes(pk->priv_id, &old_attributes);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
psa_ecc_family_t family = pk->ec_family;
|
||||
size_t bits = pk->ec_bits;
|
||||
int has_private = 0;
|
||||
if (pk->priv_id != MBEDTLS_SVC_KEY_ID_INIT) {
|
||||
has_private = 1;
|
||||
}
|
||||
psa_key_type_t old_type = psa_get_key_type(&old_attributes);
|
||||
int has_private = PSA_KEY_TYPE_IS_KEY_PAIR(old_type);
|
||||
size_t bits = psa_get_key_bits(&old_attributes);
|
||||
psa_ecc_family_t family = PSA_KEY_TYPE_ECC_GET_FAMILY(old_type);
|
||||
#else
|
||||
const mbedtls_ecp_keypair *ec = mbedtls_pk_ec_ro(*pk);
|
||||
int has_private = (ec->d.n != 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue