Граф коммитов

22 Коммитов

Автор SHA1 Сообщение Дата
Tobias Klauser cd7d49e622 all: add //go:build lines to assembly files
For golang/go#41184

Change-Id: Ica67fdbf2745ad2eef63dbb9ef70136e9e6fd348
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/319469
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-13 12:29:33 +00:00
Russ Cox 5ea612d1eb all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I70526bf588bf4078887e567795867ece785d666b
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/294415
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:31:48 +00:00
Russ Cox b8e89b74b9 blake2s: fix 386 assembly not to smash SP
For golang/go#44269.

Change-Id: I92e168674612af390bcb80a0579df5c777c26970
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/292052
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-18 14:52:15 +00:00
Russ Cox 86c0c3e7f9 blake2s: fix amd64 assembly not to smash SP
For golang/go#44269.

Change-Id: I877a8056dbd8ab1dedadb562aa1b3d9e1e0d55da
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/292049
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-18 14:51:59 +00:00
Tamir Duberstein be400aefbc all: build tags: appengine,!gccgo => purego,gc
appengine is obsolete and superseded by purego, and gc is a more
precise tag for files that use gc-syntax assembly.

Change-Id: I716f59de772ebeee4adf4d2a432edf300122cef0
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/269920
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-12-03 16:30:18 +00:00
Katie Hockman baeed622b8 blake2b,blake2s: clarify difference between blake2b and blake2s
Fixes golang/go#37784

Change-Id: I2fdaf96979390f3744ba8135da78107a15f5e9a8
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/226845
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-03 20:14:58 +00:00
Udalov Max d864b10871 blake2s: use math.bits rotate functions instead of ad-hoc implementation
This makes code more readable and idiomatic.

Updates golang/go#31456

Benchstat:
name       old time/op   new time/op   delta
Write64-8    211ns ± 6%    205ns ± 2%    ~     (p=0.243 n=10+9)
Write1K-8   3.26µs ± 3%   3.12µs ± 2%  -4.44%  (p=0.000 n=9+9)
Sum64-8      227ns ± 5%    217ns ± 6%  -4.58%  (p=0.009 n=10+10)
Sum1K-8     3.28µs ± 2%   3.31µs ± 4%    ~     (p=0.412 n=10+9)

name       old speed     new speed     delta
Write64-8  303MB/s ± 6%  312MB/s ± 1%    ~     (p=0.203 n=10+8)
Write1K-8  314MB/s ± 3%  329MB/s ± 2%  +4.64%  (p=0.000 n=9+9)
Sum64-8    281MB/s ± 5%  295MB/s ± 5%  +4.93%  (p=0.009 n=10+10)
Sum1K-8    313MB/s ± 2%  310MB/s ± 4%    ~     (p=0.447 n=10+9)

Change-Id: Iee0e88f4405d4da1feacddaf24835e86d8ddeff7
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/173278
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-22 18:39:09 +00:00
Igor Zhilianin 45a5f77698 all: fix typos
Change-Id: I62cbcfcd0be5f6a74d93b85b24ff7607533bb239
GitHub-Last-Rev: 9967869e70
GitHub-Pull-Request: golang/crypto#64
Reviewed-on: https://go-review.googlesource.com/c/145240
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-29 02:12:03 +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
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
Tobias Klauser 3680b74bae blake2s: fix vet format string issue
Fix the following format string issue reported by go vet:

  blake2s_test.go:188: Fatalf format %v reads arg #3, but call has only 2 args

Change-Id: I689eadb7d7310ae93acd8a8419755f2724ff41dd
Reviewed-on: https://go-review.googlesource.com/75978
Reviewed-by: Filippo Valsorda <hi@filippo.io>
2017-11-05 17:26:29 +00:00
Andreas Auernhammer b286ef4198 blake2s: implement BLAKE2X
This CL implements BLAKE2X, a extensible-output functions (XOF) on top of BLAKE2s.
BLAKE2x is described in https://blake2.net/blake2x.pdf

Change-Id: I20838811e270f4767b8bd5e239a1fe1fb994fe1c
Reviewed-on: https://go-review.googlesource.com/38054
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2017-07-05 21:44:04 +00:00
Mathias Hall-Andersen 6e3a28fe26 blake2s: add 128-bit digest support.
Although a 128-bit digest provides little collision resistance it can be
used as a MAC, as found in the WireGuard protocol.

Change-Id: I06ee528e5711035da8f1b254c223a6fda8890abf
Reviewed-on: https://go-review.googlesource.com/39370
Reviewed-by: Adam Langley <agl@golang.org>
2017-06-06 16:20:18 +00:00
Andreas Auernhammer 55a552f082 x/crypto/*: add import comment
Add import comment for blake2b, blake2s, chacha20poly1305 and cryptobyte.

Change-Id: I4703b5cd669e43a5d81422b2ded8b8f54eee5f9b
Reviewed-on: https://go-review.googlesource.com/39952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-07 17:36:45 +00:00
Andreas Auernhammer 40541ccb1c blake2s: register BLAKE2s
Register BLAKE2s-256 if the package is imported.
Change-Id: Ib415ae641f21d863720bf9c089017ee97654a555
Reviewed-on: https://go-review.googlesource.com/36878
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-02 19:32:44 +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
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 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
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 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