sm4: reduce bounds check

This commit is contained in:
Sun Yimin 2024-01-31 14:48:46 +08:00 committed by GitHub
parent 056d14a892
commit a2ce3f51d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,7 +61,7 @@ func (x *cbc) CryptBlocks(dst, src []byte) {
if x.enc == cbcEncrypt {
iv := x.iv
for len(src) > 0 {
for len(src) >= BlockSize {
// Write the xor to dst, then encrypt in place.
subtle.XORBytes(dst[:BlockSize], src[:BlockSize], iv)
x.b.Encrypt(dst[:BlockSize], dst[:BlockSize])