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:
@@ -6,6 +6,7 @@
|
||||
|
||||
package blake2b
|
||||
|
||||
var useAVX2 = false
|
||||
var useSSE4 = supportSSE4()
|
||||
|
||||
//go:noescape
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user