Skip to content

aead: test buffer zeroing on authentication failure - #2516

Merged
tarcieri merged 1 commit into
masterfrom
aead/test-authentication-failure-behavior
Nov 13, 2026
Merged

tarcieri merged 1 commit into
masterfrom
aead/test-authentication-failure-behavior

Conversation

@tarcieri

Copy link
Copy Markdown
Member

In the past we've debated what to do with buffers when authentication tag verification fails during decryption. I think we should have a consistent, testable solution regardless, and this PR adds tests. SIV modes and optimized implementations that interleave authentication and decryption into a single pass may have buffers containing plaintext before tag verification can occur.

Previously I advocated for re-encryption on failure, but I've since changed my mind. One problem with this approach is re-encryption is much slower than zeroing, so it wastes time and may potentially help attackers in that regard.

So in lieu of that I'd suggest we have a single, consistent, well-tested behavior, and the other approach we use for handling these failures is zeroing out the buffers instead, which is what this tests for.

In the past we've debated what to do with buffers when authentication
tag verification fails during decryption. I think we should have a
consistent, testable solution regardless, and this PR adds tests.
SIV modes and optimized implementations that interleave authentication
and decryption into a single pass may have buffers containing plaintext
before tag verification can occur.

Previously I advocated for re-encryption on failure, but I've since
changed my mind. One problem with this approach is re-encryption is much
slower than zeroing, so it wastes time and may potentially help
attackers in that regard.

So in lieu of that I'd suggest we have a single, consistent, well-tested
behavior, and the other approach we use for handling these failures is
zeroing out the buffers instead, which is what this tests for.
@tarcieri
tarcieri requested a review from newpavlov November 13, 2026 17:54
@tarcieri tarcieri changed the title [WIP] aead: test buffer zeroing on authentication failure aead: test buffer zeroing on authentication failure Nov 13, 2026
@tarcieri
tarcieri marked this pull request as ready for review November 13, 2026 18:42
@newpavlov

Copy link
Copy Markdown
Member

Looks good and I am glad that you've changed your mind!

But I think it may be worth to make part of the next breaking release (I have a draft with breaking changes which I would like to include, but it's not finished yet) and document it as a requirement for proper implementations of the trait.

@tarcieri

Copy link
Copy Markdown
Member Author

We specifically left what happens on decryption failure as implementation defined AFAIK, so I don't think it's a breaking change.

As it were, we've gotten reports of outstanding bugs in this regard that this can confirm fixes.

@newpavlov

newpavlov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Potentially breaking tests for implementations which re-encrypt (or leave ciphertext intact like two-pass implementations) could be considered a breaking change. But it's a minor issue, so I am fine with going forward with it if you want.

@tarcieri

Copy link
Copy Markdown
Member Author

Yeah, it will break the tests for old releases, but we can cut a new release of aead and the impacted downstream crates at the same time so at least the latest versions will work

@tarcieri
tarcieri merged commit 6c1eab1 into master Nov 13, 2026
12 checks passed
@tarcieri
tarcieri deleted the aead/test-authentication-failure-behavior branch November 13, 2026 19:06
tarcieri added a commit to RustCrypto/AEADs that referenced this pull request Nov 13, 2026
@newpavlov

Copy link
Copy Markdown
Member

Hm, I think we had an issue where we discussed whether to zeroize or to re-encrypt, but I can not find it...

@tarcieri

Copy link
Copy Markdown
Member Author

It was RustCrypto/AEADs#660

I can leave a comment there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants