aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/argon2/blamka_amd64.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/crypto/argon2/blamka_amd64.go')
-rw-r--r--vendor/golang.org/x/crypto/argon2/blamka_amd64.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/golang.org/x/crypto/argon2/blamka_amd64.go b/vendor/golang.org/x/crypto/argon2/blamka_amd64.go
new file mode 100644
index 0000000..063e778
--- /dev/null
+++ b/vendor/golang.org/x/crypto/argon2/blamka_amd64.go
@@ -0,0 +1,60 @@
1// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build amd64 && gc && !purego
6
7package argon2
8
9import "golang.org/x/sys/cpu"
10
11func init() {
12 useSSE4 = cpu.X86.HasSSE41
13}
14
15//go:noescape
16func mixBlocksSSE2(out, a, b, c *block)
17
18//go:noescape
19func xorBlocksSSE2(out, a, b, c *block)
20
21//go:noescape
22func blamkaSSE4(b *block)
23
24func processBlockSSE(out, in1, in2 *block, xor bool) {
25 var t block
26 mixBlocksSSE2(&t, in1, in2, &t)
27 if useSSE4 {
28 blamkaSSE4(&t)
29 } else {
30 for i := 0; i < blockLength; i += 16 {
31 blamkaGeneric(
32 &t[i+0], &t[i+1], &t[i+2], &t[i+3],
33 &t[i+4], &t[i+5], &t[i+6], &t[i+7],
34 &t[i+8], &t[i+9], &t[i+10], &t[i+11],
35 &t[i+12], &t[i+13], &t[i+14], &t[i+15],
36 )
37 }
38 for i := 0; i < blockLength/8; i += 2 {
39 blamkaGeneric(
40 &t[i], &t[i+1], &t[16+i], &t[16+i+1],
41 &t[32+i], &t[32+i+1], &t[48+i], &t[48+i+1],
42 &t[64+i], &t[64+i+1], &t[80+i], &t[80+i+1],
43 &t[96+i], &t[96+i+1], &t[112+i], &t[112+i+1],
44 )
45 }
46 }
47 if xor {
48 xorBlocksSSE2(out, in1, in2, &t)
49 } else {
50 mixBlocksSSE2(out, in1, in2, &t)
51 }
52}
53
54func processBlock(out, in1, in2 *block) {
55 processBlockSSE(out, in1, in2, false)
56}
57
58func processBlockXOR(out, in1, in2 *block) {
59 processBlockSSE(out, in1, in2, true)
60}