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 support for XChaCha and XChaChaPoly1305 #18

Conversation

MatthiasValvekens
Copy link

This is a resubmit of haskell-crypto#365. Since the parent project is now defunct, I rebased them onto the master branch of this fork. The original PR description is included below.


This PR adds support for the extended nonce variants of ChaCha and ChaChaPoly1305, as implemented in libsodium (among others), and specified in this RFC draft: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha-03. Like haskell-crypto#364, I'm submitting this PR because I'd like to have this functionality in another project of mine that depends on cryptonite.

Since the only difference with the "base" cipher lies in the way the initial state is generated, the only change(s) in the Haskell API are a couple new initialisation functions & associated types. I considered overloading the existing initialize functions and branching on the length of the nonce, but I figured keeping them separate would be cleaner.

This addition did require a number of additions at the C level, though (mainly to implement the extra HChaCha primitive). I haven't written any "serious" C in a while, so some extra attention would be appreciated there. Obviously, comments on other aspects of the implementation are also more than welcome.

Thanks a lot!

Copy link
Owner

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

kazu-yamamoto added a commit that referenced this pull request Sep 25, 2023
@kazu-yamamoto
Copy link
Owner

Rebased and merged.
Thanks.

@MatthiasValvekens The current ChaCha API does not take "counter".
See Sec 2.4 of RFC 8439.
Are you interested in supporting "counter"?

@kazu-yamamoto
Copy link
Owner

Closing.

@intricate
Copy link

Hey @kazu-yamamoto, any idea when this will be included in a release? I'd very much like to use XChaCha20-Poly1305 in a project I'm working on 😃

@kazu-yamamoto
Copy link
Owner

Let's make a new release after #24 is merged.

@kazu-yamamoto
Copy link
Owner

v0.34 has been released.

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

Successfully merging this pull request may close these issues.

3 participants