Pages

Wednesday, January 23, 2013

CommonCrypto issue on ios

Hi,

I am having few issues with commoncrypto api.  I am using commoncrypto api for aes-ctr encryption/decryption. I am creating a commoncrypto object with the below code

 

CCCryptorStatus  status = CCCryptorCreateWithMode(kCCDecrypt, kCCModeCTR, kCCAlgorithmAES128, ccNoPadding,

                                                      iv->bytes, key->bytes, key->len, NULL, 0, 0, kCCModeOptionCTR_BE, &cryptor);

then

status = CCCryptorUpdate(cryptor, inputData, len, ptr,remainingBytes,&movedBytes);

ptr += movedBytes;

    remainingBytes -= movedBytes;

    totalBytesWritten += movedBytes;

   

    status = CCCryptorFinal(cryptor,

                            ptr,

                            remainingBytes,

                            &movedBytes

                            );

 

Initially I had few memory issues with my code, to resolve those issue I have enabeld " Guard malloc", "Enable Scribble", "Enable Guard Edges".  With these setting enabled my app is working as expected on the simulator, however when I disable the above setting, Encryption and decryption are not working as expected. 

Any ideas what I am I missing here?


View the original article here

0 comments:

Post a Comment