Skip to content

Commit a3daff4

Browse files
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 <[email protected]>
1 parent 771fd7d commit a3daff4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/psa_crypto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5194,6 +5194,12 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
51945194
goto exit;
51955195
}
51965196

5197+
/* No input to add (zero length), nothing to do. */
5198+
if (input_length == 0) {
5199+
status = PSA_SUCCESS;
5200+
goto exit;
5201+
}
5202+
51975203
if (operation->lengths_set) {
51985204
if (operation->ad_remaining < input_length) {
51995205
status = PSA_ERROR_INVALID_ARGUMENT;

0 commit comments

Comments
 (0)