Skip to content

feat!: build XMLDSig verification without std - #331

Merged
polaz merged 12 commits into
mainfrom
feat/#330-alloc-only-xmldsig
Oct 29, 2026
Merged

polaz merged 12 commits into
mainfrom
feat/#330-alloc-only-xmldsig

Conversation

@polaz

@polaz polaz commented Oct 29, 2026

Copy link
Copy Markdown
Member

Summary

XMLDSig verification now builds as no_std + alloc, so browser (WASM) and embedded consumers can verify signatures. C14N builds without std as well.

  • xmldsig no longer enables std. The crate is no_std without the std feature and uses core/alloc types throughout, including the embedded XML backends and the XPath engine.
  • Canonical output goes through a ByteSink trait; the std::io::Write adapter exists only with std.
  • Internal tables are seeded hash maps with std and ordered trees without it: there is no random seed source without std, and an unseeded hash table is open to collision flooding from attacker-controlled XML. Public policy sets and caller-supplied resource and named-key maps are ordered collections in every build, so enabling a feature never changes a public type.
  • Without std there is no host clock: the caller supplies the verification time (KeyTrustPolicy::verification_time, X509ChainOptions::verification_time, policy::Instant).
  • Signing (xmldsig-sign), native providers, PKCS#11 and configuration loading still require std.
  • The XPath tokenizer uses winnow instead of peresil.
  • Signature primitives are updated to 0.17.1, which exposes their error traits without std.

Breaking changes

  • Policy algorithm sets are BTreeSet; external resource maps and named keys are BTreeMap.
  • validation_instant is replaced by verification_time of type policy::Instant.
  • xmldsig-sign enables std.

Testing

  • cargo clippy -p xml-sec --lib --no-default-features --target thumbv7em-none-eabihf for c14n,xml-backend-xmloxide, xmldsig,xml-backend-xmloxide and xmldsig,xml-backend-roxmltree, -D warnings: clean.
  • tests/alloc_only_verification.rs without std for both backends: wrapping, duplicate IDs, namespace look-alikes, absent detached payload and exact coverage; 5/5 each.
  • scripts/test-wasm.sh: C14N and XMLDSig verification executed in wasm32-unknown-unknown, valid signature accepted and a forgery rejected.
  • cargo clippy --workspace --all-targets --all-features -D warnings, documentation build and doctests: clean.
  • Certificate, ECDSA and XAdES tests against the 0.17.1 primitives: 285 passed.
  • The full suite and feature matrix run in CI.

BREAKING CHANGE: policy sets and resource/key maps are ordered collections, validation_instant is replaced by verification_time, and xmldsig-sign requires std.

Closes #330

polaz added 7 commits October 28, 2026 20:50
- Port the XPath tokenizer to winnow 1.0, which builds without std;
  peresil requires it. Error selection keeps the furthest failure and
  never backtracks over fatal errors.
- The embedded XML parser of the XPath engine only builds test
  documents, so peresil becomes a dev-dependency.
- Disable default features of dependencies that pull std, and move
  their std features and the ECDSA basepoint tables under `std`.
- `xmldsig` no longer selects `std`.

Part of #330
- Replace std paths with core/alloc across verification, C14N, the
  embedded XPath engine and the embedded xmloxide kernel.
- Lookup tables keyed by document content are seeded hash tables with
  std and ordered trees without it (no seed source).
- Canonical output goes through a byte sink; the io::Write adapter
  stays behind std. C14nError::Io is std-only, OutputRefused reports an
  internal consumer's refusal.
- Policy time is structured-pkix Instant; instant_from_system_time
  converts host time with std. Without std the caller's verification
  time is the only operation time.
- Public policy sets and external-resource maps are BTreeSet/BTreeMap;
  KeyResolverConfig::named_keys is a BTreeMap.
- X509TrustEvidence::verification_time returns the Instant directly,
  replacing validation_instant.
- Base64 streaming decodes whole quartets without io::Read.
- xmldsig-sign selects std; libm supplies XPath floor/ceiling and
  portable-atomic the document identity counter where core lacks them.

BREAKING CHANGE: policy time fields are Instant, policy algorithm sets
are BTreeSet, external resources and named keys are BTreeMap, and
C14nError::Io exists only with std.

Part of #330
- The embedded roxmltree parse error implements core::error::Error.
- Table re-exports and capacity accounting compile only with xmldsig,
  so a C14N-only alloc build has no dead items.

Part of #330
- The alloc-only job lints C14N and XMLDSig verification for each XML
  backend on thumbv7em-none-eabihf.
- The WASM module verifies a signed SAML response and rejects a
  tampered copy, alongside the C14N check.

Part of #330
- Pre-signed HMAC fixtures, reproduced and compared by a std test, let
  the coverage checks run without signing.
- Exact coverage, wrapping, duplicate IDs, lookalike namespaces and an
  absent detached payload are checked on both builds; CI runs them
  without std for each XML backend.

Part of #330
- C14N and XMLDSig verification build on core and alloc; signing,
  configuration loading and the CLI still require std
- the caller supplies the verification time without std
- CI coverage of the alloc-only build and the WASM verification smoke

Part of #330
0.17.1 exposes the core error traits of the ASN.1, PKIX and CMS
crates without std, which XMLDSig verification needs to build on
core and alloc. The 0.17.0 PKIX change needs no adaptation here.

Part of #330
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-29T12:28:19.119759Z 3ae0a0e 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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 178 files, which is 78 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3826acb and bab3000.

Files ignored due to path filters: 1
  • benchmarks/competitors/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 178
  • .github/workflows/ci.yml
  • Cargo.toml
  • benches/support/mod.rs
  • benchmarks/competitors/src/bin/xml_sec_library.rs
  • crates/xml-sec-config/src/lib.rs
  • crates/xml-sec-config/src/settings.rs
  • crates/xml-sec-config/tests/configuration.rs
  • crates/xml-sec-xades/Cargo.toml
  • crates/xml-sec-xades/examples/interop_probe.rs
  • crates/xml-sec-xades/src/path.rs
  • crates/xml-sec-xades/src/path/tests.rs
  • crates/xml-sec-xades/tests/basic.rs
  • docs/README.md
  • docs/ci-hardening.md
  • docs/features.md
  • docs/migration-libxmlsec1.md
  • docs/policy-configuration.md
  • docs/rust-api.md
  • docs/xml-backend-patches.md
  • docs/xmldsig.md
  • fuzz/src/lib.rs
  • scripts/import-xml-backends.sh
  • scripts/patches/roxmltree-0.21.1.patch
  • scripts/patches/xmloxide-0.5.0.patch
  • scripts/test-wasm.sh
  • scripts/xml-kernel-examples.pl
  • src/api.rs
  • src/c14n/escape.rs
  • src/c14n/mod.rs
  • src/c14n/ns_exclusive.rs
  • src/c14n/scratch.rs
  • src/c14n/serialize.rs
  • src/c14n/sink.rs
  • src/c14n/xml_base.rs
  • src/collections.rs
  • src/document.rs
  • src/encoding.rs
  • src/key_establishment.rs
  • src/key_manager.rs
  • src/key_manager/tests.rs
  • src/lib.rs
  • src/operation.rs
  • src/parser_roxmltree/documentation_tests.rs
  • src/parser_roxmltree/parse.rs
  • src/parser_xmloxide/documentation_tests.rs
  • src/parser_xmloxide/encoding/mod.rs
  • src/parser_xmloxide/error/mod.rs
  • src/parser_xmloxide/parser/input.rs
  • src/parser_xmloxide/parser/mod.rs
  • src/parser_xmloxide/parser/push.rs
  • src/parser_xmloxide/parser/xml.rs
  • src/parser_xmloxide/tree/mod.rs
  • src/parser_xmloxide/tree/node.rs
  • src/parser_xmloxide/validation/dtd.rs
  • src/parser_xmloxide/validation/mod.rs
  • src/policy.rs
  • src/policy/clock.rs
  • src/policy/key_establishment.rs
  • src/policy/profiles.rs
  • src/policy/profiles/composition.rs
  • src/policy/profiles/constraints.rs
  • src/provider.rs
  • src/provider/key_encapsulation.rs
  • src/rsa_encoding.rs
  • src/sxd_document/dom_no_unsafe.rs
  • src/sxd_document/lazy_hash_map.rs
  • src/sxd_document/lib.rs
  • src/sxd_document/raw_no_unsafe.rs
  • src/sxd_document/storage.rs
  • src/sxd_document/str_ext.rs
  • src/sxd_document/string_pool_no_unsafe.rs
  • src/sxd_document/thindom_no_unsafe.rs
  • src/sxd_xpath/arena.rs
  • src/sxd_xpath/axis.rs
  • src/sxd_xpath/context.rs
  • src/sxd_xpath/expression.rs
  • src/sxd_xpath/function.rs
  • src/sxd_xpath/function/core.rs
  • src/sxd_xpath/grammar.rs
  • src/sxd_xpath/lib.rs
  • src/sxd_xpath/node_test.rs
  • src/sxd_xpath/nodeset.rs
  • src/sxd_xpath/nodeset/storage.rs
  • src/sxd_xpath/parser.rs
  • src/sxd_xpath/runtime.rs
  • src/sxd_xpath/token.rs
  • src/sxd_xpath/tokenizer.rs
  • src/xml.rs
  • src/xml/dom/differential.rs
  • src/xml/dom/mod.rs
  • src/xml/dom/preflight.rs
  • src/xml/dom/roxmltree.rs
  • src/xml/dom/storage.rs
  • src/xml/dom/storage/names.rs
  • src/xml/dom/tree.rs
  • src/xml/dom/tree/comparison.rs
  • src/xml/dom/xmloxide.rs
  • src/xmldsig/digest.rs
  • src/xmldsig/extension/scalar.rs
  • src/xmldsig/keys.rs
  • src/xmldsig/modern.rs
  • src/xmldsig/parse.rs
  • src/xmldsig/pkix.rs
  • src/xmldsig/pq_algorithm.rs
  • src/xmldsig/sign.rs
  • src/xmldsig/signature.rs
  • src/xmldsig/signing_key.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/transforms/parameters.rs
  • src/xmldsig/transforms/relationship.rs
  • src/xmldsig/transforms/source.rs
  • src/xmldsig/transforms/xslt/tests.rs
  • src/xmldsig/trust.rs
  • src/xmldsig/types.rs
  • src/xmldsig/types/projection.rs
  • src/xmldsig/uri.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/verify/capture.rs
  • src/xmldsig/verify/session.rs
  • src/xmldsig/verify/session/detached.rs
  • src/xmldsig/verify/session/key_receipt.rs
  • src/xmldsig/verify/session/lookup.rs
  • src/xmldsig/verify/tests.rs
  • src/xmldsig/whitespace.rs
  • src/xmldsig/x509.rs
  • src/xmldsig/xpath.rs
  • src/xmldsig/xpath/source.rs
  • src/xmldsig/xpath/storage.rs
  • src/xmlenc/cipher_reference.rs
  • src/xmlenc/decrypt.rs
  • src/xmlenc/encrypt.rs
  • src/xmlenc/types.rs
  • tests/alloc_only_fixtures.rs
  • tests/alloc_only_verification.rs
  • tests/authenticated_reference_replay.rs
  • tests/aws_lc_provider.rs
  • tests/capability_ledger.rs
  • tests/cipher_reference.rs
  • tests/detached_payloads.rs
  • tests/donor_full_verification_suite.rs
  • tests/donor_interop_suite.rs
  • tests/donor_negative_vectors.rs
  • tests/fixtures/xmldsig/alloc-only/detached.xml
  • tests/fixtures/xmldsig/alloc-only/two-signatures.xml
  • tests/fixtures_smoke.rs
  • tests/hmac_pipeline.rs
  • tests/key_establishment_policy.rs
  • tests/key_info_candidates.rs
  • tests/merlin_interop.rs
  • tests/modern_algorithms.rs
  • tests/opc_relationship_transform.rs
  • tests/phaos_interop.rs
  • tests/policy_profiles.rs
  • tests/rsa_pss.rs
  • tests/rust_api.rs
  • tests/session_lookups.rs
  • tests/signing_digest.rs
  • tests/verification_evidence.rs
  • tests/wasm-smoke/Cargo.toml
  • tests/wasm-smoke/src/lib.rs
  • tests/x509_chain_integration.rs
  • tests/xmlenc_agreement.rs
  • tests/xmlenc_donor_integration.rs
  • tests/xmlenc_nested.rs
  • tests/xmlsec1_interop.rs
  • tests/xslt_transform_integration.rs
  • tools/xml-sec-tools/Cargo.toml
  • tools/xml-sec-tools/src/kernel_examples.rs
  • tools/xml-sec-tools/src/kernel_examples/tests.rs
  • tools/xml-sec-tools/src/main.rs
  • tools/xmlsec1/Cargo.toml
  • tools/xmlsec1/src/commands.rs
  • tools/xmlsec1/src/commands/tests.rs
  • tools/xmlsec1/src/policy_commands.rs
  • tools/xmlsec1/tests/ml_kem_keys.rs
  • tools/xmlsec1/tests/policy_commands.rs
  • vendor/sxd-document-no-unsafe/Cargo.toml
  • vendor/sxd-xpath-no-unsafe/Cargo.toml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 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.

polaz added 3 commits October 29, 2026 11:25
- The fuzz harness and the competitor benchmark still built policy
  algorithm sets as HashSet; they now use BTreeSet like the policy types.
- The XMLEnc donor test imported BTreeMap unconditionally although only
  legacy-algorithms tests use it, which failed builds without that feature.
- Refresh the competitor lockfile for the 0.17.1 primitives and winnow.
- The xmldsig fixture count includes the two alloc-only inputs.
- Unit tests link std even when the library is built without it; the
  crate is no_std only outside cfg(test), while the library target and
  the embedded target still check the no_std build.
- Test byte sinks implement ByteSink directly, so canonicalization tests
  run in every build; only the io::Write refusal test needs std.
- Path validation tests supply their verification time, as callers must
  without a host clock.
- XPath tests charge set insertions through one per-build helper.
- The xslt feature selects std: its engine shares state across threads
  and reads the host clock.
- Documentation examples of the embedded XML parsers become unit tests;
  the generator now copies the documented item's cfg attributes onto
  the test, so the parse_file example runs only where parse_file exists.
- The maintained xmloxide delta records the std gates on the
  parse_file tests, so the source check matches the tree again.
@polaz
polaz enabled auto-merge (squash) October 29, 2026 11:20
- Repository tooling logic moves into one workspace crate,
  xml-sec-tools, run with cargo; shell scripts only sequence commands.
- Its first subcommand, kernel-examples, replaces the Perl generator of
  the embedded parsers' documentation tests with the same output,
  including the documented item's cfg, and its checks are unit tests.
Branch protection requires a status named "alloc-only XML input". The
renamed job reported under a new name, so the required check never
arrived and the PR waited forever.

Part of #330
@polaz
polaz merged commit 9ace0e8 into main Oct 29, 2026
29 checks passed
@polaz
polaz deleted the feat/#330-alloc-only-xmldsig branch October 29, 2026 17:08
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(xmldsig): alloc-only verification path

1 participant