File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "os/exec"
1212 "path/filepath"
1313 "regexp"
14+ "runtime"
1415 "strings"
1516 "sync"
1617
@@ -298,6 +299,19 @@ func detectValidPublicKey(content string) bool {
298299
299300func detectAESAcceleration () bool {
300301 if ! cpu .Initialized {
302+ if runtime .GOOS == "darwin" && runtime .GOARCH == "arm64" {
303+ // golang.org/x/sys/cpu supports darwin/amd64, linux/amd64, and linux/arm64,
304+ // but apparently lacks support for darwin/arm64: https://github.com/golang/sys/blob/v0.5.0/cpu/cpu_arm64.go#L43-L60
305+ //
306+ // According to https://gist.github.com/voluntas/fd279c7b4e71f9950cfd4a5ab90b722b ,
307+ // aes-128-gcm is faster than chacha20-poly1305 on Apple M1.
308+ //
309+ // So we return `true` here.
310+ //
311+ // This workaround will not be needed when https://go-review.googlesource.com/c/sys/+/332729 is merged.
312+ logrus .Debug ("Failed to detect CPU features. Assuming that AES acceleration is available on this Apple silicon." )
313+ return true
314+ }
301315 logrus .Warn ("Failed to detect CPU features. Assuming that AES acceleration is not available." )
302316 return false
303317 }
You can’t perform that action at this time.
0 commit comments