FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
crypto/cipher: panic on invalid iv length

Give better user feedback when invalid iv is used
to construct a cipher.

Fixes issue 3411

Please review this at http://codereview.appspot.com/6656049/

Affected files:
M src/pkg/crypto/cipher/cbc.go
M src/pkg/crypto/cipher/cfb.go


Index: src/pkg/crypto/cipher/cbc.go
===================================================================
--- a/src/pkg/crypto/cipher/cbc.go
+++ b/src/pkg/crypto/cipher/cbc.go
@@ -33,6 +33,9 @@
// mode, using the given Block. The length of iv must be the same as the
// Block's block size.
func NewCBCEncrypter(b Block, iv []byte) BlockMode {
+ if len(iv) != self.BlockSize() {
+ panic("cipher.NewCBCEncrypter: iv length must equal block size")
+ }
return (*cbcEncrypter)(newCBC(b, iv))
}

@@ -58,6 +61,9 @@
// mode, using the given Block. The length of iv must be the same as the
// Block's block size and must match the iv used to encrypt the data.
func NewCBCDecrypter(b Block, iv []byte) BlockMode {
+ if len(iv) != self.BlockSize() {
+ panic("cipher.NewCBCDecrypter: iv length must equal block size")
+ }
return (*cbcDecrypter)(newCBC(b, iv))
}

Index: src/pkg/crypto/cipher/cfb.go
===================================================================
--- a/src/pkg/crypto/cipher/cfb.go
+++ b/src/pkg/crypto/cipher/cfb.go
@@ -17,6 +17,9 @@
// using the given Block. The iv must be the same length as the Block's
block
// size.
func NewCFBEncrypter(block Block, iv []byte) Stream {
+ if len(iv) != self.BlockSize() {
+ panic("cipher.NewCBFEncrypter: iv length must equal block size")
+ }
return newCFB(block, iv, false)
}

@@ -24,6 +27,9 @@
// using the given Block. The iv must be the same length as the Block's
block
// size.
func NewCFBDecrypter(block Block, iv []byte) Stream {
+ if len(iv) != self.BlockSize() {
+ panic("cipher.NewCBFEncrypter: iv length must equal block size")
+ }
return newCFB(block, iv, true)
}

Search Discussions

  • Minux at Oct 12, 2012 at 5:29 am
    Please note that this CL doesn't exist anymore on Rietveld.
  • Shane Hansen at Oct 12, 2012 at 5:52 am
    I'm sorry, I'm a real n00b with using hg change and hg mail.
    I had found a mistake in this one and neglected to update the
    original changeset properly.

    The new review is here:
    https://codereview.appspot.com/6652053/

    I appreciate your patience as I get familiar with the system.
    Thanks,
    --Shane Hansen
    On Thu, Oct 11, 2012 at 11:28 PM, minux wrote:

    Please note that this CL doesn't exist anymore on Rietveld.
  • Minux at Oct 12, 2012 at 6:30 am

    On Fri, Oct 12, 2012 at 1:46 PM, Shane Hansen wrote:

    The new review is here:
    https://codereview.appspot.com/6652053/

    I appreciate your patience as I get familiar with the system.
    It's OK, my note is just to redirect potential reviewers to the real CL.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 12, '12 at 5:12a
activeOct 12, '12 at 6:30a
posts4
users2
websitegolang.org

2 users in discussion

Minux: 2 posts Shane Hansen: 2 posts

People

Translate

site design / logo © 2022 Grokbase