1
0
mirror of https://github.com/golang/go synced 2024-11-20 10:34:42 -07:00

crypto/cipher: panic when IV length does not equal block size in NewOFB

Functions like NewCBCDecrypter, NewCBCEncrypter, NewCFBDecrypter,
NewCFBEncrypter and NewCTR all panic when IV length does not equal block size.
This commit changes NewOFB to panic too, instead of returning nil silently.

Change-Id: Ic4d3ebfad79bb0cf4759fa1c1a400c1a8d043490
Reviewed-on: https://go-review.googlesource.com/61850
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Filippo Valsorda <hi@filippo.io>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Joe Kyo 2017-09-06 10:31:03 +01:00 committed by Filippo Valsorda
parent 6c102e141c
commit 16edf0b1f7

View File

@ -19,7 +19,7 @@ type ofb struct {
func NewOFB(b Block, iv []byte) Stream {
blockSize := b.BlockSize()
if len(iv) != blockSize {
return nil
panic("cipher.NewOFB: IV length must equal block size")
}
bufSize := streamBufferSize
if bufSize < blockSize {