After digging around in the documentation, I think the function I need is SecKeyCreateFromData rather than SecKeyCreateWithData. But when I type that into my app, it isn't recognized as a valid function.
The documentation seems to suggest that SecKeyCreateFromData and kSecAttrKeyTypeAES are only available in Mac OS, which I can only guess is some kind of typo? I can't believe that AES encryption isn't available in iOS.
You are, alas, completely off in the weeds )-:
SecKeyEncryptis for use with asymmetric encryption, like RSA or EC. For symmetric encryption, like AES, you’ll need to use Common Crypto. The CryptoCompatibility sample code shows the way.
My project is in Swift so I'd prefer to keep the code in Swift if possible.
This is quite challenging. Common Crypto is not a nice API to call from Swift in general. Moreover, prior to Xcode 10 (currently in beta), even importing the module is un-fun. My recommendation is that you take the code from CryptoCompatibility, wrap it into a nice Objective-C class method that’s easy to call from Swift, and call that.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks for the help. I managed to get something working.
I hate Swift anyway. I only use it so people won't think I'm a troglodyte.