kotlin.IllegalStateException: Algorithm not found: dev.whyoleg.cryptography.algorithms.AES.GCM.Companion@1230318
Closed this issue · 2 comments
azisanw19 commented
Hello, thanks to your library. I want to encrypt with AES-GCM in iOS with KMP but i get something wrong with the code
@OptIn(DelicateCryptographyApi::class)
fun encryptAES_GCM_NoPad(
data: ByteArray,
key: ByteArray,
iv: ByteArray,
aad: ByteArray?
): ByteArray {
// Mendapatkan default provider
val provider = CryptographyProvider.Default
// Mendapatkan algoritma AES-GCM
val aesGCM = provider.get(AES.GCM)
// Mendekode key dari ByteArray
val decodedKey: AES.GCM.Key
runBlocking {
decodedKey = aesGCM.keyDecoder().decodeFromByteArray(AES.Key.Format.RAW, key)
}
// Mendapatkan cipher dari key
val cipher = decodedKey.cipher()
// Melakukan enkripsi
val bytes: ByteArray
runBlocking {
bytes = cipher.encryptWithIv(
iv, data, aad
)
}
return bytes
}this is log of the crash
kotlin.IllegalStateException: Algorithm not found: dev.whyoleg.cryptography.algorithms.AES.GCM.Companion@1230318
at 0 Bluetooth.debug.dylib 0x105658f3f kfun:kotlin.Throwable#<init>(kotlin.String?){} + 99
at 1 Bluetooth.debug.dylib 0x105652ee3 kfun:kotlin.Exception#<init>(kotlin.String?){} + 95
at 2 Bluetooth.debug.dylib 0x1056530b3 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 95
at 3 Bluetooth.debug.dylib 0x105653577 kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 95
at 4 Bluetooth.debug.dylib 0x106b9da83 kfun:dev.whyoleg.cryptography.CryptographyProvider#get(dev.whyoleg.cryptography.CryptographyAlgorithmId<0:0>){0§<dev.whyoleg.cryptography.CryptographyAlgorithm>}0:0 + 315
at 5 Bluetooth.debug.dylib 0x106bb5c3b kfun:dev.whyoleg.cryptography.CryptographyProvider#get(dev.whyoleg.cryptography.CryptographyAlgorithmId<0:0>){0§<dev.whyoleg.cryptography.CryptographyAlgorithm>}0:0-trampoline + 67
whyoleg commented
Which provider do you use? AES-GCM supported on iOS only via openssl provider at current moment (more info)
azisanw19 commented
I'm using ios arm, it's not supported in the documentation yet. Waiting for support in ios arm. Thanks.