perf: pre-compute required transcript hashes per security policy - #6010
Open
MrMistic wants to merge 1 commit into
Open
perf: pre-compute required transcript hashes per security policy#6010MrMistic wants to merge 1 commit into
MrMistic wants to merge 1 commit into
Conversation
Contributor
|
Could you please use the PR template for the description: https://github.com/aws/s2n-tls/blob/main/.github/PULL_REQUEST_TEMPLATE.md |
Contributor
Author
yep, fixed |
kaukabrizvi
reviewed
Jul 27, 2026
Contributor
There was a problem hiding this comment.
Is connection reuse in scope for this optimization? s2n_connection_wipe preserves conn->config but resets required_hash_algs back to all 7, so a wiped-and-reused connection would re-hedge all 7 hashes unless set_config is called again.
MrMistic
force-pushed
the
tls13-hash-fix
branch
from
August 6, 2026 11:12
f3a31a0 to
f084ba5
Compare
MrMistic
force-pushed
the
tls13-hash-fix
branch
from
August 6, 2026 20:00
f084ba5 to
ba2f10b
Compare
MrMistic
force-pushed
the
tls13-hash-fix
branch
from
August 7, 2026 22:26
ba2f10b to
52a1ac7
Compare
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.
Goal
Skip transcript hashing for hash algorithms that the connection's security policy can never require.
Why
Before cipher suite negotiation completes, s2n-tls hedges by hashing every transcript update with all hash algorithms (MD5, SHA-1, MD5+SHA-1, SHA-224, SHA-256, SHA-384, SHA-512). For most policies, several of these can never be needed. For example, a TLS 1.3-only policy can only ever use SHA-256 or SHA-384 (RFC 8446 §7.1), so the other hashes are wasted work on every ClientHello.
How
At
s2n_security_policies_init(), pre-compute for each security policy the set of hash algorithms that could be needed before negotiation:Connections copy the pre-computed bitmap at config-set time (
s2n_connection_set_config/s2n_connection_set_security_policy). The existing post-ServerHello narrowing ins2n_conn_update_required_handshake_hashesis unchanged and still reduces to the single negotiated hash.Callouts
security_policy_selection[]table sinces2n_security_policystructs are const. Policies not in the table (e.g. test-constructed) are computed on the fly.Testing
Related
N/A
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.