-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
crypto.privateDecrypt keeps failing after "Passphrase required" error #32240
Labels
Comments
bnoordhuis
added a commit
to bnoordhuis/io.js
that referenced
this issue
Mar 13, 2020
The publicEncrypt/privateDecrypt/etc. family of functions didn't clear OpenSSL's error stack on early return. Notably, trying to use an encrypted key with the wrong passphrase left an error on the stack that made subsequent encrypt or decrypt operations fail, even with an unencrypted key. Fixes: nodejs#32240
bnoordhuis
added
confirmed-bug
Issues with confirmed bugs.
crypto
Issues and PRs related to the crypto subsystem.
labels
Mar 13, 2020
Thanks for the bug report. #32248 should fix that. |
addaleax
pushed a commit
that referenced
this issue
Mar 30, 2020
The publicEncrypt/privateDecrypt/etc. family of functions didn't clear OpenSSL's error stack on early return. Notably, trying to use an encrypted key with the wrong passphrase left an error on the stack that made subsequent encrypt or decrypt operations fail, even with an unencrypted key. Fixes: #32240 PR-URL: #32248 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
targos
pushed a commit
that referenced
this issue
Apr 22, 2020
The publicEncrypt/privateDecrypt/etc. family of functions didn't clear OpenSSL's error stack on early return. Notably, trying to use an encrypted key with the wrong passphrase left an error on the stack that made subsequent encrypt or decrypt operations fail, even with an unencrypted key. Fixes: #32240 PR-URL: #32248 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This is still a problem in v16.7.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
If you call
crypto.privateDecrypt(...)
with an passphrase-encrypted private RSA key PEM but without providing a passphrase, it correctly raisesTypeError: Passphrase required for encrypted key
. But after that, if you try to call it again with an unencrypted private RSA key PEM, then the same error is raised. It seems like the first call corrupts some internal state (maybe openssl one) breaking subsequent calls. Example follows:Output:
The text was updated successfully, but these errors were encountered: