Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get matching RSA SHA512 signature compared to nodejs crypto #619

Closed
paullinator opened this issue Apr 15, 2024 · 3 comments
Closed

Comments

@paullinator
Copy link

paullinator commented Apr 15, 2024

give the same privateKey I'm using the following code to generate and verify signatures using nodejs crypto and jsrsasign. jsrsasign can't seem to create a valid signature that node crypto with verify as correct. Here's my code. Any help would be appreciated

https://github.com/EdgeApp/edge-react-gui/blob/paul/paybisSig/src/testcrypto.ts

@kjur
Copy link
Owner

kjur commented Apr 19, 2024

Sorry but I can't see the link above.

@kjur
Copy link
Owner

kjur commented Apr 19, 2024

I see your code before and it seems the issue of RSAPSS salt length difference between node crypto and jsrsasign.

To verify RSAPSS signature generated by Node crypto, you need to specify salt length in jsrsasign as follows:

const s3 = new jsrsasign.KJUR.crypto.Signature({alg: "SHA512withRSAandMGF1", psssaltlen: -2});

RSAPSS signature default:
Node crypto: saltLength=crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN=-2 (This will be 446 for SHA512)
jsrsasign: 20(SHA1), 32(SHA256), 48(SHA384), 64(SHA512)

@kjur
Copy link
Owner

kjur commented May 19, 2024

I seems no further comments. This will be closed.

@kjur kjur closed this as completed May 19, 2024
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

No branches or pull requests

2 participants