-
Notifications
You must be signed in to change notification settings - Fork 734
post-quantum: add unstable ML-DSA support #2550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+144
−68
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4554f0c
bench: remove PostQuantum benchmarks
djc 791ab79
bogo: remove PostQuantum setup
djc 38c320f
post-quantum: stick with rustls 0.23 for now
djc de09959
post-quantum: add unstable ML-DSA support
djc f8aabe1
Bump rustls-post-quantum version to 0.2.3
djc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
post-quantum: add unstable ML-DSA support
- Loading branch information
commit de09959eb1034afa7a2ffb8d51fa877d4023c764
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,114 @@ | ||
//! The functionality of this crate became part of the core rustls | ||
//! crate from the 0.23.22 release. When using that version of the crate, | ||
//! use the `prefer-post-quantum` Cargo feature to control whether to prefer | ||
//! using post-quantum algorithms instead of using this crate. | ||
//! This crate provide a [`CryptoProvider`] built on the default aws-lc-rs default provider. | ||
//! | ||
//! Features: | ||
//! | ||
//! - `aws-lc-rs-unstable`: adds support for three variants of the experimental ML-DSA signature | ||
//! algorithm. | ||
//! | ||
//! Before rustls 0.23.22, this crate additionally provided support for the ML-KEM key exchange | ||
//! (both "pure" and hybrid variants), but these have been moved to the rustls crate itself. | ||
//! In rustls 0.23.22 and later, you can use rustls' `prefer-post-quantum` feature to determine | ||
//! whether the ML-KEM key exchange is preferred over non-post-quantum key exchanges. | ||
|
||
pub use rustls::crypto::aws_lc_rs::default_provider as provider; | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
use rustls::SignatureScheme; | ||
use rustls::crypto::CryptoProvider; | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
use rustls::crypto::WebPkiSupportedAlgorithms; | ||
pub use rustls::crypto::aws_lc_rs::kx_group::{MLKEM768, X25519MLKEM768}; | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
use webpki::aws_lc_rs as webpki_algs; | ||
|
||
pub fn provider() -> CryptoProvider { | ||
#[cfg_attr(not(feature = "aws-lc-rs-unstable"), allow(unused_mut))] | ||
let mut provider = rustls::crypto::aws_lc_rs::default_provider(); | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
{ | ||
provider.signature_verification_algorithms = SUPPORTED_SIG_ALGS; | ||
} | ||
provider | ||
} | ||
|
||
/// Keep in sync with the `SUPPORTED_SIG_ALGS` in `rustls::crypto::aws_lc_rs`. | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
static SUPPORTED_SIG_ALGS: WebPkiSupportedAlgorithms = WebPkiSupportedAlgorithms { | ||
all: &[ | ||
webpki_algs::ECDSA_P256_SHA256, | ||
webpki_algs::ECDSA_P256_SHA384, | ||
webpki_algs::ECDSA_P384_SHA256, | ||
webpki_algs::ECDSA_P384_SHA384, | ||
webpki_algs::ECDSA_P521_SHA256, | ||
webpki_algs::ECDSA_P521_SHA384, | ||
webpki_algs::ECDSA_P521_SHA512, | ||
webpki_algs::ED25519, | ||
webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, | ||
webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, | ||
webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA256, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA384, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA512, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, | ||
webpki_algs::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
webpki_algs::ML_DSA_44, | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
webpki_algs::ML_DSA_65, | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
webpki_algs::ML_DSA_87, | ||
], | ||
mapping: &[ | ||
// Note: for TLS1.2 the curve is not fixed by SignatureScheme. For TLS1.3 it is. | ||
( | ||
SignatureScheme::ECDSA_NISTP384_SHA384, | ||
&[ | ||
webpki_algs::ECDSA_P384_SHA384, | ||
webpki_algs::ECDSA_P256_SHA384, | ||
webpki_algs::ECDSA_P521_SHA384, | ||
], | ||
), | ||
( | ||
SignatureScheme::ECDSA_NISTP256_SHA256, | ||
&[ | ||
webpki_algs::ECDSA_P256_SHA256, | ||
webpki_algs::ECDSA_P384_SHA256, | ||
webpki_algs::ECDSA_P521_SHA256, | ||
], | ||
), | ||
( | ||
SignatureScheme::ECDSA_NISTP521_SHA512, | ||
&[webpki_algs::ECDSA_P521_SHA512], | ||
), | ||
(SignatureScheme::ED25519, &[webpki_algs::ED25519]), | ||
( | ||
SignatureScheme::RSA_PSS_SHA512, | ||
&[webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY], | ||
), | ||
( | ||
SignatureScheme::RSA_PSS_SHA384, | ||
&[webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY], | ||
), | ||
( | ||
SignatureScheme::RSA_PSS_SHA256, | ||
&[webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY], | ||
), | ||
( | ||
SignatureScheme::RSA_PKCS1_SHA512, | ||
&[webpki_algs::RSA_PKCS1_2048_8192_SHA512], | ||
), | ||
( | ||
SignatureScheme::RSA_PKCS1_SHA384, | ||
&[webpki_algs::RSA_PKCS1_2048_8192_SHA384], | ||
), | ||
( | ||
SignatureScheme::RSA_PKCS1_SHA256, | ||
&[webpki_algs::RSA_PKCS1_2048_8192_SHA256], | ||
), | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
(SignatureScheme::ML_DSA_44, &[webpki_algs::ML_DSA_44]), | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
(SignatureScheme::ML_DSA_65, &[webpki_algs::ML_DSA_65]), | ||
#[cfg(feature = "aws-lc-rs-unstable")] | ||
(SignatureScheme::ML_DSA_87, &[webpki_algs::ML_DSA_87]), | ||
], | ||
}; |
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.
Uh oh!
There was an error while loading. Please reload this page.