From: Joe Kyo Date: Wed, 6 Sep 2017 09:31:03 +0000 (+0100) Subject: crypto/cipher: panic when IV length does not equal block size in NewOFB X-Git-Tag: go1.10beta1~1214 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=16edf0b1f7401df07e0d2f96c8b97516e50cffd9;p=gostls13.git 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 Run-TryBot: Filippo Valsorda TryBot-Result: Gobot Gobot --- diff --git a/src/crypto/cipher/ofb.go b/src/crypto/cipher/ofb.go index e86ebcb237..7b35f8995c 100644 --- a/src/crypto/cipher/ofb.go +++ b/src/crypto/cipher/ofb.go @@ -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 {