From 2801fb948449033c3c3da2d3e3d1910ba69d512b Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Mon, 19 Oct 2020 19:10:29 +0200 Subject: [PATCH] Hack for 32biy/64bit array in native shared code, needs safeguards --- .../com/ionspin/kotlin/crypto/util/LibsodiumUtil.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtil.kt b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtil.kt index 81577aa..0a06d5c 100644 --- a/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtil.kt +++ b/multiplatform-crypto-libsodium-bindings/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtil.kt @@ -60,15 +60,15 @@ actual object LibsodiumUtil { actual fun unpad(paddedData: UByteArray, blocksize: Int) : UByteArray { val paddedDataCopy = paddedData.copyOf() val paddedDataCopyPinned = paddedDataCopy.pin() - var newSize = ULongArray(1) { 0UL } - val newSizePinned = newSize.pin() + var newSizeULong = ULongArray(1) { 0UL } + val newSizePinned = newSizeULong.pin() sodium_unpad( - newSizePinned.addressOf(0), + newSizePinned.addressOf(0) as kotlinx.cinterop.CValuesRef, // TODO Find a better solution for this! paddedDataCopyPinned.toPtr(), paddedData.size.convert(), blocksize.convert() ) - val unpaddedSize = newSize[0] + val unpaddedSize = newSizeULong[0] if (unpaddedSize > Int.MAX_VALUE.toULong()) { throw RuntimeException("Unsupported array size (larger than Integer max value) $unpaddedSize") }