术中导航
The Counter Mode or CTR is a simple counter based block cipher implementation in cryptography. Each or every time a counter initiated value is encrypted and given as input to XOR with plaintext or original text which results in ciphertext block. The CTR mode is independent of feedback use and thus can be implemented in parallel in this mode. It generates the next keystream block by encrypting successive values as named as "counter". This counter can be any purpose or function which generates a sequence that is guaranteed not to call for a long time, although an actual increment-by-one counter is the simplest or easiest and most popular or famous. When utilization of the easiest deterministic input function or work used to be promoted or secret or controversial; attacker argued that "deliberately reveal a cryptosystem to a known systematic input represents an unnecessary or unused risk."
计数器模式或CTR是密码术中基于计数器的简单的块密码实现。 每次或每次对计数器的初始值进行加密,并以纯文本或原始文本作为XOR的输入时,都会产生密文块。 CTR模式与反馈的使用无关,因此可以在此模式下并行实现。 它通过加密名为“ counter”的连续值来生成下一个密钥流块。 该计数器可以是生成序列的任何目的或功能,该序列可以保证长时间不调用,尽管实际的逐一递增计数器是最简单,最简单,最受欢迎或最受欢迎的。 当使用最简单的确定性输入功能或以前曾被宣传,秘密或有争议的工作时; 攻击者认为“故意向已知的系统输入泄露密码系统表示不必要或未使用的风险”。
Its simple implementation is shown below as:
它的简单实现如下所示:
Image source: https://www.geeksforgeeks.org/block-cipher-modes-of-operation/
图片来源:https://www.geeksforgeeks.org/block-cipher-modes-of-operation/
We can be considered as a counter-based version of CFB mode without the feedback in this cryptography. In this mode, both the sender and receiver need to get access to a reliable counter, which finds out a new shared value each time a ciphertext block is exchanged or changes the value which is shared. This shared counter is not necessarily a secret value, but the challenge is that both sides must keep the counter synchronized at a time when both are active.
没有这种密码学的反馈,我们可以被视为CFB模式的基于计数器的版本。 在这种模式下,发送方和接收方都需要访问可靠的计数器,每次交换密文块或更改共享的值时,该计数器都会找到新的共享值。 该共享计数器不一定是一个秘密值,但是挑战在于,当双方都处于活动状态时,双方都必须保持计数器同步。
操作方式 (Operation)
Both encryption and decryption in CTR mode are depicted in the following illustration or steps. Steps in operation are,
下图或步骤描述了CTR模式下的加密和解密。 操作步骤如下:
Firstly, load the initial counter value in the top register is the same for both the sender and the receiver in this mode. It plays the same role as the IV in CFB (and CBC) mode similar way.
首先,在此模式下,对于发送方和接收方,将初始计数器值加载到顶部寄存器中是相同的。 它在CFB (和CBC )模式下的作用与IV相似。
Then, encrypt the contents of the counter with the key and place the result in the bottom register in this mode.
然后,用该密钥加密计数器的内容,并将结果放入此模式的底部寄存器中。
Then, take the first plaintext or original text block P1 and XOR this to the contents of the bottom register. The result of this is C1 as ciphertext. Send C1 as ciphertext to the receiver and update the counter in this mode. The counter update replaces the ciphertext feedback in CFB mode like no feedback required.
然后,将第一个纯文本或原始文本块P1与其进行“异或”到底部寄存器的内容中。 其结果是C1作为密文。 将C1作为密文发送到接收器,并在此模式下更新计数器。 计数器更新将替换CFB模式下的密文反馈,就像不需要反馈一样。
Continue in this manner until the last plaintext block has been encrypted.
以这种方式继续,直到最后一个明文块已被加密。
Thus, decryption is the reverse process. This ciphertext block is XORed with the output of encrypted contents of the counter value of shared. After decryption of each ciphertext, the block counter is updated as in case of encryption in the cryptography.
因此,解密是相反的过程。 该密文块与共享计数器值的加密内容的输出进行异或。 在解密每个密文之后,与在加密中加密的情况一样,更新块计数器。
计数器模式分析 (Analysis of Counter Mode)
It does not have message dependency and hence a ciphertext block does not depend on the previous plaintext or original text blocks.
它不具有消息依赖性,因此密文块不依赖于先前的明文或原始文本块。
Similar to CFB mode, CTR mode does not involve the decryption process of the block cipher in that way. This is because the CTR mode is using the block cipher to generate a key-stream, which is encrypted using the XOR function in cryptography. In other words, CTR mode also converts a block cipher to a stream cipher in cryptography.
与CFB模式类似,CTR模式不以这种方式涉及分组密码的解密过程。 这是因为CTR模式使用分组密码生成密钥流,该密钥流使用密码学中的XOR函数进行了加密。 换句话说,CTR模式还将密码学中的块密码转换为流密码。
优点 (Advantages)
Wherever CTR mode has mostly all benefits of CFB mode. Just beside, it does not propagate the error of transmission at all in this mode.
在任何地方,CTR模式都具有CFB模式的所有优势。 紧挨着,在这种模式下它根本不会传播传输错误。
缺点 (Disadvantages)
The main disadvantage of CTR mode is that it requires a synchronous counter at the sender and receiver in this mode. Decreases of synchronization lead to the incorrect recovery of plaintext or original text.
CTR模式的主要缺点在于,在此模式下,发送方和接收方都需要一个同步计数器。 同步减少会导致不正确地恢复纯文本或原始文本。
翻译自: https://www.includehelp.com/cryptography/counter-ctr-mode-in-cryptography.aspx
术中导航