Skip to content

feat: support SHA-384 digests and RSA-SHA384 signatures - #654

Open
cjbarth wants to merge 1 commit into
node-saml:masterfrom
cjbarth:feat/sha384
Open

cjbarth wants to merge 1 commit into
node-saml:masterfrom
cjbarth:feat/sha384

Conversation

@cjbarth

@cjbarth cjbarth commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

xml-crypto has SHA-1, SHA-256 and SHA-512, and no SHA-384. A document whose SignatureMethod is rsa-sha384 fails with signature algorithm '…#rsa-sha384' is not supported, one whose DigestMethod is sha384 fails with hash algorithm '…#sha384' is not supported, and neither name can be used to sign.

XMLDSig 1.1 lists both as optional (§6.2.4, §6.4.2), and RFC 9231 defines the identifiers (§2.1.3, §2.3.3). The implementations a signed document is likely to come from or go to have both:

Implementation rsa-sha384 sha384 digest
xml-crypto master no no
.NET System.Security.Cryptography.Xml yes yes
JDK javax.xml.crypto.dsig yes yes
goxmldsig yes yes
xmlsec, as python3-saml uses it yes yes
ruby-saml yes yes

node-saml is the caller that needs it now. Since node-saml/node-saml#479 it takes the algorithm for a Redirect-binding signature from SignedXml's SignatureAlgorithms, and it keeps a second lookup among OpenSSL digest names only for the identifiers that map lacks. rsa-sha384 is the one of those worth keeping, so that lookup can go once this is released.

This PR adds:

  • Sha384, the digest http://www.w3.org/2001/04/xmldsig-more#sha384.
  • RsaSha384, the signature http://www.w3.org/2001/04/xmldsig-more#rsa-sha384: PKCS Initial support for enveloped signatures #1 v1.5, as rsa-sha256 and rsa-sha512 are.
  • Both registered by default in HashAlgorithms and SignatureAlgorithms, so a document that names them verifies with no configuration, like the other SHA-2 sizes.
  • The two identifiers in HashAlgorithmType and SignatureAlgorithmType, and in the README's lists. Both unions already end in string, so this changes editor completion and nothing else.

Left out on purpose:

  • SHA-224. XMLDSig 1.1 lists it as optional too, but .NET, goxmldsig, python3-saml and ruby-saml don't offer it.
  • The other PSS sizes (sha384-rsa-MGF1, sha512-rsa-MGF1). Nothing here needs them.

Tests

  • A fixture from another implementation. test/static/rsa_sha384_signature.xml is signed by JDK 21 with client.pem, using rsa-sha384 over a sha384 digest. It verifies, and stops verifying when the signed content changes.
  • Signing matches the JDK. Signing the same document with the same parameters writes the DigestValue and SignatureValue the JDK wrote. PKCS Initial support for enveloped signatures #1 v1.5 is deterministic, so they are equal byte for byte.
  • rsa-sha384 joins the sign-and-verify list in test/signature-unit-tests.spec.ts.

All five tests failed before the change with the two is not supported errors above. Each also fails when SHA-256 is put in place of SHA-384 in RsaSha384's signing, in its verifying, or in Sha384.

Checks

  • npm run build && npm test && npm run lint pass (555 tests).
  • JDK 21 verifies a document this branch signs with rsa-sha384 and a sha384 digest over an Id reference, and rejects it after an edit.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for SHA-384 digests and RSA-SHA384 signatures when signing and verifying XML.
  • Tests
    • Added coverage for verifying, creating, and rejecting modified RSA-SHA384 signatures.

A document whose SignatureMethod is rsa-sha384, or whose DigestMethod is
sha384, could be neither signed nor verified: both names were missing from
the algorithm maps. XMLDSig 1.1 lists them as optional (6.2.4, 6.4.2) and
RFC 9231 defines the identifiers (2.1.3, 2.3.3). .NET, the JDK, goxmldsig,
xmlsec and ruby-saml all have both.

Adds `Sha384` and `RsaSha384`, registers them by default, and names the two
identifiers in the algorithm type unions and the README.

The fixture is signed by JDK 21. One test verifies it, and another checks
that signing the same document here writes the same DigestValue and
SignatureValue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cjbarth cjbarth added this to the v6.4 milestone Oct 8, 2026
@cjbarth cjbarth added the enhancement Adds a feature, option or export without breaking existing callers label Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3941f90-a251-4d31-ae38-e94a291c6a65
📥 Commits

Reviewing files that changed from the base of the PR and between a311adc and ea0b0a6.

📒 Files selected for processing (9)
  • README.md
  • src/hash-algorithms.ts
  • src/signature-algorithms.ts
  • src/signed-xml.ts
  • src/types.ts
  • test/README.md
  • test/signature-integration-tests.spec.ts
  • test/signature-unit-tests.spec.ts
  • test/static/rsa_sha384_signature.xml

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The change adds SHA-384 digest and RSA-SHA384 signature support. It updates the algorithm types and registries, documents the supported algorithms, and adds a signed XML fixture with integration and unit test coverage.

Changes

SHA-384 support

Layer / File(s) Summary
Algorithm contracts and implementations
src/types.ts, src/hash-algorithms.ts, src/signature-algorithms.ts, README.md
Adds SHA-384 and RSA-SHA384 algorithm types and implementations. The README lists SHA384 as a hash algorithm and RSA-SHA384 as a signature algorithm.
Registration and fixture-based tests
src/signed-xml.ts, test/static/rsa_sha384_signature.xml, test/README.md, test/signature-integration-tests.spec.ts, test/signature-unit-tests.spec.ts
Registers both algorithms. Adds a JDK-signed fixture and tests for verification, modified-content rejection, and matching generated digest and signature values.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Suggested reviewers: shunkica

Merge Risk: ⚪ Minimal · up to ea0b0

No actionable issue remains from this review; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the two main changes: SHA-384 digest support and RSA-SHA384 signature support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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.

cjbarth added a commit to cjbarth/node-saml that referenced this pull request Oct 8, 2026
…next major rejects

`validateSignatureForRedirect` still falls back to a lookup among OpenSSL
digest names for a `SigAlg` xml-crypto does not implement. It accepts
rsa-sha224, rsa-md5 and names that are no identifier at all, such as a bare
`RSA-SHA256`. The next major version removes it (node-saml#489).

A signature that verifies through the lookup now logs a warning under
`NODE_DEBUG=node-saml`, and the README says which identifiers remain.
rsa-sha384 is left out of the warning: the next major keeps it through
xml-crypto (node-saml/xml-crypto#654).

Closes node-saml#490.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adds a feature, option or export without breaking existing callers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant