mirror of
https://github.com/espressif/mbedtls.git
synced 2025-06-23 00:44:43 +08:00
Add buffer protection to psa_key_derivation_key_agreement
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
81899aba11
commit
9739ac047a
@ -7341,12 +7341,13 @@ exit:
|
|||||||
psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation,
|
psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation,
|
||||||
psa_key_derivation_step_t step,
|
psa_key_derivation_step_t step,
|
||||||
mbedtls_svc_key_id_t private_key,
|
mbedtls_svc_key_id_t private_key,
|
||||||
const uint8_t *peer_key,
|
const uint8_t *peer_key_external,
|
||||||
size_t peer_key_length)
|
size_t peer_key_length)
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_key_slot_t *slot;
|
psa_key_slot_t *slot;
|
||||||
|
LOCAL_INPUT_DECLARE(peer_key_external, peer_key);
|
||||||
|
|
||||||
if (!PSA_ALG_IS_KEY_AGREEMENT(operation->alg)) {
|
if (!PSA_ALG_IS_KEY_AGREEMENT(operation->alg)) {
|
||||||
return PSA_ERROR_INVALID_ARGUMENT;
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
@ -7356,9 +7357,13 @@ psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *op
|
|||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL_INPUT_ALLOC(peer_key_external, peer_key_length, peer_key)
|
||||||
status = psa_key_agreement_internal(operation, step,
|
status = psa_key_agreement_internal(operation, step,
|
||||||
slot,
|
slot,
|
||||||
peer_key, peer_key_length);
|
peer_key, peer_key_length);
|
||||||
|
|
||||||
|
exit:
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
psa_key_derivation_abort(operation);
|
psa_key_derivation_abort(operation);
|
||||||
} else {
|
} else {
|
||||||
@ -7370,7 +7375,7 @@ psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *op
|
|||||||
}
|
}
|
||||||
|
|
||||||
unlock_status = psa_unregister_read(slot);
|
unlock_status = psa_unregister_read(slot);
|
||||||
|
LOCAL_INPUT_FREE(peer_key_external, peer_key);
|
||||||
return (status == PSA_SUCCESS) ? unlock_status : status;
|
return (status == PSA_SUCCESS) ? unlock_status : status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user