You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
971 B

  1. // Copyright 2016 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. // +build amd64,!gccgo,!appengine
  5. package blake2s
  6. var (
  7. useSSE4 = supportSSE4()
  8. useSSSE3 = supportSSSE3()
  9. useSSE2 = true // Always available on amd64
  10. )
  11. //go:noescape
  12. func supportSSSE3() bool
  13. //go:noescape
  14. func supportSSE4() bool
  15. //go:noescape
  16. func hashBlocksSSE2(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  17. //go:noescape
  18. func hashBlocksSSSE3(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  19. //go:noescape
  20. func hashBlocksSSE4(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte)
  21. func hashBlocks(h *[8]uint32, c *[2]uint32, flag uint32, blocks []byte) {
  22. if useSSE4 {
  23. hashBlocksSSE4(h, c, flag, blocks)
  24. } else if useSSSE3 {
  25. hashBlocksSSSE3(h, c, flag, blocks)
  26. } else if useSSE2 {
  27. hashBlocksSSE2(h, c, flag, blocks)
  28. } else {
  29. hashBlocksGeneric(h, c, flag, blocks)
  30. }
  31. }