AFAIK,CFB8模式的块大小为1字节。所以我可以推断出IV也是1字节长。然而,当我做一个测试,将相同的iv只有1个字节传递到用于加密和解密函数的公共crypto create函数中时,加密和解密的消息不匹配。
所以我认为API应该使用超过1个字节作为IV。我想知道为什么?
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);发布于 2013-01-30 17:34:33
它没有1个字节的块大小,它只是每1个字节重新同步一次。IV实际上是16字节(对于AES)。
发布于 2013-01-30 17:34:36
IV大小必须与对称算法块大小匹配。因此,对于AES,您应该有一个16字节的IV。
CFB-8的移位大小为一个字节。它与密码的块大小无关。
https://stackoverflow.com/questions/14600277
复制相似问题