mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Add buffer protection for cipher_generate_iv
and cipher_set_iv
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
8b8e485961
commit
7abf8ee51b
@ -4361,7 +4361,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (status == PSA_SUCCESS) {
|
if (status == PSA_SUCCESS) {
|
||||||
memcpy(iv, local_iv, default_iv_length);
|
psa_crypto_copy_output(local_iv, default_iv_length, iv, iv_size);
|
||||||
*iv_length = default_iv_length;
|
*iv_length = default_iv_length;
|
||||||
operation->iv_set = 1;
|
operation->iv_set = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -4373,11 +4373,13 @@ exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
|
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
|
||||||
const uint8_t *iv,
|
const uint8_t *iv_external,
|
||||||
size_t iv_length)
|
size_t iv_length)
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
|
|
||||||
|
LOCAL_INPUT_DECLARE(iv_external, iv);
|
||||||
|
|
||||||
if (operation->id == 0) {
|
if (operation->id == 0) {
|
||||||
status = PSA_ERROR_BAD_STATE;
|
status = PSA_ERROR_BAD_STATE;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -4393,6 +4395,8 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL_INPUT_ALLOC(iv_external, iv_length, iv);
|
||||||
|
|
||||||
status = psa_driver_wrapper_cipher_set_iv(operation,
|
status = psa_driver_wrapper_cipher_set_iv(operation,
|
||||||
iv,
|
iv,
|
||||||
iv_length);
|
iv_length);
|
||||||
@ -4403,6 +4407,9 @@ exit:
|
|||||||
} else {
|
} else {
|
||||||
psa_cipher_abort(operation);
|
psa_cipher_abort(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL_INPUT_FREE(iv_external, iv);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user