Skip to content

Commit daa9e60

Browse files
committed
Add unstable support for ML-DSA signature algorithms
1 parent 1e923bf commit daa9e60

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,4 @@ jobs:
382382
cargo hack check
383383
--feature-powerset
384384
--no-dev-deps
385-
--mutually-exclusive-features aws-lc-rs,aws-lc-rs-fips
385+
--mutually-exclusive-features aws-lc-rs,aws-lc-rs-fips,__aws-lc-rs-unstable

Cargo.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ name = "webpki"
7171
[features]
7272
default = ["std"]
7373
alloc = ["ring?/alloc", "pki-types/alloc"]
74+
__aws-lc-rs-unstable = ["aws-lc-rs", "aws-lc-rs/unstable"]
7475
aws-lc-rs = ["dep:aws-lc-rs", "aws-lc-rs/aws-lc-sys", "aws-lc-rs/prebuilt-nasm"]
7576
aws-lc-rs-fips = ["dep:aws-lc-rs", "aws-lc-rs/fips"]
7677
ring = ["dep:ring"]
7778
std = ["alloc", "pki-types/std"]
7879

7980
[dependencies]
8081
aws-lc-rs = { version = "1.9", optional = true, default-features = false }
81-
pki-types = { package = "rustls-pki-types", version = "1.11", default-features = false }
82+
pki-types = { package = "rustls-pki-types", version = "1.12", default-features = false }
8283
ring = { version = "0.17", default-features = false, optional = true }
8384
untrusted = "0.9"
8485

src/aws_lc_rs_algs.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
2+
use aws_lc_rs::unstable;
13
use aws_lc_rs::{signature, try_fips_mode};
24
use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm, alg_id};
35

@@ -54,6 +56,30 @@ impl SignatureVerificationAlgorithm for AwsLcRsAlgorithm {
5456
}
5557
}
5658

59+
/// ML-DSA signatures using the [4, 4] matrix (security strength category 2).
60+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
61+
pub static ML_DSA_44: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
62+
public_key_alg_id: alg_id::ML_DSA_44,
63+
signature_alg_id: alg_id::ML_DSA_44,
64+
verification_alg: &unstable::signature::MLDSA_44,
65+
};
66+
67+
/// ML-DSA signatures using the [6, 5] matrix (security strength category 3).
68+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
69+
pub static ML_DSA_65: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
70+
public_key_alg_id: alg_id::ML_DSA_65,
71+
signature_alg_id: alg_id::ML_DSA_65,
72+
verification_alg: &unstable::signature::MLDSA_65,
73+
};
74+
75+
/// ML-DSA signatures using the [8. 7] matrix (security strength category 5).
76+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
77+
pub static ML_DSA_87: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
78+
public_key_alg_id: alg_id::ML_DSA_87,
79+
signature_alg_id: alg_id::ML_DSA_87,
80+
verification_alg: &unstable::signature::MLDSA_87,
81+
};
82+
5783
/// ECDSA signatures using the P-256 curve and SHA-256.
5884
pub static ECDSA_P256_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
5985
public_key_alg_id: alg_id::ECDSA_P256,
@@ -194,6 +220,12 @@ mod tests {
194220
// Algorithms deprecated because they are nonsensical combinations.
195221
super::ECDSA_P256_SHA384, // Truncates digest.
196222
super::ECDSA_P384_SHA256, // Digest is unnecessarily short.
223+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
224+
super::ML_DSA_44,
225+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
226+
super::ML_DSA_65,
227+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
228+
super::ML_DSA_87,
197229
];
198230

199231
const UNSUPPORTED_SIGNATURE_ALGORITHM_FOR_RSA_KEY: Error =

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pub mod aws_lc_rs {
113113
RSA_PKCS1_3072_8192_SHA384, RSA_PSS_2048_8192_SHA256_LEGACY_KEY,
114114
RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
115115
};
116+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
117+
pub use super::aws_lc_rs_algs::{ML_DSA_44, ML_DSA_65, ML_DSA_87};
116118
}
117119

118120
/// An array of all the verification algorithms exported by this crate.
@@ -173,6 +175,12 @@ pub static ALL_VERIFICATION_ALGS: &[&dyn pki_types::SignatureVerificationAlgorit
173175
aws_lc_rs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY,
174176
#[cfg(feature = "aws-lc-rs")]
175177
aws_lc_rs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
178+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
179+
aws_lc_rs::ML_DSA_44,
180+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
181+
aws_lc_rs::ML_DSA_65,
182+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
183+
aws_lc_rs::ML_DSA_87,
176184
];
177185

178186
fn public_values_eq(a: untrusted::Input<'_>, b: untrusted::Input<'_>) -> bool {

0 commit comments

Comments
 (0)