mirror of https://github.com/ARMmbed/mbed-os.git
attestation: Don't create attestation key twice
If psa_attestation_inject_key() is called twice, exit with a non-fatal error status without attempting to create another attestation key. The key already exists and doesn't need to be added again.pull/11315/head
parent
5c81d19bc1
commit
43af68d630
|
@ -42,6 +42,12 @@ psa_attestation_inject_key_impl(const uint8_t *key_data,
|
|||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
|
||||
status = psa_open_key(key_id, &handle);
|
||||
if (status == PSA_SUCCESS) {
|
||||
/* The key already has been injected */
|
||||
goto exit;
|
||||
}
|
||||
|
||||
psa_set_key_usage_flags(&attributes, usage);
|
||||
psa_set_key_algorithm(&attributes, PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256));
|
||||
psa_set_key_type(&attributes, type);
|
||||
|
|
Loading…
Reference in New Issue