Skip to content

Commit 25c57cb

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

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

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: 29 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,27 @@ impl SignatureVerificationAlgorithm for AwsLcRsAlgorithm {
5456
}
5557
}
5658

59+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
60+
pub static ML_DSA_44: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
61+
public_key_alg_id: alg_id::ML_DSA_44,
62+
signature_alg_id: alg_id::ML_DSA_44,
63+
verification_alg: &unstable::signature::MLDSA_44,
64+
};
65+
66+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
67+
pub static ML_DSA_65: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
68+
public_key_alg_id: alg_id::ML_DSA_65,
69+
signature_alg_id: alg_id::ML_DSA_65,
70+
verification_alg: &unstable::signature::MLDSA_65,
71+
};
72+
73+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
74+
pub static ML_DSA_87: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
75+
public_key_alg_id: alg_id::ML_DSA_87,
76+
signature_alg_id: alg_id::ML_DSA_87,
77+
verification_alg: &unstable::signature::MLDSA_87,
78+
};
79+
5780
/// ECDSA signatures using the P-256 curve and SHA-256.
5881
pub static ECDSA_P256_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm {
5982
public_key_alg_id: alg_id::ECDSA_P256,
@@ -194,6 +217,12 @@ mod tests {
194217
// Algorithms deprecated because they are nonsensical combinations.
195218
super::ECDSA_P256_SHA384, // Truncates digest.
196219
super::ECDSA_P384_SHA256, // Digest is unnecessarily short.
220+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
221+
super::ML_DSA_44,
222+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
223+
super::ML_DSA_65,
224+
#[cfg(all(feature = "__aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
225+
super::ML_DSA_87,
197226
];
198227

199228
const UNSUPPORTED_SIGNATURE_ALGORITHM_FOR_RSA_KEY: Error =

src/lib.rs

Lines changed: 2 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.

0 commit comments

Comments
 (0)