Commit Graph
693 Commits
Author SHA1 Message Date
Brad Fitzpatrick 2fc4c88bf4 ssh: also start forward listeners on ListenUnix
Forgotten file from CL 112635.

The integration tests didn't catch this because the integration tests
never run (sshd isn't in $PATH usually), but even when $PATH is
modified, it seems to have been failing for ages on both Debian jessie
and stretch. I'll fix the tests and make them run in TryBots in later
changes.

Change-Id: I85fd3b6109a73990bc353a61da5f527b9a698501
Reviewed-on: https://go-review.googlesource.com/113056
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-14 16:50:30 +00:00
Brad Fitzpatrick 034e5325b6 ssh: don't start goroutines handling forwarded connections until needed
The extra goroutines were distracting while debugging something else,
especially as I wasn't using that feature. This also saves a bit of
memory.

Change-Id: Ia6489e64bbd3d5a6ff699a25018676d8ff8bd2e4
Reviewed-on: https://go-review.googlesource.com/112635
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2018-05-14 11:17:49 +00:00
Michael Munday 94e3fad7f1 chacha20poly1305: add test for empty plaintext and additional data
The code (especially assembly implementations) should be able to
handle this scenario.

Change-Id: I68c6a5b8a099a23a87bfcb5f7246a2134f82bb9e
Reviewed-on: https://go-review.googlesource.com/112977
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-13 06:46:51 +00:00
Hana (Hyang-Ah) Kim 2d027ae1dd ssh/terminal: run tests only on supported platforms
The tag matches the platforms defined in util*.go
where the most tested logic is defined.

Change-Id: I90f67d988c795738c3effbc8554a933a7cb355d2
Reviewed-on: https://go-review.googlesource.com/112555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-09 20:57:47 +00:00
Filippo Valsorda 1258d06b9d salsa20: panic when len(out) < len(in) following cipher.Stream
Change-Id: I5c8d603cc3ec844b8d44e51b3138bcf16e95c7fc
Reviewed-on: https://go-review.googlesource.com/112235
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
2018-05-09 19:27:45 +00:00
Filippo Valsorda 21052ae466 openpgp: fix vet issue in tests
https://golang.org/cl/111416 made vet spot this new issue by recognizing
the len() call as side-effect free:

    redundant or: md.IsSymmetricallyEncrypted || md.IsSymmetricallyEncrypted

Change-Id: I8b72eedb458365a50e14d5eec35b972ee61efb1f
Reviewed-on: https://go-review.googlesource.com/112255
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-09 02:20:26 +00:00
Leon Klingele 4ec37c66ab sha3: add NewLegacyKeccak256
Keccak uses a different domain separation byte as the NIST-
standardized SHA-3 hashing function.

Fixes golang/go#19709

Change-Id: I1b45afce9b7719241b24bbdc9b67718d73b457d3
GitHub-Last-Rev: 4f2a701c5ff0c6ee36c931794ea76bed9a98835e
GitHub-Pull-Request: golang/crypto#41
Reviewed-on: https://go-review.googlesource.com/106462
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-05 02:55:34 +00:00
Filip Haglund 1f94bef427 scrypt: update example to match recommendation two lines below
Change-Id: I6eb5db30df9bc1c4b3c4124c9cdd3d504d33ad9d
GitHub-Last-Rev: 1f585c4bf946a3241f8c38e1e954c4e5f8dc4713
GitHub-Pull-Request: golang/crypto#43
Reviewed-on: https://go-review.googlesource.com/110120
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 21:59:45 +00:00
Kris Kwiatkowski 76a954637d sha3: enable TestUnalignedWrites
Changes function name from "testUnalignedWrites" to "TestUnalignedWrites"
which makes "go test" actually run this test.

Change-Id: Ie46f11ee1fd5c8780d5704d2fabe6ddb229262f9
Reviewed-on: https://go-review.googlesource.com/111282
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 15:31:09 +00:00
Filippo Valsorda 8b1d31080a bn256: explicitly fix MakeAffine for ∞
When c = ∞, z = 0 and 0 does not have a modular inverse, triggering
undefined behavior (recently changed to returning nil) in ModInverse.

Unclear how this used to work anyway. Looks like ModInverse was
leaving the receiver untouched, making zInv = 0 when pool = nil.

Fixes golang/go#25199

Change-Id: Ib39abf59f0e71cf43cdb5836142ebdd3b206fb3f
Reviewed-on: https://go-review.googlesource.com/110695
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2018-05-02 18:48:08 +00:00
Tom Thorogood 2c241ca304 chacha20poly1305: correct AVX2 feature detection
CL 110355 switched out the adhoc cpu feature detection for x/sys/cpu, in
doing so the AVX2 check was broken. The assembly code uses MULX which is
part of BMI2.

Updates golang/go#24843

Change-Id: I4719b8ff3211eb1c823099512e593e540d6f3be8
GitHub-Last-Rev: 70542b53cd09fcae26c3579cd84bcee39a4b8a57
GitHub-Pull-Request: golang/crypto#44
Reviewed-on: https://go-review.googlesource.com/110796
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-05-02 12:12:36 +00:00
Michael Munday 613d6eafa3 ssh: fix copy and paste error
Doesn't matter because contentKey and lengthKey are the same length,
but we should really be looping over lengthKey here.

Change-Id: Ic7af3c553eb4382239bec1c030e77c7f5baa0662
Reviewed-on: https://go-review.googlesource.com/109735
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 15:52:21 +00:00
Joe Shaw 80f0338f9e ocsp: remove error for > 1 certificate in response
Some OCSP responders contain more than one certificate, which can be
used to "help the OCSP client verify the responders signature" (RFC
6960 section 4.2.1).  This client doesn't do verification of the chain
to the root, but it's not an error for a responder to send more than
one.

Fixes golang/go#21527

Change-Id: Ie23cfcb347a4f7cdfb1a0cbad2aa03a1242553af
Reviewed-on: https://go-review.googlesource.com/57510
Reviewed-by: Adam Langley <agl@golang.org>
2018-05-01 15:29:04 +00:00
Andreas Auernhammer ae8bce0030 crypto/{blake2b,blake2s,argon2,chacha20poly1305}: replace CPU feature detection
This change removes package specific CPU-feature detection code and
replaces it with x/sys/cpu.

Fixes golang/go#24843

Change-Id: I150dd7b3aeb8eef428c91f9b1df741ceb8a87a24
Reviewed-on: https://go-review.googlesource.com/110355
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-30 18:12:35 +00:00
Alberto Donizetti db7d12313a ssh/agent: remove len check in Unlock
Unlock compares the length of the passphrase with the given one before
calling subtle.ConstantTimeCompare. This is redundant, since
ConstantTimeCompare already perform a lengths check before doing
anything. Remove the check from Unlock.

Updates golang/go#25173

Change-Id: Ib5fec3a94392bddf2996f5c6bf5a414529e86f2f
Reviewed-on: https://go-review.googlesource.com/110068
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2018-04-30 11:26:54 +00:00
Michael Munday b49d69b5da internal/chacha20: add s390x SIMD implementation
Based on the SIMD algorithm described in:
ChaCha, a variant of Salsa20 by Daniel J. Bernstein
https://cr.yp.to/chacha/chacha-20080128.pdf

Requires the vector facility (vx).

name            old speed     new speed      delta
ChaCha20/32     178MB/s ± 0%   174MB/s ± 0%    -2.10%  (p=0.000 n=9+10)
ChaCha20/63     341MB/s ± 0%   337MB/s ± 0%    -1.16%  (p=0.000 n=10+10)
ChaCha20/64     367MB/s ± 0%   335MB/s ± 0%    -8.73%  (p=0.000 n=10+10)
ChaCha20/256    404MB/s ± 0%  1448MB/s ± 0%  +258.61%  (p=0.000 n=9+10)
ChaCha20/1024   410MB/s ± 0%  1568MB/s ± 0%  +282.73%  (p=0.000 n=9+10)
ChaCha20/1350   393MB/s ± 0%  1389MB/s ± 0%  +253.58%  (p=0.000 n=10+10)
ChaCha20/65536  414MB/s ± 0%  1634MB/s ± 0%  +294.79%  (p=0.000 n=10+10)

Change-Id: I9a600fb5ae8ee3f3b81ae6b01cff139c1272d684
Reviewed-on: https://go-review.googlesource.com/35842
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 23:03:45 +00:00
Michael Munday 754cb46fa0 chacha20poly1305: update to use new ChaCha20 API
Use the new streaming API introduced in CL 104856. Performance
change is negligible:

name                       old speed      new speed      delta
Chacha20Poly1305Open_64     131MB/s ± 2%   135MB/s ± 2%  +3.01%  (p=0.000 n=18+18)
Chacha20Poly1305Seal_64     137MB/s ± 2%   141MB/s ± 3%  +2.89%  (p=0.000 n=19+20)
Chacha20Poly1305Open_1350   305MB/s ± 3%   309MB/s ± 2%  +1.38%  (p=0.001 n=19+20)
Chacha20Poly1305Seal_1350   309MB/s ± 2%   311MB/s ± 2%  +0.74%  (p=0.032 n=19+18)
Chacha20Poly1305Open_8K     338MB/s ± 3%   340MB/s ± 2%    ~     (p=0.108 n=19+20)
Chacha20Poly1305Seal_8K     335MB/s ± 4%   342MB/s ± 2%  +1.96%  (p=0.000 n=19+19)

Change-Id: I2232c9d8d8431f30fb85b4b371d78a57e633283e
Reviewed-on: https://go-review.googlesource.com/108657
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 23:00:03 +00:00
Michael Munday 83c378c48d ssh: update to use new ChaCha20 API
Use the new streaming API added in CL 104856.

Change-Id: I6453a54a9739f20fc4d05f476c6e26f720ccd354
Reviewed-on: https://go-review.googlesource.com/108656
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 22:59:36 +00:00
Michael Munday 12dd70caea internal/chacha20: implement the cipher.Stream interface and optimize
SIMD implementations of ChaCha20 (such as CL 35842) interleave block
computations in order to achieve high performance. This means that
they produce more than 64 bytes of output at a time. Unfortunately
when encrypting small amounts of data (such as Poly1305 keys) the
current interface to ChaCha20 forces the additional encrypted blocks
of output to be discarded and recomputed later since it does not
maintain any state. This additional overhead slows down the encryption
of small amounts of data when using such optimized code.

This CL makes the generic ChaCha20 implementation stateful, caching
key, nonce and counter values and buffering any unused key stream bytes.
ChaCha20 now also implements the high level cipher.Stream interface
which makes the API more consistent with other stream ciphers in the
standard library's crypto package. This will make it easier to add high
performance SIMD implementations in the future.

In addition to modifying the API I have also added some optimizations
to improve the performance of the generic implementation. Note that
the performance will improve further on amd64 with Go 1.11 due to
CL 95475 (binary.LittleEndian.PutUint32 optimization). These benchmarks
are based on Go 1.10.1.

name            old speed      new speed      delta
ChaCha20/32      174MB/s ± 2%   174MB/s ± 1%     ~     (p=0.796 n=10+10)
ChaCha20/63      309MB/s ± 1%   337MB/s ± 2%   +9.32%  (p=0.000 n=10+9)
ChaCha20/64      299MB/s ± 2%   350MB/s ± 1%  +17.12%  (p=0.000 n=9+8)
ChaCha20/256     297MB/s ± 2%   390MB/s ± 1%  +31.40%  (p=0.000 n=10+10)
ChaCha20/1024    300MB/s ± 0%   400MB/s ± 3%  +33.38%  (p=0.000 n=7+10)
ChaCha20/1350    290MB/s ± 1%   386MB/s ± 2%  +33.10%  (p=0.000 n=9+10)
ChaCha20/65536   301MB/s ± 1%   416MB/s ± 2%  +38.25%  (p=0.000 n=9+10)

ChaCha20-Poly1305 (AEAD optimizations manually disabled):

name                       old speed      new speed      delta
Chacha20Poly1305Open_64     122MB/s ± 7%   131MB/s ± 2%   +7.23%  (p=0.000 n=18+18)
Chacha20Poly1305Seal_64     125MB/s ± 4%   137MB/s ± 2%   +9.88%  (p=0.000 n=20+19)
Chacha20Poly1305Open_1350   244MB/s ± 4%   305MB/s ± 3%  +25.04%  (p=0.000 n=20+19)
Chacha20Poly1305Seal_1350   242MB/s ± 3%   309MB/s ± 2%  +27.56%  (p=0.000 n=20+19)
Chacha20Poly1305Open_8K     260MB/s ± 7%   338MB/s ± 3%  +29.96%  (p=0.000 n=20+19)
Chacha20Poly1305Seal_8K     262MB/s ± 5%   335MB/s ± 4%  +27.80%  (p=0.000 n=20+19)

No change in allocations for either set of benchmarks.

Change-Id: I28ca7947904e9d79debe2d5aac6623526fe5e595
Reviewed-on: https://go-review.googlesource.com/104856
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 22:54:13 +00:00
Michael Munday dccd99e89d sha3: add optimized implementation for s390x
Message-security-assist extension 6 adds support for the SHA-3 and
SHAKE algorithms. This CL allows the sha3 package to use these new
features.

name                 old speed     new speed      delta
PermutationFunction  328MB/s ± 0%   385MB/s ± 0%    +17.28%  (p=0.000 n=9+10)
Sha3_512_MTU         108MB/s ± 0%  2011MB/s ± 0%  +1768.56%  (p=0.000 n=10+10)
Sha3_384_MTU         149MB/s ± 0%  2437MB/s ± 0%  +1534.22%  (p=0.000 n=10+10)
Sha3_256_MTU         185MB/s ± 0%  2739MB/s ± 0%  +1379.93%  (p=0.000 n=10+10)
Sha3_224_MTU         195MB/s ± 0%  2782MB/s ± 0%  +1326.05%  (p=0.000 n=10+10)
Shake128_MTU         225MB/s ± 0%  4436MB/s ± 0%  +1873.18%  (p=0.000 n=9+9)
Shake256_MTU         209MB/s ± 0%  4521MB/s ± 0%  +2059.86%  (p=0.000 n=8+10)
Shake256_16x         188MB/s ± 0%  1366MB/s ± 0%   +624.70%  (p=0.000 n=9+10)
Shake256_1MiB        212MB/s ± 0%  5861MB/s ± 0%  +2666.67%  (p=0.000 n=10+10)
Sha3_512_1MiB        116MB/s ± 0%  4328MB/s ± 0%  +3628.33%  (p=0.000 n=10+10)

Change-Id: I8ebc503ca2b9eda2ebb361dffdbfe79dd97e1975
Reviewed-on: https://go-review.googlesource.com/59391
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 18:01:11 +00:00
Agniva De Sarker 719079de17 ssh/test: skip tests if run as root
Fixes golang/go#14269

Change-Id: I8819de040e5f5ca3e46819d71b0cd9145b6de6d5
Reviewed-on: https://go-review.googlesource.com/109475
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
2018-04-26 11:53:54 +00:00
Andreas Auernhammer b0697eccbe blake2b: Revert "blake2b: use internal/cpu to determine AVX and SSE 4 support"
This reverts commit d6449816ce because of golang/go#24828.

Change-Id: I14b4e1265b2e75897fa12548dbdfb77c308afaaf
Reviewed-on: https://go-review.googlesource.com/108795
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2018-04-25 07:15:31 +00:00
Agniva De Sarker 2b6c08872f ssh/agent: update documentation link
Fixes golang/go#24982

Change-Id: I81c646b92230bdcbc7f08de535dd657e86bb03ce
Reviewed-on: https://go-review.googlesource.com/108775
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-23 11:01:33 +00:00
Andrey Mirtchovski e73bf333ef x/crypto: cryptobyte: manage integers with implicit tags
This change adds two functions to cryptobyte to encode and decode
int64 with tags supplied by the user.

This change also modifies a documentation comment which was outdated.

Fixes golang/go#24973

Change-Id: I2e3ca475891ba62df902f33085719f94e87a27cc
GitHub-Last-Rev: cd0300d9bfbd4e38f22503a046ea18f9ddd37676
GitHub-Pull-Request: golang/crypto#42
Reviewed-on: https://go-review.googlesource.com/108456
Reviewed-by: Adam Langley <agl@golang.org>
2018-04-20 17:11:55 +00:00
Tobias Klauser d6449816ce blake2b: use internal/cpu to determine AVX and SSE 4 support
CL 106235 removed runtime.support_avx on which blake2b depends to
determine AVX support. Switch to use the corresponding feature flags
from internal/cpu instead. While at it, also use AVX2 and SSE4 (for Go
1.7 and later) from there.

Change-Id: I4f7a27fcfa0c5d0d7a50444c7aa32519b97e90dd
Reviewed-on: https://go-review.googlesource.com/106336
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-11 16:13:17 +00:00
Andrey Mirtchovski f70185d77e cryptobyte: minor documentation fix
This change fixes a minor misspelling in the documentation for ReadBytes.

Change-Id: Ia1cfedfce11844c4d901b9aeed52065f3749dfa2
GitHub-Last-Rev: d1560b97807871c356d1b704d4879b1cf94a3fd8
GitHub-Pull-Request: golang/crypto#40
Reviewed-on: https://go-review.googlesource.com/106116
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-10 18:26:41 +00:00
Han-Wen Nienhuys beb2a9779c ssh/knownhosts: disregard IP address if the hostname is available
This fixes the following vulnerability scenario:

* Victim logs into SAFE-HOST on SAFE-IP-ADDRESS regularly.

* Victim is cajoled into connecting to attacker controlled
  ATTACK-HOST, on ATTACK-IP-ADDRESS. ATTACK-HOST uses a different host
  key type (e.g. Ed25519 vs RSA). The new key is added at the end of
  known_hosts.

* Attacker makes DNS system return ATTACK-IP-ADDRESS for SAFE-HOST.

* Victim logs into SAFE-HOST, but is not warned because the host key
  matches ATTACK-IP-ADDRESS.

For this attack to work, the key type has to be different, because
knownhosts gives precedence to the first key found for each type. Add
a test that asserts this behavior.

The new semantics simplify the code, but callers that modify
.ssh/known_host interactviely must now take an extra step to remain
OpenSSH compatible: on successful login, the IP address must be
checked without hostname, and if it is not known, added separately to
the known_hosts file, so future logins that use an IP address only
will be protected too.

Thanks to Daniel Parks <security@demonhorse.net> for finding this
vulnerability.

Change-Id: I62b1b60ceb02e2f583a4657213feac1a8885dd42
Reviewed-on: https://go-review.googlesource.com/104939
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-09 15:00:46 +00:00
Han-Wen Nienhuys b2aa35443f ssh: drop extra connection Close call in TestMuxReadWrite
The extra Close call runs in a separate goroutine, and races with the
deferred Close call, leading to test flakes if the extra call fails

Change-Id: Ia1a2fb3932906da7cd0a8854b55f82785bb33716
Reviewed-on: https://go-review.googlesource.com/104335
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-03 16:09:46 +00:00
ValarDragon 12892e8c23 blake2b,blake2s: implement BinaryMarshaler, BinaryUnmarshaler
The marshal method allows the hash's internal state to be serialized and
unmarshaled at a later time, without having the re-write the entire stream
of data that was already written to the hash.

Fixes golang/go#24548

Change-Id: I82358c34181fc815f85d5d1509fb2fe0e62e40bd
Reviewed-on: https://go-review.googlesource.com/103241
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
2018-03-30 21:03:55 +00:00
Mark Rushakoff 88942b9c40 xtea: comment cleanup
Change-Id: Ibd61a57fbbaa2775adb370a7e91b6dc0f8ca8782
GitHub-Last-Rev: f0111f4a5f941067661fee89e37a95e3503ebdda
GitHub-Pull-Request: golang/crypto#36
Reviewed-on: https://go-review.googlesource.com/102035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-22 17:52:30 +00:00
Florian Uekermann 80db560fac nacl/sign: add package
This change adds the equivalents of crypto_sign, crypto_sign_open and
crypto_sign_keypair in TweetNaCl and libsodium using the Ed25519 system.
The original NaCl codebase does not contain functions with identical
semantics but its documentation stated the intent of using Ed25519 in
future releases.

Fixes golang/go#24350

Change-Id: I4c3c86b4875f2f718ad9299c2274b4ad9e11fbeb
Reviewed-on: https://go-review.googlesource.com/100578
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2018-03-20 22:59:59 +00:00
Brad Morgan c3a3ad6d03 acme/autocert: use valid certificates from the cache during renewal
Currently, the renewal flow will check the cache before renewing to make
sure it is actually necessary. This change modifies this flow to update
the local state so the cached cert is actually used by the manager.

Fixes golang/go#22960

Change-Id: I16668e8098616190938ee52858294b59bc1a5160
Reviewed-on: https://go-review.googlesource.com/89995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-19 06:17:31 +00:00
Filippo Valsorda 374053ea96 openpgp/packet: improve handling of short MPIs for RSA values
MPIs are (supposed to be) stripped of leading zeroes. Avoid passing
such short values into crypto/rsa, even if it currently happens to work.

Change-Id: I5a5f4813b8358e83fcc2deeda1272d2733814542
Reviewed-on: https://go-review.googlesource.com/100844
Reviewed-by: Adam Langley <agl@golang.org>
2018-03-16 18:01:49 +00:00
Mike Tsao b4956d363a openpgp: serialize correct bitlength for generated ECC keys
Rather than rounding the `type || X || Y` byte sequence to the next
8-bit boundary, packet.NewECDSAPublicKey() now rounds the X and Y
coordinates individually, then adds the bitlength 3 of type 4
(compressed). For NIST P-256, this leads to a bit length of 515,
rather than 520. GnuPG calculates 515 as well, and
https://tools.ietf.org/html/rfc6637#section-6 explicitly states that
"the exact size of the MPI payload is 515 bits for 'Curve P-256,'"
so the new formula is consistent.

Fixes golang/go#23460

Change-Id: I64b340d1c761bfd795a1a64dc2f7a831c8b2ff32
Reviewed-on: https://go-review.googlesource.com/87995
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-15 20:43:35 +00:00
Lars Lehtonen 819dbedbcb openpgp/packet: fix swallowed errors in (*EncryptedKey).parse
Change-Id: I23da7bcda044417804a4c827501437d506002e8e
Reviewed-on: https://go-review.googlesource.com/63430
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-03-15 20:41:12 +00:00
Andrew Bonventre 21652f85b0 CONTRIBUTING.md: remove note about not accepting Pull Requests
Updates golang/go#24185

Change-Id: I99281b2bd1c1ca82c02269d232d7714852a3b94c
Reviewed-on: https://go-review.googlesource.com/100679
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-14 18:02:59 +00:00
Adam Langley c4a91bd4f5 ed25519: require canonical signatures
https://tools.ietf.org/html/rfc8032#section-5.1.7 requires that s be in
the range [0, order) in order to prevent signature malleability. This is
a new requirement in the RFC so the ed25519 package predates it. This
change aligns the code with the RFC.

The linked bug says that libsodium is also enforcing this check by
default.

See golang/go#24350

Change-Id: Ib69ce7c9e5a58971cbe225318d9fd87660bd5e4b
Reviewed-on: https://go-review.googlesource.com/100436
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-13 19:52:38 +00:00
Kyle Spiers 182114d582 sha3: fix typo in Shake256 docs
Change-Id: I1d8d1016a956bf185d3a5af76188b8287fce6391
Reviewed-on: https://go-review.googlesource.com/100195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-12 19:55:33 +00:00
Ilya Tocar c7dcf104e3 ripemd160: use bits.Rotate for rotates
Replace x << k | x >> (32 - k) with bits.RotateLeft32 and add
benchmark to check performance. This makes code cleaner and improves performance:

MillionA-6  34.8ms ± 1%  26.7ms ± 1%  -23.41%  (p=0.000 n=10+10)

Change-Id: I1b0c45f5ea12c7b53ab1ec5a26efc1903555fa66
Reviewed-on: https://go-review.googlesource.com/97915
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-08 18:56:24 +00:00
Tobias Klauser 7effd64e11 ssh/terminal: store termios copy in terminal state on Solaris
TestMakeRawState currently fails on Solaris:

  --- FAIL: TestMakeRawState (0.00s)
          terminal_test.go:334: states do not match; was &{0xc420015dd0}, expected &{0xc420015da0}

Change terminal.State to include a copy to the unix.Termios (like the
implementation for Linux and the BSDs) which also makes terminal.MakeRaw behave
as expected and lets TestMakeRawState pass.

Change-Id: I29382f83b84ff301991e1db170f32f41e144aec8
Reviewed-on: https://go-review.googlesource.com/99456
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-08 17:26:49 +00:00
Tobias Klauser 526a373fd7 ssh/terminal: simplify defer
Directly use unix.IoctlSetTermios and windows.SetConsoleMode instead of
wrapping them with a closure.

Change-Id: I6309253fbb6e59e029424273b48aaa608873ea17
Reviewed-on: https://go-review.googlesource.com/99455
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-08 17:19:52 +00:00
Mark Rushakoff 85f98707c9 argon2: fix typo and code formatting in comments
Change-Id: I31fde79e91dd2f19a688bd62ac421d564634d5b3
GitHub-Last-Rev: caab01d6611a39e8aeb49b3de3c3abcdc759efaa
GitHub-Pull-Request: golang/crypto#33
Reviewed-on: https://go-review.googlesource.com/97798
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-06 22:39:34 +00:00
Jake Burkhead 0b6b69c7d2 acme/autocert: return error from cachePut
Fixes https://github.com/golang/go/issues/23569

Change-Id: I0f3ffab74acd2b69da0bbec2e0e90e42c2618071
GitHub-Last-Rev: e66a888d643dacc290ef58649dcc248d1925219e
GitHub-Pull-Request: golang/crypto#35
Reviewed-on: https://go-review.googlesource.com/98756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-06 22:18:58 +00:00
Alex Vaghin 91a49db82a acme: stop polling authz on 4xx client errors
"At Let's Encrypt, we are seeing clients in the wild that continue
polling their challenges long after those challenges have expired and
started serving 404."

The 4xx response code errors are client errors and should not be
retried.

Fixes golang/go#24145

Change-Id: I012c584fc4defd3a0d64a653860c35705c5c6653
Reviewed-on: https://go-review.googlesource.com/97695
Run-TryBot: Alex Vaghin <ddos@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-28 16:13:26 +00:00
Han-Wen Nienhuys 8c653846df ssh: document how to unmarshal public keys
Fixes golang/go#21491.

Change-Id: I5c720f1f6c6acfa7f4cd50920f65db7e57ba3792
Reviewed-on: https://go-review.googlesource.com/95115
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-27 08:58:43 +00:00
Brad Fitzpatrick beaf6a3570 ssh: fix error variable naming convention, add docs
Follow up to CL 96336

Change-Id: I038f3901919c5136273e5df051bc6e958082f830
Reviewed-on: https://go-review.googlesource.com/96415
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-26 09:37:11 +00:00
Han-Wen Nienhuys 49796115aa ssh: use a variable rather than type for NoAuthError
Change-Id: Ib61e0bc7d953cefde0436f77fe6a610201043c85
Reviewed-on: https://go-review.googlesource.com/96336
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Spencer Tung <spencertung@google.com>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2018-02-22 18:24:04 +00:00
Spencer Tung 432090b8f5 Adding a unique error when no authentication method has been passed in
yet.

Since ServerAuthError returns all errors collected during the
userAuthLoop, it will always include the generic error "no auth passed
yet" (assuming the connection fails).

Change-Id: I5f6c67f3f0762b023618178d4028600d2b6c9253
Reviewed-on: https://go-review.googlesource.com/92737
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-19 16:34:59 +00:00
Damien Tournoud 650f4a345a openpgp: allow NewEntity to specify the default cipher
The openpgp package promotes bad defaults by not setting the
preferred cipher and hash of new entities created by
`openpgp.NewEntity`.

The preferred hash can be set by passing a `packet.Config`
with a `DefaultHash` set, but the same cannot be done for
the preferred cipher.

This change copies the DefaultCipher into the self-signature, similar to
DefaultHash.

Change-Id: I80e1289d67b7cd4079be8c1d5ba603a555dbe5c1
Reviewed-on: https://go-review.googlesource.com/66430
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2018-02-14 00:00:28 +00:00
Yaron de Leeuw 3a6c3ce65c openpgp: correct NewEntity name creation
Confusingly, `Identity.Name` should actually refer to `uid.Id` and not
`uid.Name`. This fixes the code in NewEntity, and creates a test case to
verify.

Change-Id: Id46de876fc7b0359faecfeb9b09a8e454710d485
Reviewed-on: https://go-review.googlesource.com/92595
Reviewed-by: Adam Langley <agl@golang.org>
2018-02-13 22:19:55 +00:00