Skip to content

fix: default RSA-PSS saltLength to RSA_PSS_SALTLEN_MAX_SIGN#1029

Merged
boorad merged 2 commits into
mainfrom
fix/rsa-pss-saltlen-default
May 6, 2026
Merged

fix: default RSA-PSS saltLength to RSA_PSS_SALTLEN_MAX_SIGN#1029
boorad merged 2 commits into
mainfrom
fix/rsa-pss-saltlen-default

Conversation

@boorad
Copy link
Copy Markdown
Collaborator

@boorad boorad commented May 6, 2026

Summary

When padding: RSA_PKCS1_PSS_PADDING is set on sign/verify but saltLength is omitted, RNQC was passing undefined straight through to OpenSSL — which falls back to digest length (-1). Node.js defaults this case to RSA_PSS_SALTLEN_MAX_SIGN (-2), so signatures produced by RNQC were not interoperable with Node's defaults.

This PR mirrors Node's behavior in lib/internal/crypto/sig.js (getSaltLength): when padding === RSA_PKCS1_PSS_PADDING and saltLength === undefined, default to RSA_PSS_SALTLEN_MAX_SIGN. Behavior is unchanged when saltLength is set explicitly.

Changes

  • packages/react-native-quick-crypto/src/keys/signVerify.ts: add getSaltLength() helper applying the Node.js default; wire it into Sign.sign and Verify.verify.
  • example/src/tests/keys/sign_verify_oneshot.ts: new test verifying that an unspecified-salt sign round-trips and matches an explicit RSA_PSS_SALTLEN_MAX_SIGN verify.
  • example/src/tests/keys/sign_verify_streaming.ts: same coverage for the streaming createSign / createVerify API.

Testing

  • Run example app — new tests RSA-PSS defaults saltLength to MAX_SIGN when undefined pass in both keys.sign/verify suites.
  • Existing RSA-PSS tests with explicit saltLength still pass (no regression).
  • Cross-check: signature produced by RNQC with default saltLength can be verified by Node.js with default options, and vice versa.

Fixes #1006

boorad added 2 commits May 6, 2026 09:15
…erify

Match Node.js behavior: when padding === RSA_PKCS1_PSS_PADDING and
saltLength is undefined, default to RSA_PSS_SALTLEN_MAX_SIGN before
forwarding to native. Closes #1006.
Verify that omitting saltLength with RSA_PKCS1_PSS_PADDING produces a
signature that round-trips both with no explicit saltLength and with
the explicit RSA_PSS_SALTLEN_MAX_SIGN constant.
@boorad boorad self-assigned this May 6, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-quick-crypto Ready Ready Preview, Comment May 6, 2026 1:23pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🤖 End-to-End Test Results - Android

Status: ✅ Passed
Platform: Android
Run: 25437933067

📸 Final Test Screenshot

Maestro Test Results - android

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🤖 End-to-End Test Results - iOS

Status: ✅ Passed
Platform: iOS
Run: 25437933253

📸 Final Test Screenshot

Maestro Test Results - ios

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@boorad boorad merged commit 78a047d into main May 6, 2026
9 checks passed
@boorad boorad deleted the fix/rsa-pss-saltlen-default branch May 6, 2026 13:57
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.

crypto.sign/verify: default RSA-PSS saltLength to RSA_PSS_SALTLEN_MAX_SIGN

1 participant