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: can't reuse BlockMode by NewCBCDecrypter() #11159
Labels
Comments
@alphaqiu thks, this can fix the issue, but as a std library, this seems not so nice.. |
Is there a documentation problem? |
@bradfitz |
As already mentioned, you don't need to crypto/cipher.cbcDecrypter
to be exported. You just need to type assert the blockmode to
interface{ SetIV([]byte) }.
If you just want to reuse cbcDecrypter, then there is another solution.
Just decrypt new IV as ciphertext, and the IV will be set to the IV you
want.
|
Isn't that inherent in the documentation for
crypto/cipher.BlockMode?
“A BlockMode represents a block cipher running
in a block-based mode (CBC, ECB etc).”
Different Key/IV pair correspond to different
BlockMode.
|
@minux thks, fixed |
mikioh
changed the title
crypto/cipher can't reuse BlockMode by NewCBCDecrypter()
crypto/cipher: can't reuse BlockMode by NewCBCDecrypter()
Jun 11, 2015
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
code:
http://play.golang.org/p/oZ5OwdRYLV
After cbcDecrypter.CryptBlocks, the x.iv is changed. so reuse BlockMode got a wrong decrypt text.
i saw the source code has a exported method : SetIV, but cbcEncrypter is not exported.
this means everytime i must new a cbcDecrypter object.
The text was updated successfully, but these errors were encountered: