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>
This commit is contained in:
Austin Clements
2016-10-24 19:19:48 +00:00
parent 814723eff7
commit 8291fff38a
3 changed files with 23 additions and 0 deletions
+1
View File
@@ -6,6 +6,7 @@
package blake2b
var useAVX2 = false
var useSSE4 = supportSSE4()
//go:noescape
+3
View File
@@ -6,6 +6,9 @@
package blake2b
var useAVX2 = false
var useSSE4 = false
func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
hashBlocksGeneric(h, c, flag, blocks)
}
+19
View File
@@ -21,6 +21,25 @@ func fromHex(s string) []byte {
}
func TestHashes(t *testing.T) {
defer func(sse4, avx2 bool) {
useSSE4, useAVX2 = sse4, avx2
}(useSSE4, useAVX2)
if useAVX2 {
t.Log("AVX2 version")
testHashes(t)
useAVX2 = false
}
if useSSE4 {
t.Log("SSE4 version")
testHashes(t)
useSSE4 = false
}
t.Log("generic version")
testHashes(t)
}
func testHashes(t *testing.T) {
key, _ := hex.DecodeString("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f")
input := make([]byte, 255)