Skip to content
uencoder

CTR (Counter Mode)

CTR mode turns a block cipher into a stream cipher: it encrypts an incrementing counter to generate a keystream that is XORed with the plaintext, supporting parallelism and random access, but provides no integrity.

Purpose

It offers stream-cipher padding-free operation while allowing parallel encryption and random-access decryption.

Mechanism

Encryption: C_i = P_i ⊕ E_K(nonce || counter_i). The counter increments from an initial value, and the nonce must be unique. Blocks are independent, so it parallelizes. It is unauthenticated — pair it with a MAC (e.g., CCM) or use GCM.

Use cases

  • AES-CTR streaming encryption
  • Random access to encrypted data (e.g., disks)
  • Parallel encryption acceleration
  • The underpinning of AES-GCM

Examples

  • Input
    nonce + counter 0,1,2...
    Output
    keystream blocks

    Parallelizable

Common errors

Nonce reuse replays the keystream
Use a unique nonce per message

Related terms

Related tools

References