Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSStatus -9809 while decryption

Tags:

iphone

rsa

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

like image 516
ss kurup Avatar asked Jun 12 '26 13:06

ss kurup


1 Answers

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];
like image 89
dragos Avatar answered Jun 15 '26 01:06

dragos