sm4: ctr mode fix issue and comments

This commit is contained in:
Sun Yimin 2023-06-27 17:52:23 +08:00 committed by GitHub
parent 8041c5e310
commit 1d0e77388a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ func (x *ctr) genCtr(start int) {
}
// Increment counter
end := start + BlockSize
for i := end - 1; i >= 0; i-- {
for i := end - 1; i >= start; i-- {
x.ctr[i]++
if x.ctr[i] != 0 {
break
@ -70,7 +70,7 @@ func (x *ctr) refill() {
x.b.EncryptBlocks(x.out[remain:], x.ctr)
remain += x.b.blocksSize
// Increment counter
// Generate complelte [x.b.batchBlocks] counters
for i := 0; i < x.b.batchBlocks; i++ {
x.genCtr(i * BlockSize)
}