Skip to content

test(xmldsig): add donor full verification suite accounting - #41

Merged
polaz merged 16 commits into
mainfrom
test/#40-p1-025-donor-verification-suite
Apr 4, 2026
Merged

polaz merged 16 commits into
mainfrom
test/#40-p1-025-donor-verification-suite

Conversation

@polaz

@polaz polaz commented Mar 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • implement P1-025 donor full verification suite with deterministic pass/fail/skip accounting
  • migrate XMLDSig crypto backend from ring to RustCrypto (rsa + p256/p384/p521 + sha1/sha2)
  • add Aleksey P-521 (ecdsa-sha384) donor coverage with explicit interop validation rules and exact skip inventory assertions
  • track Merlin donor vectors as explicit expected skips with concrete reasons

Testing

  • cargo fmt -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo nextest run --all-features
  • cargo build

Closes #40

- add P1-025 integration suite with deterministic pass/fail/skip tracking
- validate aleksey RSA/ECDSA vectors through verify pipeline
- record explicit skip reasons for deferred merlin DSA/KeyInfo/X509 vectors

Closes #40
Copilot AI review requested due to automatic review settings March 30, 2026 03:11
@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d882ad55-82ef-4e71-abd1-0218a47e2380

📥 Commits

Reviewing files that changed from the base of the PR and between 68fa067 and 1b6631e.

📒 Files selected for processing (2)
  • Cargo.toml
  • tests/donor_full_verification_suite.rs

📝 Walkthrough

Summary by CodeRabbit

  • Tests

    • Added a donor full XML signature verification suite (verifies 6 passing cases and records 8 skipped cases) and updated a smoke test’s fixture counts.
    • Added 7 new XML signature fixtures covering DSA, RSA and multiple X.509 variants.
  • Chores

    • Updated cryptographic dependency and implementation wiring to new crypto components for signature and digest handling.

Walkthrough

Adds a donor XMLDSig integration test tracking pass/fail/skip counts, introduces seven Merlin donor XMLDSig fixtures, updates fixture inventory expectations, replaces the ring crypto backend with RustCrypto crates, and reimplements digest and signature verification to use the new primitives and formats.

Changes

Cohort / File(s) Summary
Integration test
tests/donor_full_verification_suite.rs
Adds donor_full_verification_suite_tracks_pass_fail_skip_counts that enumerates donor vectors, runs verification (PEM and probe paths), and asserts exact passed/failed/skipped counts and ordered skip reasons.
Merlin donor fixtures
tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/...
signature-enveloped-dsa.xml, signature-enveloping-rsa.xml, signature-x509-crt-crl.xml, signature-x509-crt.xml, signature-x509-is.xml, signature-x509-ski.xml, signature-x509-sn.xml
Adds seven XMLDSig fixtures (enveloped/enveloping, DSA/RSA, X.509 variants) used by the new donor test.
Fixture inventory test
tests/fixtures_smoke.rs
Updates expected fixture totals and embedded message text to reflect added fixtures (total count updated to 77; donor xmldsig count updated).
Cargo dependency changes
Cargo.toml
Removes ring; adds optional RustCrypto-style crates (rsa, sha1, sha2, p256, p384, p521, signature, subtle, optional x509-parser/der) and wires them into xmldsig feature.
Digest implementation
src/xmldsig/digest.rs
Replaces ring hashing with RustCrypto (sha1, sha2) and swaps ring constant-time equality for subtle::ConstantTimeEq.
Signature verification
src/xmldsig/signature.rs
Reimplements RSA and ECDSA verification via RustCrypto: SPKI parsing, RSA PKCS#1 v1.5 verification per-hash, modulus-bit checks, curve-specific ECDSA (p256/p384/p521) handling, and DER vs fixed-width signature interpretation.
Test helpers / ECDSA tests
tests/c14n_golden.rs, tests/ecdsa_signature_integration.rs
Switches SHA-1 test helper to sha1 crate; replaces ring P-384 signing with p384 signing primitives and emits raw/DER bytes as required by tests.
Docs/comments
src/xmldsig/parse.rs
Doc-only clarification for SignatureAlgorithm::EcdsaP384Sha384.

Sequence Diagram(s)

sequenceDiagram
    participant Test Runner
    participant Fixture
    participant Verify Pipeline
    participant RustCrypto
    Test Runner->>Fixture: load XML vector (+ optional PEM)
    Test Runner->>Verify Pipeline: verify_signature_with_pem_key(xml, key) / VerifyContext::verify(xml)
    Verify Pipeline->>Fixture: parse SignedInfo / References / KeyInfo
    Verify Pipeline->>RustCrypto: compute digest (SHA-1/SHA-2)
    Verify Pipeline->>RustCrypto: parse SPKI / prepare verifying key
    Verify Pipeline->>RustCrypto: verify signature (RSA PKCS#1 v1.5 or ECDSA)
    RustCrypto-->>Verify Pipeline: verification result / parse errors
    Verify Pipeline-->>Test Runner: Ok(Valid)/Ok(Invalid(reason))/Err(Unsupported)
    Test Runner->>Test Runner: increment passed/failed/skipped and record diagnostics
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • #40 — test(xmldsig): implement P1-025 donor full verification suite — This PR implements the donor full verification test and Merlin vectors that match the issue objectives.
  • structured-world/xml-sec#39 — Adds donor full verification vectors and deterministic test accounting consistent with that issue's scope.

Possibly related PRs

  • structured-world/xml-sec#34 — Related: interacts with VerifyContext/VerifyResult model and status-based outcomes used by the new integration test.
  • structured-world/xml-sec#27 — Related: overlaps on ECDSA verification logic, curve handling, and signature format processing.
  • structured-world/xml-sec#22 — Related: overlaps on RSA verification changes and PKCS#1 v1.5 verification implementation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test(xmldsig): add donor full verification suite accounting' directly summarizes the main change—implementing P1-025 donor full verification suite with deterministic pass/fail/skip accounting for XMLDSig.
Description check ✅ Passed The description clearly covers the changeset: implementing P1-025 donor full verification suite, migrating from ring to RustCrypto, adding Aleksey P-521 coverage, and tracking Merlin vectors as expected skips.
Linked Issues check ✅ Passed The PR fulfills all acceptance criteria from issue #40: deterministic pass/fail/skip accounting test, Aleksey RSA-SHA* and ECDSA-SHA* vectors passing, Merlin vectors with explicit skip reasons, and build/test/lint commands passing.
Out of Scope Changes check ✅ Passed All changes are in scope: test fixtures, test implementations, crypto dependency migration (ring→RustCrypto) supporting the verification suite, and documentation updates necessary for the full verification suite implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/#40-p1-025-donor-verification-suite

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an integration test suite for ROADMAP task P1-025 to run end-to-end XMLDSig verification against donor vectors while tracking deterministic pass/fail/skip accounting.

Changes:

  • Introduces a new integration test enumerating donor vector cases with expected outcomes (valid vs explicit skip).
  • Runs supported Aleksey RSA/ECDSA vectors through xmldsig::verify_signature_with_pem_key and asserts overall validity.
  • Records skip reasons for deferred Merlin vectors and asserts expected pass/skip counts.

Comment thread tests/donor_full_verification_suite.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/donor_full_verification_suite.rs`:
- Around line 137-139: The test eagerly calls read_fixture before matching on
case.expectation, causing Skip cases to attempt filesystem reads; move the
read_fixture call inside the match so only the ValidWithKey (or other variants
that actually need the fixture) arm(s) call read_fixture. Specifically, in the
loop over cases() defer calling read_fixture(&root.join(case.xml_path)) until
inside the match for Expectation::ValidWithKey (and any other expectation
variants that require the XML), leaving Skip arms to avoid filesystem access and
simply count as skipped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a2c9b5fc-5390-4910-af75-81205b2b3a8a

📥 Commits

Reviewing files that changed from the base of the PR and between 561d6fd and 272381b.

📒 Files selected for processing (1)
  • tests/donor_full_verification_suite.rs

Comment thread tests/donor_full_verification_suite.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/donor_full_verification_suite.rs`:
- Around line 163-167: The test assertion uses assert!(failed.is_empty(), ...)
which should be replaced with assert_eq!(failed.len(), 0, ...) to provide
structured failure output; update the assertion referencing the failed variable
(the existing assert block that prints failed.join("\n")) to use
assert_eq!(failed.len(), 0, "donor full verification suite had failures:\n{}",
failed.join("\n")) so failure counts and messages are clearer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 275bf27e-5f2c-4941-a1a9-d011af2d416b

📥 Commits

Reviewing files that changed from the base of the PR and between 272381b and 0dd410f.

📒 Files selected for processing (1)
  • tests/donor_full_verification_suite.rs

Comment thread tests/donor_full_verification_suite.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread tests/donor_full_verification_suite.rs Resolved
Comment thread tests/donor_full_verification_suite.rs Resolved
Comment thread tests/donor_full_verification_suite.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread tests/donor_full_verification_suite.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread tests/donor_full_verification_suite.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/donor_full_verification_suite.rs`:
- Around line 16-20: The VectorCase struct's xml_path field should be changed
from Option<&'static str> to &'static str to enforce the invariant at compile
time; update the struct definition (VectorCase { xml_path: &'static str, ... }),
adjust every VectorCase construction to supply the fixture string instead of
Some(...), and remove any runtime .expect(...) / match arms that handle None
(use xml_path directly in the test loop and in helper calls like the XML-loading
logic). Also update other places that referenced xml_path as Option (e.g., where
instances are created around the other noted cases) so they pass plain &'static
str values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dfd8e466-5690-48a1-9ce6-295af073a94a

📥 Commits

Reviewing files that changed from the base of the PR and between 75f07d0 and ba269ff.

📒 Files selected for processing (9)
  • tests/donor_full_verification_suite.rs
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-enveloped-dsa.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-enveloping-rsa.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-crt-crl.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-crt.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-is.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-ski.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-sn.xml
  • tests/fixtures_smoke.rs

Comment thread tests/donor_full_verification_suite.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread tests/donor_full_verification_suite.rs Resolved
Comment thread tests/donor_full_verification_suite.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/donor_full_verification_suite.rs`:
- Around line 164-166: Replace the loose length-only check for skipped entries
with an exact comparison: build an expected_skipped Vec (or slice) of the exact
"case.name: reason" strings you expect and assert equality against the collected
skipped Vec (or, if ordering is not stable, sort both before comparing); update
the code that pushes format!("{}: {}", case.name, reason) in the
Expectation::Skip arm (symbols: Expectation::Skip, skipped, case.name, reason,
read_fixture) and replace the later skipped.len() assertion with
assert_eq!(skipped, expected_skipped) (or assert_eq!(sorted_skipped,
sorted_expected_skipped)) so failures show the concrete missing/extra entries
and reasons; apply the same change to the other occurrence referenced around the
later block.
- Around line 70-74: The test entry currently marks the vector
"aleksey-ecdsa-p521-sha384" as Expectation::Skip which incorrectly removes it
from the pass set; change that Expectation to include the vector in the passing
set (e.g., replace Expectation::Skip { ... } with Expectation::ValidWithKey {
... } or the appropriate passing variant used in this suite) so the Aleksey
P-521 ECDSA-SHA384 fixture is exercised and counted as passed, and if you
instead intend to narrow Aleksey coverage, update the suite’s claimed
coverage/summary to exclude P-521 rather than leaving the specific name skipped;
locate the entry by the name "aleksey-ecdsa-p521-sha384" and the
Expectation::Skip construct to apply the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 81b4231c-235e-4c0f-8e93-15e1bc19c751

📥 Commits

Reviewing files that changed from the base of the PR and between 75f07d0 and bff2b95.

📒 Files selected for processing (9)
  • tests/donor_full_verification_suite.rs
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-enveloped-dsa.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-enveloping-rsa.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-crt-crl.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-crt.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-is.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-ski.xml
  • tests/fixtures/xmldsig/merlin-xmldsig-twenty-three/signature-x509-sn.xml
  • tests/fixtures_smoke.rs

Comment thread tests/donor_full_verification_suite.rs Resolved
Comment thread tests/donor_full_verification_suite.rs Resolved
Comment thread tests/donor_full_verification_suite.rs Resolved
- replace ring digests/signature verification with RustCrypto crates

- add ECDSA P-521 (ecdsa-sha384) verification path and donor fixture coverage

- update integration tests and fixture inventory to match new crypto backend
@polaz
polaz requested a review from Copilot April 4, 2026 07:24
@polaz
polaz merged commit 50b85a9 into main Apr 4, 2026
13 checks passed
@polaz
polaz deleted the test/#40-p1-025-donor-verification-suite branch April 4, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

polaz added a commit that referenced this pull request Apr 4, 2026
- map manifest reference parse failures to explicit DsigError variant
- track reference origin/index for SignedInfo vs Manifest processing
- process only direct ds:Manifest children under ds:Object

Closes #41
polaz added a commit that referenced this pull request Apr 4, 2026
- reject non-whitespace mixed text in ds:Manifest

- return manifest-specific InvalidStructure for empty manifest children

- explicitly handle MissingUri in manifest policy precheck

- add regression tests for mixed content and empty manifest

Closes #41
polaz added a commit that referenced this pull request Apr 4, 2026
- clarify process_manifests docs to require ID-based same-document references

- document whole-document URI references as non-signing for direct child selection

- add regression test for SignedInfo reference to ds:Object with nested Manifest without ID

Refs #41
polaz added a commit that referenced this pull request Apr 4, 2026
…-processing

feat(xmldsig): process manifest references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(xmldsig): implement P1-025 donor full verification suite

2 participants