]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/cipher: bad CTR IV length now triggers panic
authorAdam Langley <agl@golang.org>
Tue, 29 Mar 2011 19:47:35 +0000 (15:47 -0400)
committerAdam Langley <agl@golang.org>
Tue, 29 Mar 2011 19:47:35 +0000 (15:47 -0400)
R=rsc
CC=golang-dev
https://golang.org/cl/4326042

src/pkg/crypto/cipher/ctr.go

index 04436ec23b0115d6a819c5443f1390cc44420f32..147b74fc2fd4d7a24c7592410e6aa4b235854a95 100644 (file)
@@ -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),