gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/sm3/sm3block_arm64.go (about) 1 //go:build arm64 2 // +build arm64 3 4 package sm3 5 6 /* 7 sm3/sm3block_arm64.go 平台CPU是arm64架构时SM3的块处理。 8 具体实现 : sm3/sm3block_arm64.s 9 */ 10 11 import ( 12 "fmt" 13 "runtime" 14 15 "golang.org/x/sys/cpu" 16 ) 17 18 var useSM3NI = cpu.ARM64.HasSM3 19 20 func init() { 21 cpuType = runtime.GOARCH 22 if false { 23 fmt.Printf("该平台CPU架构为arm64, 对SM3指令集的支持: %v\n", useSM3NI) 24 } 25 } 26 27 var t = []uint32{ 28 0x79cc4519, 29 0x9d8a7a87, 30 } 31 32 //go:noescape 33 func blockARM64(dig *digest, p []byte) 34 35 //go:noescape 36 func blockSM3NI(h []uint32, p []byte, t []uint32) 37 38 func block(dig *digest, p []byte) { 39 if !useSM3NI { 40 blockARM64(dig, p) 41 } else { 42 h := dig.h[:] 43 blockSM3NI(h, p, t) 44 } 45 }