-
Notifications
You must be signed in to change notification settings - Fork 284
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
Why different default RSA padding at publicEncrypt and publicDecrypt ? #1093
Comments
Good question. My hunch would be that defaulting to PKCS#1 padding is for backwards compatibility with the API from before it supported multiple padding schemes. Perhaps @indutny can confirm, he wrote that. |
ping @indutny for opinion. |
ping @nodejs/crypto for opinion. |
The error in the above code is not caused by the padding scheme but the wrong use of decryption in let decBuffer = crypto.publicDecrypt(secKey, Buffer.from(cipher, 'base64')) The right result can be obtained after changing it as let decBuffer = crypto.privateDecrypt(secKey, Buffer.from(cipher, 'base64')) Anyway, |
closing as answered, please re-open if it is still outstanding, thanks! |
I am wondering why there is a different in RSA padding at publicEncrypt (RSA_PKCS1_OAEP_PADDING) and publicDecrypt (RSA_PKCS1_PADDING) functions in crypto lib ? Shouldn't be the same for consistency ?
Proof of concept:
This will produce the following error (due to the difference in padding scheme):
Error: error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01
I am not comfortable choosing the right RSA padding myself so I think it would be nice to be the same for both function or at least being explicit mention at the documention why there is different padding schemes.
Thanks a lot!
The text was updated successfully, but these errors were encountered: