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 will:
- completely corrupt decrypted block
- flip corresponding bits in decrypted block
- in counter mode decryption, flipping bits anywhere in the ciphertext will flip corresponding bits in decrypted plaintext
- in CBC mode decryption, flipping bits in ciphertext block will:
Authenticated Encryption (AE)
-
two general approaches:
- generically compose encryption and MAC
- build “all-in-one” primitive that does both
-
syntax:
- (decryption can fail; analogous to Bob rejecting verifier)
-
security definition:
- let be a secret key
- toss a coin (in secret) to get bit
- if :
-
-
- modified to return “fail” on previous outputs if :
-
-
- give Mallory oracles (Mallory gets to repeatedly query them)
- Mallory guesses 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:
-
- encrypts plaintext and returns ciphertext and verifier (“tag”)
-
- returns or an error if doesn’t match supplied 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 to resist brute force attacks, even as computers becomef aster
- for ciphers/PRG keys:
- want to resist exhaustive search for
- 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: ~ SHA-256/s
- GPU mining: ~ SHA-256/s
- ASIC mining: ~ SHA-256/s
- CPU mining: ~ SHA-256/s
- birthday attack:
- generate random values, look for collision
- requires time, space
- for 128-bit output, takes steps; doable