Bugzilla – Attachment 2806 Details for
Bug 2522
Key parser should reflect errors from OpenSSL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
translate libcrypto error code on PEM_read_bio_PrivateKey failure
bz2522.diff (text/plain), 1.30 KB, created by
Damien Miller
on 2016-04-08 16:24:09 AEST
(
hide
)
Description:
translate libcrypto error code on PEM_read_bio_PrivateKey failure
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2016-04-08 16:24:09 AEST
Size:
1.30 KB
patch
obsolete
>diff --git a/sshkey.c b/sshkey.c >index 9c0674d..130a791 100644 >--- a/sshkey.c >+++ b/sshkey.c >@@ -3725,7 +3725,44 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, > > if ((pk = PEM_read_bio_PrivateKey(bio, NULL, NULL, > (char *)passphrase)) == NULL) { >- r = SSH_ERR_KEY_WRONG_PASSPHRASE; >+ unsigned long pem_err = ERR_peek_last_error(); >+ int pem_reason = ERR_GET_REASON(pem_err); >+ >+ /* >+ * Translate OpenSSL error codes to determine whether >+ * passphrase is required/incorrect. >+ */ >+ switch (ERR_GET_LIB(pem_err)) { >+ case ERR_LIB_PEM: >+ switch (pem_reason) { >+ case PEM_R_BAD_PASSWORD_READ: >+ case PEM_R_PROBLEMS_GETTING_PASSWORD: >+ case PEM_R_BAD_DECRYPT: >+ r = SSH_ERR_KEY_WRONG_PASSPHRASE; >+ goto out; >+ default: >+ r = SSH_ERR_INVALID_FORMAT; >+ goto out; >+ } >+ case ERR_LIB_EVP: >+ switch (pem_reason) { >+ case EVP_R_BAD_DECRYPT: >+ r = SSH_ERR_KEY_WRONG_PASSPHRASE; >+ goto out; >+ case EVP_R_BN_DECODE_ERROR: >+ case EVP_R_DECODE_ERROR: >+ case EVP_R_PRIVATE_KEY_DECODE_ERROR: >+ r = SSH_ERR_INVALID_FORMAT; >+ goto out; >+ default: >+ r = SSH_ERR_LIBCRYPTO_ERROR; >+ goto out; >+ } >+ case ERR_LIB_ASN1: >+ r = SSH_ERR_INVALID_FORMAT; >+ goto out; >+ } >+ r = SSH_ERR_LIBCRYPTO_ERROR; > goto out; > } > if (pk->type == EVP_PKEY_RSA &&
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dtucker
:
ok+
Actions:
View
|
Diff
Attachments on
bug 2522
:
2781
| 2806 |
2844