Commit Graph
726 Commits
Author SHA1 Message Date
Adam Langley de07523181 chacha20poly1305: add some more XChaCha20-Poly1305 test vectors.
These vectors were generated with libsodium to ensure that Go is
compatible with that library:

  #include <stdio.h>
  #include <sodium.h>
  #include <stdlib.h>

  static void hexdump(const uint8_t *in, size_t in_len) {
  	printf("\t\t\"");
  	for (size_t i = 0; i < in_len; i++) {
  		printf("%02x", in[i]);
  	}
  	printf("\",\n");
  }

  int main() {
  	uint8_t nonce[24];
  	uint8_t key[32];
  	uint8_t m[64], c[64+16];
  	uint8_t ad[16];

  	for (size_t ad_len = 0; ad_len < sizeof(ad); ad_len += 4) {
  		for (size_t m_len = 0; m_len < sizeof(m); m_len += 5) {
  			randombytes(nonce, sizeof(nonce));
  			randombytes(key, sizeof(key));
  			randombytes(m, m_len);
  			randombytes(ad, ad_len);

  			unsigned long long c_len = sizeof(c);
  			if (crypto_aead_xchacha20poly1305_ietf_encrypt(c, &c_len, m, m_len, ad, ad_len, NULL, nonce, key)) {
  				abort();
  			}

  			printf("\t{\n");
  			hexdump(m, m_len);
  			hexdump(ad, ad_len);
  			hexdump(key, sizeof(key));
  			hexdump(nonce, sizeof(nonce));
  			hexdump(c, c_len);
  			printf("\t},\n");
  		}
  	}

  	return 0;
  }

Change-Id: I4e9e4dc26e0e842c82319829599dbe48c331726f
Reviewed-on: https://go-review.googlesource.com/128615
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-08 21:18:26 +00:00
Adam Langley ff745d0763 acme/autocert: fix race in test.
The timeNow package variable doesn't work well here: since the renewal
functionality spawns goroutines that invoke timeNow, once a test has
caused such goroutines to exist, another test can't fiddle with it
without the race detector triggering.

Instead, have a private member of Manager that the tests can set if they
need.

Change-Id: Iaf1a68d8efb84c9c5e2804aeb9cc6b2d3f3fef43
Reviewed-on: https://go-review.googlesource.com/128655
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-08 21:16:02 +00:00
Noel Georgi f027049dab ssh: RFC5208 support PKCS#8 key
Change-Id: I3d0ea816843c88930af3aa1f613978e0e90fa389
Reviewed-on: https://go-review.googlesource.com/127779
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2018-08-07 10:46:21 +00:00
Filippo Valsorda 80fca2ff14 chacha20poly1305: add example for NewX
Change-Id: I619e38a2c8629e851435299fa5204f5fd48a1d87
Reviewed-on: https://go-review.googlesource.com/128055
Reviewed-by: Adam Langley <agl@golang.org>
2018-08-06 19:00:21 +00:00
Filippo Valsorda f792edd33d chacha20poly1305: add XChaCha20-Poly1305
The XChaCha20 construction does not have an authoritative spec, but this
implementation is based on the following documents:

https://cr.yp.to/snuffle/xsalsa-20081128.pdf
https://download.libsodium.org/doc/secret-key_cryptography/aead.html
http://loup-vaillant.fr/tutorials/chacha20-design
https://tools.ietf.org/html/draft-paragon-paseto-rfc-00#section-7

Tested against the following implementations:

https://github.com/jedisct1/libsodium/blob/7cdf3f0e841/test/default/aead_xchacha20poly1305.c
https://git.kernel.org/pub/scm/linux/kernel/git/zx2c4/linux.git/diff/lib/zinc/selftest/chacha20poly1305.h?h=zinc
https://git.zx2c4.com/wireguard-go/tree/xchacha20poly1305/xchacha20.go

name                            time/op          speed
Chacha20Poly1305/Open-64-8         225ns ± 1%     283MB/s ± 1%
Chacha20Poly1305/Open-64-X-8       390ns ± 0%     164MB/s ± 0%
Chacha20Poly1305/Seal-64-8         222ns ± 0%     287MB/s ± 0%
Chacha20Poly1305/Seal-64-X-8       386ns ± 0%     165MB/s ± 1%
Chacha20Poly1305/Open-1350-8      1.12µs ± 1%    1.21GB/s ± 1%
Chacha20Poly1305/Open-1350-X-8    1.28µs ± 0%    1.05GB/s ± 0%
Chacha20Poly1305/Seal-1350-8      1.15µs ± 0%    1.17GB/s ± 0%
Chacha20Poly1305/Seal-1350-X-8    1.32µs ± 1%    1.02GB/s ± 0%
Chacha20Poly1305/Open-8192-8      5.53µs ± 0%    1.48GB/s ± 0%
Chacha20Poly1305/Open-8192-X-8    5.71µs ± 1%    1.44GB/s ± 1%
Chacha20Poly1305/Seal-8192-8      5.54µs ± 1%    1.48GB/s ± 1%
Chacha20Poly1305/Seal-8192-X-8    5.74µs ± 1%    1.43GB/s ± 1%

Updates golang/go#24485

Change-Id: Iea6f3b4c2be67f16f56720a200dcc895c0f9d520
Reviewed-on: https://go-review.googlesource.com/127819
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2018-08-06 17:10:22 +00:00
Filippo Valsorda 56440b844d acme/autocert: expand tls-alpn-01 docs
Change-Id: Ia2fe53e6c85ffe4859248e50ab0e489a3b783ef5
Reviewed-on: https://go-review.googlesource.com/126607
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-02 22:12:40 +00:00
Alex Vaghin c126467f60 acme/autocert: add support for tls-alpn-01
Because tls.Config now requires more fields to be set
in order for tls-alpn to work, Manager provides a new
TLSConfig method for easier setup.

This CL also adds a new internal package for end-to-end tests.
The package implements a simple ACME CA server.

Fixes golang/go#25013
Fixes golang/go#25901
Updates golang/go#17251

Change-Id: I2687ea8d5c445ddafad5ea2cdd36cd4e7d10bc86
Reviewed-on: https://go-review.googlesource.com/125495
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-23 16:41:46 +00:00
Alex Vaghin a521dfce25 acme: expect 202 Accepted from Let's Encrypt
ACME draft specifies the CA servers should respond
with 201 Created status code but Let's Encrypt
responds with 202 Accepted when creating a new account.

This change adds 202 Accepted as a valid response.
Otherwise, the Client hangs while doing retries,
discarding 202 responses as invalid.

Tests are not updated intentionally
due to this being non-conformant with the spec.

Fixes golang/go#26251

Change-Id: I2918fce3873592c02e96f4118c4d1ecb42da3c4f
Reviewed-on: https://go-review.googlesource.com/125415
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-23 16:08:21 +00:00
Wilfried Teiken a214413485 openpgp: support creating signatures compatible with 'gpg --sign'.
This is neither a '--clearsign' nor a '--detach-sign' which are already
supported.  Verification of these signatures is already supported by
ReadMessage.

The code shares a lot with standard encrypt/sign, so mostly a
refactoring of 'Encrypt' to allow use of the code path without
actually doing a signing.

Change-Id: I5bb7487134ffcf1189ed74e28dbbbe1c01b356d1
GitHub-Last-Rev: 01162222600a4a2a230a444387b33883faf596ec
GitHub-Pull-Request: golang/crypto#50
Reviewed-on: https://go-review.googlesource.com/116017
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-07-18 16:05:20 +00:00
Alex Vaghin a49355c7e3 acme: consistently return original errors from retries
The retry logic returns an "acme: no more retries for ..." error
in some cases, while *Error type in others.

This change makes retries always return the last error as received
from the CA server, if available. No change in returned values
of successful requests.

Change-Id: I3df2cb332a3e2739bba457c0ee50d7ca5bd836d9
Reviewed-on: https://go-review.googlesource.com/119975
Reviewed-by: Maciej Dębski <maciejd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Vaghin <ddos@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-21 12:51:26 +00:00
Alex Vaghin 7f39a6fea4 internal/subtle: add Google App Engine support
The new package subtle added in golang.org/cl/112236 breaks
compatibility with App Engine due to the import of unsafe.

This changes adds an App Engine alternative without using unsafe.

Tested with:

  $ go test -test.tags=appengine -v
  === RUN   TestAliasing
  --- PASS: TestAliasing (0.00s)
  PASS
  ok  	golang.org/x/crypto/internal/subtle	0.009s

Change-Id: I2fc6b02a860b3ee11fa31652ba302fc7db9df153
Reviewed-on: https://go-review.googlesource.com/119095
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-19 20:02:35 +00:00
ia 027cca12c2 all: gofmt
Just ran

	gofmt -w .

on the project root. That's all.

Change-Id: Ia90223dda399c1df67e7bcf75c6773de63902cc8
GitHub-Last-Rev: 8ba80b96761b077a4e084a93d5f18e6b2f7375ad
GitHub-Pull-Request: golang/crypto#52
Reviewed-on: https://go-review.googlesource.com/119375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-17 04:21:18 +00:00
Filippo Valsorda a8fb68e720 openpgp: restore signing in SerializePrivate
Signing was moved in NewEntity as it makes more sense there, but there
might be code that relies on SerializePrivate to make signatures with
parameters that were modified after NewEntity.

As it used to always sign in SerializePrivate, it shouldn't break
anything to sign in both places.

Fixes golang/go#25463

Change-Id: Ia7f509daf31ac05fedc441225d554f333b288d70
Reviewed-on: https://go-review.googlesource.com/118015
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Yaron de Leeuw <jarondl@google.com>
Reviewed-by: Alexandre Viau <viau.alexandre@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-06-14 22:13:31 +00:00
Filippo Valsorda 5cd40a374b acme/autocert: surface details of acme.AuthorizationError
Fixes golang/go#19800

Change-Id: If915a70f4dee78e71dcfc487726cdf83d45b4d50
Reviewed-on: https://go-review.googlesource.com/115938
Reviewed-by: Alex Vaghin <ddos@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 20:24:12 +00:00
aviau 550ed51fee openpgp: fix bad error message
When failing, TestKeyExpiry would output the wrong expected key id. It
would output "Expected key 1ABB25A0" instead of "Expected key 96A672F5".

Avoid this mistake by declaring the variable only once and using it in
the error format.

Change-Id: I860d82bf2c7fa80558051cdb21a41d506e95c25f
Reviewed-on: https://go-review.googlesource.com/118958
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-14 19:53:31 +00:00
aviau fd5f17ee72 openpgp: read keys with revoked user ids
The existing code was wrongly assuming that UserID packets must be
immediately followed by a Signature packet. However, this is not true.

See RFC4880 11.1:
> Immediately following each User ID packet, there are zero or more
> Signature packets.

This change will ensure that Entities that are not immediately followed
by a Signature packet are read without raising a StructuralError.
Instead, UserID packets that are not immediately followed by a self
signature will be ignored.

Maximum backwards compatibility is retained because revoked UserIDs are
not added to the Entity's identities.

In a follow-up patch, we should probably add these UserIDs to the
Entity's identities too, but not without making sure that the revocation
is also available in the Entity's (or the Identity's) Revocations slice.
This would require adding support for a new Signature Type,
"Certification revocation signature", as defined in RFC 48880 5.2.1.

Fixes golang/go#25850

Change-Id: Idde34b97429998f28e0c687171024e51ed959bf0
Reviewed-on: https://go-review.googlesource.com/118376
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-14 17:48:26 +00:00
Filippo Valsorda 37a17fe027 internal/subtle: add Any/InexactOverlap (new package) and apply them across packages
AnyOverlap and InexactOverlap implement checks for the aliasing
requirements defined by the crypto/cipher interfaces. Apply them to all
implementations as the actual requirement could be architecture-dependent
and user code should not rely on undefined behavior.

Updates golang/go#21624

Change-Id: I465de02fb3fec4e0c6f1fdee1ef6ae7ed5abff10
Reviewed-on: https://go-review.googlesource.com/112236
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13 22:47:33 +00:00
Roland Shoemaker e6b1200d11 acme: fix encoding of the TLS-ALPN challenge extension
To comply with the specification the value of the extension should be a ASN.1
OCTET STRING rather than a raw SHA 256 hash. This change uses asn1.Marshal to
wrap the hash before putting it in the extension.

Change-Id: I4ebe88a00238c6f928555d605e4b5dd98aad8128
Reviewed-on: https://go-review.googlesource.com/118696
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-13 20:22:54 +00:00
Maciej Dębski 8ac0e0d97c acme: add support for TLS-ALPN
This adds support for the new challenge type, as described in
https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-01

Updates golang/go#25013

Change-Id: I81b335ff4b4e89e705a70e7d38dd21c3d5f5c25f
Reviewed-on: https://go-review.googlesource.com/116995
Reviewed-by: Alex Vaghin <ddos@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-08 09:28:29 +00:00
Brad Fitzpatrick b47b158736 acme/autocert: change a var to a const
A var isn't needed and a const is what the upstream (Go 1.10+) version
it's copying is.

Change-Id: I335270be3b3d09ac3c22cf6fb889a74ac39b8f1d
Reviewed-on: https://go-review.googlesource.com/116379
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-06-06 01:55:41 +00:00
Filippo Valsorda d16218638d acme/autocert: fix build in Go 1.9
Updates golang/go#22066

Change-Id: I7eb6a60deb6680003245815760e2ce6a8f7d8b15
Reviewed-on: https://go-review.googlesource.com/116496
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-06 00:54:49 +00:00
Filippo Valsorda 78e79280f6 acme/autocert: update Manager.Client and Cache docs
Fixes golang/go#22064

Change-Id: Icb3f5b2c1967630a3dcbd9661b3492f5d3acc654
Reviewed-on: https://go-review.googlesource.com/115937
Reviewed-by: Alex Vaghin <ddos@google.com>
2018-06-06 00:37:54 +00:00
Filippo Valsorda 8f8078c97f acme/autocert: support both RSA and ECDSA clients on the fly
GetCertificate has all the information it needs to know if a client
supports ECDSA in ClientHelloInfo. Deprecate and ignore ForceRSA, and
just obtain a RSA certificate on the fly when a client that doesn't
support ECDSA connects.

This changes the cache key format to have a "+rsa" suffix for RSA
certificates. The default (ForceRSA = false) cache key is unchanged,
so most DirCache instances will still be valid. Caches created with
ForceRSA set will be silently ignored and certificates reissued.

The cache keys for HTTP tokens and the account key are changed to be
guaranteed not to overlap with valid domain names as well.

Note that ECDSA support detection is more strict in following RFC 5246
than crypto/tls, which ignores signature_algorithms.

Fixes golang/go#22066

Change-Id: I70227747b563d6849cb693f83a950d57040b3f39
Reviewed-on: https://go-review.googlesource.com/114501
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-06 00:31:03 +00:00
Alex Vaghin df8d4716b3 acme: clarify retries and backoff algorithm
There's been some confusion about failed request retries.
Rightfully so: some requests are retried, others are not.

This change attempts to clarify the issue and unify backoff
usage in all Client's methods by introducing a new exported
optional field RetryBackoff and adding retry logic where missing.

Also, updates golang/go#22457.

Change-Id: Ied434edf998d52925a48b6b3b2407d45a6e9d2ee
Reviewed-on: https://go-review.googlesource.com/109615
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-02 22:01:24 +00:00
David Benjamin 5ba7f63082 ed25519: actually be compatible with RFC 8032
Most implementations, including this one, consider the private key to be
the concatenation of the initial 32-byte seed and the public key.
However the RFC 8032 formulation considers the "private key" to just be
the seed, which, in turn, means the upcoming draft-ietf-curdle-pkix
specification for embedding Ed25519 into PKCS#8 only stores the seed.

Exporting ed25519.PrivateKey to the seed is easy: key[:32]. Importing
the seed to ed25519.PrivateKey is not currently possible because the
logic is tied up in ed25519.GenerateKey. Split out
ed25519.NewKeyFromSeed for this, as well as an ed25519.PrivateKey.Seed
accessor to keep the abstraction consistent.

Change-Id: I4068eaf2073009dff3d84224aa145b56b59a5854
Reviewed-on: https://go-review.googlesource.com/115297
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-31 19:11:17 +00:00
Alex Vaghin ab813273cd acme/autocert: improve authorizations cleanup
Fixes a bug introduced in golang.org/cl/100078 where incorrect
ACME client was used, causing nil pointer dereference.

The change also improves related tests,
removing code paths diverging in testing.

Fixes golang/go#25581

Change-Id: I8c5531fcc5814a5a64f14911c0ad86c476a76d2f
Reviewed-on: https://go-review.googlesource.com/114817
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-27 07:24:34 +00:00
Alex Vaghin a3beeb7486 acme/autocert: support configurable CSR extensions
Package users can now provide extra CSR extensions
to serve certificates with desired properties.

Fixes golang/go#17801.
Change-Id: Iac1010f41391c865f6e318bad2e0dafc2ffef6b1
Reviewed-on: https://go-review.googlesource.com/42470
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-25 16:01:59 +00:00
Tobias Klauser 159ae71589 ssh/terminal: fix TestMakeRawState on iOS
Fix the following failure on iOS:

--- FAIL: TestMakeRawState (0.00s)
	terminal_test.go:332: failed to get terminal state from MakeRaw: operation not permitted

Updates golang/go#25535

Change-Id: I1ab6feb31ba5e89dc0d5f2a1cefd56c09f178e80
Reviewed-on: https://go-review.googlesource.com/114415
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-24 12:53:53 +00:00
Leo Antunes 75e913eb8a acme/autocert: revoke dangling pending authzs
We now keep track of pending authorization requests during verify() and
defer the asynchronous revocation of the ones that failed.
This should help avoid letsencrypt's "too many currently pending
authorizations" error.

Fixes golang/go#23426

Change-Id: Ibffb10f59733962d45e43b67fc42a2ec7c5faf51
Reviewed-on: https://go-review.googlesource.com/100078
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Leo Antunes <costela@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-23 19:40:57 +00:00
Ryan Canty da3eeb5d87 openpgp: sign Entity during instantiation in NewEntity
Previously if you created a new Entity then ran `Serialize` _before_ running `SerializePrivate`, the resulting armored public key was corrupted, giving the error of `unexpected EOF`. This fix signs the public key with the private key upon creation of a NewEntity. Since SerializePrivate only is applicable to entities created with NewEntity per the docs we can also safely remove the signing portion from that function.

Fixes #25463

Change-Id: I58b808987ee173079f33bce3d6c3527f9233b2cd
GitHub-Last-Rev: 2c4b8e4d630a06d782816f8fbd3d59f01ece2565
GitHub-Pull-Request: golang/crypto#47
Reviewed-on: https://go-review.googlesource.com/114001
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-23 17:23:42 +00:00
Michael Munday 1a580b3eff chacha20poly1305: delete unused assembly functions
These are triggering vet errors when vendored into std.

Change-Id: Ied8158941d176129c76509acff7314a6a483c9f9
Reviewed-on: https://go-review.googlesource.com/113176
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-15 00:15:09 +00:00
Michael Munday 425cc7d9a7 poly1305: add additional test cases
Increase the number of test vectors in this package to provide
better validation of new SIMD implementations.

Change-Id: Ia89883609e78cef53ba40a9cae41f4e0a3bccc80
Reviewed-on: https://go-review.googlesource.com/112855
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-14 23:09:06 +00:00
bill_ofarrell 4eb8c2c8d8 poly1305: add optimized s390x SIMD implementation with VMSL
SIMD implementation based the on the algorithm outlined in:
NEON crypto, Daniel J. Bernstein and Peter Schwabe
https://cryptojedi.org/papers/neoncrypto-20120320.pdf
and as modified for VMSL as described in
Accelerating Poly1305 Cryptographic Message Authentication on the z14
O'Farrell, Gadriwala, et al, CASCON 2017, p48-55
https://ibm.ent.box.com/s/jf9gedj0e9d2vjctfyh186shaztavnht

name		old		new		delta
64		485MB/s		1315 MB/s	+171.58%
1K		607MB/s		4352 MB/s	+616.97%
64Unaligned	485MB/s		1373 MB/s       +183.09%
1KUnaligned	606MB/s		4286 MB/s	+607.26%
2M		607MB/s		5529 MB/s	+810.87%

Change-Id: I31ccc25ced09180d99ea5c9233f0dcdc8666fc98
Reviewed-on: https://go-review.googlesource.com/110297
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2018-05-14 22:55:51 +00:00
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