//
// 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
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
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")
+ }
+ encrypter := CFBEncrypter{c: c, iv: make([]byte, BlockSize)}
+ copy(encrypter.iv, iv)
+ return &encrypter
}
func (c *CFBEncrypter) XORKeyStream(dst, src []byte) {
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")
+ }
+ decrypter := CFBDecrypter{c: c, iv: make([]byte, BlockSize)}
+ copy(decrypter.iv, iv)
+ return &decrypter
}
func (c *CFBDecrypter) XORKeyStream(dst, src []byte) {