1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:54:40 -07:00

crypto/cipher: bad CTR IV length now triggers panic

R=rsc
CC=golang-dev
https://golang.org/cl/4326042
This commit is contained in:
Adam Langley 2011-03-29 15:47:35 -04:00
parent d41d6fec10
commit 9225bbfc0c

View 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),