Repository navigation
feat(xmldsig): expose KeyInfo candidates of verified signatures - #329
Conversation
A verified session now visits the key material an authenticated Signature's KeyInfo offered, as core verification parsed and materialized it: no second parse and no trust decision. - VerifiedSession::visit_key_info_candidates_in and SelectedSignature::visit_key_info_candidates visit certificate DER, DEREncodedKeyValue SPKI, parsed KeyValue and unmaterialized RetrievalMethod candidates in document order. - Each candidate names its own element (each certificate its X509Certificate) or, for material read from a caller-supplied resource, the KeyInfoReference or RetrievalMethod that read it. Element provenance travels with the sources through reference expansion and retrieval. - KeyInfoReading tells Read, Absent, or NotRead (caller, resolver or recipient key), so an unread KeyInfo is never an empty list. - Scoped verification moves the parsed buffers into the session and reserves their capacity on its account; collecting verification retains nothing. Each visit charges the query Work. Closes #251
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16e3babd3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🔇 Additional comments: 1
src/xmldsig/verify/session/key_info.rs: 1
8-9:Trivial · Maintainability & Code Quality · Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Mark the new public types
#[non_exhaustive].
KeyInfoReading,KeyInfoOriginandKeyInfoCandidateare public. They are re-exported fromxmldsig. OnlyKeyInfoMaterialhas#[non_exhaustive].The related public types in this crate, such as
ReferenceCoverageandExternalPayload, use#[non_exhaustive]. Without it, adding aKeyInfoReadingorKeyInfoOriginvariant, or aKeyInfoCandidatefield, is a breaking change.♻️ Proposed change
#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum KeyInfoReading {#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum KeyInfoOrigin {#[derive(Clone, Copy, Debug)] +#[non_exhaustive] pub struct KeyInfoCandidate<'a> {
tests/key_info_candidates.rsmatchesKeyInfoReadingonly throughassert_eq!. It does not break with this change.Also applies to: 21-22, 54-55

Review info
-
Run configuration-
- Source mode: Auto
- Repository: structured-world/xml-sec
- Branch: feat/&
#35;251-key-info-candidates - File: .coderabbit.yaml
- Commit: 16e3bab
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ab9cdba5-8552-4ed3-8794-90dda256f6f3
Files selected for processing: 9-
docs/xmldsig.mdsrc/xmldsig/mod.rssrc/xmldsig/parse.rssrc/xmldsig/verify.rssrc/xmldsig/verify/capture.rssrc/xmldsig/verify/session.rssrc/xmldsig/verify/session/key_info.rssrc/xmldsig/verify/tests.rstests/key_info_candidates.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
-
- A RetrievalMethod an external KeyInfo left unread was dropped before candidate retention, so a visit could report Read while omitting an offered hint. Scoped verification now keeps those hints apart from key selection and visits them as Unmaterialized, attributed to the KeyInfoReference that read that KeyInfo, after the document-order candidates. Collecting verification still discards them. - KeyInfoReading, KeyInfoOrigin and KeyInfoCandidate are #[non_exhaustive], like KeyInfoMaterial. Regression test: an_unread_hint_inside_external_key_info_is_still_a_candidate. Part of #251
Summary
A consumer that validates certificate paths with its own trust inputs can now get the key material a verified signature's
KeyInfooffered, bound to exactly what core verification read. Before, verification parsedKeyInfoonly for key selection and dropped it, and a retainedXmlDocumentgave no way back to the nodes.Session API
VerifiedSession::visit_key_info_candidates_in(signature, work, visitor)(orSelectedSignature::visit_key_info_candidates) visits the candidates of an authenticated Signature in document order, as verification parsed and materialized them under the operation's policy, budgets and provider. There is no second parse and no trust decision: the selected-key receipt still tells which key verified.KeyInfoMaterial:Certificate(DER fromX509Certificateor a raw certificateRetrievalMethod),SubjectPublicKeyInfo(dsig11:DEREncodedKeyValue),KeyValue(parsed parameters, including unusable ones) andUnmaterialized(aRetrievalMethodverification did not read).KeyNameoffers no material and is not a candidate.KeyInfoOrigin::Elementnames the material's own element: each certificate itsX509Certificate, also when a same-documentKeyInfoReferenceorX509DataRetrievalMethodled to it.KeyInfoOrigin::Retrievednames theKeyInfoReferenceorRetrievalMethodthat read material from a caller-supplied resource.RetrievalMethodan externalKeyInfoleft unread is still visited asUnmaterialized, attributed to theKeyInfoReferencethat read thatKeyInfo, after the document-order candidates. It never reaches key selection, which would resolve it against the wrong document.KeyInfoReading,KeyInfoOrigin,KeyInfoMaterialandKeyInfoCandidateare#[non_exhaustive].KeyInfoReading:Read,Absent, orNotReadwhen the key came from the caller, a resolver ignoring document hints or a recipient mechanism. An unreadKeyInfois never reported as an empty one. An unauthenticated Signature is not selectable.Retention
Scoped verification moves the parsed buffers into the session after the SignatureValue verifies and reserves their capacity on the session's account until it ends; nothing is copied. Collecting verification retains nothing: element tracking is gated at compile time by the capture type. No policy is added; the existing
KeyInfoingestion limits bound retention, and each visit charges the queryWork. Public parse types are unchanged.docs/xmldsig.mddocuments the API in a new "KeyInfoCandidates" section.Testing
cargo fmt --check;cargo clippy --workspace --all-targets -D warningswith all features and with defaults; library clippy for the verification-onlyxmldsiggraph;node scripts/check-pedantic-lints.mjs stable;scripts/check-features.shfordsig-roxmltreeanddsig-xmloxide.cargo nextest run --workspace --all-featureswith the pinned xmlsec1 1.3.13 oracle: 5709 passed; the PKCS#11 test passed separately throughscripts/test-pkcs11.shwith a disposable SoftHSM store.cargo test --doc --workspace --all-features;RUSTDOCFLAGS=-D warnings cargo doc --workspace --all-features --no-deps.tests/key_info_candidates.rs: every material with its own element, caller key (NotRead) and missingKeyInfo(Absent), same-documentKeyInfoReferenceandX509DataRetrievalMethod, externalKeyInfoReferenceand raw certificate retrieval attributed to their instruction with an unsupplied resource left unmaterialized, an unread hint inside an externalKeyInfo, unauthenticated Signature refused, exhausted query work and visitor errors kept distinct, and retained capacity charged until the session ends.Closes #251