Block Cipher


Block cipher is an encryption algorithm that takes a predetermined number of bits (binary digits), known as a block, and encrypts that block.

  • take the input plaintext and break it into a fixed-length series of symbols (block) and then encrypt and decrypt the block as if it was a single symbol
  • blocks typically have 64 bits
  • majority of encryption algorithms in use are block ciphers
  • more versatile
  • more resource intensive and complex
    • more susceptible to errors
  • works better with messages whose sizes are fixed, known in advance, or reported in protocol headers
  • used in:
    • symmetric algorithms
    • asymmetric algorithms
      • the entire padded block is treated as a number, which then has some algebraic function applied to it to produce a ciphertext
    • cryptographic hash functions
    • pseudorandom number generators (PRNG)
    • message authentication codes (MAC)
  • block ciphers often use Feistel Functions

Construction of Block Ciphers

Padding

  • all block ciphers work on fixed-length blocks of plaintext
    • these blocks must be padded out to the fixed block size of the algorithm
    • can be done by adding bytes to the end of the short blocks, along with a counter value that indicates how much padding was used
    • if the plaintext is a multiple of the block size,
      • then a final block that just contains padding must have been added
      • the added padding byte thus must be removed

Block Mode

Block mode defines the specific processes and operations that the cipher uses.

  • aka mode of operation
  • specifies how a block cipher applies a single-block operation to a plaintext larger than the block cipher’s block size

Electronic Code Book (ECB)

  • once the message has been padded to the cipher’s block size, it can be encrypted
  • easiest, least secure method is the Electronic Code Book (ECB)
  • In ECB mode,
    • each block of plaintext is processed independently by the cipher
    • each block is processed or encrypted using the same key
  • using the same key to encrypt each block brings a significant:
    • advantage:
      • greatly simplifies the process
      • encryption can be done in parallel
    • disadvantage:
      • while may be adequate for messages that are no greater than the block size, for longer messages, identical blocks of plaintext will produce identical blocks of ciphertext
  • does not use an initialization vector (IV)

Cipher Block and Feedback Chaining

With Cipher Block Chaining (CBC),

  • the first block of data is ed with a block of random data called the initialization vector (IV)
    • to create a unique ciphertext block each time the encryption is performed
    • IV is a randomly generated sequence of bits equal cipher’s block size
  • every subsequent block of plaintext is XORed with the previous block of ciphertext before being encrypted
    • thus ciphertext blocks are ‘chained’ together

With Cipher Feedback (CFB) mode,

  • the IV is encrypted and then XORed with the first block of the plaintext,
    • producing the first block of ciphertext
  • then that block is encrypted, and the result is XORed with the next block of plaintext,
    • producing the next block of ciphertext

Weakness of both CBC and CFB

  1. with both CBC and CFB, the encryption of block depends on the encryption of block
  • so neither is amenable to the parallel encryption of data
    • affects speed and throughput
  • both modes can be decrypted in parallel, though
  1. Also, random access is complicated by the need to decrypt block before one can decrypt the desired block
  2. Errors can propagate from one ciphertext block to the next

Difference Between CBC and CFB

  • With CBC,
    • a one-bit change in the IV will result in the same change in the same bit in the first block of decrypted ciphertext
    • so attacker could potentially tamper with the IV to introduce changes to the first block of the message
    • so necessary to ensure the integrity of the IV
  • With CFB,
    • a one-bit change in the IV will result in random errors in the decrypted message
    • thus not an effective method of tampering with the message
  • With CBC,
    • the decryption of messages requires the use of the block cipher in decryption mode
  • With CFB,
    • the block cipher is used in the encryption mode for both encryption and decryption
      • can result in a simpler implementation

Output Feedback (OFB)

In Output Feedback (OFB) mode a block cipher generates keystream blocks which are XORed with the plaintext blocks to create the ciphertext blocks.

  • Chaining dependencies do not exist in OFB mode
    • each block is created independently of plaintext and ciphertext blocks
  • encryption and decryption processes are the same
  • errors do not propagate

Counter Mode

Counter (CTR) mode operates as a stream cipher.

  • data sender and receiver use a synchronized counter which computes a new shared value each time a ciphertext block is exchanged
  • has a positional dependency because a ciphertext block depends on the position of the current plaintext block
  • since ciphertext blocks do not depend on other blocks,
    • errors do not propagate
  • addresses weakness 2 by not using previous blocks of the plaintext (CBC) or ciphertext (CFB) in producing the ciphertext.
    • uses an IV combined with a counter value
      • thus one can both:
        • parallelize the encryption process
        • and decrypt a single block of the ciphertext
  • includes a nonce value
    • is a unique, randomly generated value
    • is inserted into each block cipher encryption round
    • similar to how a salt value is used in hashes
    • is intended to prevent replay attacks

Initialization Vector (IV)

  • all modes other than ECB, need an IV which either must:
    • be communicated to the receiver
    • or the message must be prefixed by a throw-away block of data
      • since decryption of an CBC or CFB stream of data without knowing the IV will only cause problems for the first block
  • IV does not need to be secret, but it must be unpredictable