RustCrypto / block-ciphers

Collection of block cipher algorithms written in pure Rust
670 stars 131 forks source link

threefish: add method to update tweak between encrypt/decrypt calls #459

Open k3rb3ros opened 3 hours ago

k3rb3ros commented 3 hours ago

Currently, there is no way to update the tweak value between successive encrypt/decrypt calls without creating a new cipher instance. This is inefficient and it would be appreciated if you added a way to update the tweak without creating a new cipher instance. I'm not sure it would be possible to add given that your current implementation stores all of the cipher state in a giant array sk, but in the original C implementation keyCtx is passed into every encrypt/decrypt call, which allowed the tweak to be changed between cipher calls without mucking with the rest of the cipher state.

newpavlov commented 2 hours ago

We probably should first add a trait for tweakable block ciphers, see: https://github.com/RustCrypto/traits/issues/177