Граф коммитов

168 Коммитов

Автор SHA1 Сообщение Дата
Han-Wen Nienhuys 1e856cbfdf crypto/ssh: fix format string error in test.
Change-Id: I0c84f11fb74ee478617deb1b743a759c9f789101
Reviewed-on: https://go-review.googlesource.com/10822
Reviewed-by: Adam Langley <agl@golang.org>
2015-06-08 19:52:49 +00:00
Dmitry Savintsev 7ac880de98 crypto/ssh: trivial spacing change for gofmt compliance
Extra space added by 'gofmt -w' to align key/value columns
in the new test (TestParseCertWithOptions).

Follow-up on https://go-review.googlesource.com/#/c/9375/.

Change-Id: Id7dd0bc420888f12ce0af4178096bdc9f5c57161
Reviewed-on: https://go-review.googlesource.com/9627
Reviewed-by: Adam Langley <agl@golang.org>
2015-06-08 19:50:34 +00:00
Han-Wen Nienhuys 9fb97e878d x/crypto/ssh: add padding oracle countermeasures for AES-CBC.
This deprives an attacker of feedback for guesses against the packet
length given by the connection dropping.

Change-Id: I14939a82e5243a86d192bb18be93d45589227147
Reviewed-on: https://go-review.googlesource.com/9908
Reviewed-by: Adam Langley <agl@golang.org>
2015-05-30 19:27:53 +00:00
datianshi e3f150b437 ssh: add hmac-sha2-256.
Fixes golang/go#10274

Change-Id: Id8386828ee92ccc6cba5197831cdb8b2ce0cd648
Reviewed-on: https://go-review.googlesource.com/8353
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-05-14 18:39:32 +00:00
Han-Wen Nienhuys 74f810a015 x/crypto/ssh: bail early if a server has no auth methods configured.
Change-Id: I58fdfbe00fcc4ca09da9699edcc181cc512feef7
Reviewed-on: https://go-review.googlesource.com/9807
Reviewed-by: JP Sugarbroad <jpsugar@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
2015-05-11 18:34:55 +00:00
Dmitry Savintsev 59435533c8 crypto/ssh: fix encoding of ssh certs with critical options
Attention - BREAKING change for the certificates generated with
the previous versions of crypto/ssh!  Need to regenerate
certificates with a version of crypto/ssh library including
this fix.

[PROTOCOL.cerkeys] requires two length fields for non-empty
values of critical options (or extensions - but those are
currently always empty)  - see
https://bugzilla.mindrot.org/show_bug.cgi?id=2389.
Add SSH-conform handling of such composite values in marshalTuples
and parseTuples and related test (TestParseCertWithOptions) parsing
a certificate created with ssh-keygen which includes critical options.

Fixes #10569

Change-Id: Iecbfca67a66668880635141c72bc5fc370a9c112
Reviewed-on: https://go-review.googlesource.com/9375
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
2015-05-04 20:45:50 +00:00
Dmitry Savintsev c84e1f8e3a crypto/ssh: update references to the old code.google.com repo
Changed code.google.com repository links to the current
golang.org/x/crypto/ssh (except Gerrit homepage).

Change-Id: I7301d21401b163ceef8cfc1cf535dee998f9cb0d
Reviewed-on: https://go-review.googlesource.com/9250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-22 11:59:31 +00:00
Dmitry Savintsev 8b27f58b78 crypto/ssh: fix the links to the SSH protocol documents
Minor change - updated the links to the ssh PROTOCOL.* docs.
Currently the [PROTOCOL...] links in References on top of
https://godoc.org/golang.org/x/crypto/ssh and
https://godoc.org/golang.org/x/crypto/ssh/agent
take you to the top-level directory list on
http://cvsweb.openbsd.org/cgi-bin/cvsweb/
instead of directly to the respective document pages.

Change-Id: Ifd3f0bc2ef393ab02f023c13b93340fdb0a05af3
Reviewed-on: https://go-review.googlesource.com/8963
Reviewed-by: Adam Langley <agl@golang.org>
2015-04-16 17:18:06 +00:00
Nathan(yinian) Hu 5c68cfdf2a crypto/ssh: add support for aes128-cbc cipher.
The aes128cbc cipher is commented out in cipher.go on purpose, anyone wants to
use the cipher needs to uncomment line 119 in cipher.go

Fixes #4274.

Change-Id: I4bbc88ab884bda821c5f155dcf495bb7235c8605
Reviewed-on: https://go-review.googlesource.com/8396
Reviewed-by: Adam Langley <agl@golang.org>
2015-04-10 21:42:31 +00:00
Han-Wen Nienhuys 88b65fb663 ssh: return session ID in ConnMeta.SessionID.
SessionID() returned nil previously.

Fixes #9761.

Change-Id: I53d2b347571d21eab2d913c2228e85997a84f757
Reviewed-on: https://go-review.googlesource.com/3872
Reviewed-by: Adam Langley <agl@golang.org>
2015-02-04 17:27:33 +00:00
Dave Cheney 7db43667c7 ssh: make godoc examples easier to reuse
Fixes golang/go#9747

Move the example tests to an external test package so that they
must explicitly reference the ssh package. The side effect is the
examples now become easier to copy and paste.

Change-Id: Ibbddea42bc5a41d11ffdef5144d9884ef3ef603f
Reviewed-on: https://go-review.googlesource.com/3710
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-02 06:42:08 +00:00
Michael Marineau 160b2e156e ssh/agent: do not return nil entries from keyring.Signers()
The slice returned is constructed with both a pre-set length and
append() resulting in a slice twice as long and half-full of nil.
Setting the capacity instead of length gets the desired result.

Change-Id: I758423594e4f4c0506c53f227454f57a9dc8bdf1
Reviewed-on: https://go-review.googlesource.com/2659
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-12 20:38:54 +00:00
Kristopher Watts 280be005b3 ssh: add ServerConfig.ServerVersion option
The SSH server does not allow for setting a version string in the same
manner as the client.  This update adds a ServerVersion member to the
ServerConfig structure which when set, causes the server to use that
member instead of the default version string.  This allows building
an golang based SSH server which can present any version string
the user wishes.

It also adds an else statement to the client assignment of the
ClientVersion to avoid an allocation when using a user defined
ClientVersion.

Change-Id: I43d97cfd5a174f2c68f53c5b4e267539ef21937b
Reviewed-on: https://go-review.googlesource.com/1860
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-06 03:05:11 +00:00
Derek Che a7ead6ddf0 ssh/terminal: fix SetSize when nothing on current line
SetSize has a problem may cause the following ReadPassword setting
temporary prompt not working, when changing width the current
SetSize will call clearAndRepaintLinePlusNPrevious which would
print an old prompt whatever the current line has, causing a following
ReadPassword with temporary prompt not printing the different prompt.

When running code like this, the nt.SetSize prints a "> " as
prompt then the temporary "Password: " prompt would never show up.

```go
        oldState, err := terminal.MakeRaw(int(os.Stdin.Fd()))
        width, height, _ = terminal.GetSize(int(os.Stdin.Fd()))
        nt := terminal.NewTerminal(os.Stdin, "> ")
        nt.SetSize(width, height)
        password, err = nt.ReadPassword("Password: ")
```

the new test cases is to test SetSize with different terminal sizes,
either shrinking or expanding, a following ReadPassword should get the
correct temporary prompt.

Change-Id: I33d13b2c732997c0c88670d53545b8c0048b94b6
Reviewed-on: https://go-review.googlesource.com/1861
Reviewed-by: Adam Langley <agl@golang.org>
2014-12-19 22:48:49 +00:00
David Symonds 1fbbd62cfe crypto: add import comments.
Change-Id: I33240faf1b8620d0cd600de661928d8e422ebdbc
Reviewed-on: https://go-review.googlesource.com/1235
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 23:26:36 +00:00
Adam Langley 5ff91abc76 go.crypto/ssh/terminal: support bracketed paste mode.
Some terminals support a mode where pasted text is bracketed by escape sequences. This is very useful for terminal applications that otherwise have no good way to tell pastes and typed text apart.

This change allows applications to enable this mode and, if the terminal supports it, will suppress autocompletes during pastes and indicate to the caller that a line came entirely from pasted text.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/171330043
2014-11-16 14:01:45 -08:00
Andrew Gerrand a73c6bbfc5 go.crypto: use golang.org/x/... import paths
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/167190043
2014-11-10 08:50:25 +11:00
Adam Langley 1a85842c9e go.crypto/ssh/terminal: fix Home and End.
In my notes I had Home and End down as OH and OF. But that's nonsense, they are [H and ]F.
I never noticed before because I don't have Home and End keys on my keyboard.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/172100043
2014-11-07 19:20:14 -08:00
Adam Langley 30ad74476e go.crypto/ssh/terminal: remove \r from passwords on Windows.
Fixes golang/go#9040.

(Note: can't compile or test this one prior to committing.)

LGTM=iant, bradfitz
R=bradfitz, mathias.gumz, iant
CC=golang-codereviews
https://golang.org/cl/171000043
2014-11-04 10:58:06 -08:00
Adam Langley 7780ec1765 go.crypto/ssh/terminal: fix crash when terminal narrower than prompt.
Previously, if the current line was "empty", resizes wouldn't trigger
repaints. However, the line can be empty when the prompt is non-empty
and the code would then panic after a resize because the cursor position
was outside of the terminal.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/158090043
2014-10-25 11:16:08 -07:00
Han-Wen Nienhuys 72116d5c17 go.crypto/ssh: clean up address parsing in forward code.
LGTM=agl
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/134700043
2014-09-16 12:34:31 -07:00
Han-Wen Nienhuys fc84ae5437 go.crypto/ssh: reuse packet buffer for channel writes.
Test that different extended data streams within a channel are
thread-safe.

benchmark             old MB/s     new MB/s     speedup
BenchmarkEndToEnd     79.26        87.98        1.11x

benchmark                          old allocs     new allocs     delta
BenchmarkEndToEnd                  110            73             -33.64%

benchmark                          old bytes     new bytes     delta
BenchmarkEndToEnd                  2605720       1299768       -50.12%

LGTM=dave, jpsugar
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/136420043
2014-09-16 12:30:05 -07:00
Han-Wen Nienhuys 9e886ee4f2 go.crypto/ssh: skip tests that start ssh-agent.
Also stops leaking /tmp/ directories.

Fixes golang/go#8489.

LGTM=dave, minux
R=dave, minux, agl
CC=golang-codereviews
https://golang.org/cl/124010043
2014-08-13 10:56:59 -07:00
Dave Cheney ed03dad8de go.crypto/ssh/test: skip tests during -short mode
This proposal effectively disables all the ssh/test tests when run with the -short flag supplied.

For developers and users of this package, there should be no change unless they are in the habbit of always supplying -short, which I belive is untrue.

For the CI dashboard the effect should be that these tests, which are really not portable enough to run reliably on all our various builders, are disabled.

LGTM=adg
R=adg, agl, hanwen
CC=golang-codereviews
https://golang.org/cl/125860043
2014-08-08 11:42:28 +10:00
Adam Langley 76cee1b7b1 go.crypto/ssh/terminal: better handling of window resizing.
There doesn't appear to be perfect behaviour for line editing
code in the face of terminal resizing. But this change works
pretty well on xterm and gnome-terminal and certainly a lot
better than it used to.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/105580043
2014-08-01 11:22:47 -07:00
Dave Cheney 2aff5f12d8 go.crypt/ssh/terminal: declare TCGETS, TCSETS constants locally.
Currently the ssh/terminal package cannot be compiled under gccgo. Even though gccgo may be running on linux, its syscall package is slightly different and does not contain these constants.

This proposal resolves the issue by declaring the two constants locally, as we've done for the *BSDs.

LGTM=hanwen, iant
R=hanwen, iant, gobot
CC=golang-codereviews
https://golang.org/cl/101670043
2014-07-07 10:24:36 +10:00
Adam Langley 9fb3568646 go.crypto/ssh/terminal: support ^U, ^D and ^L.
LGTM=bradfitz
R=bradfitz, marios.nikolaou
CC=golang-codereviews
https://golang.org/cl/92220043
2014-05-27 19:45:07 -07:00
Adam Langley c34e38ab9e go.crypto/ssh: fix authentication after all public keys are rejected by a server.
Validating a public key doesn't return any remaining methods so, if all public keys were rejected, a nil slice would be returned for the remaining methods and authentication would stop.

We could have validateKey return methods, but that wouldn't solve the problem of what to do if the callback returns no keys. In that case we don't have any keys to test.

So this change makes it possible for an AuthMethod to return a nil slice for the remaining methods (meaning "reuse the last list"). It also fixes a scoping bug.

Fixes golang/go#7787.

LGTM=hanwen
R=hanwen
CC=golang-codereviews
https://golang.org/cl/94350043
2014-05-13 10:51:53 -07:00
Adam Langley 2dfe547928 go.crypto/ssh: use permissions from public key cache when accepting a key.
Fixes golang/go#7913.

LGTM=hanwen
R=hanwen
CC=golang-codereviews
https://golang.org/cl/96220043
2014-05-12 11:19:56 -07:00
Han-Wen Nienhuys 6f0540ef5e go.crypto/ssh: try authentication methods in ClientConfig order.
LGTM=jpsugar, agl
R=agl, jpsugar
CC=golang-codereviews
https://golang.org/cl/92240045
2014-05-12 11:16:49 -07:00
Mikio Hara f8eacb97ce go.crypto/ssh/test: enable test cases on dragonfly
LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/98840043
2014-05-05 12:10:24 -07:00
Mikio Hara b71337fce2 go.crypto/ssh/terminal: add support for BSD variants
LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/97850043
2014-05-05 12:07:22 -07:00
David Calavera df2851958a ssh/forward: Fix reference to the functions to call to route authentication requests.
R=agl
CC=golang-codereviews, hanwen
https://golang.org/cl/95910043
2014-05-02 10:55:29 -07:00
Han-Wen Nienhuys 7c7765c32f go.crypto/ssh/agent: add key type to testAgentInterface failure messages.
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/88260043
2014-04-15 13:48:43 -07:00
Han-Wen Nienhuys 15264ff7c7 go.crypto/ssh/agent: prefix errors with "agent".
R=agl, dave, jpsugar
CC=golang-codereviews
https://golang.org/cl/87810047
2014-04-15 13:42:07 -07:00
Han-Wen Nienhuys dac81c328b go.crypto/ssh: fix messages_test.go on 32-bit platforms.
LGTM=dave
R=agl, dave
CC=golang-codereviews
https://golang.org/cl/88060043
2014-04-15 09:09:03 -07:00
Yan Zou e1b0d6c49f go.crypto/ssh: Add support for the pre-2006 RC4 cipher mode.
LGTM=hanwen
R=agl, hanwen
CC=golang-codereviews
https://golang.org/cl/86600044
2014-04-14 10:43:20 -07:00
Han-Wen Nienhuys 058f0eec52 go.crypto/ssh: only offset channel IDs when debugMux is
set.

Otherwise, the package leaks data about total number of
connections established through its channel IDs.

R=agl, jpsugar
CC=golang-codereviews
https://golang.org/cl/87280043
2014-04-14 09:23:18 -07:00
David du Colombier 7e43632730 go.crypto/ssh: build test_unix_test on Plan 9
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/86630043
2014-04-12 22:07:48 +02:00
Adam Langley 43c4f8a896 go.crypto/ssh: remove old files.
In c0fc595a2cb5, hg didn't notice the files that had been removed from
the working directory. These, old files are breaking the build.

CC=golang-codereviews
https://golang.org/cl/86240043
2014-04-09 14:37:07 -07:00
Adam Langley fa50e7408b go.crypto/ssh: import gosshnew.
See https://groups.google.com/d/msg/Golang-nuts/AoVxQ4bB5XQ/i8kpMxdbVlEJ

R=hanwen
CC=golang-codereviews
https://golang.org/cl/86190043
2014-04-09 13:57:52 -07:00
David du Colombier a2c10b4975 go.crypto/ssh: build tests on Plan 9
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/64390044
2014-02-19 20:51:49 +01:00
Brad Fitzpatrick 63a71ca82d undo CL 51690043 / abf8f8812575
Breaks FreeBSD build of subrepo for non-tip users.

««« original CL description
go.crypto/ssh/terminal: enable freebsd build

syscall.Termios, which was the only thing breaking the build, is
available in go tip now
(https://code.google.com/p/go/source/detail?r=873d664b00ec)

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/51690043

»»»

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/51100044
2014-01-13 15:00:50 -08:00
Michael Gehring ef64186525 go.crypto/ssh/terminal: enable freebsd build
syscall.Termios, which was the only thing breaking the build, is
available in go tip now
(https://code.google.com/p/go/source/detail?r=873d664b00ec)

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/51690043
2014-01-13 14:35:19 -08:00
Jakob Borg 4758fe8ce4 go.crypto/ssh: Increase window size.
Increase window size for channels (session and tcpip) to 64 *
max packet size (32 KB), which is the same value that OpenSSH
uses. Also breaks out the relevant harcoded constants into named
constants in channel.go.

Fixes golang/go#6675.

R=golang-dev, dave, hanwen, agl
CC=golang-dev
https://golang.org/cl/18120043
2013-11-01 04:24:39 +11:00
Han-Wen Nienhuys 577ae2abf9 go.crypto/ssh: cosmetic: unnest signing code for public key auth.
R=dave
CC=golang-dev
https://golang.org/cl/15930044
2013-10-26 03:25:59 +11:00
Han-Wen Nienhuys 34df1ce598 go.crypto/ssh: in {Server,Client}Conn, read session ID from
transport layer.

R=agl, dave
CC=golang-dev
https://golang.org/cl/15870044
2013-10-25 11:15:34 -04:00
Dave Cheney c0d640c887 go.crypto/ssh: ensure {Server,Client}Conn do not expose io.ReadWriter
Transport should not be a ReadWriter. It can only write packets, i.e. no partial reads or writes. Furthermore, you can currently do ClientConn.Write() while the connection is live, which sends raw bytes over the connection. Doing so will confuse the transports because the data is not encrypted.

As a consequence, ClientConn and ServerConn stop being a net.Conn

Finally, ensure that {Server,Client}Conn implement LocalAddr and RemoteAddr methods that previously were exposed by an embedded net.Conn field.

R=hanwen
CC=golang-dev
https://golang.org/cl/16610043
2013-10-25 06:29:58 +11:00
Han-Wen Nienhuys 105632d35b go.crypto/ssh: only close connection if it was open in TestClientUnsupportedKex.
R=dave
CC=golang-dev
https://golang.org/cl/15450046
2013-10-24 04:12:59 +11:00
Jonathan Pittman 94779a0cf1 go.crypto/ssh: Implement CertTime to properly handle the "infinite" time
value ^0, which would become negative when expressed as int64.

R=agl, dave, jpsugar, hanwen
CC=golang-dev
https://golang.org/cl/15520047
2013-10-23 12:44:23 -04:00