xs/vendor/git.schwanenlied.me/yawning/kyber.git/hwaccel.go
Russ Magee caac02a77b 1/2 Updated Makefile to allow VENDOR flag (adds -vendor to version string)
2/2 Added vendor/ dir to lock down dependent pkg versions.
The author of git.schwanenlied.me/yawning/{chacha20,newhope,kyber}.git has copied
their repos to gitlab.com/yawning/ but some imports of chacha20 from newhope still
inconsistently refer to git.schwanenlied.me/, breaking build.
Licenses for chacha20 also changed from CC0 to AGPL, which may or may not be an
issue. Until the two aforementioned issues are resolved, locking to last-good
versions is probably the best way forward for now.

To build with vendored deps, use make VENDOR=1 clean all
2020-01-29 13:55:38 -08:00

46 lines
1.2 KiB
Go

// hwaccel.go - Hardware acceleration hooks.
//
// To the extent possible under law, Yawning Angel has waived all copyright
// and related or neighboring rights to the software, using the Creative
// Commons "CC0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package kyber
var (
isHardwareAccelerated = false
hardwareAccelImpl = implReference
implReference = &hwaccelImpl{
name: "Reference",
nttFn: nttRef,
invnttFn: invnttRef,
pointwiseAccFn: pointwiseAccRef,
cbdFn: cbdRef,
}
)
type hwaccelImpl struct {
name string
nttFn func(*[kyberN]uint16)
invnttFn func(*[kyberN]uint16)
pointwiseAccFn func(*poly, *polyVec, *polyVec)
cbdFn func(*poly, []byte, int)
}
func forceDisableHardwareAcceleration() {
// This is for the benefit of testing, so that it's possible to test
// all versions that are supported by the host.
isHardwareAccelerated = false
hardwareAccelImpl = implReference
}
// IsHardwareAccelerated returns true iff the Kyber implementation will use
// hardware acceleration (eg: AVX2).
func IsHardwareAccelerated() bool {
return isHardwareAccelerated
}
func init() {
initHardwareAcceleration()
}