crypto/ssh
Filippo Valsorda 0a08dada0f ssh: reject unencrypted keys from ParsePrivateKeyWithPassphrase
The behavior of ParsePrivateKeyWithPassphrase when the key is
unencrypted is unspecified. Currently, it just parses them like
ParsePrivateKey, which is unlikely to be what anyone wants: for us to
ignore a passphrase that they explicitly passed. It also makes the
implementation of encrypted OpenSSH keys in the next CL more confused.

Instead, make ParsePrivateKey return a PassphraseNeededError, so the
application logic can be ParsePrivateKey -> detect encrypted key ->
obtain passphrase -> ParsePrivateKeyWithPassphrase. That error will also
let us return the public key for OpenSSH keys.

Change-Id: Ife4fb2499ae538bef36e353adf9bc8e902662386
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/207599
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2019-12-05 16:18:47 +00:00
..
agent ssh/agent: fix TestServerResponseTooLarge on Plan 9 2019-11-28 16:05:24 +00:00
knownhosts crypto/ssh/knownhosts: fix out-of-date documentation for checkAddr 2019-01-23 08:56:48 +00:00
terminal Revert "ssh/terminal: account for win32 api changes" 2019-09-26 18:03:35 +00:00
test ssh/test: fix test goroutine error handling 2019-11-17 06:32:00 +00:00
testdata ssh: reject unencrypted keys from ParsePrivateKeyWithPassphrase 2019-12-05 16:18:47 +00:00
benchmark_test.go all: fix ineffectual assignments 2019-01-31 18:25:04 +00:00
buffer.go ssh: remove unused buffer.eof return value 2017-09-25 11:19:01 +00:00
buffer_test.go go.crypto/ssh: import gosshnew. 2014-04-09 13:57:52 -07:00
certs.go ssh: add sk-ecdsa-sha2-nistp256 and sk-ed25519 2019-12-02 14:38:27 +00:00
certs_test.go ssh: accept ed25519 certs 2017-12-18 18:48:59 +00:00
channel.go all: fix errors reported by vet, golint 2017-11-28 17:48:09 +00:00
cipher.go chacha20: expose internal/chacha20 package 2019-11-11 21:38:06 +00:00
cipher_test.go ssh: rename methods in packetCipher interface 2019-04-11 14:11:16 +00:00
client.go all: fix typos 2018-10-29 02:12:03 +00:00
client_auth.go ssh/gss: support kerberos authentication for ssh server and client 2019-05-10 10:41:15 +00:00
client_auth_test.go ssh: add diffie-hellman-group-exchange-sha256 2019-06-17 13:33:40 +00:00
client_test.go ssh: fix protocol version exchange (for multi-line) 2018-01-11 10:11:23 +00:00
common.go ssh: drop dh-group1-sha1 from default key exchanges 2019-09-09 09:17:59 +00:00
common_test.go ssh: invert algorithm choices on the server 2019-04-18 16:56:55 +00:00
connection.go ssh: fixing a small typo in connection.go 2017-05-31 07:46:08 +00:00
doc.go ssh: require host key checking in the ClientConfig 2017-03-30 15:57:35 +00:00
example_test.go ssh: rename ExampleHostKeyCheck to ExampleClientConfig_HostKeyCallback 2019-04-11 14:11:56 +00:00
handshake.go ssh: invert algorithm choices on the server 2019-04-18 16:56:55 +00:00
handshake_test.go ssh: skip testHandshakeErrorHandlingN on js/wasm 2019-07-01 09:49:42 +00:00
kex.go ssh: fix dropped error 2019-11-08 23:12:17 +00:00
kex_test.go x/crypto/ssh: close memPipe after running kex test. 2015-08-17 22:17:06 +00:00
keys.go ssh: reject unencrypted keys from ParsePrivateKeyWithPassphrase 2019-12-05 16:18:47 +00:00
keys_test.go ssh: reject unencrypted keys from ParsePrivateKeyWithPassphrase 2019-12-05 16:18:47 +00:00
mac.go ssh: Add the hmac-sha2-256-etm@openssh.com algorithm 2017-02-08 15:25:40 +00:00
mempipe_test.go ssh: fix spelling of test so that it runs 2015-07-15 23:39:58 +00:00
messages.go ssh: add diffie-hellman-group-exchange-sha256 2019-06-17 13:33:40 +00:00
messages_test.go x/crypto/ssh: support more keytypes in the agent. 2016-04-25 17:01:51 +00:00
mux.go all: fix errors reported by vet, golint 2017-11-28 17:48:09 +00:00
mux_test.go all: fix typos 2018-10-29 02:12:03 +00:00
server.go ssh: add sk-ecdsa-sha2-nistp256 and sk-ed25519 2019-12-02 14:38:27 +00:00
session.go all: run gofmt -s on source code 2017-11-28 19:40:09 +00:00
session_test.go ssh: print server exit reason in tests 2019-04-11 14:19:40 +00:00
ssh_gss.go ssh/gss: support kerberos authentication for ssh server and client 2019-05-10 10:41:15 +00:00
ssh_gss_test.go ssh/gss: support kerberos authentication for ssh server and client 2019-05-10 10:41:15 +00:00
streamlocal.go ssh: also start forward listeners on ListenUnix 2018-05-14 16:50:30 +00:00
tcpip.go ssh: don't start goroutines handling forwarded connections until needed 2018-05-14 11:17:49 +00:00
tcpip_test.go go.crypto/ssh: import gosshnew. 2014-04-09 13:57:52 -07:00
testdata_test.go x/crypto: fix typos 2016-07-06 16:40:51 +00:00
transport.go ssh: rename methods in packetCipher interface 2019-04-11 14:11:16 +00:00
transport_test.go ssh: fix protocol version exchange (for multi-line) 2018-01-11 10:11:23 +00:00