]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost28147/cfb.go
Simplify keys and IVs arguments passing: use slices instead of arrays
[gogost.git] / src / cypherpunks.ru / gogost / gost28147 / cfb.go
index c94bdbbfc2d566ddc93bf552b42f56d2eefa68e8..b7b605007c7e19f7176e9629ad177b18b468f8a5 100644 (file)
@@ -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) {