Cryptography — encryption mode of block cipher

Time:2021-8-30

Encryption mode of block cipher

1. Bitwise XOR

  • The first step is to convert the data to binary

2. ECB – electronic code book

ECB mode is a simple encryption mode. Plaintext data is divided into fixed size blocks, and each block is encrypted separately. The encryption and decryption of each block are independent, and the same method is used for encryption, so parallel computing can be carried out. In this mode, one block is cracked, and other blocks can be cracked with the same method to obtain plaintext data.The security is poor, which is suitable for the case of less data. Before encryption, the plaintext data needs to be filled to an integer multiple of the block size

This mode 3.04 is not provided in the go interface

Summary:

  • Features: simple, high efficiency, regular ciphertext, easy to crack
  • Last plaintext packetmustTo fill
  • No initialization vector is required

3. CBC – cipher block chain

In the CBC mode, each packet shall perform XOR operation with the encrypted data of the previous packet first, and then encrypt. Before encrypting the first data block, the initialization vector IV shall be used for XOR operation. CBC mode is the most commonly used encryption mode. Its main disadvantage is that encryption is continuous and cannot be processed in parallel. Like ECB, message blocks must be filled to an integer multiple of the block size

Summary:

  • Features: the ciphertext is irregular and is often encrypted
  • The last plaintext packet needs to be filled
  • An initialization vector is required, and the initialization vector used for encryption and decryption must be the same

4. CFB – cipher feedback, ciphertext feedback mode

In CFB mode, the ciphertext of the previous packet is encrypted and XOR is performed with the plaintext of the current packet to generate the ciphertext of the current packet. The first step is to encrypt the initialization vector, and this mode does not need to be filled with data, as well as OFB mode and CTR mode mentioned later

Summary:

  • Features: ciphertext is irregular. Plaintext grouping is bit exclusive or with data stream to finally generate ciphertext
  • An initialization vector is required, and the initialization vector used for encryption and decryption must be the same
  • No filling is required

5. OFB – output feedback mode

In OFB mode, the output of the cryptographic algorithm will be fed back to the input of the cryptographic algorithm, that is, the output of the previous cryptographic algorithm is the input of the current block cipher algorithm. The OFB mode does not directly encrypt the plaintext through the cryptographic algorithm, but generates the ciphertext packet through the exclusive or of the plaintext packet and the output of the cryptographic algorithm. In this regard, the OFB and CFB modes are very similar

Summary:

  • Features: ciphertext is irregular. Plaintext grouping is bit exclusive or with data stream to finally generate ciphertext
  • An initialization vector is required, and the initialization vector used for encryption and decryption must be the same
  • No filling is required

6. CTR – countter, counter mode

CTR mode is a stream cipher that generates a key stream by encrypting the counter accumulated step by step. The final ciphertext packet is obtained by XOR the bit sequence obtained by encrypting the counter with the plaintext packet

Summary:

  • Features: ciphertext is irregular. Plaintext grouping is bit exclusive or with data stream to finally generate ciphertext
  • No initialization vector is required
  • No filling is required