mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-22 10:16:18 +08:00
sm4: ctr mode fix issue and comments
This commit is contained in:
parent
8041c5e310
commit
1d0e77388a
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user