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: Add ECB support #5597

gopherbot opened this Issue May 30, 2013 · 3 comments


None yet
3 participants

gopherbot commented May 30, 2013

by hebipp1:

ECB support would be nice. There was also a patch already which was not pulled because
of the Go 1.1 feature freeze:

This comment has been minimized.


rsc commented May 31, 2013

Comment 1:

Why? We left ECB out intentionally: it's insecure, and if needed it's
trivial to implement.

This comment has been minimized.

gopherbot commented May 31, 2013

Comment 2 by hebipp1:

Well, I need it to implement a protocol (to encrypt the IV that's sended before the
actual content) and I don't know much about cryptography, so I'm a bit cautious to
implement it myself.

This comment has been minimized.


agl commented May 31, 2013

Comment 3:

IV are supposed to be public and shouldn't be encrypted, but anyway...
ECB is essentially "no mode" and while it isn't supported in a named fashion,
crypto/cipher.Block.Encrypt and Decrypt implement it on a block by block basis. You just
need to feed in a multiple of the blocksize:
bs := block.BlockSize()
if len(plaintext) % bs != 0 {
  panic("Need a multiple of the blocksize")
ciphertext := make([]byte, len(plaintext))
for len(plaintext) > 0 {
  block.Encrypt(ciphertext, plaintext)
  plaintext = plaintext[bs:]
  ciphertext = ciphertext[bs:]

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.