summaryrefslogtreecommitdiff
path: root/internal/stupidgcm/prefer.go
blob: a08d154a77dcc996d97b3be7b8121d01997187ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}