Four Operational Modes of Symmetric Algorithms

Symmetric algorithms use one key. Given a plaintext and a key, encryption produces ciphertext, which is approximately the same length as the plaintext. When decrypting, the same key is used as the encryption key.

There are four main encryption modes for symmetric algorithms:

An electronic code book mode Electronic Code Book (ECB)

This mode is the earliest and simplest mode. It divides the encrypted data into several groups, the size of each group is the same as the length of the encryption key, and then each group is encrypted with the same key.

The disadvantage is: the electronic codebook mode uses a key to encrypt all the blocks of the message. If the plaintext block is repeated in the original message, the corresponding ciphertext block in the encrypted message will also be repeated. Therefore, the electronic codebook mode is suitable for encrypting small messages. .


 

Two encryption block chain mode Cipher Block Chaining (CBC)

Encryption in CBC mode first divides the plaintext into fixed-length blocks, then XOR the ciphertext output from the previous encrypted block with the next plaintext block to be encrypted, and encrypt the calculation result with the key to obtain the ciphertext. When the first plaintext block is encrypted, an initialization vector is required because there is no encrypted ciphertext in front. Unlike the ECB method, through the connection relationship, the ciphertext and the plaintext are no longer in a one-to-one correspondence, which is more difficult to crack, and overcomes the attack that may be achieved by simply exchanging the ciphertext blocks.


 

Three encryption feedback mode Cipher Feedback Mode (CFB)

Encryption for character-oriented applications To use stream ciphers, you can use encryption feedback mode. In this mode, data is encrypted in smaller units, such as 8 bits, which is less than the defined block length (usually 64 bits). Its encryption steps are:

1. Use an initialization vector of length bits. The initialization vector is placed in the shift register, encrypted in the first step, and the corresponding length-bit initialization ciphertext K is generated;

2. The high n bits of the initialized ciphertext K are XORed with the first n bits of the plaintext to generate the first part of the ciphertext c (ciphertext block 0), and then c is transmitted to the receiver;

3. The bits of the vector (that is, the contents of the shift register where the initialization vector is located) are shifted to the left by n bits, so that the rightmost n bits of the shift register are unpredictable data, and the content of c is filled in it;

4. Repeat steps 1-3 until all plaintext units are encrypted.

The decryption process is reversed

Output Feedback Mode(OFB)

The output feedback mode is similar to CFB, the only difference is that the ciphertext in CFB is filled in the next stage of the encryption process, while in OFB, the high n bits of the output K of the initialization vector encryption process are filled in the next stage of the encryption process.


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326391990&siteId=291194637