Skip to content

feat(cms): add CMS signature provider - #343

Merged
polaz merged 2 commits into
mainfrom
feat/#332-cms-signature-provider
Oct 30, 2026
Merged

polaz merged 2 commits into
mainfrom
feat/#332-cms-signature-provider

Conversation

@polaz

@polaz polaz commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The optional cms feature adds xmldsig::cms::CmsProvider, which implements the structured-cms provider contract over one CryptoProvider and one compiled VerificationPolicy.
  • VerifiedSession::cms_provider binds it to the operation that verified the XML signature, so RFC 3161 tokens are checked with the same provider, policy and budgets.
  • Plain xmldsig still compiles no CMS processor, and cms builds without std.

Changes

  • Digests start through SessionDigest under the digest policy; ASN.1 digest identifiers resolve through the shared PKIX resolver.
  • Signature identifiers resolve through the shared PKIX mapping under the certificate-signature permissions, provider capability and RSA/DSA key policy. rsaEncryption takes its hash from digestAlgorithm (RFC 3370 3.2); ECDSA and RSA-PSS identifiers must name the same hash (RFC 5753 2.1.1, RFC 4056 3), Ed25519 requires SHA-512 and Ed448 requires SHAKE256, which is not a supported digest (RFC 8419 3).
  • One CmsProvider holds one certificate account for its processing session, so signer key checks share max_x509_work.
  • The provider verifies contiguous signed bytes, so every signature uses raw mode with the signed octets admitted against the operation memory.
  • The cms-xmloxide profile of check-features refuses signing and import crates in its dependency graph and runs real tokens from OpenSSL (RSA, RSA-PSS, ECDSA P-256, Ed25519). The verification-only profiles now also refuse structured-cms.
  • scripts/generate-cms-timestamp-fixtures.sh regenerates those tokens.

Testing

Feature profiles, all-feature tests with the xmlsec1 oracle and PKCS#11, lints and the thumbv7em-none-eabihf check pass on macOS; CI runs the full gates on all platforms.

Closes #332

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between a8ad3a9 and 248194c.

Files selected for processing: 22
  • .github/workflows/ci.yml
  • Cargo.toml
  • docs/features.md
  • scripts/generate-cms-timestamp-fixtures.sh
  • src/xmldsig/cms.rs
  • src/xmldsig/mod.rs
  • src/xmldsig/pkix.rs
  • src/xmldsig/verify/session/lookup.rs
  • tests/cms_timestamp.rs
  • tests/fixtures/cms/timestamp/ecdsa-p256.der
  • tests/fixtures/cms/timestamp/ecdsa-p256.tst
  • tests/fixtures/cms/timestamp/ed25519.der
  • tests/fixtures/cms/timestamp/ed25519.tst
  • tests/fixtures/cms/timestamp/ed448.der
  • tests/fixtures/cms/timestamp/payload.txt
  • tests/fixtures/cms/timestamp/rsa-pss-signed.der
  • tests/fixtures/cms/timestamp/rsa-pss.der
  • tests/fixtures/cms/timestamp/rsa-pss.tst
  • tests/fixtures/cms/timestamp/rsa.der
  • tests/fixtures/cms/timestamp/rsa.tst
  • tools/xml-sec-tools/src/check_features.rs
  • tools/xml-sec-tools/src/check_features/tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T21:57:24.644971Z 248194c New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from build/#341-primitives-0.18 to main October 30, 2026 21:18

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f248881cd

ℹ️ 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".

Comment thread src/xmldsig/cms.rs Resolved
Comment thread src/xmldsig/cms.rs Resolved
polaz added 2 commits October 30, 2026 23:20
- The optional `cms` feature adds `xmldsig::cms::CmsProvider`, which
  implements the structured-cms provider contract over one CryptoProvider
  and one compiled VerificationPolicy; `VerifiedSession::cms_provider`
  binds it to the operation that verified the XML signature.
- Digests start through SessionDigest under the digest policy; ASN.1
  digest identifiers resolve through the shared PKIX resolver.
- Signature identifiers resolve through the shared PKIX mapping under
  the certificate-signature permissions, provider capability and RSA/DSA
  key policy. rsaEncryption takes its hash from digestAlgorithm
  (RFC 3370 3.2); an ECDSA identifier must name digestAlgorithm's hash
  (RFC 5753 2.1.1).
- The provider verifies contiguous signed bytes, so every signature uses
  raw mode with the signed octets admitted against the operation memory.
- Plain `xmldsig` still compiles no CMS processor; the new cms-xmloxide
  profile checks its graph and runs real RFC 3161 tokens from OpenSSL
  (RSA, RSA-PSS, ECDSA P-256, Ed25519).

Closes #332
- Raw verification never reads digestAlgorithm, so a signer naming the
  wrong digest passed. RSA-PSS now requires its hash (RFC 4056 section 3),
  Ed25519 requires SHA-512 and Ed448 refuses every resolvable digest, since
  it requires SHAKE256 (RFC 8419 sections 3.1 and 3.2).
- Each signer resolution opened a new certificate account, so repeated key
  checks could exceed the cumulative max_x509_work. One CmsProvider now
  holds one account for its processing session.

Regression tests cover both, on two new certificate fixtures.
@polaz
polaz force-pushed the feat/#332-cms-signature-provider branch from 2f24888 to 248194c Compare October 30, 2026 21:55
@polaz
polaz merged commit 88d3bd3 into main Oct 30, 2026
29 checks passed
@polaz
polaz deleted the feat/#332-cms-signature-provider branch October 30, 2026 22:23
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.

feat(cms): CMS signature provider over the selected crypto provider

1 participant