Reputation: 3325
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);
Upvotes: 2
Views: 1257
Reputation: 69389
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.
Upvotes: 4
Reputation: 14160
It doesn't have block size of 1 byte, it is just resynchronized each 1 byte. The IV is actually 16 bytes (for AES).
Upvotes: 3