diff --git a/sm4/cbc_cipher_asm.go b/sm4/cbc_cipher_asm.go index e584a09..813e43d 100644 --- a/sm4/cbc_cipher_asm.go +++ b/sm4/cbc_cipher_asm.go @@ -49,7 +49,7 @@ func (x *cbc) CryptBlocks(dst, src []byte) { var temp []byte = make([]byte, x.b.blocksSize) var batchSrc []byte = make([]byte, x.b.blocksSize) for start > 0 { - encryptBlocksAsm(&x.b.dec[0], &temp[0], &src[start:end][0]) + x.b.DecryptBlocks(temp, src[start:end]) for i := 0; i < x.b.batchBlocks; i++ { xor.XorBytes(dst[end-(i+1)*BlockSize:end-i*BlockSize], temp[x.b.blocksSize-(i+1)*BlockSize:x.b.blocksSize-i*BlockSize], src[end-(i+2)*BlockSize:end-(i+1)*BlockSize]) } @@ -58,7 +58,7 @@ func (x *cbc) CryptBlocks(dst, src []byte) { } copy(batchSrc, src[:end]) - encryptBlocksAsm(&x.b.dec[0], &temp[0], &batchSrc[0]) + x.b.DecryptBlocks(temp, batchSrc) count := end / BlockSize for i := count; i > 1; i-- { xor.XorBytes(dst[end-BlockSize:end], temp[end-BlockSize:end], src[end-2*BlockSize:end-BlockSize]) diff --git a/sm4/ctr_cipher_asm.go b/sm4/ctr_cipher_asm.go index 337699e..68c8c46 100644 --- a/sm4/ctr_cipher_asm.go +++ b/sm4/ctr_cipher_asm.go @@ -67,7 +67,7 @@ func (x *ctr) refill() { copy(x.out, x.out[x.outUsed:]) x.out = x.out[:cap(x.out)] for remain <= len(x.out)-x.b.blocksSize { - encryptBlocksAsm(&x.b.enc[0], &x.out[remain:][0], &x.ctr[0]) + x.b.EncryptBlocks(x.out[remain:], x.ctr) remain += x.b.blocksSize // Increment counter diff --git a/sm4/gcm_cipher_asm.go b/sm4/gcm_cipher_asm.go index 5e50b29..f99ccc4 100644 --- a/sm4/gcm_cipher_asm.go +++ b/sm4/gcm_cipher_asm.go @@ -273,7 +273,7 @@ func (g *gcm) counterCrypt(out, in []byte, counter *[gcmBlockSize]byte) { copy(counters[i*gcmBlockSize:(i+1)*gcmBlockSize], counter[:]) gcmInc32(counter) } - encryptBlocksAsm(&g.cipher.enc[0], &mask[0], &counters[0]) + g.cipher.EncryptBlocks(mask, counters) xor.XorWords(out, in, mask[:]) out = out[g.cipher.blocksSize:] in = in[g.cipher.blocksSize:] @@ -285,7 +285,7 @@ func (g *gcm) counterCrypt(out, in []byte, counter *[gcmBlockSize]byte) { copy(counters[i*gcmBlockSize:], counter[:]) gcmInc32(counter) } - encryptBlocksAsm(&g.cipher.enc[0], &mask[0], &counters[0]) + g.cipher.EncryptBlocks(mask, counters) xor.XorBytes(out, in, mask[:blocks*gcmBlockSize]) } }