diff --git a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ed25519/Ed25519.kt b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ed25519/Ed25519.kt index e3b33d3..79fb7c0 100644 --- a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ed25519/Ed25519.kt +++ b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ed25519/Ed25519.kt @@ -17,17 +17,10 @@ const val crypto_core_ed25519_NONREDUCEDSCALARBYTES = 64 const val crypto_scalarmult_ed25519_BYTES = 32U const val crypto_scalarmult_ed25519_SCALARBYTES = 32U -enum class HashToCurveAlgorithm(val id: Int) { - SHA256(1), - SHA512(2), -} - expect abstract class Ed25519LowLevel() { fun isValidPoint(encoded: UByteArray): Boolean fun addPoints(p: UByteArray, q: UByteArray): UByteArray fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray - fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray - fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray fun encodedPointFromUniform(uniform: UByteArray): UByteArray fun randomEncodedPoint(): UByteArray fun randomEncodedScalar(): UByteArray @@ -51,12 +44,6 @@ object Ed25519 : Ed25519LowLevel() { fun subtract(p: Point, q: Point): Point = Point(subtractPoints(p.encoded, q.encoded)) - fun pointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point = - Point(encodedPointFromString(ctx, msg, hashAlg)) - - fun pointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point = - Point(encodedPointFromStringRo(ctx, msg, hashAlg)) - fun pointFromUniform(uniform: UByteArray): Point = Point(encodedPointFromUniform(uniform)) fun randomPoint(): Point = Point(randomEncodedPoint()) diff --git a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ristretto255/Ristretto255.kt b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ristretto255/Ristretto255.kt index 8d68157..8a43cea 100644 --- a/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ristretto255/Ristretto255.kt +++ b/multiplatform-crypto-libsodium-bindings/src/commonMain/kotlin/com.ionspin.kotlin.crypto/ristretto255/Ristretto255.kt @@ -1,8 +1,6 @@ package com.ionspin.kotlin.crypto.ristretto255 -import com.ionspin.kotlin.crypto.ed25519.HashToCurveAlgorithm import com.ionspin.kotlin.crypto.util.LibsodiumUtil -import kotlin.UByteArray /** * Created by Johannes Leupold @@ -23,8 +21,6 @@ expect abstract class Ristretto255LowLevel() { fun addPoints(p: UByteArray, q: UByteArray): UByteArray fun subtractPoints(p: UByteArray, q: UByteArray): UByteArray fun encodedPointFromHash(hash: UByteArray): UByteArray - fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray - fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray fun randomEncodedPoint(): UByteArray fun randomEncodedScalar(): UByteArray fun invertScalar(scalar: UByteArray): UByteArray @@ -47,12 +43,6 @@ object Ristretto255 : Ristretto255LowLevel() { fun pointFromHash(hash: UByteArray): Point = Point(encodedPointFromHash(hash)) - fun pointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point = - Point(encodedPointFromString(ctx, msg, hashAlg)) - - fun pointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): Point = - Point(encodedPointFromStringRo(ctx, msg, hashAlg)) - fun randomPoint(): Point = Point(randomEncodedPoint()) fun randomScalar(): Scalar = Scalar(randomEncodedScalar()) diff --git a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/JsSodiumInterface.kt b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/JsSodiumInterface.kt index 96b4ed4..71e4b31 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/JsSodiumInterface.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/JsSodiumInterface.kt @@ -375,12 +375,6 @@ external object JsSodiumInterface { @JsName("crypto_core_ristretto255_from_hash") fun crypto_core_ristretto255_from_hash(r: Uint8Array): Uint8Array - @JsName("crypto_core_ristretto255_from_string") - fun crypto_core_ed25519_from_string(ctx: String?, message: Uint8Array, hashAlg: Int): Uint8Array - - @JsName("crypto_core_ristretto255_from_string_ro") - fun crypto_core_ed25519_from_string_ro(ctx: String?, message: Uint8Array, hashAlg: Int): Uint8Array - @JsName("crypto_core_ristretto255_add") fun crypto_core_ristretto255_add(p: Uint8Array, q: Uint8Array): Uint8Array @@ -430,12 +424,6 @@ external object JsSodiumInterface { @JsName("crypto_core_ed25519_random") fun crypto_core_ed25519_random(): Uint8Array - @JsName("crypto_core_ed25519_from_string") - fun crypto_core_ed25519_from_string(ctx: String, message: Uint8Array, hashAlg: Int): Uint8Array - - @JsName("crypto_core_ed25519_from_string_ro") - fun crypto_core_ed25519_from_string_ro(ctx: String, message: Uint8Array, hashAlg: Int): Uint8Array - @JsName("crypto_core_ed25519_from_uniform") fun crypto_core_ed25519_from_uniform(r: Uint8Array): Uint8Array diff --git a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt index 5908adf..0e03232 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt @@ -20,18 +20,6 @@ actual abstract class Ed25519LowLevel actual constructor() { return result.toUByteArray() } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = getSodium().crypto_core_ed25519_from_string(ctx, msg.toUInt8Array(), hashAlg.id) - - return result.toUByteArray() - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = getSodium().crypto_core_ed25519_from_string_ro(ctx, msg.toUInt8Array(), hashAlg.id) - - return result.toUByteArray() - } - actual fun encodedPointFromUniform(uniform: UByteArray): UByteArray { val result = getSodium().crypto_core_ed25519_from_uniform(uniform.toUInt8Array()) diff --git a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt index c1e8355..6201a02 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jsMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt @@ -26,18 +26,6 @@ actual abstract class Ristretto255LowLevel actual constructor() { return result.toUByteArray() } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = getSodium().crypto_core_ristretto255_from_string(ctx, msg.toUInt8Array(), hashAlg.id) - - return result.toUByteArray() - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = getSodium().crypto_core_ristretto255_from_string_ro(ctx, msg.toUInt8Array(), hashAlg.id) - - return result.toUByteArray() - } - actual fun randomEncodedPoint(): UByteArray { val result = getSodium().crypto_core_ristretto255_random() diff --git a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/JnaLibsodiumInterface.kt b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/JnaLibsodiumInterface.kt index 7abe289..3ddb6dd 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/JnaLibsodiumInterface.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/JnaLibsodiumInterface.kt @@ -1309,22 +1309,6 @@ interface JnaLibsodiumInterface : Library { fun crypto_core_ristretto255_from_hash(p: ByteArray, r: ByteArray): Int - fun crypto_core_ristretto255_from_string( - p: ByteArray, - ctx: ByteArray?, - msg: ByteArray, - msgLen: Int, - hashAlg: Int, - ): Int - - fun crypto_core_ristretto255_from_string_ro( - p: ByteArray, - ctx: ByteArray?, - msg: ByteArray, - msgLen: Int, - hashAlg: Int, - ): Int - fun crypto_core_ristretto255_add(r: ByteArray, p: ByteArray, q: ByteArray): Int fun crypto_core_ristretto255_sub(r: ByteArray, p: ByteArray, q: ByteArray): Int @@ -1359,10 +1343,6 @@ interface JnaLibsodiumInterface : Library { fun crypto_core_ed25519_random(p: ByteArray) - fun crypto_core_ed25519_from_string(p: ByteArray, ctx: ByteArray?, msg: ByteArray, msgLen: Int, hashAlg: Int): Int - - fun crypto_core_ed25519_from_string_ro(p: ByteArray, ctx: ByteArray?, msg: ByteArray, msgLen: Int, hashAlg: Int): Int - fun crypto_core_ed25519_from_uniform(p: ByteArray, r: ByteArray): Int fun crypto_core_ed25519_add(r: ByteArray, p: ByteArray, q: ByteArray): Int diff --git a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt index f4e912c..5268c3d 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt @@ -2,7 +2,6 @@ package com.ionspin.kotlin.crypto.ed25519 import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibsodiumSuccess import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna -import com.ionspin.kotlin.crypto.util.toCString actual abstract class Ed25519LowLevel actual constructor() { actual fun isValidPoint(encoded: UByteArray): Boolean = @@ -26,36 +25,6 @@ actual abstract class Ed25519LowLevel actual constructor() { return result } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ed25519_BYTES) - val ctxEncoded = ctx?.toCString() - - sodiumJna.crypto_core_ed25519_from_string( - result.asByteArray(), - ctxEncoded?.asByteArray(), - msg.asByteArray(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - - return result - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ed25519_BYTES) - val ctxEncoded = ctx?.toCString() - - sodiumJna.crypto_core_ed25519_from_string_ro( - result.asByteArray(), - ctxEncoded?.asByteArray(), - msg.asByteArray(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - - return result - } - actual fun encodedPointFromUniform(uniform: UByteArray): UByteArray { val result = UByteArray(crypto_core_ed25519_BYTES) diff --git a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt index 387e0f4..6fa3081 100644 --- a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt @@ -2,8 +2,6 @@ package com.ionspin.kotlin.crypto.ristretto255 import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibsodiumSuccess import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodiumJna -import com.ionspin.kotlin.crypto.ed25519.HashToCurveAlgorithm -import com.ionspin.kotlin.crypto.util.toCString actual abstract class Ristretto255LowLevel actual constructor() { actual fun isValidPoint(encoded: UByteArray): Boolean = @@ -35,36 +33,6 @@ actual abstract class Ristretto255LowLevel actual constructor() { return result } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ristretto255_BYTES) - val ctxEncoded = ctx?.toCString() - - sodiumJna.crypto_core_ristretto255_from_string( - result.asByteArray(), - ctxEncoded?.asByteArray(), - msg.asByteArray(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - - return result - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ristretto255_BYTES) - val ctxEncoded = ctx?.toCString() - - sodiumJna.crypto_core_ristretto255_from_string_ro( - result.asByteArray(), - ctxEncoded?.asByteArray(), - msg.asByteArray(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - - return result - } - actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ristretto255_BYTES).also { sodiumJna.crypto_core_ristretto255_random(it.asByteArray()) } diff --git a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/util/Strings.kt b/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/util/Strings.kt deleted file mode 100644 index a38b111..0000000 --- a/multiplatform-crypto-libsodium-bindings/src/jvmMain/kotlin/com/ionspin/kotlin/crypto/util/Strings.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.ionspin.kotlin.crypto.util - -fun String.toCString(): UByteArray { - val encoded = encodeToUByteArray() - val cStr = UByteArray(encoded.size + 1) - - encoded.copyInto(cStr) - - LibsodiumUtil.memzero(encoded) - - return cStr -} \ No newline at end of file diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt index 1be30eb..49829ad 100644 --- a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ed25519/Ed25519LowLevel.kt @@ -1,11 +1,9 @@ package com.ionspin.kotlin.crypto.ed25519 import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibsodiumSuccess -import com.ionspin.kotlin.crypto.util.toCString import com.ionspin.kotlin.crypto.util.toPtr import kotlinx.cinterop.usePinned import libsodium.crypto_core_ed25519_add -import libsodium.crypto_core_ed25519_from_string import libsodium.crypto_core_ed25519_from_uniform import libsodium.crypto_core_ed25519_is_valid_point import libsodium.crypto_core_ed25519_random @@ -59,59 +57,6 @@ actual abstract class Ed25519LowLevel actual constructor() { return result } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ed25519_BYTES) - val ctxEncoded = ctx?.toCString() - - result.usePinned { resultPinned -> - msg.usePinned { msgPinned -> - if (ctxEncoded == null) { - crypto_core_ed25519_from_string(resultPinned.toPtr(), null, msgPinned.toPtr(), msg.size, hashAlg.id) - .ensureLibsodiumSuccess() - } else { - ctxEncoded.usePinned { ctxPinned -> - crypto_core_ed25519_from_string( - resultPinned.toPtr(), - ctxPinned.toPtr(), - msgPinned.toPtr(), - msg.size, - hashAlg.id - ) - .ensureLibsodiumSuccess() - } - } - } - } - - return result - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ed25519_BYTES) - val ctxEncoded = ctx?.toCString() - - result.usePinned { resultPinned -> - msg.usePinned { msgPinned -> - if (ctxEncoded == null) { - crypto_core_ed25519_from_string_ro(resultPinned.toPtr(), null, msgPinned.toPtr(), msg.size, hashAlg.id) - .ensureLibsodiumSuccess() - } else { - ctxEncoded.usePinned { ctxPinned -> - crypto_core_ed25519_from_string_ro( - resultPinned.toPtr(), - ctxPinned.toPtr(), - msgPinned.toPtr(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - } - } - } - } - - return result - } - actual fun encodedPointFromUniform(uniform: UByteArray): UByteArray { val result = UByteArray(crypto_core_ed25519_BYTES) diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt index 808a173..5bb6bd1 100644 --- a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt +++ b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/ristretto255/Ristretto255LowLevel.kt @@ -1,14 +1,10 @@ package com.ionspin.kotlin.crypto.ristretto255 import com.ionspin.kotlin.crypto.GeneralLibsodiumException.Companion.ensureLibsodiumSuccess -import com.ionspin.kotlin.crypto.ed25519.HashToCurveAlgorithm -import com.ionspin.kotlin.crypto.util.toCString import com.ionspin.kotlin.crypto.util.toPtr import kotlinx.cinterop.usePinned import libsodium.crypto_core_ristretto255_add import libsodium.crypto_core_ristretto255_from_hash -import libsodium.crypto_core_ristretto255_from_string -import libsodium.crypto_core_ristretto255_from_string_ro import libsodium.crypto_core_ristretto255_is_valid_point import libsodium.crypto_core_ristretto255_random import libsodium.crypto_core_ristretto255_scalar_add @@ -71,59 +67,6 @@ actual abstract class Ristretto255LowLevel actual constructor() { return result } - actual fun encodedPointFromString(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ristretto255_BYTES) - val ctxEncoded = ctx?.toCString() - - result.usePinned { resultPinned -> - msg.usePinned { msgPinned -> - if (ctxEncoded == null) { - crypto_core_ristretto255_from_string(resultPinned.toPtr(), null, msgPinned.toPtr(), msg.size, hashAlg.id) - .ensureLibsodiumSuccess() - } else { - ctxEncoded.usePinned { ctxPinned -> - crypto_core_ristretto255_from_string( - resultPinned.toPtr(), - ctxPinned.toPtr(), - msgPinned.toPtr(), - msg.size, - hashAlg.id - ) - .ensureLibsodiumSuccess() - } - } - } - } - - return result - } - - actual fun encodedPointFromStringRo(ctx: String?, msg: UByteArray, hashAlg: HashToCurveAlgorithm): UByteArray { - val result = UByteArray(crypto_core_ristretto255_BYTES) - val ctxEncoded = ctx?.toCString() - - result.usePinned { resultPinned -> - msg.usePinned { msgPinned -> - if (ctxEncoded == null) { - crypto_core_ristretto255_from_string_ro(resultPinned.toPtr(), null, msgPinned.toPtr(), msg.size, hashAlg.id) - .ensureLibsodiumSuccess() - } else { - ctxEncoded.usePinned { ctxPinned -> - crypto_core_ristretto255_from_string_ro( - resultPinned.toPtr(), - ctxPinned.toPtr(), - msgPinned.toPtr(), - msg.size, - hashAlg.id - ).ensureLibsodiumSuccess() - } - } - } - } - - return result - } - actual fun randomEncodedPoint(): UByteArray = UByteArray(crypto_core_ristretto255_BYTES).apply { usePinned { crypto_core_ristretto255_random(it.toPtr()) } } diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/ConversionUtil.kt b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/ConversionUtil.kt index bfe4bb3..8a882f6 100644 --- a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/ConversionUtil.kt +++ b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/ConversionUtil.kt @@ -17,14 +17,3 @@ fun Pinned.toPtr() : CPointer? { null } } - -fun String.toCString(): UByteArray { - val encoded = encodeToUByteArray() - val cStr = UByteArray(encoded.size + 1) - - encoded.copyInto(cStr) - - LibsodiumUtil.memzero(encoded) - - return cStr -}