Do you want a slightly simpler solution to #25 "Break "random access read/write" AES CTR"? Did you ever wanted to add a crate release (from git) that isn't at ?
As I mentioned on the previous page I was detailing challenge point and over-viewed few solutions. Usually I return back to existing solutions to see the alternatives and check my own solution sanity and correctness. This time was a bit different.
Surprisingly I didn't found my solution among those I viewed, so let me share it with you. Not to repeat common part in all of them, I just link a fresh write-up I liked, and quickly note that instead of getting the key and then deciphering with it, we can just feed our ciphertext to the edit
function twice: as the one we want to edit (basically it will get us right length in most implementations) and the second time as "plaintext" we want to re-encrypt. (Offset should be 0, of course. So the key-stream would be aligned.) This simple trick/tweak will just apply the key-stream against ciphertext and as the result of "edit
" we get plaintext.
Rust code of the solution: https://github.com/skaunov/challenge-25.
Bonus
I wondered of a clean way to import a particular version of crate from git, as the one I used isn't available from . And it turned out to be just a few lines to do it neatly.
[dependencies.ctr]
git = "https://github.com/RustCrypto/block-modes.git"
tag = "ctr-v0.9.1"
Top comments (0)