gpt4 book ai didi

ios - AES/CFB8 IV 尺寸

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:08:49 26 4
gpt4 key购买 nike

据我所知,CFB8 模式的 block 大小为 1 字节。所以我可以推断出 IV 的长度也是 1 字节。但是,当我进行测试时,将仅 1 个字节的相同 iv 传递到用于加密和解密功能的通用加密创建函数中,加密和解密的消息不匹配。

所以我认为 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);

最佳答案

IV 大小必须与对称算法 block 大小匹配。因此,对于 AES,您应该有一个 16 字节的 IV。

CFB-8 有一个字节的移位大小。它与密码的 block 大小无关。

关于ios - AES/CFB8 IV 尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14600277/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com