AES-CTR 模式(类似流式加密)明文中的 1 位变化会导致密文中的 1 位变化吗?

发布于 2024-10-04 04:59:29 字数 243 浏览 0 评论 0原文

据我了解,在流密码(或 AES CTR 模式)中,密钥实际上是使用 IV 加密的(或者一般来说,我们从密钥 K 生成伪随机字节)。然后,我们使用该密钥通过 XOR 来加密明文。

但据我了解,假设使用相同的密钥 K,明文中一位的变化只会改变密文中的一位。

我是对的,还是我完全错了?

如果我是对的,它是不是比 CBC 更不安全? (因为在 CBC 中,明文中一位的更改会更改密文中从更改点开始的所有位)

谢谢!

From what I understand, in stream-cipher (or AES CTR mode) the key is actually being encrypted using the IV (or in general, from key K we produce pseudo-random bytes). Than, we use this key to encrypt the plaintext using XOR.

But from what I understand, assuming that the same key K is being used, a change of one bit in the plaintext changes only 1 bit the ciphertext.

Am I right, or did I get it totally wrong?

And if I am right, isn't it less secure than CBC? (Because in CBC a change of one bit in the plaintext, changes all the bits in ciphertext from the point of the change an on)

Thanks !!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梅倚清风 2024-10-11 04:59:29

您是对的,这就是为什么存在结合 CTR 模式和数据身份验证的模式,通常称为 AEAD 模式,例如 CCMGCM 模式。

You are correct, that is why there are modes that incorporate both CTR mode and data authentication, commonly referred to as AEAD modes, for example CCM and GCM modes.

并安 2024-10-11 04:59:29

显然,CTR模式违反了香农扩散原理,因为在明文中改变一点点只会改变一点点在输出中。然而,这只是故事的一部分。事实上,您还必须更改每条消息的 IV。因此,即使您仅更改明文中的单个位,或者即使消息保持不变,以下消息中的许多位也会发生变化。

另一方面,如果您担心消息的恶意修改,CTR 和 CBC 都无法抵御这些攻击,并且正如 @GregS 所说,您应该使用经过身份验证的加密模式,例如 CCM、GCM 或 EAX

Apparently, the CTR mode violates Shannon's diffusion principle, since changing a bit in the plaintext only changes a bit in the output. However this is only part of the story. In fact, you also have to change the IV for each message. Therefore many bits will change in the following message even if you change only a single bit in the plaintext or even if the message remains the same.

On the other hand, if you are concerned with malicous modification of messages, neither CTR nor CBC are safe against those attacks and, as @GregS said, you should use authenticated encryption modes such as CCM, GCM, or EAX.

做个ˇ局外人 2024-10-11 04:59:29

这正是为什么在使用 CTR 模式时必须绝不重复密钥流的一部分的原因,就像使用流密码一样。加密端使用的计数器只能向前移动,直到密钥发生更改。

This is exactly why you must never repeat a portion of the keystream when using CTR mode, just as with a stream cipher. The counter used on the encrypting side must only ever go forward, until the key is changed.

浅忆流年 2024-10-11 04:59:29

是的你是对的。只不过不是密钥被加密,而是 IV(计数器)使用密钥加密。
这种方法允许随机访问加密流(因为数据的每个部分的计数器都是已知的)。

Yes, you are right. Except not key is being encrypted, but IV (counter) is encrypted using the key.
This approach allows random access to encrypted stream (since counter is known for each portion of data).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文