CommonCrypto XCode 9.0 unable to create key from data

Viewed 339

The following code fails with OSStatus -50 (secParam) both in my manual code and in other libraries (SwiftyRSA, Heimdall) on XCode 9.0, ios 10+. Any ideas as to why or any way to obtain more info?

let keyDict: [CFString: Any] = [
        kSecAttrKeyType: kSecAttrKeyTypeRSA,
        kSecAttrKeyClass: kSecAttrKeyClassPublic,
        kSecAttrKeySizeInBits: NSNumber(value: 4096),
        kSecAttrIsSensitive: false,
        kSecAttrIsExtractable: true,
        kSecAttrCanEncrypt: true
    ]

    var errP: Unmanaged<CFError>?
    key = SecKeyCreateWithData(
        publicKeyData as CFData, keyDict as CFDictionary, &errP
    )
1 Answers

Well, there have been an error creating keychain items with iOS10. And it was a problem in simulator, but worked on device.

As quick solution you had to enable keychain sharing. Original bug I reported was marked as Duplicate and it is closed now. Maybe regression in iOS11?

Related