Skip to content

implement djb legacy ChaCha20Poly1305 construction #703

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kamulos
Copy link

@kamulos kamulos commented Aug 3, 2025

This is a continuation of #304 : I rebased my changes and refactored most of it for better readability. I tried to do it in the most concrete way, without abstractions like the Cipher type in the crate. I don't think there is a big chance of code sharing with other algorithms.

Please have a look anytime for feedback. There is definitely some polishing to do, but in general I am happy with the state it is in and I also did some randomized testing with the libsodium. Encryption and decryption between the two libraries seem to work.

@tarcieri
Copy link
Member

tarcieri commented Aug 3, 2025

We have a crate for the libsodium-compatible ChaCha20Poly1305 secretbox construction here: https://github.com/RustCrypto/nacl-compat/tree/master/crypto_secretbox

Notably this construction doesn't support AAD, so it isn't actually an AEAD

@kamulos
Copy link
Author

kamulos commented Aug 3, 2025

Sorry, I can't entirely follow. Are you saying that what I did is already implemented? Are you saying that what I implemented is not an AEAD? Or is the link you provided something that I should have used to build what I did?

So what I implemented should use the associated data correctly. And it claims to be an AEAD. There should be compatibility with the following libsodium functions: crypto_aead_chacha20poly1305_encrypt, crypto_aead_chacha20poly1305_decrypt, crypto_aead_chacha20poly1305_encrypt_detached, crypto_aead_chacha20poly1305_decrypt_detached

@tarcieri
Copy link
Member

tarcieri commented Aug 3, 2025

TIL there's a third construction that calls itself ChaCha20Poly1305. Sigh.

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.

2 participants