whyoleg / cryptography-kotlin

Kotlin Multiplatform cryptography / crypto library
https://whyoleg.github.io/cryptography-kotlin/
Apache License 2.0
344 stars 20 forks source link

Cipher overloads #45

Closed morki closed 1 month ago

morki commented 2 months ago

Based on discussion in #38, we can continue here.

whyoleg commented 2 months ago

I will take a look in coming days. Probably there could be an issue with conflicting overloads because for AEAD + IV we can have encrypt(iv, plaintext) and encrypt(plaintext, additionalData) where both parameters are the same. Probably to make it work as expected the variant with explicit iv should be named differently (and old function is deprecated for in IvCipher). The other possibility is to introduce some class for parameters... But I don't really want to invest in researching their design.

I will come up with proposal and post it here and if you want you could implement it.

whyoleg commented 1 month ago

Hey @morki! Sorry for the delay, and for bringing some bad news: I've implemented this on my own :) The reason is simple: I needed to fix this, to be able to share some implementation details needed for support streaming AES encryption/decryption via kotlinx-io (which is WIP now). If you are curious, here are the changes: https://github.com/whyoleg/cryptography-kotlin/commit/a861a730230202d926aeb96377c219ffd40caf01. It's not merged yet, but will be available in the next release. New functions names are encryptWithIv and decryptWithIv. I was not able to deprecate old one because of the same overload clash error, so they were renamed without deprecation :(

Thanks for cooperation! Hope there will be something else in future to cooperate on!

morki commented 1 month ago

Nice to hear, thank you very much :)