From: Adam Langley Date: Tue, 29 Mar 2011 19:47:35 +0000 (-0400) Subject: crypto/cipher: bad CTR IV length now triggers panic X-Git-Tag: weekly.2011-04-04~56 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9225bbfc0c6559aa4002ea8f35696cd74475429d;p=gostls13.git crypto/cipher: bad CTR IV length now triggers panic R=rsc CC=golang-dev https://golang.org/cl/4326042 --- diff --git a/src/pkg/crypto/cipher/ctr.go b/src/pkg/crypto/cipher/ctr.go index 04436ec23b..147b74fc2f 100644 --- a/src/pkg/crypto/cipher/ctr.go +++ b/src/pkg/crypto/cipher/ctr.go @@ -22,6 +22,10 @@ type ctr struct { // NewCTR returns a Stream which encrypts/decrypts using the given Block in // counter mode. The length of iv must be the same as the Block's block size. func NewCTR(block Block, iv []byte) Stream { + if len(iv) != block.BlockSize() { + panic("cipher.NewCTR: iv length must equal block size") + } + return &ctr{ b: block, ctr: dup(iv),