diff options
| author | Joe Kyo <xunianzu@gmail.com> | 2017-09-06 10:31:03 +0100 |
|---|---|---|
| committer | Filippo Valsorda <hi@filippo.io> | 2017-09-06 14:53:44 +0000 |
| commit | 16edf0b1f7401df07e0d2f96c8b97516e50cffd9 (patch) | |
| tree | 8032f353c26ce283f32f98d483fbf99fa46462e0 /src/crypto | |
| parent | 6c102e141c5858d1b900afad8dd616370f6091bb (diff) | |
| download | go-16edf0b1f7401df07e0d2f96c8b97516e50cffd9.tar.xz | |
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>
Diffstat (limited to 'src/crypto')
| -rw-r--r-- | src/crypto/cipher/ofb.go | 2 |
1 files changed, 1 insertions, 1 deletions
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 { |
