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: Infinite loop in CTR mode #12975

Closed
spance opened this issue Oct 18, 2015 · 2 comments
Closed

crypto/cipher: Infinite loop in CTR mode #12975

spance opened this issue Oct 18, 2015 · 2 comments

Comments

@spance
Copy link

spance commented Oct 18, 2015

go version: 1.5.1
system: windows/amd64 and linux/amd64

CTR cipher mode will run into infinite loop when blockSize >= 512.

Test code:

package main

import (
    "crypto/aes"
    "crypto/cipher"
)

var bigBlockSize = 512

type BigBlock struct {
    cipher.Block
}

func (*BigBlock) BlockSize() int { return bigBlockSize }

func main() {
    buf := make([]byte, 512)
    aesBlock, _ := aes.NewCipher(buf[:16])
    bigBlock := &BigBlock{aesBlock}
    ctr := cipher.NewCTR(bigBlock, buf)
    ctr.XORKeyStream(buf, buf) // Infinite Loop if bigBlockSize >= 512
}
@gopherbot
Copy link

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

@spance
Copy link
Author

spance commented Oct 20, 2015

It works.

@spance spance closed this as completed Oct 20, 2015
agl pushed a commit that referenced this issue Oct 20, 2015
Additionally, add a test for CTR mode to cover a range of block sizes.

Fixes #12975

Change-Id: I458aac1616228747e62f92f823768d55e874877a
Reviewed-on: https://go-review.googlesource.com/16050
Reviewed-by: Adam Langley <agl@golang.org>
@golang golang locked and limited conversation to collaborators Oct 24, 2016
@rsc rsc unassigned agl Jun 23, 2022
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