Skip to content

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

Closed
@mundaym

Description

@mundaym

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions