CCCrypt decrypting in AES CBC works even without IV

后端 未结 4 1118
小蘑菇
小蘑菇 2020-12-15 12:11

I have a confusing problem, where decrypting a file which was encrypted using CCCrypt\'s AES-CBC mode with a randomized, 16byte IV produces the exact same output whether I p

4条回答
  •  臣服心动
    2020-12-15 12:28

    It's also worth pointing out that one should never include the mode with the padding options. I've seen this around quite a bit, and I've actually fallen into the same pitfall trying to be a "explicit as possible".

    kCCOptionPKCS7Padding | kCCModeCBC
    

    Should be:

    kCCOptionPKCS7Padding
    

    Fun fact 1: Both kCCModeEBC and kCCOptionPKCS7Padding share the same value: 1, and would actually evaluate to using kCCOptionPKCS7Padding, which would then default to kCCModeCBC.

    Fun fact 2: Using kCCOptionPKCS7Padding | kCCModeCBC evaluates to both kCCOptionPKCS7Padding flag and kCCOptionECBMode being set, which actually results in kCCModeEBC being used.

提交回复
热议问题