Commit Graph
251 Commits
Author SHA1 Message Date
Josh Bleecher Snyder b7d6bf2c61 crypto: add codereview.cfg
See golang.org/cl/4131 for context.

Change-Id: I050ffde0bec2c2fd639e028e1abb22a720e1b2eb
Reviewed-on: https://go-review.googlesource.com/7761
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-18 17:04:25 +00:00
Andrew Gerrand 1351f936d9 doc: add CONTRIBUTING.md
Change-Id: Ib52f590ff2bfd44acfd37eb3bb545180f157a135
Reviewed-on: https://go-review.googlesource.com/5210
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-18 23:42:20 +00:00
Richard Barnes f7445b17d6 ocsp: Add server-side OCSP processing
The current content of the ocsp module is focused on the processing needed to implement an OCSP client: it only implements request generation and response parsing.

This change adds response generation and request parsing.

Change-Id: Idf6f4e69af504520f2b58340734e45cd92bb3d60
Reviewed-on: https://go-review.googlesource.com/3666
Reviewed-by: Adam Langley <agl@golang.org>
2015-02-06 19:37:46 +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
David Leon Gil bfc286917c sha3: move test data to testdata
Change the location of the KAT data for consistency with
other packages.

Change-Id: Ica10ad7d1730603f957fb413e28fe771b3c323bc
Reviewed-on: https://go-review.googlesource.com/3267
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-24 22:04:49 +00:00
David Leon Gil 4ed45ec682 sha3: use unaligned reads and xors on x86 and x64
Speedup of about 1.4x on x64. Added benchmarks that use the
ShakeHash interface, which doesn't require copying the state.

Unaligned or generic xorIn and copyOut functions chosen via
buildline, but both are tested.

Substantial contributions from Eric Eisner.

See golang.org/cl/151630044 for the previous CR.

(There are also some minor edits/additions to the documentation.)

Change-Id: I9500c25682457c82487512b9b8c66df7d75bff5d
Reviewed-on: https://go-review.googlesource.com/2132
Reviewed-by: Adam Langley <agl@golang.org>
2015-01-12 22:01:33 +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
David Leon Gil 632d287f9f crypto/openpgp: support public keys generated by End-to-End
packet/packet.go: add ECDSA to the algorithms in CanSign()
packet/signature.go: add support for the features subpacket (which is
used to signal support for the MDC packet)
openpgp/read_test.go: add a key generated by End-to-End as a testcase
(End-to-End's keys are unusual: they set critical bits)

Change-Id: Ifaf3922cd35ea27cf1276d7a8238dd50536eb4ed
Reviewed-on: https://go-review.googlesource.com/2058
Reviewed-by: Adam Langley <agl@golang.org>
2015-01-06 19:53:31 +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
Alex Brainman c89e568385 crypto: copying .gitattributes to all subrepositories
Fixes #9281

Change-Id: I15c448ec0fe8155b5e30e0aabdb48ea1d8504042
Reviewed-on: https://go-review.googlesource.com/2073
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-23 06:54:52 +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
David Symonds 731db29863 remove codereview.cfg. 2014-12-08 10:59:03 +11:00
David Symonds 51bc81f679 convert .hgignore to .gitignore. 2014-12-08 10:41:13 +11:00
Adam Langley f59690be3f go.crypto/openpgp: fix nil Config case.
This is a followup to https://golang.org/cl/176080043/. That
change didn't handle the case of a *Config being nil.

CC=golang-codereviews
https://golang.org/cl/179200043
2014-11-21 14:11:46 -08:00
Brian Gitonga Marete ca455997ca go.crypto/openpgp: Allow config. of s2k count for symmetric encrypt.
This patch allows the user to choose the strength of the
passphrase mangling during the process in which the key is
produced from the passphrase. It only affects symmetric
encryption.

Unmodified code that calls openpgp.SymmetricallyEncrypt() will
continue to get the now-default count of 65536. Otherwise, a
count in the range [1024, 65011712] may be configured. Illegal
values in and outside this range will silently be rounded up
to legal values within the said range.

The test to s2k.Serialize() has been modified to test a
variety of non-default counts with all the valid hashes and
ensure that the decoding component of s2k can parse and
decrypt the result.

Additional testing has been done with GPG to ensure that the
latter can parse and decrypt files encrypted/encoded with
various counts.

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/176080043
2014-11-21 14:04:52 -08: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
Brian Gitonga Marete c24604da51 go.crypto/openpgp: Allow configuration of s2k hash during encryption.
This patch/CL allows the user to configure the hash function
used in the s2k key-stretching transformation during
encryption. It fixes the current limitation in which SHA1 is
hard-coded for that task.

With this change, packet.Config.DefaultHash is used by default
for the mode 3 s2k key-stretching that is currently used for
encryption, but the user may choose any other valid openpgp
hash by passing a new (possibly nil) pointer argument to
s2k.Serialize().

Note that this change introduces an API change to
s2k.Serialize() in the form of an additional
argument. However, the s2k package is a low-level facility
that (as far as I could tell) is used directly by
go.crypto/openpgp only.

The CL comes with an modified test to check the use and
decoding of all the valid hash functions with regard to
s2k.Serialize().

This patch should be followed by one that allows the user to
configure the iteration count in mode 3 s2k, and it is a
prerequisite for that forthcoming change.

R=golang-codereviews, agl
CC=agl, golang-codereviews
https://golang.org/cl/160110045
2014-10-29 18:30:24 -07:00
Adam Langley 3e2271302c go.crypto/openpgp: don't corrupt encrypted private key when decryption fails.
Since the decryption was done in place, if an incorrect key was given,
the encrypted data would be corrupted.

Fixes golang/go#8439.

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/115550043
2014-10-25 11:19:44 -07: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
Ian Lance Taylor cb7a96fa34 sha3: change range statement in test to work with Go 1.3 and earlier
LGTM=bradfitz
R=agl, bradfitz
CC=golang-codereviews
https://golang.org/cl/157930043
2014-10-13 14:14:22 -07:00
Eric Roshan-Eisner 9b55b542f6 go.crypto/sha3: optimize round function
benchmark                        old ns/op     new ns/op     delta
BenchmarkPermutationFunction     1128          733           -35.02%
BenchmarkShake256_1MiB           10004381      6832715       -31.70%

benchmark                        old MB/s     new MB/s     speedup
BenchmarkPermutationFunction     177.23       272.54       1.54x
BenchmarkShake256_1MiB           104.81       153.46       1.46x

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/156770043
2014-10-08 10:57:02 -07:00
Ian Lance Taylor 902e2dcb72 curve25519, poly1305: change last CL to build with Go 1.3
It also still works with Go 1.4.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/154120043
2014-10-07 18:09:31 -07:00
Ian Lance Taylor 20b2ab3f62 curve25519, poly1305: mark constants as RODATA
Fixes tests when using Go tip.  Without this the link steps
fails with errors like:

missing Go type information for global symbol: google3/third_party/golang/go_crypto/curve25519/curve25519.REDMASK51 size 8

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/156810043
2014-10-07 16:59:07 -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
Adam Langley 82442e0e95 go.crypto/sha3: use the go1.4 tag to register the hash functions.
Prior to Go 1.4, crypto didn't have the consts defined for SHA-3.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/133540043
2014-09-03 16:08:25 -07:00
David Leon Gil 1b32d8b50a go.crypto/sha3: update to sync with draft FIPS-202
1. API:

This exposes a minimal API: the SHA-3 functions implement hash.Hash. The
SHAKE functions implement a new "ShakeHash" interface that implements
io.Reader, io.Writer, and Reset().

(The previous Barrier() function has been removed.)

(Alternative proposal: Don't implement io.Reader, but instead provide a
"Digest(d []byte) error" function that performs a hash.Hash style copy.
Somewhat more minimal, but very easy to use incorrectly.)

2. Tests

Added the complete set of ShortMsgKATs from
   https://github.com/gvanas/KeccakCodePackage

3. Correctness

In sync with draft FIPS-202.

4. Documentation

A summary of the security properties of the SHA-3 and SHAKE functions is
provided in doc.go; some concrete recommendations as well.

Fixes 8563.

R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/130950043
2014-09-03 12:04:00 -07:00
Adam Langley 18c283559e go.crypto/openpgp: fix clearsigned parsing of messages with leading blank lines.
Fixes golang/go#8508.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/128920043
2014-08-28 10:37:22 -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
Adam Langley 3092f0d93b go.crypto/openpgp: return signature error rather than unknown issuer.
In the event that a detached signature fails to verify, the code would
continue trying to find other keys with the same key ID and eventually
conclude that the signature was issued by someone unknown
(ErrUnknownIssuer).

With this change, the signature verification error would be returned
instead. (Technically the last error if several keys had a matching key
id and neither verified.)

Fixes golang/go#8509.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/125030043
2014-08-11 15:41:56 -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
Dmitry Chestnykh b7f382b979 go.crypto/blowfish: support salts larger than 16 bytes.
Supporting larger salts makes it possible to implement bcrypt-pbkdf
(http://www.tedunangst.com/flak/post/bcrypt-pbkdf), which is used in
the latest OpenSSH versions to encrypt key files.

This change makes expandKeyWithSalt (and thus NewSaltedCipher) about
20% slower, but since it isn't used in the "heavy" phase of computation
in bcrypt (it uses ExpandKey, which didn't change), the effect on
bcrypt performance is negligible.

The 16-byte limit was an artifact of optimization and due to the fact
that it was enough for bcrypt; Eksblowfish spec or other
implementations don't limit the salt size.

Additionally, there was a bug in the previous implementation: it only
generated correct results for salts consisting of 4, 8, or 16 bytes, and panicked if salt had zero length.

LGTM=agl
R=golang-codereviews, gobot, agl
CC=golang-codereviews
https://golang.org/cl/102720045
2014-08-01 14:09:20 -07: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 aeb0262c11 go.crypto/openpgp: fix hash presence checks.
At some point in the distant past, crypto.Hash.New() changed from
returning nil when a hash function wasn't provided, to panicing. Some
of the code in openpgp predates this and was still using the nil check.

LGTM=bradfitz
R=sburford, bradfitz
CC=golang-codereviews
https://golang.org/cl/104850045
2014-06-04 11:40:03 -07: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
Dmitry Chestnykh ce1cf546ac go.crypto/hkdf: get rid of appends
LGTM=agl
R=golang-codereviews, bradfitz, agl
CC=golang-codereviews
https://golang.org/cl/95370044
2014-05-25 13:56:25 -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 84ca184138 go.crypto/openpgp: fix user id signing.
Entity.SignIdentity used the wrong signature function and produced invalid
certification signatures. Fixed.

VerifyUserIdSignature was used for checking the self-signature on an identity,
but didn't support anything but a self-signature. This change alters the
low-level API so that checking cross-signatures is possible.

Fixes golang/go#7371.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/96240043
2014-05-12 11:23:48 -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
Dmitry Chestnykh c261757620 go.crypto/blowfish: no need for key in initCipher
LGTM=robert.hencke
R=golang-codereviews, robert.hencke
CC=golang-codereviews
https://golang.org/cl/84860043
2014-05-05 11:42:21 -07:00
Adam Langley aa3adaf1aa go.crypto/openpgp: check for revoked keys.
R=agl
CC=golang-codereviews
https://golang.org/cl/95050043
2014-05-05 11:41:50 -07:00