From 5b65ee20cb27007dadfddb484cca8b0f109d5901 Mon Sep 17 00:00:00 2001 From: paregi12 Date: Mon, 8 Jun 2026 10:32:18 +0530 Subject: [PATCH] Fix iOS compilation errors: add CC_SHA384 and fix size_tVar types --- .../com/nuvio/app/features/plugins/PluginCrypto.ios.kt | 10 ++++++---- .../src/nativeInterop/cinterop/commoncrypto_shim.h | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/composeApp/src/iosFull/kotlin/com/nuvio/app/features/plugins/PluginCrypto.ios.kt b/composeApp/src/iosFull/kotlin/com/nuvio/app/features/plugins/PluginCrypto.ios.kt index c3f3a181a..5e5b205eb 100644 --- a/composeApp/src/iosFull/kotlin/com/nuvio/app/features/plugins/PluginCrypto.ios.kt +++ b/composeApp/src/iosFull/kotlin/com/nuvio/app/features/plugins/PluginCrypto.ios.kt @@ -164,7 +164,7 @@ internal fun pluginAesEncrypt( } val tagBytes = ByteArray(16) - val tagLengthVar = alloc() + val tagLengthVar = alloc() tagLengthVar.value = 16UL tagBytes.usePinned { pinnedTag -> @@ -199,7 +199,7 @@ internal fun pluginAesEncrypt( var finalData: ByteArray? = null memScoped { - val dataOutMoved = alloc() + val dataOutMoved = alloc() var options = 0U if (isEcb) { @@ -310,7 +310,7 @@ internal fun pluginAesDecrypt( } } - val tagLengthVar = alloc() + val tagLengthVar = alloc() tagLengthVar.value = 16UL val finalStatus = CCCryptorGCMFinal( @@ -343,7 +343,7 @@ internal fun pluginAesDecrypt( var finalData: ByteArray? = null memScoped { - val dataOutMoved = alloc() + val dataOutMoved = alloc() var options = 0U if (isEcb) { @@ -472,6 +472,7 @@ private fun normalizeDigestAlgorithm(algorithm: String): String { } } +@OptIn(ExperimentalForeignApi::class) private fun normalizePbkdf2Prf(algorithm: String) = when (algorithm.normalizedAlgorithmToken().removePrefix("HMAC")) { "SHA1" -> kCCPRFHmacAlgSHA1 @@ -481,6 +482,7 @@ private fun normalizePbkdf2Prf(algorithm: String) = else -> error("Unsupported PBKDF2 hash algorithm: $algorithm") } +@OptIn(ExperimentalForeignApi::class) private fun normalizeHmacAlgorithm(algorithm: String) = when (algorithm.normalizedAlgorithmToken().removePrefix("HMAC")) { "MD5" -> kCCHmacAlgMD5 to CC_MD5_DIGEST_LENGTH.toInt() diff --git a/composeApp/src/nativeInterop/cinterop/commoncrypto_shim.h b/composeApp/src/nativeInterop/cinterop/commoncrypto_shim.h index 255a0fd71..c9b762128 100644 --- a/composeApp/src/nativeInterop/cinterop/commoncrypto_shim.h +++ b/composeApp/src/nativeInterop/cinterop/commoncrypto_shim.h @@ -7,6 +7,7 @@ enum { CC_MD5_DIGEST_LENGTH = 16, CC_SHA1_DIGEST_LENGTH = 20, CC_SHA256_DIGEST_LENGTH = 32, + CC_SHA384_DIGEST_LENGTH = 48, CC_SHA512_DIGEST_LENGTH = 64, }; @@ -21,6 +22,7 @@ typedef enum { unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md); unsigned char *CC_SHA1(const void *data, CC_LONG len, unsigned char *md); unsigned char *CC_SHA256(const void *data, CC_LONG len, unsigned char *md); +unsigned char *CC_SHA384(const void *data, CC_LONG len, unsigned char *md); unsigned char *CC_SHA512(const void *data, CC_LONG len, unsigned char *md); void CCHmac( @@ -48,7 +50,7 @@ enum { int CCKeyDerivationPBKDF( CCPBKDFAlgorithm algorithm, - const char *password, + const void *password, size_t passwordLen, const uint8_t *salt, size_t saltLen,