From: Sergey Matveev Date: Fri, 26 Jul 2019 08:38:03 +0000 (+0300) Subject: Do not overwrite IVs slice memory X-Git-Tag: 4.0~10 X-Git-Url: http://www.git.cypherpunks.ru/?p=gogost.git;a=commitdiff_plain;h=edd431beb779e95ccff14114367e2fe7bf5d4f7a Do not overwrite IVs slice memory --- diff --git a/src/cypherpunks.ru/gogost/gost28147/cfb.go b/src/cypherpunks.ru/gogost/gost28147/cfb.go index b7b6050..902d12d 100644 --- a/src/cypherpunks.ru/gogost/gost28147/cfb.go +++ b/src/cypherpunks.ru/gogost/gost28147/cfb.go @@ -25,6 +25,9 @@ func (c *Cipher) NewCFBEncrypter(iv []byte) *CFBEncrypter { if len(iv) != BlockSize { panic("iv length is not equal to blocksize") } + encrypter := CFBEncrypter{c: c, iv: make([]byte, BlockSize)} + copy(encrypter.iv, iv) + return &encrypter } func (c *CFBEncrypter) XORKeyStream(dst, src []byte) { @@ -54,6 +57,9 @@ func (c *Cipher) NewCFBDecrypter(iv []byte) *CFBDecrypter { if len(iv) != BlockSize { panic("iv length is not equal to blocksize") } + decrypter := CFBDecrypter{c: c, iv: make([]byte, BlockSize)} + copy(decrypter.iv, iv) + return &decrypter } func (c *CFBDecrypter) XORKeyStream(dst, src []byte) {