Repository navigation
aead: test buffer zeroing on authentication failure - #2516
Conversation
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.
|
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. |
|
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. |
|
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. |
|
Yeah, it will break the tests for old releases, but we can cut a new release of |
|
Hm, I think we had an issue where we discussed whether to zeroize or to re-encrypt, but I can not find it... |
|
It was RustCrypto/AEADs#660 I can leave a comment there |
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.