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 (
11
11
"os/exec"
12
12
"path/filepath"
13
13
"regexp"
14
+ "runtime"
14
15
"strings"
15
16
"sync"
16
17
@@ -298,6 +299,19 @@ func detectValidPublicKey(content string) bool {
298
299
299
300
func detectAESAcceleration () bool {
300
301
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
+ }
301
315
logrus .Warn ("Failed to detect CPU features. Assuming that AES acceleration is not available." )
302
316
return false
303
317
}
You can’t perform that action at this time.
0 commit comments