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

Closed
gopherbot opened this Issue May 30, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@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: https://golang.org/cl/7860047/
@rsc

This comment has been minimized.

Contributor

rsc commented May 31, 2013

Comment 1:

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

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.
@agl

This comment has been minimized.

Contributor

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:]
}
[1] http://golang.org/pkg/crypto/cipher/#Block

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.