fix(ext/node): support RSA PSS padding option in crypto sign/verify#32269
fix(ext/node): support RSA PSS padding option in crypto sign/verify#32269bartlomieju merged 3 commits intodenoland:mainfrom
Conversation
The `padding` option passed to `crypto.createSign().sign()` and `crypto.createVerify().verify()` was silently ignored, causing RSA PSS signing with regular RSA keys to always use PKCS#1 v1.5 padding instead. This passes the `padding` option through to the Rust ops and handles `RSA_PKCS1_PSS_PADDING` (6) for regular RSA keys by using PSS signing instead of PKCS1v15. Also fixes `crypto.sign()`/`crypto.verify()` one-shot functions to preserve padding/saltLength options. Closes denoland#28493 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review feedback: - Extract magic number 6 as RSA_PKCS1_PSS_PADDING constant - Extract common PSS scheme construction into new_pss_scheme function shared by sign and verify Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kajukitli
left a comment
There was a problem hiding this comment.
lgtm
clean fix. the new_pss_scheme extraction is nice, and good that the constant got pulled out. tests cover the main cases well (various salt lengths, cross-verify failure, one-shot api).
one minor nit: the test comment says "PSS is probabilistic, so even same salt length gives different sigs" — might be worth adding an assertion that sig20 !== sig32 etc to validate they're actually different, not just same length. but not blocking.
|
Re: adding `sig20 !== sig32` assertion — since PSS is probabilistic, comparing signature bytes wouldn't actually validate that different salt lengths produce different outputs. Even two signatures with the same salt length would differ. The cross-verification test (Test 4, line 66-69) is the meaningful check here: it proves that a signature created with salt length 20 fails to verify with salt length 32, which confirms the salt length is actually being applied correctly. |
Summary
paddingoption fromcrypto.createSign().sign()/crypto.createVerify().verify()through to the Rust signing opsRSA_PKCS1_PSS_PADDING(6) for regular RSA keys by using PSS signing/verification instead of PKCS#1 v1.5crypto.sign()/crypto.verify()one-shot functions to preservepaddingandsaltLengthoptions from the original key objectCloses #28493
Test plan
tests/specs/node/crypto_sign_rsa_pss_paddingthat verifies:crypto.sign/crypto.verifywith PSS padding🤖 Generated with Claude Code