firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 46 forks source link

XChaCha20-Poly1305-IETF Usage #4

Closed jeprojects closed 5 years ago

jeprojects commented 5 years ago

Thanks for putting together this package.

Is there anyway to get access to libsodiums XChaCha20-Poly1305-IETF?

kozw commented 5 years ago

Would love to add that API, and it's working for iOS, but the Android version has a dependency on libsodium-jni, which does not include XChaCha20-Poly1305-IETF.

This needs to be sorted, there are other Android APIs missing as well. Developing...

jeprojects commented 5 years ago

I see that chacha20poly1305 is exposed in libsodium-jni. Can this be accessed through flutter_sodium?

I can see that there already has been a request to add XChaCha20-Poly1305-IETF to libsodium-jni 3 months ago: https://github.com/joshjdevl/libsodium-jni/issues/100

kozw commented 5 years ago

It should be no problem to add chacha20poly1305. However since xchacha20poly1305 is the preferred AEAD construction, this needs to be fixed. Look like I need to dive into libsodium-jni.

jeprojects commented 5 years ago

I think it would be good to add both as chacha20poly1305-ieft is compatible with other libraries where as xchacha20poly1305 can only be used with libsodium.

kozw commented 5 years ago

Agreed. Just released 1.0.6 with support for both chacha20poly1305 and chacha20poly1305-ietf. xchacha20poly1305 is also available, but only works on iOS. For both variants of chacha20poly1305, combined mode is fully supported, detached mode only works on iOS.

jeprojects commented 5 years ago

Awesome work. Thanks!

jeprojects commented 5 years ago

I just noticed that libsodium jni also has secret stream high-level api available which uses xchacha20poly1305.

https://github.com/joshjdevl/libsodium-jni/blob/master/src/test/java/org/libsodium/jni/crypto/SecretStreamTest.java

https://download.libsodium.org/doc/secret-key_cryptography/secretstream.html

kozw commented 5 years ago

There are more libsodium APIs not yet available in flutter_sodium. Eventually the plan is to support them all.

jeprojects commented 5 years ago

Just need to do tests up for this and then can do a pull request to add the xchacha20poly1305-ieft methods + chacha20poly1305-ietf & chacha20poly1305 detached mode to libsodium-jni.

https://github.com/joshjdevl/libsodium-jni/issues/116

kozw commented 5 years ago

That is amazing! For your information, I've created an issue with the complete list of missing APIs in libsodiumjni (#7).