hwaccel.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // hwaccel.go - Hardware acceleration hooks
  2. //
  3. // To the extent possible under law, Yawning Angel has waived all copyright
  4. // and related or neighboring rights to the software, using the Creative
  5. // Commons "CC0" public domain dedication. See LICENSE or
  6. // <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
  7. package norx
  8. var (
  9. isHardwareAccelerated = false
  10. hardwareAccelImpl = implReference
  11. implReference = &hwaccelImpl{
  12. name: "Reference",
  13. initFn: initRef,
  14. absorbDataFn: absorbDataRef,
  15. encryptDataFn: encryptDataRef,
  16. decryptDataFn: decryptDataRef,
  17. finalizeFn: finalizeRef,
  18. permuteFn: permuteRef,
  19. }
  20. )
  21. type hwaccelImpl struct {
  22. name string
  23. initFn func(*state, []byte, []byte)
  24. absorbDataFn func(*state, []byte, uint64)
  25. encryptDataFn func(*state, []byte, []byte)
  26. decryptDataFn func(*state, []byte, []byte)
  27. finalizeFn func(*state, []byte, []byte)
  28. permuteFn func(*state, int)
  29. }
  30. func forceDisableHardwareAcceleration() {
  31. isHardwareAccelerated = false
  32. hardwareAccelImpl = implReference
  33. }
  34. // IsHardwareAccelerated returns true iff the NORX implementation will use
  35. // hardware acceleration (eg: AVX2).
  36. func IsHardwareAccelerated() bool {
  37. return isHardwareAccelerated
  38. }
  39. func init() {
  40. // NOTYET
  41. // initHardwareAcceleration()
  42. }