I am trying to implement an rsa encryption and decryption algorithm as a part of my app in iphone.(xcode 4.2,ios sdk 5.0) I am generating keys using SecKeyGeneratePair and encrypting using SecKeyEncrypt. Both these return OSStatus 0.
But while decrypting using SecKeyDecrypt ,I get OSStatus as -9809. Please help; where have i gone wrong.
Edit: Thanks for the quick response. I copied and pasted the code from the following link:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/17242-rsa-generating-keypair-so-slowly.html
The reason is that there is a typo on the Apple page
NSData *encryptedData = [NSData dataWithBytes:cipherBuffer length:dataLength];
It should be:
NSData *encryptedData = [NSData dataWithBytes:cipherBuffer length:cipherBufferSize];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With