Remove x509-verify; inline signature verification in is_link_valid#209
Remove x509-verify; inline signature verification in is_link_valid#209lukevalenta merged 1 commit intomainfrom
Conversation
|
/bonk review |
There was a problem hiding this comment.
Review
Clean removal of x509-verify with a well-scoped inline replacement. Clippy is clean, all 46 tests pass (x509_util: 26, static_ct_api: 20).
Code-level observations
ECDSA_WITH_SHA_512 fallback logic (lines 469-472): The comment says "P-521 is unsupported, so try P-256 then P-384", but ecdsa-with-SHA512 with a P-256 key would be unusual verging on non-existent — SHA-512 is truncated to 256 bits on P-256, and I'm not aware of any real CA chain doing this. Practically this is harmless since p256::ecdsa::VerifyingKey::try_from will reject a P-384 SPKI (and vice versa), so the fallback chain is safe — it just burns a failed parse. If this is based on a specific real-world observation feel free to keep it; otherwise verify_p384 alone would be the more obvious choice for SHA-512.
use signature::Verifier as _; appears three times — once in is_link_valid (line 450, inside the ECDSA branch but before the match arms where it's actually used) and once in each of verify_p256 (line 508) and verify_p384 (line 520). The import inside is_link_valid is dead — it's only needed in the RSA branch and the two helper functions. Consider removing the one at line 450 and keeping it only where vk.verify() is actually called (the two helpers and the RSA match arms). Clippy doesn't catch it because use … as _ is excluded from unused-import warnings, but it's still noise.
Minor: redundant double-match on sig_alg for RSA (lines 473-501). The outer match already binds the three RSA OIDs, then an inner match re-dispatches on the same variable. A slight restructure could avoid this — e.g., three separate outer arms or a helper — but this is a readability nit, not a correctness issue.
Everything else looks good
spki::Errorreplacingx509_verify::spki::ErrorinStaticCTError— correct, same type.x509_cert::Certificatereplacingx509_verify::x509_cert::Certificatein test imports — correct,x509-verifywas just re-exporting.p384promoted to explicit workspace dep withecdsafeature — matches what the code uses.x509-verifyandsignatureremoved fromcargo-macheteignored list —signatureis now a real transitive dep viax509_util, no longer needs ignoring.- Cargo.lock shrinks by removing
dsa,k256,md-5,md2,p192,p224,p521,x509-ocsp, andx509-verify— expected given the feature list that was enabled.
|
Review posted on PR #209. Here's a summary of my findings: Verification results: Clippy clean, all 46 tests pass across Key feedback points:
Overall the PR is a clean, well-motivated removal of |
c49e37a to
bddb2b7
Compare
|
/bonk review |
There was a problem hiding this comment.
Verified: clippy clean, all 46 tests pass (26 x509_util, 20 static_ct_api).
This is a clean, well-scoped removal. The inline replacement in is_link_valid is straightforward and covers exactly the algorithm set needed for real-world CT/MTC chains. The helper functions (verify_p256, verify_p384, verify_rsa) are well-factored and the generic RSA approach avoids repetition.
Agree with the prior review's observations — the ECDSA_WITH_SHA_512 → verify_p384 mapping is the right call (SHA-512 with P-256 is essentially non-existent in practice), and the code is safe even in the theoretical fallback case since SPKI parsing rejects curve mismatches. The other points (dead use signature::Verifier as _ at line 450 in the old revision, redundant double-match on RSA) look like they were already addressed in the current version — the helpers now each import Verifier locally where needed, and the RSA dispatch is clean with three separate outer match arms.
The dependency changes are all correct:
p384promoted to explicit workspace dep withecdsafeaturespkiadded directly tostatic_ct_api(was previously re-exported byx509-verify)x509-verifyandsignatureremoved from cargo-machete ignore list- Cargo.lock shrinks appropriately (removes
dsa,k256,md-5,md2,p192,p224,p521,x509-ocsp,x509-verify)
LGTM.
|
PR #209 has been approved. The changes are clean and correct — |
bddb2b7 to
512527f
Compare
|
/bonk review |
There was a problem hiding this comment.
Review
Verified: all 48 tests pass (28 x509_util, 20 static_ct_api), clippy is clean with -D warnings.
This is a well-executed removal of x509-verify. The inline replacement is focused and correct — it covers exactly the signature algorithms present in real-world TLS/PKI chains. The updates addressing Lekensteyn's feedback (adding P-521 support and SHA-1 RSA) are sound.
Code observations
verify_p521 workaround (lines 500-520): The SEC1 workaround for p521 0.13.x is well-documented and correct. One subtlety: unlike verify_p256 and verify_p384 which use TryFrom<SubjectPublicKeyInfoRef> (which validates both the algorithm OID and the key bytes), verify_p521 extracts raw subject_public_key bytes and passes them to from_sec1_bytes, which only validates the point is on the P-521 curve. This means a hypothetical SPKI with algorithm OID id-ecPublicKey + named curve secp256r1 but containing a valid 133-byte P-521 point would pass verify_p521 — which cannot happen in practice (key sizes differ), but worth noting. This is fine and will be resolved naturally when upgrading to p521 >=0.14.
Algorithm dispatch (lines 461-471): Clean and easy to follow. The ECDSA_WITH_SHA_512 → verify_p521 mapping is now correct, consistent with the real-world certificate data Lekensteyn identified (e-Szigno TLS Root CA 2023).
Helper functions (lines 474-537): The use signature::Verifier as _; imports are placed correctly — one per helper where .verify() is actually called. The generic RSA helper avoids repetition nicely.
Test coverage: The new SHA-1 RSA and P-521 ECDSA chain tests exercise the newly added code paths end-to-end through validate_chain_lax, which is good coverage.
Dependency changes: All correct — p384, p521, sha1 promoted to explicit workspace deps; spki added directly to static_ct_api; x509-verify and signature removed from cargo-machete ignore list; Cargo.lock shrinks as expected.
LGTM.
|
I've reviewed and approved PR #209. Here's a summary: Verification: All 48 tests pass (28 x509_util + 20 static_ct_api), clippy is clean. Assessment: This is a clean, well-scoped removal of
The one minor subtlety I noted is that |
rozbb
left a comment
There was a problem hiding this comment.
LGTM! I got a little confused bc your first comment said that P-521 and SHA1 are excluded, but they are in fact supported
Oops, I've fixed the description! |
Replace the x509-verify dependency with a focused inline implementation in is_link_valid (x509_util) supporting the algorithms used in real-world TLS/PKI certificate chains: - ECDSA P-256 (ecdsa-with-SHA256) - ECDSA P-384 (ecdsa-with-SHA384) - ECDSA P-521 (ecdsa-with-SHA512) - RSA PKCS#1 v1.5 (SHA-1, SHA-256, SHA-384, SHA-512) SHA-1 and P-521 support is added to handle roots still present in major trust stores: 26 SHA-1 RSA roots remain in Mozilla's store (including DigiCert and GlobalSign), and one P-521 root (e-Szigno TLS Root CA 2023) is Mozilla-trusted. Add p384, p521, and sha1 as workspace dependencies. Replace x509_verify::spki::Error with spki::Error directly in static_ct_api::StaticCTError — x509-verify was only re-exporting spki. Remove x509-verify from integration_tests and from the cargo-machete ignored list (also removes 'signature' which was never directly used).
512527f to
b996b5c
Compare
|
I'm going to go ahead and merge to unblock other changes, but happy to address any other feedback in followup PRs! |
Summary
Removes the
x509-verifydependency and replaces it with a focused inline implementation inis_link_valid(x509_util) that supports exactly the algorithms present in real-world TLS/PKI certificate chains. This is a subset of the changes from #204 for updating the RustCrypto ecosystem (x509-verify uses but is not part of RustCrypto, and is not kept up-to-date with release candidate versions).Supported algorithms:
ecdsa-with-SHA256)ecdsa-with-SHA384)ecdsa-with-SHA512) (notably, was not enabled in the existingx509-verifyfeature set)Intentionally excluded (none appear in any configured root pool, and none were enabled in our existing
x509-verifyfeature set):Other changes:
p384andp521as an explicit workspace dependencies (previously only transitive deps viax509-verify)x509_verify::spki::Errorwithspki::Errordirectly instatic_ct_api::StaticCTError—x509-verifywas only re-exportingspkix509-verifyfromintegration_testsand from thecargo-macheteignored list; also removesignaturefrom that list (was never directly used)