AES/CFB8 IV size

扶醉桌前 提交于 2020-01-02 12:09:28

问题


AFAIK, CFB8 mode has block size of 1byte. So I can induce that IV is also 1byte length. However, when I do a test passing same iv of just 1 byte into common crypto create function for encrypt and decrypt function, encrypted and decrypted message mismatch.

So I think that the API should have taken more than 1 byte to use as IV. I would like to know why? Any thing wrong with my understanding?

CCCryptorStatus result = CCCryptorCreateWithMode(operation,
                                                 kCCModeCFB8,
                                                 kCCAlgorithmAES128,
                                                 ccNoPadding,
                                                 iv.bytes,
                                                 key.bytes,
                                                 key.length,
                                                 NULL,
                                                 0,
                                                 0,
                                                 0,
                                                 &_cryptor);

if (result == kCCSuccess)
    result = CCCryptorUpdate(_cryptor,
                             data.bytes,
                             data.length,
                             cipherData.mutableBytes,
                             cipherData.length,
                             &outLength);

if (result == kCCSuccess)
    result = CCCryptorFinal(_cryptor,
                            cipherData.mutableBytes,
                            cipherData.length,
                            &outLength);

if (result == kCCSuccess)
    result = CCCryptorRelease(_cryptor);

回答1:


It doesn't have block size of 1 byte, it is just resynchronized each 1 byte. The IV is actually 16 bytes (for AES).




回答2:


The IV size must match the symmetric algorithm block size. Hence, for AES you should have an IV of 16 bytes.

CFB-8 has a shift size of a byte. It bears no relation to the block size of the cipher.



来源:https://stackoverflow.com/questions/14600277/aes-cfb8-iv-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!