Saturday, June 15, 2013

Funny google

Most of the time when we use Google we enter the items we want to search and expect a good result.

While using SecKeyDecrypt function in iOS to decrypt some data I got error -9809. That is with a "-" in front.

So I went to google and searched for "SecKeyDecrypt error -9809". None of the pages said anything about "-9809".

I tried "SecKeyDecrypt error 9809" and I got some good answers.

The reason is that "-" means show the pages that do not contain the value. Exactly the opposite of what I wanted.

The solution is to include the value with "-" among quotation marks like this:

SecKeyDecrypt error "-9809"

---

Here is the description of the error in case you reached here using google:

While replicating the code here, the code returned an error "-9809" for

status = SecKeyDecrypt(    privateKey,
                         kSecPaddingPKCS1,
                         cipherBuffer,
                         cipherBufferSize,
                         plainBuffer,
                         &plainBufferSize
                         );       

The reason is that there is a typo on the page a little bit above at the line:

  NSData *encryptedData = [NSData dataWithBytes:cipherBuffer length:dataLength];

It should be:

  NSData *encryptedData = [NSData dataWithBytes:cipherBuffer length:cipherBufferSize];

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.