I am trying to get asymmetric encryption working in a program... I started out using code from the Apple documentation site (Certificate, Key, and Trust Services Programming Guide, section on Encrypting and Decrypting Data), with minor changes, when it was ready to run, decryption failed with error -9808.
After doing some searching, I discovered that some people have had that error and gotten it to go away by changing padding to kSecPaddingNone. After I did that, everything ran happily, but my decrypted data was garbage.
So I stared at the code for a while, couldn't find any obvious mistakes, then started searching the web for other solutions or ideas. I came across a thread on stackoverflow (RSA implementations in Objective C) and Parth Bhatt's code in the previous reply.
I imported his class into my program and ran the test, and, like some of the other people who commented on that thread, I also got garbage on the output, just like with the code I had written (that is, adapted from Apple's sample code).
So I am wondering if there may have been some change to the API that requires another call, or just what exactly is going on?
I did not seem to be able to comment on Parth's answer, which is why I am asking this new question.