diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a39f58f..1032c51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ workflow: variables: GIT_SUBMODULE_STRATEGY: recursive CHROME_BIN: "chromium" + ANDROID_SDK_ROOT: "/android-sdk" simpleCheck: stage: prepare diff --git a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/stream/Stream.kt b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/stream/Stream.kt index f495685..7171c71 100644 --- a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/stream/Stream.kt +++ b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/stream/Stream.kt @@ -23,8 +23,8 @@ expect object Stream { fun chacha20IetfXor(message : UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray fun chacha20IetfXorIc(message : UByteArray, nonce: UByteArray, initialCounter: ULong, key: UByteArray) : UByteArray - fun xChacha20Keygen() : UByteArray - - fun xChacha20Xor(message : UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray - fun xChacha20XorIc(message : UByteArray, nonce: UByteArray, initialCounter: ULong, key: UByteArray) : UByteArray +// fun xChacha20Keygen() : UByteArray +// +// fun xChacha20Xor(message : UByteArray, nonce: UByteArray, key: UByteArray) : UByteArray +// fun xChacha20XorIc(message : UByteArray, nonce: UByteArray, initialCounter: ULong, key: UByteArray) : UByteArray } diff --git a/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/stream/StreamTest.kt b/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/stream/StreamTest.kt index 3d365fb..fa8d442 100644 --- a/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/stream/StreamTest.kt +++ b/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/stream/StreamTest.kt @@ -69,25 +69,25 @@ class StreamTest { } } - @Test - fun testXChaCha20IetfStream() = runTest { - LibsodiumInitializer.initializeWithCallback { - val message = "This is a cha cha message".encodeToUByteArray() - val nonce = LibsodiumRandom.bufDeterministic(crypto_stream_xchacha20_NONCEBYTES, seed) - val key = Stream.xChacha20Keygen() - val encryptedUsingLibsodium = Stream.xChacha20Xor(message, nonce, key) - val encryptedUsingLibsodiumWithInitialCounter = Stream.xChacha20XorIc(message, nonce, 0U, key) - println(encryptedUsingLibsodium.toHexString()) - println(encryptedUsingLibsodiumWithInitialCounter.toHexString()) - assertTrue { - encryptedUsingLibsodium.contentEquals(encryptedUsingLibsodiumWithInitialCounter) - } - val decryptedUsingLibsodium = Stream.xChacha20Xor(encryptedUsingLibsodium, nonce, key) - println(message.toHexString()) - println(decryptedUsingLibsodium.toHexString()) - assertTrue { - decryptedUsingLibsodium.contentEquals(message) - } - } - } +// @Test +// fun testXChaCha20IetfStream() = runTest { +// LibsodiumInitializer.initializeWithCallback { +// val message = "This is a cha cha message".encodeToUByteArray() +// val nonce = LibsodiumRandom.bufDeterministic(crypto_stream_xchacha20_NONCEBYTES, seed) +// val key = Stream.xChacha20Keygen() +// val encryptedUsingLibsodium = Stream.xChacha20Xor(message, nonce, key) +// val encryptedUsingLibsodiumWithInitialCounter = Stream.xChacha20XorIc(message, nonce, 0U, key) +// println(encryptedUsingLibsodium.toHexString()) +// println(encryptedUsingLibsodiumWithInitialCounter.toHexString()) +// assertTrue { +// encryptedUsingLibsodium.contentEquals(encryptedUsingLibsodiumWithInitialCounter) +// } +// val decryptedUsingLibsodium = Stream.xChacha20Xor(encryptedUsingLibsodium, nonce, key) +// println(message.toHexString()) +// println(decryptedUsingLibsodium.toHexString()) +// assertTrue { +// decryptedUsingLibsodium.contentEquals(message) +// } +// } +// } } diff --git a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt index 5e84813..2dbc0fe 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt @@ -80,41 +80,41 @@ actual object Stream { return result.toUByteArray() } - actual fun xChacha20Keygen(): UByteArray { - val result = getSodium().crypto_stream_xchacha20_keygen() - - return result.toUByteArray() - } - - actual fun xChacha20Xor( - message: UByteArray, - nonce: UByteArray, - key: UByteArray - ): UByteArray { - val result = getSodium().crypto_stream_xchacha20_xor( - message.toUInt8Array(), - nonce.toUInt8Array(), - key.toUInt8Array() - ) - - return result.toUByteArray() - } - - actual fun xChacha20XorIc( - message: UByteArray, - nonce: UByteArray, - initialCounter: ULong, - key: UByteArray - ): UByteArray { - val result = getSodium().crypto_stream_xchacha20_xor_ic( - message.toUInt8Array(), - nonce.toUInt8Array(), - initialCounter.toUInt(), - key.toUInt8Array() - ) - - return result.toUByteArray() - } +// actual fun xChacha20Keygen(): UByteArray { +// val result = getSodium().crypto_stream_xchacha20_keygen() +// +// return result.toUByteArray() +// } +// +// actual fun xChacha20Xor( +// message: UByteArray, +// nonce: UByteArray, +// key: UByteArray +// ): UByteArray { +// val result = getSodium().crypto_stream_xchacha20_xor( +// message.toUInt8Array(), +// nonce.toUInt8Array(), +// key.toUInt8Array() +// ) +// +// return result.toUByteArray() +// } +// +// actual fun xChacha20XorIc( +// message: UByteArray, +// nonce: UByteArray, +// initialCounter: ULong, +// key: UByteArray +// ): UByteArray { +// val result = getSodium().crypto_stream_xchacha20_xor_ic( +// message.toUInt8Array(), +// nonce.toUInt8Array(), +// initialCounter.toUInt(), +// key.toUInt8Array() +// ) +// +// return result.toUByteArray() +// } } diff --git a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt index a3fbc60..eaec0e9 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt @@ -96,49 +96,49 @@ actual object Stream { return result } - actual fun xChacha20Keygen(): UByteArray { - val result = UByteArray(crypto_stream_chacha20_KEYBYTES) - - sodiumJna.crypto_stream_xchacha20_keygen(result.asByteArray()) - - return result - } - - actual fun xChacha20Xor( - message: UByteArray, - nonce: UByteArray, - key: UByteArray - ): UByteArray { - val result = UByteArray(message.size) - - sodiumJna.crypto_stream_xchacha20_xor( - result.asByteArray(), - message.asByteArray(), - message.size.toLong(), - nonce.asByteArray(), - key.asByteArray() - ) - - return result - } - - actual fun xChacha20XorIc( - message: UByteArray, - nonce: UByteArray, - initialCounter: ULong, - key: UByteArray - ): UByteArray { - val result = UByteArray(message.size) - - sodiumJna.crypto_stream_xchacha20_xor_ic( - result.asByteArray(), - message.asByteArray(), - message.size.toLong(), - nonce.asByteArray(), - initialCounter.toLong(), - key.asByteArray() - ) - - return result - } +// actual fun xChacha20Keygen(): UByteArray { +// val result = UByteArray(crypto_stream_chacha20_KEYBYTES) +// +// sodiumJna.crypto_stream_xchacha20_keygen(result.asByteArray()) +// +// return result +// } +// +// actual fun xChacha20Xor( +// message: UByteArray, +// nonce: UByteArray, +// key: UByteArray +// ): UByteArray { +// val result = UByteArray(message.size) +// +// sodiumJna.crypto_stream_xchacha20_xor( +// result.asByteArray(), +// message.asByteArray(), +// message.size.toLong(), +// nonce.asByteArray(), +// key.asByteArray() +// ) +// +// return result +// } +// +// actual fun xChacha20XorIc( +// message: UByteArray, +// nonce: UByteArray, +// initialCounter: ULong, +// key: UByteArray +// ): UByteArray { +// val result = UByteArray(message.size) +// +// sodiumJna.crypto_stream_xchacha20_xor_ic( +// result.asByteArray(), +// message.asByteArray(), +// message.size.toLong(), +// nonce.asByteArray(), +// initialCounter.toLong(), +// key.asByteArray() +// ) +// +// return result +// } } diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt index 72d9c53..cbb9fee 100644 --- a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt +++ b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/stream/Stream.kt @@ -153,70 +153,70 @@ actual object Stream { return result } - actual fun xChacha20Keygen(): UByteArray { - val result = UByteArray(crypto_stream_xchacha20_KEYBYTES) - val resultPinned = result.pin() - - crypto_stream_xchacha20_keygen(resultPinned.toPtr()) - - resultPinned.unpin() - - return result - } - - actual fun xChacha20Xor( - message: UByteArray, - nonce: UByteArray, - key: UByteArray - ): UByteArray { - val result = UByteArray(message.size) - val messagePinned = message.pin() - val resultPinned = result.pin() - val noncePinned = nonce.pin() - val keyPinned = key.pin() - - crypto_stream_xchacha20_xor( - resultPinned.toPtr(), - messagePinned.toPtr(), - message.size.convert(), - noncePinned.toPtr(), - keyPinned.toPtr() - ) - - messagePinned.unpin() - resultPinned.unpin() - noncePinned.unpin() - keyPinned.unpin() - - return result - } - - actual fun xChacha20XorIc( - message: UByteArray, - nonce: UByteArray, - initialCounter: ULong, - key: UByteArray - ): UByteArray { - val result = UByteArray(message.size) - val messagePinned = message.pin() - val resultPinned = result.pin() - val noncePinned = nonce.pin() - val keyPinned = key.pin() - - crypto_stream_xchacha20_xor_ic( - resultPinned.toPtr(), - messagePinned.toPtr(), - message.size.convert(), - noncePinned.toPtr(), - initialCounter.convert(), - keyPinned.toPtr() - ) - - messagePinned.unpin() - resultPinned.unpin() - noncePinned.unpin() - keyPinned.unpin() - - return result - } +// actual fun xChacha20Keygen(): UByteArray { +// val result = UByteArray(crypto_stream_xchacha20_KEYBYTES) +// val resultPinned = result.pin() +// +// crypto_stream_xchacha20_keygen(resultPinned.toPtr()) +// +// resultPinned.unpin() +// +// return result +// } +// +// actual fun xChacha20Xor( +// message: UByteArray, +// nonce: UByteArray, +// key: UByteArray +// ): UByteArray { +// val result = UByteArray(message.size) +// val messagePinned = message.pin() +// val resultPinned = result.pin() +// val noncePinned = nonce.pin() +// val keyPinned = key.pin() +// +// crypto_stream_xchacha20_xor( +// resultPinned.toPtr(), +// messagePinned.toPtr(), +// message.size.convert(), +// noncePinned.toPtr(), +// keyPinned.toPtr() +// ) +// +// messagePinned.unpin() +// resultPinned.unpin() +// noncePinned.unpin() +// keyPinned.unpin() +// +// return result +// } +// +// actual fun xChacha20XorIc( +// message: UByteArray, +// nonce: UByteArray, +// initialCounter: ULong, +// key: UByteArray +// ): UByteArray { +// val result = UByteArray(message.size) +// val messagePinned = message.pin() +// val resultPinned = result.pin() +// val noncePinned = nonce.pin() +// val keyPinned = key.pin() +// +// crypto_stream_xchacha20_xor_ic( +// resultPinned.toPtr(), +// messagePinned.toPtr(), +// message.size.convert(), +// noncePinned.toPtr(), +// initialCounter.convert(), +// keyPinned.toPtr() +// ) +// +// messagePinned.unpin() +// resultPinned.unpin() +// noncePinned.unpin() +// keyPinned.unpin() +// +// return result +// } } diff --git a/supported_bindings_list.md b/supported_bindings_list.md index 59a530f..9ebd0a7 100644 --- a/supported_bindings_list.md +++ b/supported_bindings_list.md @@ -143,9 +143,9 @@ native libsodium library. | crypto_stream_chacha20_xor | :heavy_check_mark: | | crypto_stream_chacha20_xor_ic | :heavy_check_mark: | | crypto_stream_keygen | Other XSalsa20 primitives are not available, so I'm leaving this out as well| -| crypto_stream_xchacha20_keygen | :heavy_check_mark: | -| crypto_stream_xchacha20_xor | :heavy_check_mark: | -| crypto_stream_xchacha20_xor_ic | :heavy_check_mark: | +| crypto_stream_xchacha20_keygen | Not at the moment | +| crypto_stream_xchacha20_xor | Not at the moment | +| crypto_stream_xchacha20_xor_ic | Not at the moment | | randombytes_buf | :heavy_check_mark: | | randombytes_buf_deterministic | :heavy_check_mark: | | randombytes_close | not present in LazySodium |