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

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

Open
k3rb3ros opened this issue Oct 24, 2024 · 7 comments
Open

Comments

@k3rb3ros
Copy link

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
Copy link
Member

We probably should first add a trait for tweakable block ciphers, see: RustCrypto/traits#177

@k3rb3ros
Copy link
Author

That would be great. What's the timeline for feature development in RustCrypto like that? Weeks, months, years?

@tarcieri
Copy link
Member

Weeks (or less) if you want to get it into an unstable release, depending on the quality of the PR

@tarcieri
Copy link
Member

(I would personally love to see traits for tweakable block ciphers land finally)

@newpavlov
Copy link
Member

I guess the main question is what API style should we use: one where we pass tweak during en/decryption of each block, or one where we modify block cipher state with a &mut self method. Initially, I thought to use the former, but the latter should be more composable and will require less changes in the cipher crate, but it may be less convenient in cases where users want to keep cipher state immutable.

@k3rb3ros
Copy link
Author

Personally, I think encapsulating cipher state from the users is a better approach, but I don't have much context on the RustCrypto project and I'm not a cryptographer. I'm just a dude on the internet who wants a feature. Although, as you said adding tweak to every cipher operation would require the greatest number of changes. You could also add additional encrypt/decrypt functions that take a tweak and then turn the existing encrypt functions into wrapper functions that call the tweak parameter versions with a zeroed-out tweak.

@tarcieri
Copy link
Member

Maybe RustCrypto/traits#177 is a better place for these discussions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants