mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 20:26:19 +08:00
sm4: fallback ctr change
This commit is contained in:
parent
27e7ceacbc
commit
8a25134c82
@ -34,17 +34,18 @@ func (c *sm4CipherAsm) NewCTR(iv []byte) cipher.Stream {
|
||||
}
|
||||
s := &ctr{
|
||||
b: c,
|
||||
ctr: bytes.Clone(iv),
|
||||
ctr: make([]byte, c.blocksSize),
|
||||
out: make([]byte, 0, bufSize),
|
||||
outUsed: 0,
|
||||
}
|
||||
copy(s.ctr, iv)
|
||||
for i := 1; i < c.batchBlocks; i++ {
|
||||
s.genCtr(i * BlockSize)
|
||||
}
|
||||
return s
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (x *ctr) genCtr(start int) {
|
||||
if start >= BlockSize {
|
||||
copy(x.ctr[start:], x.ctr[start-BlockSize:start])
|
||||
|
Loading…
x
Reference in New Issue
Block a user