https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Ahmed na

12/12/2023, 7:26 AM
hi ! Has anyone interfaced
Apple CryptoKit
into a kmp library ? My research lead me to how to use swift only code in kmp, Looking for already packaged lib 😄
j

Jan Holešovský

12/12/2023, 7:31 AM
What do you want to achieve? If you are just searching for something, you'd be better off googling or asking chatgpt; if you want to solve a problem, describe the problem 😉
a

Ahmed na

12/12/2023, 7:47 AM
I'm want to use
X448
and
X25519
encryption in my kotlin commode module these alg are offered by
Apple CryptoKit
for ios But It's a known problem with kmp that we can't use swift only libraries in kotlin The workarounds i found : https://dev.to/ttypic/going-swiftly-using-a-swift-only-libraries-in-your-kotlin-multiplatform-app-1ml9 https://github.com/KodeinKoders/playground-SwiftLib-in-KMMLib Before i try using these i'm looking for an open source library that already implemented this and exposed
Apple CryptoKit
to kmp common code
j

Jan Holešovský

12/12/2023, 8:01 AM
If your main concern are these two algorithms, then maybe using openssl would be a viable alternative for you? Integrating BoringSSL (a fork of OpenSSL - https://boringssl.googlesource.com/boringssl/) into KMP is reasonably easy, can post some pointers here if you are interested.
a

Ahmed na

12/12/2023, 8:04 AM
yeah if i can import this library into a kmp module (common or ios target) would be great would appreciate any snippets !
j

Jan Holešovský

12/13/2023, 6:45 AM
@Ahmed na I'm using the BoringSSL in https://github.com/kendy/Kotlin-Native-BigDecimal . To build BoringSSL, here are my notes: https://github.com/kendy/Kotlin-Native-BigDecimal/blob/master/bignum/README.md To actually import it then into your project using cinterops, see https://github.com/kendy/Kotlin-Native-BigDecimal/blob/master/build.gradle.kts Then when you want to actually use that, see https://github.com/kendy/Kotlin-Native-BigDecimal/blob/master/src/iosMain/kotlin/kendy/math/NativeBN.kt where I call the BoringSSL API
🙏 1
4 Views