aboutsummaryrefslogtreecommitdiff
path: root/blake2s
AgeCommit message (Collapse)Author
2025-04-14Revert "blake2s: add loong64 SIMD implementation"Michael Pratt
This reverts CL 661215. Reason for revert: Does not build on 1.23 or 1.24 Fixes #73354. Change-Id: I90abd8a3dabf5c0d9fd1062de3ba3e78ecb2f2e8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/664796 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-11blake2s: add loong64 SIMD implementationXiaolin Zhao
The performance gains on Loongson 3A6000 and 3A5000 are as follows: goos: linux goarch: loong64 pkg: golang.org/x/crypto/blake2s cpu: Loongson-3A6000-HV @ 2500.00MHz | bench.old | bench.new | | sec/op | sec/op vs base | Write64 277.8n ± 0% 113.5n ± 0% -59.14% (p=0.000 n=10) Write1K 4.246µ ± 0% 1.736µ ± 0% -59.11% (p=0.000 n=10) Sum64 289.9n ± 0% 137.7n ± 0% -52.51% (p=0.000 n=10) Sum1K 4.265µ ± 0% 1.758µ ± 0% -58.78% (p=0.000 n=10) geomean 1.099µ 467.3n -57.48% | bench.old | bench.new | | B/s | B/s vs base | Write64 219.7Mi ± 0% 537.9Mi ± 0% +144.86% (p=0.000 n=10) Write1K 230.0Mi ± 0% 562.6Mi ± 0% +144.62% (p=0.000 n=10) Sum64 210.5Mi ± 0% 443.3Mi ± 0% +110.59% (p=0.000 n=10) Sum1K 229.0Mi ± 0% 555.5Mi ± 0% +142.64% (p=0.000 n=10) geomean 222.1Mi 522.5Mi +135.21% goos: linux goarch: loong64 pkg: golang.org/x/crypto/blake2s cpu: Loongson-3A5000 @ 2500.00MHz | bench.old | bench.new | | sec/op | sec/op vs base | Write64 373.8n ± 0% 175.0n ± 0% -53.18% (p=0.000 n=10) Write1K 5.763µ ± 0% 2.595µ ± 0% -54.97% (p=0.000 n=10) Sum64 397.8n ± 0% 205.7n ± 0% -48.29% (p=0.000 n=10) Sum1K 5.787µ ± 0% 2.627µ ± 0% -54.61% (p=0.000 n=10) geomean 1.492µ 703.8n -52.83% | bench.old | bench.new | | B/s | B/s vs base | Write64 163.3Mi ± 0% 348.9Mi ± 0% +113.62% (p=0.000 n=10) Write1K 169.5Mi ± 0% 376.3Mi ± 0% +122.09% (p=0.000 n=10) Sum64 153.4Mi ± 0% 296.7Mi ± 0% +93.37% (p=0.000 n=10) Sum1K 168.7Mi ± 0% 371.8Mi ± 0% +120.33% (p=0.000 n=10) geomean 163.6Mi 346.9Mi +112.03% Change-Id: Id91ffbefc538bce294875d72e6cde72fea43afbf Reviewed-on: https://go-review.googlesource.com/c/crypto/+/661215 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Carlos Amedee <carlos@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14all: bump golang.org/x/crypto dependencies of asm generatorsRoland Shoemaker
Change-Id: Ieb2f0d45f82647978f0bd1eb47bb347f0bfb7d13 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/649499 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04blake2s: port blake2s_amd64.s to AvoGarrett Bodley
This implementation utilizes the same registers found in the reference implementation, aiming to produce a minimal semantic diff between the Avo-generated output and the original hand-written assembly. To verify the Avo implementation, the reference and Avo-generated assembly files are fed to `go tool asm`, capturing the debug output into corresponding temp files. The debug output contains supplementary metadata (line numbers, instruction offsets, and source file references) that must be removed in order to obtain a semantic diff of the two files. This is accomplished via a small utility script written in awk. Commands used to verify Avo output: GOROOT=$(go env GOROOT) ASM_PATH="blake2s/blake2s_amd64.s" REFERENCE="b2d3a6a4b4d36521cd7f653879cf6981e7c5c340" go tool asm -o /dev/null -I "$GOROOT"/src/runtime -debug \ <(git cat-file -p "$REFERENCE:$ASM_PATH") \ > /tmp/reference.s go tool asm -o /dev/null -I "$GOROOT"/src/runtime -debug \ "$ASM_PATH" \ > /tmp/avo.s normalize(){ awk '{ $1=$2=$3=""; print substr($0,4) }' } diff <(normalize < /tmp/reference.s) <(normalize < /tmp/avo.s) Change-Id: Ica8bf9f0b42dc93714aa54e783fa74ed19e6b9f4 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/601216 Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2024-06-26all: bump go.mod version and drop compatibility shimsFilippo Valsorda
Also, remove the legacy import annotations. Fixes golang/go#68147 Change-Id: Ibfcc9322f27224c0ba92ea42cd56912a7d8783fd Reviewed-on: https://go-review.googlesource.com/c/crypto/+/594256 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-10-11all: update go directive to 1.18Dmitri Shuralyov
Done with: go get go@1.18 go mod tidy go fix ./... Using go1.21.3. Also update avo to v0.5.0 in the curve25519/internal/field/_asm module. It's newer and produces no diff in the generated code. For golang/go#60268. Change-Id: I9bd771ee8561595d7f68aaca76df6e3e33d35013 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/534141 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2021-05-13all: add //go:build lines to assembly filesTobias Klauser
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-02-20all: go fmt ./...Russ Cox
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-18blake2s: fix 386 assembly not to smash SPRuss Cox
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-18blake2s: fix amd64 assembly not to smash SPRuss Cox
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>
2020-12-03all: build tags: appengine,!gccgo => purego,gcTamir Duberstein
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-04-03blake2b,blake2s: clarify difference between blake2b and blake2sKatie Hockman
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>
2019-04-22blake2s: use math.bits rotate functions instead of ad-hoc implementationUdalov Max
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>
2018-10-29all: fix typosIgor Zhilianin
Change-Id: I62cbcfcd0be5f6a74d93b85b24ff7607533bb239 GitHub-Last-Rev: 9967869e706e9fe7d13964bb32b30a44ba640869 GitHub-Pull-Request: golang/crypto#64 Reviewed-on: https://go-review.googlesource.com/c/145240 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-30crypto/{blake2b,blake2s,argon2,chacha20poly1305}: replace CPU feature detectionAndreas Auernhammer
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-03-30blake2b,blake2s: implement BinaryMarshaler, BinaryUnmarshalerValarDragon
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>
2017-11-05blake2s: fix vet format string issueTobias Klauser
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-07-05blake2s: implement BLAKE2XAndreas Auernhammer
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-06-06blake2s: add 128-bit digest support.Mathias Hall-Andersen
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-04-07x/crypto/*: add import commentAndreas Auernhammer
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-03-02blake2s: register BLAKE2sAndreas Auernhammer
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>
2016-10-28blake2s: fix build constraintsAdam Langley
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-24blake2s: test all four hashing implementationsAustin Clements
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-21blake2s: fix frame size of hashBlocksSSE4Austin Clements
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-21blake2s: remove NOSPLIT from asm functionsAustin Clements
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-21blake2s: use proper Go frame sizesAustin Clements
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-19blake2s,blake2b: fix typo in package docAndreas Auernhammer
Change-Id: I6c33e69dc3e45d86843861973952d6f11c0fae88 Reviewed-on: https://go-review.googlesource.com/31397 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17blake2s: new packageAndreas Auernhammer
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>