I have got a decryption/encryption method using CCCrypt()
which worked really well on iOS5. Now I am working with the iOS6 SDK and never changed my code, but it
There is an apple developer forum thread discussing this issue and it has a good amount of info on the topic. It seems that the padding option is an issue for many people. Comment #11 is where the solution starts to be discussed.
I'm not an expert i encryption, but I have the same problem and figured a workaround maybe it will be fine until some will find a real solution.
all I did is to figure which iOS is running and for 6+ i'm changing the CCCrypt call to no padding (0 is for no padding, 1 is the enum for kCCOptionPKCS7Padding)
float version = [[UIDevice currentDevice].systemVersion floatValue];
if (version >= 6)
{
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, 0,
keyPtr, kCCKeySizeAES128,
ivPtr,
[self bytes], dataLength,
buffer, bufferSize,
&numBytesDecrypted );
if( cryptStatus == kCCSuccess )
{
return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];
}
free( buffer );
return nil;
}
else
{
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, 1,
keyPtr, kCCKeySizeAES128,
ivPtr,
[self bytes], dataLength,
buffer, bufferSize,
&numBytesDecrypted );
if( cryptStatus == kCCSuccess )
{
return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];
}
free( buffer );
return nil;
}