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

14 Коммитов

Автор SHA1 Сообщение Дата
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