netpyoung / unity.libsodium

🔑 libsodium made easy for Unity3d
MIT License
17 stars 4 forks source link

Updated partly to libsodium 1.0.16 #2

Closed Ekwav closed 6 years ago

Ekwav commented 6 years ago

implemented the cryptokx* functions needed for keyexchange

Ekwav commented 6 years ago

Partly, because I only implemented the new functions I currently need.

netpyoung commented 6 years ago

lol too many changes. include line ending changes. I need time to check. I will check it later. and is there reason to change sodium.dll to libsodium.dll?

Ekwav commented 6 years ago

I got confused about the lib prefix or not lib prefix 😅 Windows and iOS(x64): no everything else: yes

netpyoung commented 6 years ago

so you just add this native functions,

+              [DllImport(DLL_NAME)] public static extern int crypto_kx_seed_keypair(byte[] publicKey, byte[] secretKey, byte[] seed);
+       [DllImport(DLL_NAME)] public static extern int crypto_kx_keypair(byte[] publicKey, byte[] secretKey);
+       [DllImport(DLL_NAME)] public static extern int crypto_kx_client_session_keys(byte[] rx, byte[] tx, byte[] client_pk, byte[] client_sk, byte[] server_pk);
+       [DllImport(DLL_NAME)] public static extern int crypto_kx_server_session_keys(byte[] rx, byte[] tx, byte[] server_pk, byte[] server_sk, byte[] client_pk);

and wraper string method

+       public static byte[] EncryptChaCha20(string message, byte[] nonce, byte[] key)

In your commit, there are some difference in indent style and file line ending. so it will make big diff on master.

I will post pone merge this commit on master, and I will ffind a way to apply 1.0.16, so it take a time to apply on your changes.