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

Add an RFC 8439-compliant ChaCha implementation #1

Open
kernelmethod opened this issue May 11, 2022 · 0 comments
Open

Add an RFC 8439-compliant ChaCha implementation #1

kernelmethod opened this issue May 11, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@kernelmethod
Copy link
Owner

ChaChaStream and CUDAChaChaStream both use the original implementation of ChaCha, which has a 64-bit nonce and 64-bit counter. In contrast, IETF RFC 8439 specifies that ChaCha should use a 96-bit nonce and 32-bit counter.

For CRNG purposes, the original construction makes a little more sense. A 32-bit counter only allows you to generate 256 GiB of random data before rotating the nonce, while a 64-bit counter generates 1 ZiB, which is large enough to effectively be ignored for most usecases. Nonetheless, it would be useful for us to include an RFC 8439-compliant implementation of the cipher since it's the more common version due to its usage in ChaCha20-Poly1305.

The easiest way to do this might be to add an abstract type that holds a combined nonce + counter and exposes an interface for using it in the initial ChaCha state and for incrementing it. We could then dispatch on the nonce type to support either a 64-bit nonce + 64-bit counter or 96-bit nonce + 32-bit counter. This might also make it easier to add XChaCha20 later.

@kernelmethod kernelmethod added the enhancement New feature or request label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant