go.crypto/ssh: assorted close related fixes

Fixes issue 3810.

Fixes chanWriter Write after close behaviour bug.

Fixes serverChan writePacket after close bug.

Addresses final comments by agl on 6405064, plus various cleanups.

R=agl, kardianos, gustav.paul, fullung
CC=golang-dev
http://codereview.appspot.com/6479056
go.crypto/salsa20: add package.

Package salsa20 implements the Salsa20 stream cipher as specified in
http://cr.yp.to/snuffle/spec.pdf.

(Reference implementation by dchest.)

R=golang-dev, dchest
CC=golang-dev
http://codereview.appspot.com/6496083
go.crypto/poly1305: add package.

(Reference implementation by dchest. amd64 disabled pending 6l fix.)

R=golang-dev, dchest
CC=golang-dev
http://codereview.appspot.com/6494105
go.crypto/nacl: add package

R=golang-dev, dchest, r, rsc
CC=golang-dev
http://codereview.appspot.com/6497101
go.crypto/ssh: sanity check incoming packet length

The check for a sensible packet length was removed a while ago
when the window size and channel packet size checks were moved
into channel.go. While the RFC suggests that any packet of size
less than uint32 -1 is valid, most implmentations limit the size
to a smaller value. OpenSSH chose 256kb, so that sounds like a
sensible default.

R=agl, huin, kardianos
CC=golang-dev
http://codereview.appspot.com/6490098
go.crypto/poly1305: enable AMD64 assembly

This change alters the assembly to use FSUBD instructions such that
6l will actually emit the correct FSUBRD instructions and enables
the assembly code.

R=golang-dev, r
CC=golang-dev
http://codereview.appspot.com/6514044

--HG--
rename : poly1305/poly1305_amd64.s.needs103 => poly1305/poly1305_amd64.s
rename : poly1305/sum_amd64.go.needs103 => poly1305/sum_amd64.go
go.crypto/salsa20: add salsa.Core208.

R=golang-dev, agl, r
CC=golang-dev
http://codereview.appspot.com/6530044

Committer: Adam Langley <agl@golang.org>
go.crypto/scrypt: add package

R=golang-dev, agl, r
CC=golang-dev
http://codereview.appspot.com/6535043

Committer: Adam Langley <agl@golang.org>
go.crypto: match asm variable names to Go func declarations

R=golang-dev, r
CC=golang-dev
http://codereview.appspot.com/6544048
curve25519: fix asm comment

As suggested in review of CL 6544048.

TBR=seed
CC=golang-dev
http://codereview.appspot.com/6553065
go.crypto/ssh: Read returns all unread bytes before returning io.EOF.

Fixes issue 4158.

R=dave, agl
CC=golang-dev
http://codereview.appspot.com/6586060

Committer: Dave Cheney <dave@cheney.net>
go.crypto/ssh: new test subpackage

This proposal is an attempt to improve the state of functional testing in the ssh package. The previous functional tests required the user to give away some personal details, like their password and private key to run the tests, and so were probably not run as frequently as they should.

R=agl, gustav.paul, kardianos, fullung
CC=golang-dev
http://codereview.appspot.com/6601043

--HG--
rename : ssh/tcpip_func_test.go => ssh/test/tcpip_test.go
go.crypto/blowfish: document that only 16 bytes of salt are used.

Also fix salt expansion code to fill the properly sized array,
since the following code never uses more than 4 uints.

Also remove unused expandedKey array.

R=golang-dev, agl
CC=golang-dev
http://codereview.appspot.com/6622050

Committer: Adam Langley <agl@golang.org>
go.crypto: various: fix appengine compatibility

Fixes issue 4102.

R=russross, minux.ma, rsc, agl
CC=golang-dev
http://codereview.appspot.com/6623053
go.crypto/otr: expose IsEncrypted.

It's useful to expose this bit of state because, although callers can
keep track of it themselves, it's already in the Conversation so it
seems wasteful to make them do so.

R=golang-dev, ioerror
CC=golang-dev
http://codereview.appspot.com/6724056
go.crypto/ssh: add terminal modes to ssh.RequestPty()

R=dave, agl
CC=golang-dev
http://codereview.appspot.com/6655046

Committer: Dave Cheney <dave@cheney.net>
go.crypto/ssh: never negotiate unsupported ciphers

Fixes issue 4285.

Adding a new cipher that is supported by the remote end, but not supported by our client causes that cipher to be considered a valid candidate. This fails later in setupKeys when there is no cipherModes configuration.

In summary, unsupported ciphers cannot be willed into existence by adding them to the client config. This change enforces this.

R=golang-dev, agl
CC=golang-dev
http://codereview.appspot.com/6780047
go.crypto/bcrypt: add Cost function

Extracts the cost used to generate a bcrypt hash from the hash itself.

R=agl, agl, dchest
CC=golang-dev
http://codereview.appspot.com/6810051

Committer: Adam Langley <agl@golang.org>
go.crypto: add and adjust +build lines for 386 and gccgo

R=golang-dev, bradfitz
CC=golang-dev
http://codereview.appspot.com/6827061
go.crypto/ssh/test: don't kill process if it was never started

This case arises if s.cmd.Start fails when called by
server.Dial.

R=golang-dev, dave
CC=golang-dev
http://codereview.appspot.com/6821097