Commit Graph
475 Commits
Author SHA1 Message Date
Shenghou Ma abc5fa7ad0 poly1305: make data declared in assembly files private
Update golang/go#18673.

Change-Id: I3ba89bab42f17e6fd7005df40c7a853aef1fda37
Reviewed-on: https://go-review.googlesource.com/35259
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2017-01-16 01:45:04 +00:00
Han-Wen Nienhuys 2f8be38b9a ssh: make client auth tests less chatty.
Change-Id: Ib35ce0e7437e32a3fa24a9330c479306b7fa6880
Reviewed-on: https://go-review.googlesource.com/35011
Reviewed-by: Adam Langley <agl@golang.org>
2017-01-13 19:40:33 +00:00
Han-Wen Nienhuys 7c6cc321c6 x/ssh: filter debug and ignore messages in transport.readPacket.
This prevents these messages from confusing higher layers of the
protocol.

Fixes #16927.

Change-Id: If18d8d02bdde3c0470e29a7280cd355d3e55ad78
Reviewed-on: https://go-review.googlesource.com/34959
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
2017-01-10 10:35:34 +00:00
Andrew Gerrand 1d77d5bd47 acme/autocert: fix typo in Cache doc comment
Change-Id: I13dc3119cb46f0649147959c05c6c62624c43690
Reviewed-on: https://go-review.googlesource.com/35070
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-01-10 02:19:11 +00:00
Peter Morjan c3b1d0d6d8 ssh/terminal: consistent return value for Restore
This patch makes the Restore function return nil
on success to be consistent with other functions
like MakeRaw.

Change-Id: I81e63f568787dd88466a5bb30cb87c4c3be75a5c
Reviewed-on: https://go-review.googlesource.com/34952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-07 18:00:30 +00:00
Lion Yang cb497ae8f1 chacha20poly1305: fix detection of BMI on amd64
This change detects BMI2 usability as an additional condition
to examine the usability of AVX2 version algorithm, fixes
the crash on the platfrom which supports AVX2 but not support BMI2.

Change-Id: I5438d4ec84265c79a51c1439265a33b1be04878a
Reviewed-on: https://go-review.googlesource.com/34852
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-06 18:10:41 +00:00
Joe Tsai 5b4074c2c4 all: fix some vet warnings
Change-Id: I85c2912a6862c6c251450f2a0926ecd33a9fb8e7
Reviewed-on: https://go-review.googlesource.com/34815
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-04 23:09:04 +00:00
Mikio Hara f6b343c37c blake2b: fix build on non-amd64 platforms
Change-Id: Ib9ebb1a2eff4b61f60453086be5c63ac7af1f7fc
Reviewed-on: https://go-review.googlesource.com/34672
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-12-21 23:57:47 +00:00
Martin Kreichgauer f5719d2458 ocsp: Expose ResponderID in parsed Response.
ResponderID is unmarshalled into either ResponderName or
ResponderKeyHash depending on which one is present.

Fixes golang/go#14971.

Change-Id: I5ba602753d81835da531321e94898408395068dd
Reviewed-on: https://go-review.googlesource.com/34380
Reviewed-by: Adam Langley <agl@golang.org>
2016-12-21 17:16:36 +00:00
Andreas Auernhammer d8e61c69ab blake2b: add AVX assembly
Add an AVX implementation and improve SSE4.1 assembly.

AVX vs SSE4.1
name 		old time/op 		new time/op 	delta
Write128-8 	249ns ± 0% 		220ns ± 0% 	-11.85% (p=0.029 n=4+4)
Write1K-8 	1.68µs ± 1% 		1.56µs ± 1% 	-6.71% (p=0.029 n=4+4)
Write32K-8 	52.6µs ± 0% 		48.7µs ± 0% 	-7.40% (p=0.029 n=4+4)
Sum128-8 	264ns ± 0% 		241ns ± 1% 	-8.52% (p=0.029 n=4+4)
Sum1K-8 	1.70µs ± 0% 		1.57µs ± 0% 	-7.79% (p=0.029 n=4+4)
Sum32K-8 	54.1µs ± 3% 		49.5µs ± 1% 	-8.36% (p=0.029 n=4+4)

name 		old speed 		new speed	 delta
Write128-8 	513MB/s ± 0% 		582MB/s ± 0% 	+13.38% (p=0.029 n=4+4)
Write1K-8 	610MB/s ± 1% 		654MB/s ± 1% 	+7.22% (p=0.029 n=4+4)
Write32K-8 	622MB/s ± 0% 		672MB/s ± 0% 	+7.99% (p=0.029 n=4+4)
Sum128-8 	484MB/s ± 1% 		529MB/s ± 0% 	+9.21% (p=0.029 n=4+4)
Sum1K-8 	602MB/s ± 0% 		653MB/s ± 0% 	+8.42% (p=0.029 n=4+4)
Sum32K-8 	607MB/s ± 3% 		662MB/s ± 1% 	+9.03% (p=0.029 n=4+4)

AVX2 vs AVX
name 		old time/op 		new time/op 	delta
Write128-4 	192ns ± 0% 		166ns ± 0% 	-14.03% (p=0.029 n=4+4)
Write1K-4 	1.37µs ± 0% 		1.19µs ± 0% 	-12.65% (p=0.029 n=4+4)
Write32K-4 	42.5µs ± 0% 		37.3µs ± 0% 	-12.33% (p=0.029 n=4+4)
Sum128-4 	213ns ± 0% 		188ns ± 0% 	-11.97% (p=0.029 n=4+4)
Sum1K-4 	1.40µs ± 0% 		1.22µs ± 0% 	-12.85% (p=0.029 n=4+4)
Sum32K-4 	42.8µs ± 0% 		37.3µs ± 0% 	-12.94% (p=0.029 n=4+4)

name 		old speed 		new speed 	delta
Write128-4 	662MB/s ± 0% 		771MB/s ± 0% 	+16.47% (p=0.029 n=4+4)
Write1K-4 	748MB/s ± 0% 		857MB/s ± 0% 	+14.49% (p=0.029 n=4+4)
Write32K-4 	771MB/s ± 0% 		879MB/s ± 0% 	+14.07% (p=0.029 n=4+4)
Sum128-4 	600MB/s ± 0% 		680MB/s ± 0% 	+13.49% (p=0.029 n=4+4)
Sum1K-4 	733MB/s ± 0% 		841MB/s ± 0% 	+14.72% (p=0.029 n=4+4)
Sum32K-4    	765MB/s ± 0%  		879MB/s ± 0%  	+14.85% (p=0.029 n=4+4)

Change-Id: Idf85742e952c07b76c0c7fb5404ed9b0caf0f6eb
Reviewed-on: https://go-review.googlesource.com/34319
Reviewed-by: Adam Langley <agl@golang.org>
2016-12-20 18:11:55 +00:00
Mikio Hara 2b786ab9e9 chacha20poly1305: fix typos
Change-Id: I55a2ad4495f4e1164af6a8504b035cf658f8b822
Reviewed-on: https://go-review.googlesource.com/34536
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-19 15:50:45 +00:00
Mikio Hara abc3c1b020 ssh/terminal: fix a typo
Change-Id: Iafe2ebb6d37afd2a64aa72750a722d4860bb735e
Reviewed-on: https://go-review.googlesource.com/34535
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-19 06:01:35 +00:00
Mikio Hara a70a72a727 chacha20poly1305: fix typos
Change-Id: Icf4ccb29e9eae0fb6fd237ca1d8785d4fd39a8d8
Reviewed-on: https://go-review.googlesource.com/34534
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-19 06:01:24 +00:00
Alex Vaghin 9b1a210a06 acme/autocert: add an option for RSA-based certs
Currently, autocert.Manager always generates EC-based certificates.
This change adds an optional field forcing the Manager to use RSA
instead.

An alternative idea, a "double" certificate, where the Manager
presents either RSA or EC certificate based on client's compatibility,
doesn't seem to be worth the implementation time given the constant
increase in Elliptic Curve cryptography.

Fixes golang/go#17744

Change-Id: Idc68abfc698bcff4aad99715baefc06f8fae50ad
Reviewed-on: https://go-review.googlesource.com/34570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-16 17:19:27 +00:00
Péter Szilágyi 01be46f620 crypto/ssh: use net.IP.Equal instead of bytes.Equal
A net.IP may be represented by both by a 4 as well as a 16 byte long
byte slice. Because of this, it is not safe to compare IP addresses
using bytes.Equal as the same IP address using a different internal
representation will produce mismatches.

Change-Id: I0d228771cf363ccfb9532f8bc2a2fc8eff61f6e9
Reviewed-on: https://go-review.googlesource.com/34450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-15 16:25:12 +00:00
Andreas Auernhammer 9a6f0a0198 blake2b: fix constant size
Change-Id: Icae0ec427183d1e319f5a28d6372c823c269d898
Reviewed-on: https://go-review.googlesource.com/34252
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-12 17:50:00 +00:00
Roland Shoemaker b07d8c9677 x/crypto/ocsp: Don't hard-code OCSP response hash function
Allows user to set the hash function to use in the OCSP response
when using ocsp.CreateResponse instead of hard-coding the use of
SHA-1. The field IssuerHash is added to the ocsp.Response struct
to set which hash to use. If none is provided CreateResponse falls
back to SHA1. ParseResponse also attempts to populate this field
and will fail if a unsupported hash algorithm is provided.

Change-Id: I3905b1706f347387724e57c33cb82a3b46ffcdf9
Reviewed-on: https://go-review.googlesource.com/32214
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-08 20:19:12 +00:00
Adam Langley 95cb608f36 x/crypto/ssh/terminal: replace \n with \r\n.
911fafb28f made MakeRaw match C's behaviour. This included clearing the
OPOST flag, which means that one now needs to write \r\n for a newline,
otherwise the cursor doesn't move back to the beginning and the terminal
prints a staircase.

(Dear god, we're still emulating line printers.)

This change causes the terminal package to do the required
transformation.

Fixes golang/go#17364.

Change-Id: Ida15d3cf701a21eaa59161ab61b3ed4dee2ded46
Reviewed-on: https://go-review.googlesource.com/33902
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-07 22:17:40 +00:00
David Lazar 3f77d69517 bn256: fix equations in comments
Change-Id: Icb220341756f472ade15f5fc6b91016214233da9
Reviewed-on: https://go-review.googlesource.com/34030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-06 19:59:59 +00:00
Shenghou Ma 8a549a1948 chacha20poly1305: make polyHashADInternal private
For golang/go#18154.

Change-Id: Ieab8bae9cb8be5e2817a87ae62ac0a2218f63dbb
Reviewed-on: https://go-review.googlesource.com/33855
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-02 06:00:03 +00:00
Adam Langley 7efbae5d10 x/crypto/blake2b: SSE4.1 is bit 19, not 15.
I missed this in the initial review but this will cause blake2b to
SIGILL on, at least, some Atom chips.

Fixes golang/go#18113.

Change-Id: I0c16319df71f3ce4a38411ad4c4e9d3871fd9533
Reviewed-on: https://go-review.googlesource.com/33830
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-01 19:22:57 +00:00
Brad Fitzpatrick 21853a76e0 acme/autocert: remove trailing dot from domain before requesting cert
Browsers can send an SNI name of "example.com." for
https://example.com./ but LetsEncrypt rejects the trailing dot.

Fixes golang/go#18114

Change-Id: Ie38e355e5b5566a7eb18f77a2449660e22e21b4c
Reviewed-on: https://go-review.googlesource.com/33711
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-30 19:27:24 +00:00
Ryuzo Yamamoto ede567c8e0 x/crypto/ssh: Add FingerprintLegacyMD5 and FingerprintSHA256 methods
Implement a standards-compliant fingerprint format method (RFC 4716 section 4)
and a newer SHA256 fingerprint format method.

Fixes golang/go#12292

Change-Id: I4f3f8fc1d0a263cb3b0964d0078e69006a39d1a5
Reviewed-on: https://go-review.googlesource.com/32814
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-22 14:27:12 +00:00
Alex Vaghin 9477e0b78b chacha20poly1305: fix build constraints
Similarly to https://go-review.googlesource.com/32311,
chacha20poly1305 needs additional build constraints
for non-standard toolchains.

Change-Id: I22816ef333c05450e9ab4debb3ce591518b6b84b
Reviewed-on: https://go-review.googlesource.com/32391
Run-TryBot: Alex Vaghin <ddos@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-31 18:08:06 +00:00
Adam Langley b2fa06b6af blake2s: fix build constraints
Having a trailing comma before a space doesn't mean that the next option
will be ANDed rather than ORed. This worked with the standard toolchain
because the filenames prevented the incorrect build constraints for
other platforms from being acted on.

Change-Id: Iaee5b60a7496166f23fc36319abe07c7a7ec04e5
Reviewed-on: https://go-review.googlesource.com/32311
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-28 19:53:00 +00:00
Alex Vaghin ca7e7f10cb acme: add v3 implementation to RevokeAuthorization
Let's Encrypt apparently implements authorization revocation as specified
in the v3 of the spec:
https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-6.4.2.

See the relevant boulder source code here:
https://github.com/letsencrypt/boulder/blob/be01ca17d334f73823a9c69afbcf99d777482547/wfe/wfe.go#L1177-L1213

This change makes RevokeAuthorization compatible with both v2 and v3
versions of the spec, as well as Let's Encrypt staging/production
actual implementation.

Change-Id: I7e860944005a55b156a45d96e1b8eb41126ce6bb
Reviewed-on: https://go-review.googlesource.com/31990
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-25 16:12:29 +00:00
Adam Langley 1150b8bd09 poly1305: don't move R13 in sum_arm.s.
Rather than change the value of R13 during the execution, keep R13 fixed
(after the initial prelude) and always use offsets from it.

This should help the runtime figure out what's going on if, say, a
signal should occur while running this code.

I've also trimmed the set of saved registers since Go doesn't require
the callee to maintain anything except R10 and R13.

Change-Id: Ifbeca73c1d964cc43bb7f8c20c61066f22fd562d
Reviewed-on: https://go-review.googlesource.com/31717
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-24 22:35:48 +00:00
Austin Clements 8291fff38a blake2b: test all three hashing implementations
This adds use* flags for all arches so a common test can observe what
implementations are supported and test all supported implementations.

Change-Id: I0497b91294ed99309074ac4614ac996e006630c5
Reviewed-on: https://go-review.googlesource.com/31714
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Andreas Auernhammer <aead@mail.de>
2016-10-24 19:19:48 +00:00
Austin Clements 814723eff7 blake2s: test all four hashing implementations
This adds use* flags for all arches so a common test can observe what
implementations are supported and test all supported implementations.

Change-Id: Icc9c3c1d15626e95f0446493b7fa3159bbe9567d
Reviewed-on: https://go-review.googlesource.com/31712
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Andreas Auernhammer <aead@mail.de>
2016-10-24 19:19:44 +00:00
Austin Clements 3c0d69f177 blake2s: fix frame size of hashBlocksSSE4
The frame is actually 16 bytes plus alignment, not 0.

This fixes the build on Go 1.6.

Change-Id: Id3dcf4e1628791ed55a38a819dcf3c11ecc2f488
Reviewed-on: https://go-review.googlesource.com/31711
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-21 21:01:31 +00:00
Austin Clements a9ecc67d46 blake2s: remove NOSPLIT from asm functions
Now that the frame sizes of these functions are correct, the compiler
is detecting that they overflow the NOSPLIT stack. They don't need to
be NOSPLIT, so remove that flag.

This fixes the 1.7 build. The build is not broken at tip because the
stack guard is larger.

Change-Id: Ie32779c819f63b27ec0a77a44b7d20ee2d550843
Reviewed-on: https://go-review.googlesource.com/31667
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-21 20:10:06 +00:00
Austin Clements 77e80449e8 sha3: fix SP adjustment
keccakF1600 manually subtracts 200 from SP, but the generated prologue
already does this and the extra subtraction just means keccakF1600 is
defeating the stack growth check.

Remove the unnecessary SP adjustment.

Change-Id: I9450f6b12489bcd20e9ace30f9dd3066025d3a1a
Reviewed-on: https://go-review.googlesource.com/31653
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-21 19:51:19 +00:00
Austin Clements 1705134e1b salsa20/salsa: eliminate unnecessary "callee save" prologue/epilogue
SP offsets were adjusted to fill in the now unused callee save area
using the following Python script:

import sys, re
def adj(m):
    delta = int(m.group(1))
    if delta >= 408:
        delta -= (408 - 352)
    return "%d(SP)" % delta
sys.stdout.write(re.sub(r"(\d+)\(SP\)", adj, sys.stdin.read()))

Change-Id: I06675a75d89e5834f804df595868fe4bb8976719
Reviewed-on: https://go-review.googlesource.com/31587
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-21 19:51:17 +00:00
Austin Clements a0819bbd36 salsa20/salsa: hide SP alignment from spadj
The spadj computation in the assembler can't handle SP alignment code
and will just get confused by how it's currently written. Do the
alignment in a scratch register to hide it from the assembler.

Change-Id: I8857f428d96717db29e3a56050f2381bd86807c6
Reviewed-on: https://go-review.googlesource.com/31586
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-21 19:51:15 +00:00
Austin Clements e67f5eca87 blake2b: use proper Go frame sizes
Similar to the previous commit, blake2b's assembly routines claim they
have a zero byte frame and manually subtract a frame from the SP,
which can fail to grow the stack when necessary, leading to memory
corruption.

Fix this by using the correct stack frame sizes so the generated stack
growth prologue is correct, and aligning the SP up instead of down.

Change-Id: Ic426338c45c94a2c01d549860c2295a0ee9200be
Reviewed-on: https://go-review.googlesource.com/31585
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Andreas Auernhammer <aead@mail.de>
2016-10-21 19:51:14 +00:00
Austin Clements 5953a478da blake2s: use proper Go frame sizes
Currently blake2s's assembly routines claim they have a zero byte
frame and manually subtract upwards of 704 bytes from the stack
pointer without cooperating with Go's ABI. As a result, these
functions may not grow the stack when necessary, leading to memory
corruption.

Fix this by using the correct stack frame sizes so the generated stack
growth prologue is correct, and aligning the SP up instead of down.

Change-Id: Ic426338c45c94a2c01d549860c2295a0ee9200bf
Reviewed-on: https://go-review.googlesource.com/31583
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Andreas Auernhammer <aead@mail.de>
Reviewed-by: Minux Ma <minux@golang.org>
2016-10-21 19:51:11 +00:00
Austin Clements f62085100e curve25519: eliminate unnecessary "callee save" prologues
The assembly implementations of ladderstep and mul contain register
save prologues that are unnecessary in Go because there are no callee
save registers in the Go ABI. Remove these prologues, update all SP
offsets, and reduce the frame size accordingly.

The SP offsets were updated with:

python -c 'import sys, re; sys.stdout.write(re.sub(r"(\d+)\(SP\)", lambda m: "%d(SP)" % (int(m.group(1))-YYY), sys.stdin.read()))'

where YYY was 64 for mul_amd64.s and 56 for ladderstep_amd64.s.

Change-Id: I728948809f479b1c061cc65167dadad651efab31
Reviewed-on: https://go-review.googlesource.com/31580
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-10-21 19:51:09 +00:00
Austin Clements 722a7b7827 curve25519: fix confusing SP adjustments
The curve25519 assembly routines do very non-Go-ABI SP adjustments.
These would thoroughly confuse traceback if it were to fire in one of
these functions (say, because of a signal). Plus, we're about to make
the assembler track SP balance through more operations (which it
should have done all along), and the SP alignment performed by these
functions is going to make the assembler think the SP is out of
balance.

Fix this by eliminating the SP alignment prologue from all four
assembly functions. They don't do any operations that care about SP
alignment, so this is simply unnecessary. square and freeze don't even
use the stack for anything other that saving what were presumably
"callee save" registers in some other ABI, so for these we can
eliminate the stack frame entirely.

Change-Id: If9dbb2fb6800d9cd733daa91f483eb2937e95f0f
Reviewed-on: https://go-review.googlesource.com/31579
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-21 19:51:06 +00:00
Adam Langley 3ded668c53 poly1305: enable assembly for ARM in Go 1.6.
5f31782cfb added build constraints to
disable assembly for Go 1.6 but didn't add the needed tags to the ARM
files. Also, it's not clear that was needed as the error given in
golang/go#17424 only complains about the chacha20poly1305 package.

This change reenables the assembly for Go 1.6 in the poly1305 package.
Tested with 1.6.3 and 1.5.4.

Fixes golang/go#17512.

Change-Id: I81b41f8810437ea327b415542402cd8ff5c8a390
Reviewed-on: https://go-review.googlesource.com/31492
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-20 16:32:05 +00:00
Adam Langley dec8741f62 poly1305: fix stack handling in sum_arm.s
Up till now, sum_arm.s was working only because of luck. It was written
assuming that it had stack space below the current stack pointer, but Go
decrements the stack pointer in the function prelude, so it was just
writing off the end of the stack.

This change fixes the stack manipulation so that it only writes within
the bounds.

Fixes golang/go#17499.

Change-Id: I1951b3344c21f6bd6ade79da8b96dd1bb68180db
Reviewed-on: https://go-review.googlesource.com/31443
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-20 16:31:58 +00:00
Andreas Auernhammer c367d6eeb7 blake2s,blake2b: fix typo in package doc
Change-Id: I6c33e69dc3e45d86843861973952d6f11c0fae88
Reviewed-on: https://go-review.googlesource.com/31397
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-19 07:14:13 +00:00
Andreas Auernhammer 9e9c7d4ed3 blake2b: new package
Add the hash function BLAKE2b defined in RFC 7693.

On amd64/AVX2
name 		time/op
Write128-4 	164ns ± 1%
Write1K-4 	1.19µs ± 2%
Sum128-4 	187ns ± 1%
Sum1K-4 	1.21µs ± 1%

name 		speed
Write128-4 	800MB/s ± 1%
Write1K-4 	856MB/s ± 2%
Sum128-4 	682MB/s ± 1%
Sum1K-4     	842MB/s ± 1%

On amd64/SSE4
name 		time/op
Write128-4 	192ns ± 1%
Write1K-4 	1.37µs ± 0%
Sum128-4 	215ns ± 1%
Sum1K-4 	1.39µs ± 1%

name 		speed
Write128-4 	665MB/s ± 1%
Write1K-4 	746MB/s ± 0%
Sum128-4 	592MB/s ± 1%
Sum1K-4 	735MB/s ± 1%

Change-Id: I0b41ae136980b0e8a970be330e8cc5f02b9e6818
Reviewed-on: https://go-review.googlesource.com/30918
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-18 17:05:21 +00:00
Adam Langley 14f9af67c6 chacha20poly1305: scope assembly constants
The names of the constant values were previously not scoped to the
package and |andMask| could collide with the variable of the same name
in the AES-GCM assembly.

Change-Id: I9387a6cace71a585ad2fe2afcc8436d44bde0917
Reviewed-on: https://go-review.googlesource.com/31265
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 20:27:11 +00:00
Adam Langley cdcb58c6ca poly1305: fix NaCl build.
The ARM assembly doesn't work for NaCl on ARM because it doesn't meet
the required rules. This change disables it on ARM and also fixes the
issue that the build constraints in sum_arm.s would be ignored because
they came after the #include.

Change-Id: I6cb3815ec62ac4686a6e72f405af104293586bb6
Reviewed-on: https://go-review.googlesource.com/31264
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 20:27:05 +00:00
Andreas Auernhammer 4428aee3e5 blake2s: new package
Add hash function BLAKE2s defined in RFC 7693.

On amd64/SSE4:
name       time/op
Write64-4    125ns ± 0%
Write1K-4   1.64µs ± 1%
Sum64-4      152ns ± 0%
Sum1K-4     1.67µs ± 1%

name       speed
Write64-4  508MB/s ± 0%
Write1K-4  624MB/s ± 1%
Sum64-4    420MB/s ± 0%
Sum1K-4    612MB/s ± 1%

On amd64/SSSE3:
name       time/op
Write64-4    172ns ± 0%
Write1K-4   2.42µs ± 0%
Sum64-4      172ns ± 0%
Sum1K-4     2.42µs ± 0%

name       speed
Write64-4  370MB/s ± 0%
Write1K-4  423MB/s ± 0%
Sum64-4    370MB/s ± 0%
Sum1K-4    422MB/s ± 0%

Change-Id: I5a17cc32d8f17d43db8b1d879af6ab68b44d630c
Reviewed-on: https://go-review.googlesource.com/30913
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-17 17:13:37 +00:00
Andreas Auernhammer 5f4e837b98 chacha20poly1305: fix amd64 assembly - replace PINSRB and PEXTRQ
The SSE code of chacha20poly1305 used PINSRB and PEXTRQ, which are only available
on machines supporting SSE4.1.

Fixes golang/go#17464

Change-Id: Ic7313433cb21f9a3709d23b50ab58ac1d87957af
Reviewed-on: https://go-review.googlesource.com/31187
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 00:19:40 +00:00
Adam Langley 1ed0c38df5 chacha20poly1305: clarify the correct attribution for the AMD64 assembly.
I pushed from the wrong terminal when addressing the comments on
https://golang.org/cl/31256/

Change-Id: Ic75f8348294ed0e4f77a59de948096269a454bcb
Reviewed-on: https://go-review.googlesource.com/31256
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-16 19:04:44 +00:00
Adam Langley 6bcc37609f chacha20poly1305: clarify the correct attribution for the AMD64 assembly.
Change-Id: I9c247e49a13788408b4fe49676520d608d8c4380
Reviewed-on: https://go-review.googlesource.com/31090
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-16 19:01:39 +00:00
Brad Fitzpatrick 5f31782cfb poly1305, chacha20poly1305: fix build for Go 1.6
Fixes golang/go#17424

Change-Id: I49d6e475c173da6a31542931d555ab87cc45a1c6
Reviewed-on: https://go-review.googlesource.com/30971
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-12 22:20:46 +00:00
Brad Fitzpatrick 85ce60fb24 poly1305: fix build
Updates golang/go#17422

Change-Id: Ie5f16e24f87b3d800f1182b5b09d6cf638135e33
Reviewed-on: https://go-review.googlesource.com/30970
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-12 22:18:25 +00:00