Repository navigation
Crypto cant sign/verify prehashed inputs #60263
Description
Activity
Also related: https://security.stackexchange.com/questions/239345/verify-signature-without-digest
Maybe change openssl primitives called for this case is needed
I am having a similar issue after that I have upgraded from node js v22.18.0 to v22.20.0
RangeError: Invalid keywhile trying to useScrypt.verify.
I am usingscrypt-kdf.
It was working perfectly before the upgrade.
It still work on Mac OS X, but not on my Linux (Debian 11)@Martin-Luther i dont sure what your problem is related to this bug, i think it was another thing.
scrypt-kdf is a npm package what perform a wrapper over crypto.scrypt, this is not related with crypto.sign or crypto.verify.Maybe the best is open another issue for your case, in the scrypt-kdf repo not here.
I can confirm what this bug is present from node v14.21.3 to v25.0, so is not a regression issue, sounds more like a feature request.
- added a commit that references this issue
on Oct 28, 2025 When send null to algorithm param i expect that message payload be raw, prehashed, dont want an additional internal rehash.
Do you expect such based on some of node's documentation? IIRC no documentation exists that should create such expectation.
- addedcryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Oct 28, 2025 @panva there’s no explicit documentation stating this behavior, so it can be interpreted as a feature request rather than a bug.
When I pass null as the algorithm for an EC key, I expect the input to be treated as prehashed (raw).
From the docs:
Calculates and returns the signature for data using the given private key and algorithm. If algorithm is null or undefined, then the algorithm is dependent upon the key type.
algorithm is required to be null or undefined for Ed25519, Ed448, and ML-DSA.
I’m porting the Ethereum protocol to the native node:crypto module, and I’ve run into three requirements:
- support for the keccak256 hash algorithm
- access to the recovery parameters (r, s, and recovery id)
- the DevP2P protocol handshake, which requires signing fixed-length raw bytes (no internal hashing) is the current issue.
To support this without breaking existing cases, adding a "raw" or "prehash" algorithm option might be the most consistent approach.
@codermapuche I said similar, not exactly the same. As you mentioned, scrypt-kdf is a wrapper. Excuse me if I am mistaking, but doesn't it means that it could be using the same methods to verify (over crypto.scrypt) ?
Allow me to try with node::crypto.scrypt to see if there is a change. Then I will also try to install Node JS v25.0.0 to see if it behaves better.
I do not think that what I am pointing here is a feature request, but a regression or as you put it, a potential problem with my installation. This was working with node js v22.18.0, before my upgrade.Thanks for your appreciated remarks.
@codermapuche I can confirm that everything is working with Node JS v25.0.0 .
I also had an issue with my data.A proposal is in #62345
- added 2 commits that reference this issue
on Mar 22, 2026 - added a commit that references this issue
on Mar 31, 2026 github-actions commented
on Jul 20, 2026 on Jul 20, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jul 20, 2026 github-actions commented
on Aug 20, 2026 on Aug 20, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsAwaiting Triage
Version
Node.js v22.20.0 - Node.js v24.10.0
Platform
Subsystem
crypto
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No precondition required.
What is the expected behavior? Why is that the expected behavior?
When send null to algorithm param i expect that message payload be raw, prehashed, dont want an additional internal rehash. This make impossible verify or sign keeping compatibility with external systems.
What do you see instead?
crypto module ignore my null and place a sha256 algorithm instead, performing a double hash internally.
Additional information
Many external systems provide hash + signarure to verify, but we cannot do this because the implicit rehash of crypto module.