Removed lazy sodium both java and android
This commit is contained in:
16 files changed
+36
-50
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-9
@@ -1,11 +1,2 @@
|
||||
package com.ionspin.kotlin.crypto
|
||||
|
||||
import com.goterl.lazycode.lazysodium.SodiumAndroid
|
||||
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 22-Aug-2020
|
||||
*/
|
||||
typealias SodiumWrapper = SodiumAndroid
|
||||
+5
-2
@@ -1278,8 +1278,11 @@ interface JnaLibsodiumInterface : Library {
|
||||
//
|
||||
// // ---- Scalar multiplication ----
|
||||
//
|
||||
// fun crypto_scalarmult(privateKey: Uint8Array, publicKey: Uint8Array) : Uint8Array
|
||||
// fun crypto_scalarmult_base(privateKey: Uint8Array) : Uint8Array
|
||||
// int crypto_scalarmult(unsigned char *q, const unsigned char *n,
|
||||
// const unsigned char *p)
|
||||
fun crypto_scalarmult(q: ByteArray, n: ByteArray, p: ByteArray)
|
||||
// int crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
|
||||
fun crypto_scalarmult_base(q: ByteArray, b: ByteArray)
|
||||
//
|
||||
// // ---- Scalar multiplication end ----
|
||||
}
|
||||
+1
-3
@@ -45,16 +45,14 @@ actual object LibsodiumInitializer {
|
||||
return library
|
||||
}
|
||||
|
||||
lateinit var sodium : SodiumWrapper
|
||||
|
||||
lateinit var sodiumJna : JnaLibsodiumInterface
|
||||
actual suspend fun initialize() {
|
||||
sodium = SodiumWrapper()
|
||||
sodiumJna = loadLibrary()
|
||||
isPlatformInitialized = true
|
||||
}
|
||||
|
||||
actual fun initializeWithCallback(done: () -> Unit) {
|
||||
sodium = SodiumWrapper()
|
||||
sodiumJna = loadLibrary()
|
||||
isPlatformInitialized = true
|
||||
done()
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.ionspin.kotlin.crypto.kdf
|
||||
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodium
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
|
||||
|
||||
actual object Kdf {
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ actual object Kdf {
|
||||
val subkey = UByteArray(subkeyLength)
|
||||
val contextEncoded = context.encodeToByteArray()
|
||||
|
||||
sodium.crypto_kdf_derive_from_key(
|
||||
sodiumJna.crypto_kdf_derive_from_key(
|
||||
subkey.asByteArray(),
|
||||
subkeyLength,
|
||||
subkeyId.toLong(),
|
||||
@@ -42,8 +42,8 @@ actual object Kdf {
|
||||
*/
|
||||
actual fun keygen(): UByteArray {
|
||||
val masterKey = UByteArray(crypto_kdf_KEYBYTES)
|
||||
sodium.crypto_kdf_keygen(masterKey.asByteArray())
|
||||
sodiumJna.crypto_kdf_keygen(masterKey.asByteArray())
|
||||
return masterKey
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.ionspin.kotlin.crypto.scalarmult
|
||||
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodium
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
|
||||
|
||||
actual object ScalarMultiplication {
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ actual object ScalarMultiplication {
|
||||
actual fun scalarMultiplication(secretKeyN: UByteArray, publicKeyP: UByteArray): UByteArray {
|
||||
val result = UByteArray(crypto_scalarmult_BYTES)
|
||||
|
||||
sodium.crypto_scalarmult(result.asByteArray(), secretKeyN.asByteArray(), publicKeyP.asByteArray())
|
||||
sodiumJna.crypto_scalarmult(result.asByteArray(), secretKeyN.asByteArray(), publicKeyP.asByteArray())
|
||||
|
||||
|
||||
return result
|
||||
@@ -35,7 +35,7 @@ actual object ScalarMultiplication {
|
||||
): UByteArray {
|
||||
val result = UByteArray(crypto_scalarmult_BYTES)
|
||||
|
||||
sodium.crypto_scalarmult_base(result.asByteArray(), secretKeyN.asByteArray())
|
||||
sodiumJna.crypto_scalarmult_base(result.asByteArray(), secretKeyN.asByteArray())
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package com.ionspin.kotlin.crypto.secretstream
|
||||
|
||||
import com.goterl.lazycode.lazysodium.interfaces.SecretStream
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna
|
||||
import com.ionspin.kotlin.crypto.SecretStreamXChaCha20Poly1305State
|
||||
|
||||
|
||||
-2
@@ -35,8 +35,6 @@ actual object LibsodiumRandom {
|
||||
* The randombytes_random() function returns an unpredictable value between 0 and 0xffffffff (included).
|
||||
*/
|
||||
actual fun random(): UInt {
|
||||
//Broken in lazysodium-java https://github.com/terl/lazysodium-java/issues/86
|
||||
//Using temporary forked and fixed build until pull request is accepted in original repo
|
||||
return sodiumJna.randombytes_random().toUInt()
|
||||
}
|
||||
|
||||
|
||||
-9
@@ -1,11 +1,2 @@
|
||||
package com.ionspin.kotlin.crypto
|
||||
|
||||
import com.goterl.lazycode.lazysodium.LazySodiumJava
|
||||
import com.goterl.lazycode.lazysodium.SodiumJava
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 22-Aug-2020
|
||||
*/
|
||||
typealias SodiumWrapper = SodiumJava
|
||||
Reference in new issue
Block a user