jlouis / enacl

Erlang bindings for NaCl / libsodium
MIT License
197 stars 59 forks source link

Add support for AEAD XChaCha20-Poly1305 #39

Closed ECrownofFire closed 4 years ago

ECrownofFire commented 5 years ago

Pretty much just a copy-paste from the existing ChaCha20-Poly1305 functions, with the exception that Nonce is taken as a binary.

Edit: Though considering #32 (and #33, which never got merged), this may be a good time to swap the arguments around to where they should be instead of following the existing ChaCha20-Poly1305 functions.

jlouis commented 5 years ago

Thank you!

I'm currently a bit behind in patches to this repository, but I'll get to it. From a quick skim, it is looking good :)

ECrownofFire commented 5 years ago

Oh yeah, I actually just noticed #32 (and #33). I was admittedly really lazy in doing a quick copy-paste and s/chacha/xchacha lol, but maybe it'd be a good time to swap the arguments around to where they should be? And change the ChaCha20-Poly1305 one to take a proper binary nonce instead of a 64-bit integer...

jlouis commented 5 years ago

Yeah, and in addition, more QuickCheck tests as well so I can capture a lot of the trouble early on for users. I'm more or less contemplating deprecating the enacl module and introducing sodium instead, just to make sure I create enough of a mess in people's code that they don't accidentally use the wrong parameters.

And I agree on the nonce being a binary. It is closer to the specification and probably also better: Erlang could use an arbitrary sized integer, which I'm sure breeds trouble. And if the old behavior is needed, it is rather simple to do something like <<I:24/integer>> for a 24 bit integer I.

rockwood commented 5 years ago

Hey, just wondering how we could help get this merged. Our app relies on a third-party that uses the x variant of ChaCha20.

spscream commented 4 years ago

We also need this. Please consider to merge it.

jlouis commented 4 years ago

This has now been merged to master. But note I might want to fix the argument orders as well on this one and the chacha20 variant. Also, need some tests on the beast, which I currently don't have.