Skip to content

Throw SignatureException on native sign errors in WolfCryptSignature - #296

Merged
rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:sigSignWrapNativeErrors
Oct 21, 2026
Merged

rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:sigSignWrapNativeErrors

Conversation

@cconlon

@cconlon cconlon commented Oct 13, 2026

Copy link
Copy Markdown
Member

This PR makes WolfCryptSignature.engineSign() throw SignatureException when native signing fails, as JCA requires. Before, a WolfCryptException from native RSA, RSA-PSS or ECDSA signing escaped Signature.sign(). For example, FIPS v7 rejects an RSA-PSS salt longer than the hash, per FIPS 186-5 §5.4(g).

Changes

  • Catch WolfCryptException in engineSign() and rethrow it as SignatureException with the original as the cause, matching the EdDSA, ML-DSA and SLH-DSA classes.
  • Add testRsaPssSignNativeErrorThrowsSignatureException.

@cconlon cconlon self-assigned this Oct 13, 2026
@cconlon
cconlon requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot October 13, 2026 22:16

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-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.

Fenrir Automated Review — PR #296

Scan targets checked: wolfcrypt-jni-src, wolfcrypt-jni-bugs
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: src/test/java/com/wolfssl/provider/jce/test/WolfCryptSignatureTest.java

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

Copilot AI 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.

🟡 Changes recommended

The regression test should verify that the original native exception is preserved as the cause.

1 open finding
What changed in this PR

Wraps native signing failures in JCA-compatible SignatureException instances.

Changes:

  • Converts native RSA, RSA-PSS, and ECDSA signing errors.
  • Adds an RSA-PSS native-error regression test.
File Description
WolfCryptSignature.java Wraps native signing failures.
WolfCryptSignatureTest.java Tests RSA-PSS failure behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cconlon
cconlon force-pushed the sigSignWrapNativeErrors branch from e83bc7e to 7ed69f7 Compare October 13, 2026 22:32
@cconlon cconlon assigned rlm2002 and unassigned cconlon Oct 13, 2026
@rlm2002
rlm2002 merged commit 2373955 into wolfSSL:master Oct 21, 2026
189 checks passed
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.

4 participants