Question

I have a problem using 3DES encryption in my iPhone app. I have 9 byte message to be encrypted. When I use kCCOptionECBMode, the first 8 byte block is encrypted correctly (I have a sample result produced by server). How can I encrypt the last byte? When I use kCCOptionPKCS7Padding or kCCOptionECBMode| kCCOptionPKCS7Padding, it gives wrong result with status kCCBufferTooSmall. I have gone through some posts related to 3DES encryption on SO but not helped me.

 ccStatus = CCCrypt(kCCEncrypt,
                       kCCAlgorithm3DES,
                       kCCOptionECBMode,
                       vkey, 
                       kCCKeySize3DES,
                       vinitVec,
                       vplainText,
                       plainTextBufferSize,
                       (void *)bufferPtr,
                       [data length],
                       &movedBytes);
Was it helpful?

Solution

Problem was with data length parameter. I should calculate data length after padding and pass it to function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top