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

gopherbot opened this issue May 30, 2013 · 3 comments

crypto/cipher: Add ECB support #5597

gopherbot opened this issue May 30, 2013 · 3 comments


Copy link

@gopherbot 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:
Copy link

@rsc rsc commented May 31, 2013

Comment 1:

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

@gopherbot 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.
Copy link

@agl 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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants