X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost28147%2Fcfb.go;h=b7b605007c7e19f7176e9629ad177b18b468f8a5;hb=69e668f3499122e0b1140f3bd927de41ad279b94;hp=5c39ffa8b76195c3e94f4ad7fa7757a5fc9afc41;hpb=014be6ab0719643d1e2996a360ab0619124b7e0e;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost28147/cfb.go b/src/cypherpunks.ru/gogost/gost28147/cfb.go index 5c39ffa..b7b6050 100644 --- a/src/cypherpunks.ru/gogost/gost28147/cfb.go +++ b/src/cypherpunks.ru/gogost/gost28147/cfb.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2017 Sergey Matveev +// Copyright (C) 2015-2019 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,8 +21,10 @@ type CFBEncrypter struct { iv []byte } -func (c *Cipher) NewCFBEncrypter(iv [BlockSize]byte) *CFBEncrypter { - return &CFBEncrypter{c, iv[:]} +func (c *Cipher) NewCFBEncrypter(iv []byte) *CFBEncrypter { + if len(iv) != BlockSize { + panic("iv length is not equal to blocksize") + } } func (c *CFBEncrypter) XORKeyStream(dst, src []byte) { @@ -48,8 +50,10 @@ type CFBDecrypter struct { iv []byte } -func (c *Cipher) NewCFBDecrypter(iv [BlockSize]byte) *CFBDecrypter { - return &CFBDecrypter{c, iv[:]} +func (c *Cipher) NewCFBDecrypter(iv []byte) *CFBDecrypter { + if len(iv) != BlockSize { + panic("iv length is not equal to blocksize") + } } func (c *CFBDecrypter) XORKeyStream(dst, src []byte) {