Upgrade RustCrypto ecosystem to enable ml-dsa 0.1.0-rc.8#212
Upgrade RustCrypto ecosystem to enable ml-dsa 0.1.0-rc.8#212lukevalenta merged 1 commit intomainfrom
Conversation
395add7 to
6f06cca
Compare
|
/bonk review |
There was a problem hiding this comment.
Review: Upgrade RustCrypto ecosystem to enable ml-dsa 0.1.0-rc.8
This is a large but well-structured PR that upgrades the entire RustCrypto dependency tree to enable ml-dsa 0.1.0-rc.8 (fixing a WASM stack overflow). I've reviewed all 37 changed files. Overall this is solid work — the changes are mechanically sound and the approach of introducing OwnedTbsCertificate/OwnedCertificate to work around x509-cert 0.3's private fields is pragmatic.
Architecture & Design
OwnedTbsCertificate / OwnedCertificate (x509_util) — Good solution to x509-cert 0.3's private fields. The manual DER encoding in OwnedTbsCertificate::to_der() is inherently fragile (any ASN.1 encoding bug would silently produce invalid certificates), but the round-trip tests and golden file tests provide good coverage. The from_der → to_der round-trip test confirming byte-for-byte equality with the original cert DER is the right thing to test here.
Removal of x509-verify — Replacing the x509-verify crate with hand-rolled signature dispatch in x509_util::is_link_valid is a notable change. The new code dispatches on OID to verify_p256, verify_p384, and verify_rsa — this covers the algorithms that matter for WebPKI chains (P-256, P-384, RSA with SHA-256/384/512). This is cleaner than pulling in x509-verify with all its feature flags (md2, md5, dsa, k256, p192, p224, p521...). Worth noting that if chains signed with algorithms outside this set appear in the wild, they'll be silently rejected — but that's the right behavior for CT/MTC.
Removal of [patch.crates-io] for der — The der fork is no longer needed since der 0.8 natively supports Tag::RelativeOid. Good cleanup.
LogEntry Trait Changes
The addition of the Metadata associated type and make_metadata() to the LogEntry trait is a clean generalization. This decouples the sequencer from the specific metadata shape, enabling future applications (like IETF MTC) that need old_tree_size/new_tree_size in their metadata. The existing CT and bootstrap MTC implementations correctly pass through SequenceMetadata unchanged.
Specific Observations
-
bootstrap_mtc_api::tbs_cert_to_log_entry— The function signature changed from taking ownedTbsCertificateandRdnSequenceto references (&TbsCertificate,&RdnSequence). This is a good API improvement. TheName::from_der(&issuer.to_der()?)round-trip to convertRdnSequence → Nameis a bit unfortunate but necessary sinceNameis a newtype overRdnSequencewith no directFromimpl. -
sct_validator::extract_scts_from_cert— Now parses toOwnedCertificateviafrom_der, mutates extensions in-place, and re-serializes. This is cleaner than the previous approach of reconstructing the TBS field-by-field. Theextract_lifetime_daysfunction now takes&Validityinstead of&Certificate, which is a better API. -
randmigration — TheOsRng→rand::rng(),thread_rng()→rand::rng(),gen_range→random_rangechanges look correct throughout. TheCryptoRngtrait bound change ingenerate_encoded_ed25519_keyfromCryptoRngCoretoCryptoRng + ?Sizedfollows the rand 0.10 API. -
getrandomfeatures — The feature flag change fromjstowasm_jsmatches the getrandom 0.4 rename. This is required for WASM targets. -
Golden file tests — The
build_precert_tbsandextract_scts_from_certgolden file tests are important for catching any DER encoding regressions introduced by theOwnedTbsCertificatemanual encoding path. -
Integration test fixtures — The
fixtures.rschanges forx509-cert 0.3builder API (BuilderProfile,Criticalitytrait,Validity::new, etc.) look correct. The use ofcrypto_common::Generatefor key generation follows the new RustCrypto patterns.
Potential Concerns
-
Pre-release dependencies: The PR pins several crates to RC/pre versions (ed25519-dalek 3.0.0-pre.6, p256/p384 0.14.0-rc.8, rsa 0.10.0-rc.17, signature 3.0.0-rc.10, x509-cert 0.3.0-rc.4, pkcs8 0.11.0-rc.11). The tracking comment in
Cargo.tomlis good — these should be upgraded to stable once the coordinated RustCrypto release happens. Thep384entry was added to workspace dependencies (previously not present), which is fine since it was already used transitively. -
OwnedTbsCertificate::to_der()manual encoding: This hand-rolls ASN.1 SEQUENCE construction with manual header + content concatenation. If x509-cert ever exposes a builder or public field API again, this should be replaced. The comment linking to RustCrypto/formats#1505 is helpful for future maintenance. -
validate_chaininbootstrap_mtc_api: Theissuerparameter changed fromRdnSequenceto&RdnSequence. This is a breaking API change if anything external calls this function, but sincebootstrap_mtc_apiis internal, this is fine.
Build Changes
The CI build command changed from cargo build --verbose to cargo build --tests --workspace --verbose — this ensures test-only code also compiles, which is good for catching compile errors in dev-dependencies.
Overall this is a well-executed dependency upgrade. The main risk is the manual DER encoding in OwnedTbsCertificate/OwnedCertificate, which is well-mitigated by the round-trip and golden file tests.
|
Review posted on PR #212. Here's a summary of the key findings: Overall: Well-structured dependency upgrade across 37 files. The changes are mechanically sound. Key highlights:
Main risks: Manual ASN.1 encoding in |
6f06cca to
2a71055
Compare
|
/bonk review |
There was a problem hiding this comment.
Review: RustCrypto ecosystem upgrade for ml-dsa 0.1.0-rc.8
I've reviewed all 29 changed files. This is a well-executed coordinated dependency upgrade. The code is correct, the API adaptations are mechanical and sound, and the new OwnedTbsCertificate/OwnedCertificate abstraction is a pragmatic solution to x509-cert 0.3's private fields. Approving.
What I verified
-
OwnedTbsCertificate::to_der()manual ASN.1 encoding (x509_util/src/lib.rs:79-148): The field ordering exactly matches the RFC 5280 TBSCertificate SEQUENCE (version, serialNumber, signature, issuer, validity, subject, subjectPublicKeyInfo, issuerUniqueID, subjectUniqueID, extensions). Context-specific tags and tag modes (EXPLICIT for version/extensions, IMPLICIT for unique IDs) are correct. The round-trip tests (test_owned_tbs_certificate_round_trip,test_owned_certificate_round_trip) and golden file tests provide good regression coverage. -
is_link_validsignature dispatch (x509_util/src/lib.rs:633-674): Replacingx509-verifywith direct OID dispatch toverify_p256,verify_p384,verify_p521, andverify_rsa<D>is clean. The algorithm coverage (P-256, P-384, P-521, RSA SHA-1/256/384/512) matches what's needed for WebPKI chains. The SHA-1 RSA and P-521 ECDSA chain validation tests confirm these paths work. -
x509-cert 0.3 accessor method migration: All field accesses (
tbs_certificate,subject,issuer,validity,extensions,signature,subject_public_key_info,issuer_unique_id,subject_unique_id) consistently use the new accessor methods (.tbs_certificate(),.subject(), etc.) across all crates. -
rand 0.10 migration:
OsRng→rand::rng(),thread_rng()→rand::rng(),gen_range→random_range,gen()→random(),CryptoRngCore→CryptoRng + ?Sized— all correct. The doc example insigned_note/src/lib.rsproperly usesTryRng/TryCryptoRngfor the rand 0.10 API. -
extract_scts_from_certrefactor (sct_validator/src/sct.rs:52-68): The switch toOwnedCertificatefor mutable TBS access is cleaner than the previous field-by-field reconstruction.extract_lifetime_daysnow takes&Validityinstead of&Certificate, which is a better API boundary. -
build_precert_tbsrefactor (static_ct_api/src/rfc6962.rs:224-240): UsesOwnedTbsCertificate::from(tbs), mutates extensions in-place to remove CT poison, then callsto_der(). Clean and correct. -
serialize_signatureless_cert(bootstrap_mtc_api/src/lib.rs:220-269): ConstructsOwnedTbsCertificateandOwnedCertificatedirectly from log entry fields. Thetest_serialize_signatureless_certtest verifies the round-trip. -
tbs_cert_to_log_entrysignature change (bootstrap_mtc_api/src/lib.rs:483-533): Now takes&TbsCertificateand&RdnSequence(was owned). TheName::from_der(&issuer.to_der()?)round-trip forRdnSequence → Nameis a necessary workaround sinceNameis a newtype with no directFrom<RdnSequence>. -
LogEntrytraitMetadataassociated type (tlog_tiles/src/entries.rs:70-90): Themake_metadatafactory method withold_tree_size/new_tree_sizeparameters is a clean generalization. Existing implementations (BootstrapMtcLogEntry,StaticCTLogEntry) correctly ignore the extra parameters and pass throughSequenceMetadata. -
CI build command (
.github/workflows/rust.yml:32):cargo build --tests --workspace --verboseis better than the previouscargo build --verbose— it catches compile errors in test-only code and dev-dependencies. -
derpatch removal (Cargo.toml): The[patch.crates-io]for the forkeddercrate is gone, sinceder 0.8natively supportsTag::RelativeOid. -
getrandom feature rename:
js→wasm_jsmatches the getrandom 0.4 API. -
integration_tests/src/fixtures.rs: Correctly adapted to x509-cert 0.3'sBuilderProfiletrait,Criticalitytrait,Validity::new, andcrypto_common::Generatefor key generation.
Minor observations (non-blocking)
-
The
Validity::newconstructor atx509_util/src/lib.rs:1058-1071(in the test) creates the value with separateTime::UtcTime(...)calls. This pattern appears in several places and works correctly, but it's verbose. If x509-cert ever provides a convenience constructor, it would simplify these. -
The tracking comment at
Cargo.toml:80-85for pre-release RC crates is important for future maintenance. All pinned RC versions (ed25519-dalek 3.0.0-pre.6,p256/p384/p521 0.14.0-rc.8,rsa 0.10.0-rc.17,signature 3.0.0-rc.10,x509-cert 0.3.0-rc.4,pkcs8 0.11.0-rc.11) should be upgraded together once the RustCrypto coordinated release lands. -
The
rebuild_cert_with_extensionshelper instatic_ct_api/src/rfc6962.rs:436-443is a nice demonstration of theOwnedCertificateAPI's ergonomics for test utilities.
LGTM — clean upgrade with good test coverage for the manual DER encoding paths.
|
Review posted on PR #212 with approval. Here's a summary of what I reviewed: All 29 changed files examined. The PR is a well-executed coordinated RustCrypto dependency upgrade. Key findings:
|
2a71055 to
a5862ba
Compare
Upgrades all RustCrypto crates to their latest RC versions to unblock ml-dsa 0.1.0-rc.8, which fixes a WASM stack overflow with ML-DSA signatures in Cloudflare Workers. Workspace dependency changes: - der 0.7.10 (patched fork) → 0.8.0 (Tag::RelativeOid now native) - const-oid 0.9.6 → 0.10 - spki 0.7 → 0.8 - pkcs8 (new) 0.11.0-rc.11 - signature 2.2.0 → 3.0.0-rc.10 - sha1 0.10 → 0.11 - sha2 0.10 → 0.11 - digest (new) 0.11 - rand 0.8.5 → 0.10.0 - rand_core 0.6.4 → 0.10.0 - getrandom 0.2 → 0.4 - ed25519-dalek 2.1.1 → 3.0.0-pre.6 - p256 0.13 → 0.14.0-rc.8 - p384 0.13 → 0.14.0-rc.8 - p521 0.13 → 0.14.0-rc.8 - rsa 0.9 → 0.10.0-rc.17 - x509-cert 0.2.5 → 0.3.0-rc.4 - crypto-common (new) 0.2 Add OwnedTbsCertificate and OwnedCertificate to x509_util: - Freely mutable owned representations of the x509-cert types whose fields were made private in x509-cert 0.3 (RustCrypto/formats#1505) - DER encoding/decoding via #[derive(Sequence)] with #[asn1(...)] attributes, matching the pattern used by TbsCertificateLogEntry in bootstrap_mtc_api and the original x509-cert 0.2 structs - Used in static_ct_api (rfc6962.rs) and bootstrap_mtc_api wherever certificate fields need to be mutated before re-encoding Adapt to x509-cert 0.3 API changes (private fields → accessor methods, Validity::new, RelativeDistinguishedName::try_from, etc.) throughout bootstrap_mtc_api, bootstrap_mtc_worker, ct_worker, sct_validator, static_ct_api, and integration_tests. Adapt to rand 0.10 API changes (OsRng→SysRng, thread_rng()→rng(), gen_range→random_range, RngExt, TryRng/TryCryptoRng in doc examples). Adapt is_link_valid in x509_util to the upgraded crates: - verify_rsa bound: sha2::digest::Digest + rsa::pkcs8::AssociatedOid → digest::Digest + const_oid::AssociatedOid (rsa 0.10-rc API) - verify_p521: p521 0.14 makes VerifyingKey a type alias for ecdsa::VerifyingKey<NistP521>, so it now uses the same TryFrom<SubjectPublicKeyInfoRef>/DerSignature pattern as p256/p384
a5862ba to
04a9e43
Compare
Upgrades all RustCrypto crates to their latest RC versions to unblock
ml-dsa 0.1.0-rc.8, which fixes a WASM stack overflow with ML-DSA
signatures in Cloudflare Workers.
Workspace dependency changes:
In x509_util, adapt is_link_valid to the upgraded crates:
to digest::Digest + const_oid::AssociatedOid to match rsa 0.10-rc's API
for ecdsa::VerifyingKey, so it now inherits TryFrom
and DerSignature, matching the p256/p384 helper pattern
Add OwnedTbsCertificate and OwnedCertificate to x509_util:
and CertificateInner (all fields pub), making it straightforward to
construct, modify, and re-encode certificates without the field-by-field
DER boilerplate that x509-cert 0.3's private fields otherwise require
to_x509 for ergonomic construction and conversion
build_precert_tbs, extract_scts_from_cert, serialize_signatureless_cert
from_der; extract_lifetime_days accepts &Validity instead of &Certificate
unique ID and extension encoding
Adapt to x509-cert 0.3 API changes (private fields, accessor methods,
Validity::new, RelativeDistinguishedName::try_from, etc.) throughout
bootstrap_mtc_api, bootstrap_mtc_worker, ct_worker, sct_validator,
static_ct_api, and integration_tests.
Adapt to rand 0.10 API changes (OsRng→SysRng, thread_rng()→rng(),
gen_range→random_range, RngExt, TryRng/TryCryptoRng in doc examples).