在 Rijndael 加密中对许多文件使用静态 IV 值可以吗?
我对 Rijndael 加密 中的 IV 有疑问。
我目前使用 Rijndael 的方法是使用一对 static Key
和 Iv
进行所有加密操作(我的意思是我使用这对 Key Iv 代表我计算机中所有受保护的文件)。
我听说每个 Rijndael 加密的 IV 必须唯一
。这是真的吗?我当前使用单个静态密钥和 Iv 对
的方法有什么问题(如果有)?
I have a question about IV in Rijndael encryption.
My current approach of using Rijndael is to use a pair of static Key
and Iv
for all encryption operations (I mean I use this pair of Key and Iv for all protected files in my computer).
I heard that IV must be unique
for each Rijndael encryption. Is that true? What is the problem (if any) for my current approach of using single static Key and Iv pair
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您对同一消息加密两次,您将获得相同的结果 - 通过改变密钥或 IV,情况并非如此。 (改变 IV 更简单,因为您可以以纯文本形式传输它;它不涉及任何形式的秘密交换。)
这意味着如果您重复使用相同的 IV,则可以向攻击者提供信息:如果他们知道一条消息,当他们再次看到相同的加密数据时,他们就会知道这是同一条消息。
所以是的,我每次都会改变 IV。 (并尽量避免在任何地方使用相同的密钥,理想情况下......这就像对多个网站使用相同的密码:这意味着如果您在一个地方受到威胁,那么您在任何地方都失去了安全性。)
If you encrypt the same message twice, you'll get the same results - by varying either the key or the IV, that won't be the case. (Varying the IV is simpler as you can transmit that in plain text; it doesn't involve any sort of secret exchange.)
That means if you reuse the same IV, that can give information to an attacker: if they know the contents of one message, and they see the same encrypted data again, they'll know it's the same message.
So yes, I would vary the IV each time. (And try to avoid using the same key everywhere, ideally... it's like using the same password for multiple web sites: it means if you're compromised in one place, you've lost security everywhere.)
初始化向量将 AES 引擎初始化为特定状态。
使用动态 IV 的主要目标是同一文件的两次连续加密不会产生相同的加密值。
要解密文件,您还需要使用相同的 IV 初始化 AES 引擎。因此,IV 必须与加密文件一起存储。
我认为初始化向量不会在您的用例中提供太多额外的安全性。当您加密可能受到字典攻击的数据(线路密码、卡号、PIN 码)时,拥有它会很好。对于文件来说,这几乎是不可能的。
The initialization vector initializes the AES engine to a specific state.
The main goal of using a dynamic IV is that two consecutive encryptions of the same file won't result in the same encrypted value.
To decrypt the file, you also need to initialize the AES engine with this same IV. As a consequence, the IV has to be stored with your encrypted file.
I don't think that the initialization vector will offer much additional security in your use case. It's nice to have it when you're encrypting data that can be subject to dictionnary attacks (passwords on the wire, card numbers, PIN code). For files, it will hardly be possible..