Skip to content

Commit

Permalink
feat(s/c/aes): internal/cpu => internal/cpuproxy
Browse files Browse the repository at this point in the history
I extracted this diff from 62177de with
the intent of coming up with a more manageable patch set.

The idea here is to take advantage of the cpuproxy package to use the
information it provides to better initialize crypto using arm64.

The original issue describing this problem in its full extent was
ooni/probe#1444.

We're now working to forward-port this patch to go1.17.

The current issue describing this problem as of go1.17 is
ooni/probe#1863.

Is there a better way?
  • Loading branch information
bassosimone committed Nov 10, 2021
1 parent 7807667 commit 849ebe0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/crypto/aes/cipher_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package aes
import (
"crypto/cipher"
"crypto/internal/subtle"
"internal/cpu"
"internal/cpuproxy"
)

// defined in asm_*.s
Expand All @@ -28,8 +28,8 @@ type aesCipherAsm struct {
aesCipher
}

var supportsAES = cpu.X86.HasAES || cpu.ARM64.HasAES
var supportsGFMUL = cpu.X86.HasPCLMULQDQ || cpu.ARM64.HasPMULL
var supportsAES = cpuproxy.HasAES()
var supportsGFMUL = cpuproxy.HasGFMUL()

func newCipher(key []byte) (cipher.Block, error) {
if !supportsAES {
Expand Down

0 comments on commit 849ebe0

Please sign in to comment.