Skip to content

Commit

Permalink
disable sm3 sm4 ni via env. variable
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Mar 8, 2023
1 parent 6bbcc97 commit 8181592
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test_qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ jobs:
- name: Test
run: go test -v -short ./...
env:
DISABLE_SM3NI: 1
DISABLE_SM4NI: 1
GOARCH: ${{ matrix.arch }}
7 changes: 5 additions & 2 deletions sm3/sm3block_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

package sm3

import "golang.org/x/sys/cpu"
import (
"os"
"golang.org/x/sys/cpu"
)

var useSM3NI = cpu.ARM64.HasSM3
var useSM3NI = cpu.ARM64.HasSM3 && os.Getenv("DISABLE_SM3NI")) != "1"

var t = []uint32{
0x79cc4519,
Expand Down
3 changes: 2 additions & 1 deletion sm4/cipher_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ package sm4

import (
"crypto/cipher"
"os"

"github.com/emmansun/gmsm/internal/alias"
"golang.org/x/sys/cpu"
)

var supportSM4 = cpu.ARM64.HasSM4
var supportSM4 = cpu.ARM64.HasSM4 && os.Getenv("DISABLE_SM4NI") != "1"
var supportsAES = cpu.X86.HasAES || cpu.ARM64.HasAES
var supportsGFMUL = cpu.X86.HasPCLMULQDQ || cpu.ARM64.HasPMULL
var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI2
Expand Down

0 comments on commit 8181592

Please sign in to comment.