feat(tls,quic): add CryptoProvider injection seam (closes #6236)#6435
Open
v1p3r4llbl4ck-86 wants to merge 1 commit into
Open
feat(tls,quic): add CryptoProvider injection seam (closes #6236)#6435v1p3r4llbl4ck-86 wants to merge 1 commit into
v1p3r4llbl4ck-86 wants to merge 1 commit into
Conversation
Lets consumers swap the default `ring`-based `rustls::crypto::CryptoProvider`
for an alternative — notably `rustls-post-quantum` to enable the
X25519MLKEM768 hybrid post-quantum key-exchange group (IANA codepoint
0x11EC, draft-ietf-tls-ecdhe-mlkem-04) on the libp2p TLS handshake (both
the libp2p-tls TCP path and the libp2p-quic QUIC path).
API additions (all behaviour-preserving — existing call sites unchanged):
libp2p-tls
+ make_client_config_with_provider(keypair, remote_peer_id, provider)
+ make_server_config_with_provider(keypair, provider)
+ Config::new_with_provider(identity, provider)
+ private default_libp2p_provider() helper that hoists the cipher-suite
mutation previously duplicated at both make_*_config call sites
libp2p-quic
+ Config::new_with_provider(keypair, provider)
+ private Self::new_inner(keypair, custom_provider) helper shared by
Self::new and Self::new_with_provider
The existing `make_client_config`, `make_server_config`, `Config::new` (in
both crates) become one-liners that delegate to the new `_with_provider`
variants with `None`. A consumer that doesn't call the new APIs cannot
tell the patch is in place — `cargo test` against the upstream test
matrix passes unchanged.
Why this shape:
- Threading `Option<CryptoProvider>` (rather than a builder/setter) keeps
the public API surface minimal and matches the existing arity of
`make_*_config`.
- The `default_libp2p_provider()` helper de-duplicates the
`provider.cipher_suites = verifier::CIPHERSUITES.to_vec()` mutation that
used to appear inline at both call sites, which makes future provider
swaps mechanically safe.
- The QUIC patch piggybacks on the libp2p-tls patch via the same
`_with_provider` helpers — no separate provider-injection logic in the
QUIC layer.
Closes libp2p#6236.
jxs
reviewed
May 16, 2026
Member
jxs
left a comment
There was a problem hiding this comment.
Hi, can you not bypass the PR template and answer it?
thanks
Contributor
|
This pull request has merge conflicts. Could you please resolve them @v1p3r4llbl4ck-86? 🙏 |
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
Lets consumers swap the default
ring-basedrustls::crypto::CryptoProviderfor an alternative — notablyrustls-post-quantumto enable the X25519MLKEM768 hybrid post-quantum key-exchange group (IANA codepoint0x11EC, draft-ietf-tls-ecdhe-mlkem-04) on the libp2p TLS handshake — both the libp2p-tls TCP path and the libp2p-quic QUIC path.Closes #6236.
API additions (all behaviour-preserving)
libp2p-tls:make_client_config_with_provider(keypair, remote_peer_id, provider)make_server_config_with_provider(keypair, provider)Config::new_with_provider(identity, provider)default_libp2p_provider()helper that hoists the cipher-suite mutation previously duplicated at bothmake_*_configcall siteslibp2p-quic:Config::new_with_provider(keypair, provider)Self::new_inner(keypair, custom_provider)helper shared bySelf::newandSelf::new_with_providerThe existing
make_client_config,make_server_config,Config::new(in both crates) become one-liners that delegate to the new_with_providervariants withNone. A consumer that doesn't call the new APIs cannot tell the patch is in place.Test plan
cargo build -p libp2p-tls -p libp2p-quiccleancargo test -p libp2p-tlspassesX25519MLKEM768incrypto_provider().kx_groupswhen givenrustls_post_quantum::provider().clone(), and that classical X25519 stays present for back-compatWhy this shape
Option<CryptoProvider>(rather than a builder/setter) keeps the public API surface minimal and matches the existing arity ofmake_*_config.default_libp2p_provider()helper de-duplicates theprovider.cipher_suites = verifier::CIPHERSUITES.to_vec()mutation previously inline at both call sites — makes future provider swaps mechanically safe._with_providerhelpers — no separate provider-injection logic in the QUIC layer.Happy to split into per-crate commits or reshape the API (builder pattern instead of free functions, etc.) on review feedback.