Commit 9225bbfc authored by Adam Langley's avatar Adam Langley

crypto/cipher: bad CTR IV length now triggers panic

R=rsc
CC=golang-dev
https://golang.org/cl/4326042
parent d41d6fec
...@@ -22,6 +22,10 @@ type ctr struct { ...@@ -22,6 +22,10 @@ type ctr struct {
// NewCTR returns a Stream which encrypts/decrypts using the given Block in // 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. // counter mode. The length of iv must be the same as the Block's block size.
func NewCTR(block Block, iv []byte) Stream { func NewCTR(block Block, iv []byte) Stream {
if len(iv) != block.BlockSize() {
panic("cipher.NewCTR: iv length must equal block size")
}
return &ctr{ return &ctr{
b: block, b: block,
ctr: dup(iv), ctr: dup(iv),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment