diff options
author | Jakob Unterwurzacher | 2020-02-15 17:21:30 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-02-15 17:21:30 +0100 |
commit | d5ce340c02601992cc9dab1bd7d3c2d95d81155e (patch) | |
tree | e709cea1677b2d9dff80ce83d5086aaaebf03c49 /internal/stupidgcm | |
parent | 9aeb2a3df68539ad3a44283b9b94e1b28f011941 (diff) |
merge prefer_openssl package into stupidgcm
Now that I have discovered golang.org/x/sys/cpu and that Go
versions below 1.6 are uncommon, there was not much useful
code left in prefer_openssl.
Merge the remains into stupidgcm.
Diffstat (limited to 'internal/stupidgcm')
-rw-r--r-- | internal/stupidgcm/prefer.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/stupidgcm/prefer.go b/internal/stupidgcm/prefer.go new file mode 100644 index 0000000..a08d154 --- /dev/null +++ b/internal/stupidgcm/prefer.go @@ -0,0 +1,26 @@ +package stupidgcm + +import ( + "golang.org/x/sys/cpu" +) + +// PreferOpenSSL tells us if OpenSSL is faster than Go GCM on this machine. +// +// Go GCM is only faster if the CPU: +// +// 1) Is X86 +// 2) Has AES instructions +// 3) Go is v1.6 or higher +// +// See https://github.com/rfjakob/gocryptfs/wiki/CPU-Benchmarks +// for benchmarks. +func PreferOpenSSL() bool { + if BuiltWithoutOpenssl { + return false + } + // Safe to call on other architectures - will just read false. + if cpu.X86.HasAES { + return false + } + return true +} |