I have an encrypted data stream (AES 128, CBC, PKCS7), which I try to decrypt as it arrives. Sometimes I get a 334 packet, which I then try to decrypt. When I do this on iPhone 5, it returns kCCBufferTooSmall (which is expected for non-mod 16 data). However, when I have the same thing on the iPhone 3GS, it returns kCCSuccess and gives me a partially decrypted stream (the last ten bytes or so 333 that it gives me are dummy - null terminators and random data).
Both devices are iOS 6.1.2. The application is built with a basic SDK installed on the latest SDK (6.1) in order to deploy iOS 5.0.
I created the following test case that also shows this problem:
+ (void)decryptionTest { NSData *data = [NSMutableData dataWithLength:334];
Why am I getting kCCSuccess when it should fail due to a block size mismatch?
source share