aead: require &mut self for seal/open and add TLS AEAD variants#514
Open
janrueth wants to merge 1 commit into
Open
aead: require &mut self for seal/open and add TLS AEAD variants#514janrueth wants to merge 1 commit into
janrueth wants to merge 1 commit into
Conversation
Change all seal/open methods on AeadCtxRef from &self to &mut self. The TLS-specific AEADs (aes_*_gcm_tls12, aes_*_gcm_tls13) are stateful and internally mutate the EVP_AEAD_CTX during seal operations (nonce counter tracking). Using &self allows LLVM to optimize under the assumption that the context is read-only, which can corrupt nonce state and cause cryptographic failures. This was the root cause of cloudflare/quiche#2383. Using &mut self universally (for both generic and TLS AEADs) is the simplest fix and prevents this class of bug entirely. Also adds Algorithm constructors for the four TLS GCM variants: - aes_128_gcm_tls12 / aes_256_gcm_tls12 - aes_128_gcm_tls13 / aes_256_gcm_tls13 These enforce strictly monotonic nonces at the AEAD level, matching the TLS 1.2 and TLS 1.3 nonce construction requirements. Tests cover: - Round-trip seal/open for all TLS variants - TLS nonce monotonicity enforcement (reuse and backwards rejected) - Contrast: generic GCM accepts non-monotonic nonces
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.
Change all seal/open methods on AeadCtxRef from &self to &mut self.
The TLS-specific AEADs (aes_gcm_tls12, aes_gcm_tls13) are stateful and internally mutate the EVP_AEAD_CTX during seal operations (nonce counter tracking). Using &self allows LLVM to optimize under the assumption that the context is read-only, which can corrupt nonce state and cause cryptographic failures. This was the root cause of cloudflare/quiche#2383.
Using &mut self universally (for both generic and TLS AEADs) is the simplest fix and prevents this class of bug entirely.
Also adds Algorithm constructors for the four TLS GCM variants:
These enforce strictly monotonic nonces at the AEAD level, matching the TLS 1.2 and TLS 1.3 nonce construction requirements.
Tests cover: