Skip to content

Lecture 5 - Combining Confidentiality and Integrity

Lecture 5 - Combining Confidentiality and Integrity

eecs-388

Ciphertext Malleability

  • many encryption methods are malleable - can transform a ciphertext into another ciphertext that decrypts to a related plaintext, without knowing the plaintext
    • in CBC mode decryption, flipping bits in ciphertext block ii will:
      • completely corrupt decrypted block ii
      • flip corresponding bits in decrypted block i+1i+1
    • in counter mode decryption, flipping bits anywhere in the ciphertext will flip corresponding bits in decrypted plaintext

Authenticated Encryption (AE)

  • two general approaches:

    • generically compose encryption and MAC
    • build “all-in-one” primitive that does both
  • syntax:

    • c:=Ek(p)c := E_k(p)
    • p/"fail":=Dk(c)p / \text{"fail"} := D_k(c) (decryption can fail; analogous to Bob rejecting verifier)
  • security definition:

    1. let kk be a secret key
    2. toss a coin (in secret) to get bit bb
    3. if b=0b = 0:
      • G():=Ek();H():=Dk∗()G() := E_k(); H() := D^*_k()
          • modified to return “fail” on previous E()E() outputs if b=1b = 1:
      • G():=random bits;H():="fail"G() := \text{random bits}; H() := \text{"fail"}
    4. give Mallory G()/H()G()/H() oracles (Mallory gets to repeatedly query them)
    5. Mallory guesses bb in polynomial time
  • we say AE is secure if Mallory can’t do meaningfully better than guessing

Composing Integrity and Confidentiality

MAC-then-Encrypt

  • note that we use two keys here
    • integrity: if one key leaks, the other is still strong
    • generic composition: individual functions do not make any promises about what happens if you use the same key for both of them (individually, the functions may be strong; but together, they may leak some information about the key)

Encrypt-and-MAC

Encrypt-then-MAC

  • safest approach
  • only approach that guarantees that ciphertext has not been tampered with when we go to decrypt it
  • aka, for all other approaches, we must decrypt first then check if it’s valid, leaving us open to padding oracle attacks
    • the oracle doesn’t necessarily need to explicitly return “MAC error” vs “Padding error”; something as simple as taking a few extra milliseconds is enough

Padding Oracle Attack

Authenticated Encryption with Associated Data (AEAD)

  • integrity and encryption in a single primitive:
    • c,v:=seal(k,p,[associated data])c,v := seal(k,p,[\text{associated data}])
      • encrypts plaintext pp and returns ciphertext cc and verifier vv (“tag”)
    • p,err:=unseal(k,c,v,[associated data])p, \text{err} := unseal(k,c,v,\text{[associated data]})
      • returns pp or an error if vv doesn’t match supplied cc and associated data
    • optional associated data:
      • covered by verifier but not encrypted
      • useful for binding data to its context
  • examples:
    • AES-GCM (Galois Counter Mode), hardware accelerated in recent CPUs
    • ChaCha20-Poly1305, common on mobile

Galois/Counter Mode (GCM)

  • most widely used AEAD cipher mode
  • non-generic composition of AES in CTR mode for encryption and a special MAC based on polynomials over finite (Galois) fields
  • note: GCM violates principle of key separation
  • warning: can construct GCM ciphertexts that decrypt under many keys (differently, but without error)
  • warning: GCM nonce reuse is catastrophic; encrypting two ciphertexts with the same (k, nonce) leaks the plaintext and the MAC key

Parameter Sizes

  • choose ∣k∣|k| to resist brute force attacks, even as computers becomef aster
  • for ciphers/PRG keys:
    • want to resist exhaustive search for kk
    • 128 bits considered “classically” safe
    • for quantum-resistance, use 256 bits
  • for hash functions:
    • want collision resistance (CR)
    • need 2n bits of output for n bits of CR, due to “birthday” attacks
  • estimating what’s feasible to compute:
    • CPU mining: ~10810^8 SHA-256/s
    • GPU mining: ~101110^{11} SHA-256/s
    • ASIC mining: ~101410^{14} SHA-256/s
    • CPU mining: ~102110^{21} SHA-256/s
  • birthday attack:
    • generate random values, look for collision
    • requires 2∣k∣/22^{|k|/2} time, 2∣k∣/22^{|k|/2} space
    • for 128-bit output, takes 2642^{64} steps; doable
Sep 15, 2026