Block cipher modes of operation

(block cipher) mode of operation

A block cipher takes a fixed-length block of text of bits and a key as input and produces a -bit block of ciphertext.

If our messages exceed the block-width, then the block cipher can still be used by breaking up the plaintext. NIST defines 5 modes of operation for use with any symmetric block cipher, including triple DES and AES.

A mode of operation is a technique for enhancing the effect of a cryptographic algorithm or adapting the algorithm for an application.

Link to original

ModeDescriptionTypical Application
Electronic Codebook (ECB)Each block of plaintext bits is encoded independently using the same key.- Secure transmission of single values
Cipher Block Chaining (CBC)The input to the encryption algorithm is the XOR of the next bits of plaintext and the preceding bits of ciphertext.- General-purpose block-oriented transmission
- Authentication
Cipher Feedback (CFB)Input is processed bits at a time. Preceding ciphertext is used as input to the encryption algorithm to produce pseduorandom output, which is XORed with plaintext to produce next unit of ciphertext.- General-purpose stream-oriented transmission
- Authentication
Output Feedback (OFB)Similar to CFB, except that the input to the encryption algorithm is the preceding encryption output, and full blocks are used.- Stream-oriented transmission over noisy channel (e.g. satellite communication)
Counter (CTR)
not covered
Each block of plaintext is XORed with an encrypted counter. The counter is incremented for each subsequent block.- General-purpose block-oriented transmission
- Useful for high-speed requirements

All of NIST-approved block cipher modes of operation (except ECB) involve feedback

Think of encryption as taking input from a input register whose length equals encryption block length and with output stored in an output register. Input register updated one block at a time by feedback mechanism. After each update, encryption algorithm is executed, producing a result in output register. Meanwhile, a block of plaintext is accessed.

Electronic Codebook (ECB)

Electronic Codebook (ECB)

This is the simplest mode, plaintext message is broken into independent blocks .

  • Each block with encrypted individually, independently of other blocks: .
  • Requires last block be padded to a full bits if it is a partial block.
  • Each is a value that is substituted, like a codebook.

Each ciphertext block is decrypted also individually, with same :

Link to original

Limitations

For lengthy messages, ECB may not be secure. If the same -bit block of plaintext appears more than once, it always produces the same ciphertext. So if the message is highly structured, it may be possible for someone to exploit these regularities.

Ideal Use

This is ideal for a short amount of data, such as an encryption key. e.g. transmitting a DES / AES key securely

Cipher Block Chaining (CBC)

Cipher Block Chaining (CBC)

Cipher input is XOR of current plaintext block with preceding ciphertext block. For (initialisation vector) and :

EncryptionDecryption

This requires the last block to be padded to a full bits if it is a partial block.

Link to original

Proof of Correctness

Initialisation Vector

The initialisation vector is a data block that is the same size as the cipher block. IV must be known to both sender and receiver but be unpredictable by third party & protected against unauthorised changes.

Properties and Use

  • Repeating patterns of bits are not exposed as the input to the encryption function for each plaintext block bears no fixed relationship to the plaintext block.
  • Identical plaintext blocks mapped to different ciphertext.
  • Chaining dependencies: depends on all preceding plaintext.
  • Self-synchronising: if an error occurs (changed bits, dropped blocks) in but not , then is correctly decrypted.

CBC is appropriate for encrypting messages of length greater than bits.

Stream Ciphers

It is possible to convert a block cipher into a stream cipher using one of the modes CFB and OFB (or CTR but not covered).

A stream cipher eliminates the need to pad a message to be an integral number of blocks. It can also operate in real time: character stream can be encrypted and transmitted immediately.

Cipher FeedBack (CFB)

Cipher FeedBack (CFB)

As with Cipher Block Chaining (CBC), units of plaintext are chained together, so that ciphertext of any plaintext unit is a function of all the preceding plaintext.

Rather than blocks of bits, plaintext is divided into segments (‘units of transmission’) of bits. A common value is .

Link to original

CFB Encryption & Decryption

The input is a -bit shift register initially set to some initialisation vector. Let be the most significant bits of .

First unit of ciphertext is XOR of:

  • first segment of plaintext
  • leftmost (most significant) bits of output of encryption function

Contents of shift register are shifted left by bits, and is placed in rightmost (least significant) bits of shift register.

Process continues until all plaintext units have been encrypted.

Decryption uses the same scheme, except that the received ciphertext unit is XORed with the output of encryption function to produce plaintext unit:

Although CFB can be seen as a stream cipher, it does not conform to typical construction of a stream cipher: usually stream ciphers take as input some initial value and a key and generate a stream of bits, which is then XORed with plaintext bits. In CFB, the stream of bits that is XORed with plaintext also depends on the plaintext.

Output FeedBack (OFB)

Output FeedBack (OFB)

Similar to Cipher FeedBack (CFB), except:

  • Output of encryption function is fed back to shift register in OFB. (CFB: ciphertext unit is fed back to shift register)
  • OFB operates on full blocks, not on an -bit subset.

Nonce

Nonce: time-varying value that has at most a negligible chance of repeating.

Link to original

Link to original

OFB: Encryption & Decryption

Nonce unique to each execution of encryption operation:

  • Sequence of depends only on key and IV and not on plaintext.
  • For given and , stream used to XOR with stream is fixed.
  • If 2 different messages had an identical block of plaintext in identical position, an attacker could determine that portion of stream.

If we let block size be : if last plaintext block contains bits (indicated by *), most significant bits of last output block are used for XOR. Remaining bits of last output block are discarded.

Introduction to Public-Key Cryptography

  • Present an overview of the basic principles of public-key cryptosystems. 
  • Explain the different uses of public-key cryptosystems. 
  • List and explain the requirements for a public-key cryptosystem.

Principles of public-key cryptosystems

  • Secrecy (public-key cryptosystem)

    Secrecy (confidentiality) means only , who possesses , can decrypt , where is a secret intended for .

    Link to original
  • Authentication (public-key cryptosystem)

    Authentication means only , who possesses can have generated . (everyone may decrypt and read as is public)

    Link to original

Overview of Public-Key Cryptography

Applications of public-key cryptosystems

  • Encryption / decryption: sender encrypts a message with recipient’s public key
  • Key exchange: two sides cooperate to exchange a session key different approaches are possible, involving private key(s) of one or both parties
  • Digital signature: sender “signs” a message with its private key signing is achieved by a cryptographic algorithm applied to a message or small block of data that is a function of message

Requirements for public-key cryptography

  1. Computationally easy for any principal to generate a pair (public key , private key )
  2. Computationally easy for sender , knowing and , to generate .
  3. Computationally easy for receiver to decrypt using to recover :
  4. It is computationally infeasible for an adversary:
    • Knowing to determine
    • Knowing and to recover
  5. (useful but not always necessary) The two keys can be applied in either order:

Function terminology

is a function from the set (f’s domain) to the set (f’s codomain).

Image (functions)

Image of is a subset of ‘s codomain that is output of on a subset of its domain (image is the smaller oval inside ).

  • Image of under is (value of when applied to )
  • Image of a subset under is subset defined by
  • Image of entire domain of is called the image of .
Link to original

Inverse image (functions)

Inverse image (or preimage) of a particular subset of the codomain of a function is the set of all elements of the domain that map to the members of .

Link to original

One-way function

A function is a one-way function, if is ‘easy’ to compute for all , but $f^{-1} is ‘hard’ or ‘infeasible’ to compute.

  • ‘easy’: solved in polynomial time as function of input length
  • ‘infeasible’: effort to solve grows faster than polynomial time as a function of input size
Link to original

Trapdoor one-way function

A trapdoor one-way function is a one-way function easy to calculate in one direction and infeasible to calculate in the other direction unless certain additional information is known (with which the inverse can be calculated in polynomial time, it is feasible to find for , an where ).

Link to original

Public-key cryptanalysis

  • Brute-force attacks are possible: we use large keys to counter this.
  • Computing private key from public key: no proof that this attack is infeasible. (not even for RSA)
  • Probable-message attack: suppose a short message is encrypted with . The attack computes all for all possible plaintexts for and stops as soon as concluding that (the message sent). Solution: append random bits to before encryption.

1 item under this folder.