mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-22 02:06:18 +08:00
1.8 KiB
1.8 KiB
ZUC original performance:
goos: windows
goarch: amd64
pkg: github.com/emmansun/gmsm/zuc
cpu: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
BenchmarkEncrypt1K-6 30052 39131 ns/op 26.04 MB/s
BenchmarkEncrypt8K-6 3853 310722 ns/op 26.35 MB/s
Performance after delay mod & lfsr array copy:
goos: windows
goarch: amd64
pkg: github.com/emmansun/gmsm/zuc
cpu: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
BenchmarkEncrypt1K-6 41754 26916 ns/op 37.86 MB/s
BenchmarkEncrypt8K-6 5290 215252 ns/op 38.03 MB/s
Performance after delay mod & lfsr array copy & merge sbox0/sbox1 (sbox size from 0.5k to 128k, so i do not commit it):
goos: windows
goarch: amd64
pkg: github.com/emmansun/gmsm/zuc
cpu: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
BenchmarkEncrypt1K-6 49195 23710 ns/op 42.98 MB/s
BenchmarkEncrypt8K-6 6000 191255 ns/op 42.81 MB/s
func (s *zucState32) f32(x0, x1, x2 uint32) uint32 {
w := s.r1 ^ x0 + s.r2
w1 := s.r1 + x1
w2 := s.r2 ^ x2
u := l1((w1 << 16) | (w2 >> 16))
v := l2((w2 << 16) | (w1 >> 16))
s.r1 = uint32(bigSbox[u>>16])<<16 | uint32(bigSbox[u&0xFFFF])
s.r2 = uint32(bigSbox[v>>16])<<16 | uint32(bigSbox[v&0xFFFF])
return w
}
// bigSbox is generated by
for i := 0; i < 256; i++ {
for j := 0; j < 256; j++ {
if (j > 0 || i > 0) && j%16 == 0 {
fmt.Println()
}
fmt.Printf("0x%04x,", uint16(sbox0[i])<<8|uint16(sbox1[j]))
}
}
fmt.Println()
Performance with AMD64 SIMD & AESNI:
goos: windows
goarch: amd64
pkg: github.com/emmansun/gmsm/zuc
cpu: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
BenchmarkEncrypt1K-6 409755 2802 ns/op 363.62 MB/s
BenchmarkEncrypt8K-6 54120 22413 ns/op 365.28 MB/s