-
Notifications
You must be signed in to change notification settings - Fork 64
Armv8.2 SM3和SM4
Sun Yimin edited this page Jan 5, 2022
·
31 revisions
go test -v -short -bench . -run=^$ ./...
goos: linux
goarch: arm64
pkg: github.com/emmansun/gmsm/sm3
BenchmarkHash8Bytes
BenchmarkHash8Bytes-2 2738724 438.4 ns/op 18.25 MB/s
BenchmarkHash1K
BenchmarkHash1K-2 192519 6232 ns/op 164.32 MB/s
BenchmarkHash8K
BenchmarkHash8K-2 24950 48112 ns/op 170.27 MB/s
BenchmarkHash8K_SH256
BenchmarkHash8K_SH256-2 223354 5369 ns/op 1525.81 MB/s
PASS
ok github.com/emmansun/gmsm/sm3 5.857s
和CPU指令级别的差距基本上是10倍!
AESE指令相当于:
- AddRoundKey(state, RoudKey)
- ShiftRows(State)
- SubBytes(State)
所以,如果RoundKey = 0, 那么AESE相当于执行了
- ShiftRows(State)
- SubBytes(State)
go test -v -short -bench . -run=^$ ./...
goos: linux
goarch: arm64
pkg: github.com/emmansun/gmsm/sm4
BenchmarkEncrypt
BenchmarkEncrypt-2 2145859 559.1 ns/op 28.62 MB/s
BenchmarkDecrypt
BenchmarkDecrypt-2 2145296 559.4 ns/op 28.60 MB/s
BenchmarkExpand
BenchmarkExpand-2 2064466 581.2 ns/op
PASS
ok github.com/emmansun/gmsm/sm4 5.334s
SM3和SM4 CPU指令实现,找不到相关CPU环境,mark先。
- Summary of A64 cryptographic instructions
- Arm A64 Instruction Set Architecture
- linux arm64 crypto / (https://github.com/torvalds/linux/tree/master/arch/arm64/crypto)
- A Quick Guide to Go's Assembler
- Golang arm instructions mapping
- A C/C++ header file that converts Intel SSE intrinsics to Arm/Aarch64 NEON intrinsics.
- asm2go