Intro

A block cipher is an encryption algorithm used in symmetric key encryption that encrypts plaintext in fixed-size blocks. The block size depends on the algorithm, but the length of the plaintext can be variable because block ciphers utilize modes of operation, which will be explained below. A block cipher can also be abstracted as a Pseudo-random Function where the message space is n bits and the key space is k bits.

Design

The basic flow of block cipher encryption is as follows:

  1. Expand the key into round keys via key expansion.
  2. Apply each round key sequentially using the round function.
  3. Output the ciphertext .

The implementation of the round function and key expansion depends on the specific algorithm. Typically, in the round function, building blocks such as substitution, transposition, shift, and swap are used to satisfy Confusion and Diffusion.

Mode of Operation

If the length of the plaintext to be encrypted is longer than the block size, a mode of operation can be used. The mode of operation defines the methods to securely use a single key multiple times. There are two types of modes of operation:

Confidentiality onlyAuthenticated Encryption with Additional Data(AEAD)
- ECB(Electric Codebook)
- CBC(Cipher-block Chaining)
- CFB(Cipher Feedback)
- OFB(Output Feedback)
- CTR(Counter)
- GCM(Galois counter)
- CCM(Counter with cipher block chaining message authentication code)
- SIV(Synthetic initialization vector)
- AES-GCM-SIV

Comparison with Stream cipher

Stream CipherBlock Cipher
Processing UnitBit/ByteBlock of data
Key typeGenerated for each bit/byteSingle key used for multiple rounds
ImplementationSimpler, often used in hardwareMore complex, often used in software
Use CaseReal-time applications, low latencyFile encryption, data at rest
SpeedTypically fasterTypically slower
Padding RequiredNot requiredRequired if data does not fit block size
SecurityKey reuse can lead to vulnerabilitiesMore secure with proper padding and mode of operation
ExampleRC4, Salsa20, ChaCha20AES, DES, Blowfish