github.com/mad-day/Yawning-crypto@v0.0.0-20190711051033-5a5f8cca32ec/morus/hwaccel.go (about) 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 8 package morus 9 10 var ( 11 isHardwareAccelerated = false 12 hardwareAccelImpl = implReference 13 14 implReference = &hwaccelImpl{ 15 name: "Reference", 16 aeadEncryptFn: aeadEncryptRef, 17 aeadDecryptFn: aeadDecryptRef, 18 } 19 ) 20 21 type hwaccelImpl struct { 22 name string 23 aeadEncryptFn func([]byte, []byte, []byte, []byte, []byte) []byte 24 aeadDecryptFn func([]byte, []byte, []byte, []byte, []byte) ([]byte, bool) 25 } 26 27 func forceDisableHardwareAcceleration() { 28 isHardwareAccelerated = false 29 hardwareAccelImpl = implReference 30 } 31 32 // IsHardwareAccelerated returns true iff the MORUS implementation will use 33 // hardware acceleration (eg: AVX2). 34 func IsHardwareAccelerated() bool { 35 return isHardwareAccelerated 36 } 37 38 func init() { 39 initHardwareAcceleration() 40 }