mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-05 18:40:01 +00:00
Add early exit if zero length AEAD AD passed in.
With multipart AEAD, if we attempt to add zero length additional data, then with the buffer sharing fixes this can now lead to undefined behaviour when using gcm. Fix this by returning early, as there is nothing to do if the input length is zero. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
f6275b745f
commit
304766ffa8
@ -5194,6 +5194,12 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No input to add (zero length), nothing to do. */
|
||||||
|
if (input_length == 0) {
|
||||||
|
status = PSA_SUCCESS;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (operation->lengths_set) {
|
if (operation->lengths_set) {
|
||||||
if (operation->ad_remaining < input_length) {
|
if (operation->ad_remaining < input_length) {
|
||||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user