Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/cipher: panic on s390x when len(src) == 0 #17435

Closed
mundaym opened this issue Oct 13, 2016 · 2 comments
Closed

crypto/cipher: panic on s390x when len(src) == 0 #17435

mundaym opened this issue Oct 13, 2016 · 2 comments

Comments

@mundaym
Copy link
Member

mundaym commented Oct 13, 2016

What version of Go are you using (go version)?

go version go1.7.1 linux/s390x

What did you do?

Encrypt an empty plaintext using AES in CBC mode.

c := cipher.NewCBCEncrypter(b, iv[:])
pt := make([]byte, 0)
c.CryptBlocks(pt, pt)
fmt.Println("ok!")

https://play.golang.org/p/InSmIcI_MT

What did you expect to see?

ok!

What did you see instead?

panic: runtime error: index out of range

goroutine 1 [running]:
panic(0xb2c00, 0x1245f0)
    /localbox/munday/go/src/runtime/panic.go:527 +0x190
crypto/aes.(*cbc).CryptBlocks(0xc42000e220, 0x14fad8, 0x0, 0x0, 0x14fad8, 0x0, 0x0)
    /localbox/munday/go/src/crypto/aes/cbc_s390x.go:51 +0xd8
main.main()
    /localbox/munday/main.go:18 +0x122
exit status 2

Will send a CL to fix (I'm working on a test now). If there is still time I'd like to get this fix into 1.7.2.

@gopherbot
Copy link

CL https://golang.org/cl/31070 mentions this issue.

@bradfitz bradfitz added this to the Go1.7.2 milestone Oct 13, 2016
@gopherbot
Copy link

CL https://golang.org/cl/31291 mentions this issue.

gopherbot pushed a commit that referenced this issue Oct 17, 2016
… when src length is 0

Adds a test to check that block cipher modes accept a zero-length
input.

Fixes #17435.

Change-Id: Ie093c4cdff756b5c2dcb79342e167b3de5622389
Reviewed-on: https://go-review.googlesource.com/31070
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/31291
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Run-TryBot: Chris Broadfoot <cbro@golang.org>
ceseo pushed a commit to powertechpreview/go that referenced this issue Dec 1, 2016
… when src length is 0

Adds a test to check that block cipher modes accept a zero-length
input.

Fixes golang#17435.

Change-Id: Ie093c4cdff756b5c2dcb79342e167b3de5622389
Reviewed-on: https://go-review.googlesource.com/31070
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/31291
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Run-TryBot: Chris Broadfoot <cbro@golang.org>
@golang golang locked and limited conversation to collaborators Oct 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants