WIP: Legacy ChaCha20Poly1305 Construction#304
WIP: Legacy ChaCha20Poly1305 Construction#304kamulos wants to merge 1 commit intoRustCrypto:masterfrom
Conversation
|
Unfortunately it looks like you won't be able to use Here's the "djb" version: Here's the IETF version: If I'm reading these correctly, the Poly1305 inputs differ in the following way:
Where:
Here's an example of unpadded Poly1305: https://github.com/RustCrypto/AEADs/blob/458a8a8/xsalsa20poly1305/src/lib.rs#L284 |
|
Thanks for the fast analysis, that helped a lot! I just hacked something into a commit, that seems to be working, but obviously is not any good. My main problem is, that the |
|
@kamulos unfortunately the Sorry to stray even further from "this will be easy", but it seems like to implement this construction on top of the current API the @newpavlov has written a number of abstractions for this sort of thing and may be able to help.
If you implement a block-sized buffer (16-bytes), you can pass data a block-at-a-time to Poly1305 using the |
|
😄 no worries, that doesn't sound too bad. I think I have all the necessary information now. I will prepare something as soon as I find time and send it to you for a review. |
0bb63ea to
e8ec2ae
Compare
e8ec2ae to
b06ed94
Compare
|
OK, I found a little bit of time and made progress. Can you have a look at the
|
|
You don't need to worry about trying to impl any traits for it since it's a private implementation detail used only for this purpose. |
|
Closing this PR as stale. Please rebase and open an new PR if you'd like to continue it. |
I just quickly copied the code from the
xchacha20poly1305module and adapted it toChaCha20Legacytogether with theLegacyNonce. I set theNonceSizetoU8.It is however not working and I could use some hints where to search. When I encrypt using libsodium and decrypt using my new module the mac verification fails (
if self.mac.verify(tag).is_ok()incipher.rs:87). When I do the same thing with XChaCha20Poly1305 everything works. So probably I just did not change something I am supposed to change, but I don't know what that is.This is my test program:
Cargo.toml
main.rs (comment in and out to switch to xchacha)