-
Notifications
You must be signed in to change notification settings - Fork 51
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
chacha20: 64-bit counter support #334
Comments
I have some seemingly working code for this, but it builds on the Rng PR with |
Let's try to land #333 first |
I took another look at my 64-bit counter code, and it isn't working correctly on the NEON backend atm. It uses a const bool in The largest use-case for a 64-bit counter (that I can think of) is file system encryption for mobile devices. I've ran some benches, and I will keep working on it a little, but I'd probably prefer a solution that doesn't need to modify the backends, if that's possible. Because the way it is now, every new backend would also need to have specific code for updating the counter |
On second thought, I feel like more control over a larger nonce would be favorable over having a larger counter |
@nstilt1 not sure what you mean by that? Are you suggesting making the construction generic over the nonce size rather than a larger counter? |
@tarcieri I'm suggesting that 64-bit counters are unnecessary, contrary to what I've said previously. I think having 96 bits for a nonce is more practical because it is easier to prevent nonce reuse with finer control over the value. What do you mean about making the construction generic over the nonce size? |
I wasn't sure what you meant by "more control over a larger nonce". I agree practically larger counter support probably doesn't matter which is why the current implementation avoided dealing with it. I'm not sure the added complexity is worth it, though it could be considered a compatibility bug with the legacy implementation which is somewhat surprisingly pervasive. |
The
ChaCha20Legacy
construction, i.e. the djb variant, is supposed to use a 64-bit counter but currently uses a 32-bit counter because it shares its core implementation with the IETF construction which uses a 32-bit counter.This results in a counter overflow after generating 256 GiB of keystream. Compatible implementations are able to generate larger keystreams.
I'm not sure how much of a practical concern this actually is, but it did come up in discussions here: rust-random/rand#934 (comment)
We can probably make the counter type generic between
u32
/u64
in the core implementation if need be.The text was updated successfully, but these errors were encountered: