fix(aes-gcm): reject empty nonces - #885
Open
thevilledev wants to merge 1 commit into
Open
Conversation
Zero-length nonces violate NIST SP 800-38D and expose the GHASH authentication key when encrypting an empty message. Reject them at the type level and cover the invariant with a compile-fail example. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
Member
|
This is probably a good idea in general but it's also imposing a new bound on a generic parameter, which is a breaking change: anyone using it in a generic context will need to propagate this bound. |
Member
|
As a temporary solution we could panic on empty nonces. I doubt that anyone uses the crate with them, so it should not affect anyone while serving as a guard against misuse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Running the Wycheproof AES-GCM vectors exposed failures for the
ZeroLengthIvcases. A zero-length nonce violates NIST SP 800-38D and can disclose the GHASH authentication key.Changes
NonceSizebound requiring non-zero nonce sizes.AesGcmimplementation, preventing bypasses.AesGcm<Aes128, U0>.Tests
Tests pass.