mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-31 00:32:50 +00:00
Protect buffer in psa_import_key
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
parent
8a35fd58ee
commit
f028fe195b
@ -2199,11 +2199,12 @@ rsa_exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
||||||
const uint8_t *data,
|
const uint8_t *data_external,
|
||||||
size_t data_length,
|
size_t data_length,
|
||||||
mbedtls_svc_key_id_t *key)
|
mbedtls_svc_key_id_t *key)
|
||||||
{
|
{
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
LOCAL_INPUT_DECLARE(data_external, data);
|
||||||
psa_key_slot_t *slot = NULL;
|
psa_key_slot_t *slot = NULL;
|
||||||
psa_se_drv_table_entry_t *driver = NULL;
|
psa_se_drv_table_entry_t *driver = NULL;
|
||||||
size_t bits;
|
size_t bits;
|
||||||
@ -2223,6 +2224,8 @@ psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
|||||||
return PSA_ERROR_NOT_SUPPORTED;
|
return PSA_ERROR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL_INPUT_ALLOC(data_external, data_length, data);
|
||||||
|
|
||||||
status = psa_start_key_creation(PSA_KEY_CREATION_IMPORT, attributes,
|
status = psa_start_key_creation(PSA_KEY_CREATION_IMPORT, attributes,
|
||||||
&slot, &driver);
|
&slot, &driver);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
@ -2277,6 +2280,7 @@ psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
|
|||||||
|
|
||||||
status = psa_finish_key_creation(slot, driver, key);
|
status = psa_finish_key_creation(slot, driver, key);
|
||||||
exit:
|
exit:
|
||||||
|
LOCAL_INPUT_FREE(data_external, data);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
psa_fail_key_creation(slot, driver);
|
psa_fail_key_creation(slot, driver);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user