The error you’re getting is
errSecParam, indicating that
SecKeyDecryptis not happy with the parameters you passed it. As to the exactly what’s going wrong here, it’s hard to say without more info. My biggest concern is that you seem to be treating cyphertext as a string. That’s a really bad idea. As an obvious example of the problem, this line:
size_t cipherBufferSize = strlen((char *)cipherBuffer);
assumes that the cyphertext contains no zero bytes, which is not a reasonable assumption. However, there are more subtle things that might go wrong.
The correct way to store binary data, like cypher text, in Cocoa is with the NSData type. For an example of how to use this for cryptographic work, you should check out the CryptoCompatibility sample code. Specifically, the QCCRSASmallCryptorCompat class shows how to encrypt and decrypt small chunks of data with
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"