sm4: fix arm64 cbc 8 blocks decryption issue

This commit is contained in:
Sun Yimin 2023-08-03 16:40:31 +08:00 committed by GitHub
parent dba47d3c14
commit 71afa44b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/emmansun/gmsm/sm4"
)
func benchmarkEBCEncrypt1K(b *testing.B, block cipher.Block) {
func benchmarkECBEncrypt1K(b *testing.B, block cipher.Block) {
buf := make([]byte, 1024)
b.SetBytes(int64(len(buf)))
@ -19,16 +19,16 @@ func benchmarkEBCEncrypt1K(b *testing.B, block cipher.Block) {
}
}
func BenchmarkSM4EBCEncrypt1K(b *testing.B) {
func BenchmarkSM4ECBEncrypt1K(b *testing.B) {
var key [16]byte
c, _ := sm4.NewCipher(key[:])
benchmarkEBCEncrypt1K(b, c)
benchmarkECBEncrypt1K(b, c)
}
func BenchmarkAES128EBCEncrypt1K(b *testing.B) {
var key [16]byte
c, _ := aes.NewCipher(key[:])
benchmarkEBCEncrypt1K(b, c)
benchmarkECBEncrypt1K(b, c)
}
func benchmarkCBCEncrypt1K(b *testing.B, block cipher.Block) {

View File

@ -185,13 +185,14 @@ decrypt8BlocksLoop:
VEOR V7.B16, t1.B16, t1.B16
VEOR V8.B16, t2.B16, t2.B16
VEOR V9.B16, t3.B16, t3.B16
VST1.P [t0.S4, t1.S4, t2.S4, t3.S4], 64(R9)
VLD1.P 64(R11), [V6.S4, V7.S4, V8.S4, V9.S4]
VEOR V6.B16, t4.B16, t4.B16
VEOR V7.B16, t5.B16, t5.B16
VEOR V8.B16, t6.B16, t6.B16
VEOR V9.B16, t7.B16, t7.B16
VST1.P [t0.S4, t1.S4, t2.S4, t3.S4], 64(R9)
VST1.P [t4.S4, t5.S4, t6.S4, t7.S4], 64(R9)
RET