Cyrille QUÉMIN
01/12/2019, 6:17 PMolonho
01/12/2019, 9:53 PMfun main(): Unit = memScoped {
val error = alloc<CFErrorRefVar>()
val cfAttributes = CFDictionaryCreateMutable(null, 2, null, null)
CFDictionaryAddValue(cfAttributes, kSecAttrKeyType, kSecAttrKeyTypeEC)
CFDictionaryAddValue(cfAttributes, kSecAttrKeySizeInBits, CFBridgingRetain(NSNumber(int = 256)))
val privateKey = SecKeyCreateRandomKey(cfAttributes, error.ptr)
if (error.value != null)
println("error ${CFBridgingRelease(error.value)}")
if (privateKey != null)
println("got key ${CFBridgingRelease(privateKey)}")
CFBridgingRelease(cfAttributes)
CFBridgingRelease(privateKey)
}
works for me. Maybe you just hit some troubles with toll-free bridges on CoreFoundation collectionsCyrille QUÉMIN
01/13/2019, 5:50 AM