| Summary: | PKCS#8 private keys with AES-128-CBC stopped working | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | Peter Wu <peter> | ||||
| Component: | ssh-keygen | Assignee: | Damien Miller <djm> | ||||
| Status: | CLOSED FIXED | ||||||
| Severity: | normal | CC: | djm, dtucker | ||||
| Priority: | P5 | ||||||
| Version: | 7.5p1 | ||||||
| Hardware: | amd64 | ||||||
| OS: | Linux | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 2698 | ||||||
| Attachments: |
|
||||||
|
Description
Peter Wu
2017-03-26 02:24:49 AEDT
I can't replicate this on either OpenBSD or Linux (Ubuntu variant). I tried the key you provided and one that I generated: $ ssh-keygen -t rsa -f k -C '' -N '' Generating public/private rsa key pair. Your identification has been saved in k. Your public key has been saved in k.pub. The key fingerprint is: SHA256:m4QOVbZ5Q5sWhFIox47fgcUManmU2RNzIJJfYl9SmNw The key's randomart image is: +---[RSA 2048]----+ | .o+@BX* | | o=X+&*E+ | | +BoBo+* | | ..o+.oo . | | ....S. | | o...o | | . o | | | | | +----[SHA256]-----+ $ openssl pkcs8 -topk8 -in k -out k.pem -v2 AES-128-CBC Enter Encryption Password: Verifying - Enter Encryption Password: $ chmod 0600 k.pem $ ssh-keygen -yf k.pem Enter passphrase: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0cTGZ+1cqjei8PdYa7FoFUHYsUST7jTneMP+FktaD3RKqrkpKQdvTBfRqcYUeiwscgqmKa5KYvNvz2GXhO3Nk6Pe46MI9CC+bKoR/Gt+okQU54zua4TlmRRsPxQdGat6vtcD7bPeFcIpXLGt4troMs7VVSBgrVI1Z+QG2v41L85l360vsmo5mVDDKWODlG7D0QyulJpf9WVuAD9fAorBKh5hA2mcWLYiInD9uxsw3xst0nPnQdHXvTNkfF2u8LD6Hurh5ewYu58a8RSozCDqSn0s3F0Sm5oO4oJw+zd1QG/ljJ/fn2bPr2RCUx9L2CkjQcQAFZm13flx8tg77pJ+Z $ ./ssh-keygen -yf k.pem Enter passphrase: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0cTGZ+1cqjei8PdYa7FoFUHYsUST7jTneMP+FktaD3RKqrkpKQdvTBfRqcYUeiwscgqmKa5KYvNvz2GXhO3Nk6Pe46MI9CC+bKoR/Gt+okQU54zua4TlmRRsPxQdGat6vtcD7bPeFcIpXLGt4troMs7VVSBgrVI1Z+QG2v41L85l360vsmo5mVDDKWODlG7D0QyulJpf9WVuAD9fAorBKh5hA2mcWLYiInD9uxsw3xst0nPnQdHXvTNkfF2u8LD6Hurh5ewYu58a8RSozCDqSn0s3F0Sm5oO4oJw+zd1QG/ljJ/fn2bPr2RCUx9L2CkjQcQAFZm13flx8tg77pJ+Z [djm@demiurge openssh]$ ssh -V OpenSSH_7.2p2, OpenSSL 1.0.1f 6 Jan 2014 [djm@demiurge openssh]$ ./ssh -V OpenSSH_7.5p1, OpenSSL 1.0.1f 6 Jan 2014 Perhaps the passphrase was wrongly entered (bad keyboard state?). It works now when the correct passphrase is typed in (rebooted in between). Can the error message can be improved? $ ssh-keygen -yf keypk8.pem Enter passphrase: 1233 Load key "keypk8.pem": invalid format $ ssh -V OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017 $ ssh-keygen -yf keypk8.pem Enter passphrase: 1233 Load key "keypk8.pem": incorrect passphrase supplied to decrypt private key $ ssh -V OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 Created attachment 2990 [details]
search first entry in libcrypto error stack for better error
OpenSSL makes it unfortunately painful to determine the actual problem when it fails, by scattering root and proximal problems across an error stack. This patch searches deeper in the stack and prefers to return "wrong passphrase" errors when it finds them to other causes.
Comment on attachment 2990 [details]
search first entry in libcrypto error stack for better error
looks reasonable but I don't know openssl that well. maybe you want get one of the libressl folks to look?
Patch applied. This will be in openssh 7.6 Close all resolved bugs after release of OpenSSH 7.7. |