Outline
- Overview of Modes of Operation
- Security Pitfalls/Advantages of each Mode of Operation
Introduction
- Block Ciphers: Typical block ciphers encrypt fixed-size blocks of data.
- Example: DES encrypts -bit blocks.
- Example: AES encrypts -bit blocks.
- Message Size: In practice, messages are often larger than the standard block size.
- Processing Large Messages: To handle larger messages:
- Divide the message into a number of blocks.
- Cipher each block one by one.
- Mode of Operation: A mode of operation describes the specific process of encrypting each block of a message using a single key.
Modes of Operation Overview
Current well-known modes of operation include:
- Electronic Code Book mode (ECB)
- Cipher Block Chaining mode (CBC)
- Cipher Feedback mode (CFB)
- Output Feedback mode (OFB)
- Counter mode (CTR)
- Galois Counter mode (GCM)
Terminology
- Initialize Vector (IV):
- A block of bits used to randomize the encryption process.
- Purpose: To produce distinct ciphertexts even for identical plaintext blocks or messages.
- Must be non-repeating for certain modes, often required to be unpredictable.
- Nonce (Number used Once):
- A random or pseudo-random number.
- Purpose: To ensure that past communications cannot be reused in replay attacks. The nonce should be unique for each message encrypted with the same key.
- Note: Sometimes the term “nonce” is used interchangeably with “initialize vector (IV)”, especially when the primary requirement is uniqueness.
- Padding:
- The process of adding extra bits to the final block of plaintext to ensure it meets the required block size for the cipher.
- Necessary for modes like ECB and CBC if the message length is not an exact multiple of the block size.
Electronic Codebook Mode (ECB)
Operation
-
Encryption: Each plaintext block is encrypted independently using the secret key .
- Formula:
-
Decryption: Each ciphertext block is decrypted independently using the secret key .
- Formula:
-
Definitions:
- : Encryption function
- : Decryption function
- : Plaintext block
- : Ciphertext block
- : Secret key
- : Block size in bits
Diagram Description (Based on Slide 6)
- Encryption:
- The message is divided into -bit blocks: .
- Each block is fed into the encryption algorithm with the key .
- The output is the corresponding -bit ciphertext block .
- All encryptions are independent.
- Decryption:
- The ciphertext is divided into -bit blocks: .
- Each block is fed into the decryption algorithm with the key .
- The output is the corresponding -bit plaintext block .
- All decryptions are independent.
Ciphertext Stealing (CTS) for ECB
- Problem: Padding is required in ECB if the last block is not bits long. Padding isn’t always feasible (e.g., when ciphertext must occupy the exact same buffer as the plaintext).
- Solution: Ciphertext Stealing (CTS) allows ECB use without padding.
- Process (for last two blocks and ):
- Assume has bits and has bits, where .
- Step 1: Encrypt the second-to-last plaintext block:
- Step 2: Construct an intermediate block by concatenating the last (partial) plaintext block with the trailing bits of : (where selects the rightmost bits of )
- Step 3: The final ciphertext block consists of the leading bits of : (where selects the leftmost bits of )
- Step 4: The second-to-last ciphertext block is the encryption of :
- Note: Decryption involves reversing these steps. Detailed diagrams/procedures are often left as exercises.
Security Issues
- Pattern Preservation: Identical plaintext blocks always encrypt to identical ciphertext blocks (given the same key).
- Leakage: If an attacker (Eve) observes that , , and are the same, she knows , , and are also the same.
- Attack Vector: Eve could perform an exhaustive search to decrypt just one repeated block and learn the content of all identical blocks.
- Block Independence & Substitution: Since blocks are independent, Eve can manipulate the ciphertext without knowing the key.
- Attack: Eve can capture messages, identify blocks with specific meanings (e.g., block 8 always contains salary info), and substitute blocks from previous messages or rearrange blocks within a message.
- Example (Slide 9): Eve works part-time (low pay). The company sends payment info to the bank; block 7 contains the payment amount. Eve intercepts the ciphertext for her payment. She replaces block 7 with a copy of block 7 from a previous message containing the payment for a full-time colleague. She receives higher pay. This is a substitution attack.
Error Propagation
- A single-bit error in a transmitted ciphertext block will cause errors within the corresponding decrypted plaintext block .
- The error affects only the corresponding block. Decryption of other blocks ( where ) remains unaffected.
- Effect within the block: Typically, about half of the bits in the decrypted block will be incorrect due to the properties of block ciphers.
Advantages of ECB Mode
- No Synchronization Needed: Block encryption/decryption for / doesn’t depend on other blocks, so synchronization between sender and receiver for block processing isn’t required beyond agreeing on the key.
- Error Isolation: Transmission errors (bit flips) in one ciphertext block only affect the decryption of that specific block . Errors do not propagate to subsequent blocks.
- Parallelizable: Encryption and decryption of multiple blocks can be performed in parallel, potentially increasing throughput.
Limitations of ECB Mode
- Deterministic Encryption: Identical plaintext blocks produce identical ciphertext blocks (with the same key). This is the primary weakness.
- Susceptibility to Substitution Attacks: Due to block independence and deterministic encryption, attackers can rearrange, repeat, or substitute ciphertext blocks to manipulate the decrypted message without needing the key. (See Security Issues and Slide 12 example table).
Applications
- Not Recommended for Messages: Generally not recommended for encrypting messages longer than one block, especially over insecure channels, due to the security weaknesses (pattern preservation, substitution).
- Single Block Encryption: Tolerable if the message fits within a single block.
- Encrypted Databases (with caution): Sometimes used where random access to encrypted records is needed. Since blocks are independent, a specific record (if aligned with block boundaries) can be decrypted or re-encrypted without affecting others. However, the pattern preservation weakness can still be a concern depending on the data structure.
Visual Example (Slide 14)
- An image encrypted using AES-256 in ECB mode.
- Observation: Although encrypted, the outline and major features of the original image (“CRYPTOGRAPHY AND DATA SECURITY”) are still clearly visible in the encrypted version. This is because identical blocks of color/pixels in the original image encrypt to identical blocks in the ciphertext image, preserving patterns. This visually demonstrates the primary weakness of ECB.
Cipher Block Chaining (CBC) Mode
Operation
-
Goal: To make each ciphertext block dependent on all preceding plaintext blocks.
-
Initialization Vector (IV): Uses an IV () to start the process. The IV must be known by both sender and receiver. It should ideally be random and unpredictable for each message encryption session.
-
Encryption: Before encrypting plaintext block , it is XORed with the previous ciphertext block .
- Formula:
- Initial step:
-
Decryption: Each ciphertext block is first decrypted, and then the result is XORed with the previous ciphertext block to recover the plaintext .
- Formula:
- Initial step:
-
Derivation Proof (Decryption):
-
Definitions:
- : Encryption function
- : Decryption function
- : Plaintext block
- : Ciphertext block
- : Secret key
- : Block size in bits
- : Initialization Vector (acts as )
- : Bitwise XOR operation
Diagram Description (Based on Slide 15)
- Encryption:
- An -bit IV () is used.
- For block 1: is XORed with , then encrypted with to get .
- For block (): is XORed with the previous ciphertext block , then encrypted with to get .
- The process chains blocks together.
- Decryption:
- The same -bit IV () is used.
- For block 1: is decrypted with , then XORed with to get .
- For block (): is decrypted with , then XORed with the previous ciphertext block to get .
Discussion
- Dependency: Encryption of a block depends on and all preceding plaintext blocks () due to the chaining mechanism ( depends on and , etc.).
- Identical Plaintext Blocks: Repeated plaintext blocks within the same message will (almost always) encrypt to different ciphertext blocks because the input to the encryption function () changes.
- Initialization Vector (IV):
- Must be known by both sender and receiver.
- Typically, the IV is generated by the sender and sent in the clear (unencrypted) along with the ciphertext, often prepended to the first ciphertext block. It does not need to be secret, but it must be unique (preferably random/unpredictable) for each message encrypted with the same key.
- Decryption Dependency: Decryption of depends on and . It is not dependent on the entire message decryption process before it, only the immediately preceding ciphertext block.
- Error Propagation: Occurs (see details below).
CBC Encryption Algorithm (Pseudocode - Slide 17)
CBC_Encryption (IV, K, Plaintext blocks P[1...N])
{
C[0] = IV // Use IV as the "zeroth" ciphertext block
for (i = 1 to N)
{
Temp = P[i] XOR C[i-1]
C[i] = E_K(Temp)
}
return Ciphertext blocks C[1...N]
}
(Note: MathJax formatting applied conceptually here) for ( to ) { } return
Security Issues
- Pattern Hiding (Within a Message): CBC hides patterns within a single message. Identical plaintext blocks usually yield different ciphertext blocks.
- Identical Messages & IV Reuse: If two identical messages are encrypted with the same key and the same IV, they will produce the exact same ciphertext.
- Problem: If an attacker sees the same ciphertext twice, they know the same message was sent.
- Partial Leakage: If the first blocks of two different messages are identical, and the same IV is used, the first ciphertext blocks will also be identical.
- Mitigation: Always use a unique, unpredictable IV for each message. Using a timestamp as an IV is sometimes suggested but may not provide sufficient unpredictability. Random IVs are generally preferred.
- Ciphertext Manipulation (End of Stream): An attacker can potentially append blocks to the end of a ciphertext stream without being detected immediately if integrity is not checked separately. (The effect on the final plaintext block might be predictable if the attacker can guess the plaintext). More sophisticated attacks like padding oracle attacks exist if padding is handled improperly during decryption.
Error Propagation
- Effect of Error in : A single-bit error in ciphertext block during transmission has the following effects during decryption:
- On : The error completely corrupts the decryption of the corresponding plaintext block . Due to block cipher properties, typically ~50% of the bits in will be flipped.
- On : The same single-bit error appears in the same bit position in the next plaintext block . This is because . The error in directly flips the corresponding bit in after the XOR operation.
- On Subsequent Blocks ( onwards): Plaintext blocks to are not affected by the error in , as their decryption only depends on .
- Self-Recovery: The effect of a ciphertext bit error is limited. The decryption process automatically recovers (resynchronizes) after two blocks ( and ).
Ciphertext Stealing (CTS) for CBC
- Similar to ECB CTS, it can be applied to CBC to avoid padding.
- Process (Conceptual - Slide 20): Involves manipulating the last two blocks () and the preceding ciphertext block () differently.
- (Pad the last partial block with zeros to full block size )
- (Final ciphertext block is partial)
- (Second-to-last ciphertext block)
- Note: The
padfunction here inserts s. Decryption reverses this.
Applications
- General Message Encryption: CBC is widely used for encrypting messages and data streams where confidentiality is required and patterns need to be obscured.
- Not Ideal for Random Access: Because decryption of block requires , CBC is generally not suitable for applications requiring efficient random access to encrypted data (like databases where individual records need frequent decryption/re-encryption). Accessing requires accessing and .
- Authentication: CBC is also used as a basis for authentication mechanisms, such as CBC-MAC (Cipher Block Chaining Message Authentication Code).
Cipher Feedback Mode (CFB)
Operation
-
Stream Cipher Emulation: CFB uses a block cipher to generate a pseudorandom keystream that is XORed with plaintext, effectively turning the block cipher into a self-synchronizing stream cipher.
-
Shift Register: Uses an -bit shift register (initially containing the IV).
-
Parameter : Operates on segments of bits at a time, where . Often (byte) or .
-
Encryption:
- Encrypt the current content of the shift register () using key : .
- Select the leftmost bits of : .
- XOR with the -bit plaintext segment : .
- Update the shift register: Shift left by bits, discard the old leftmost bits, and place the -bit ciphertext segment into the rightmost positions. .
-
Decryption:
- Encrypt the current content of the shift register () using key : .
- Select the leftmost bits of : .
- XOR with the -bit ciphertext segment : .
- Update the shift register: Shift left by bits, discard the old leftmost bits, and place the received -bit ciphertext segment into the rightmost positions. . (Shift register update is identical for encryption and decryption).
-
Formulas (Summarized):
- Keystream generation:
- Encryption:
- Decryption:
- Register Update: (Conceptual: shift left by , append )
-
Definitions:
- : Encryption function (Decryption function is not used)
- : -bit Plaintext segment
- : -bit Ciphertext segment
- : Secret key
- : Initialization Vector (initial state of the shift register)
- : State of the -bit shift register after step
- : Temporary -bit register holding
- : -bit keystream segment for step
- : Block size of the underlying cipher
- : Feedback size (number of bits processed per step)
- : Function selecting the leftmost bits
- : Function shifting register left by bits
- : Concatenation
Diagram Description (Based on Slide 22 - Encryption)
- Starts with IV in shift register .
- For step :
- (content of register before step ) is encrypted using with key , result stored in .
- The leftmost bits of are selected ().
- is XORed with the -bit plaintext to produce -bit ciphertext .
- is shifted left by bits.
- The ciphertext is placed in the newly vacated rightmost bits of the register to form .
- This is transmitted.
CFB as a Stream Cipher
- Although CFB uses a block cipher internally, its operation mimics a stream cipher.
- It generates a keystream () which is XORed with the plaintext.
- It’s a nonsynchronous (or self-synchronizing) stream cipher because the keystream generation depends on the ciphertext that has been previously generated (and transmitted). If synchronization is lost, it can resynchronize after steps once correct ciphertext segments are received.
CFB Encryption Algorithm (Pseudocode - Slide 24)
CFB_Encryption (IV, K, r, Plaintext P) // P is sequence of r-bit blocks
{
Initialize shift register S with IV
i = 1
while (more r-bit blocks P_i in P)
{
// Keystream Generation
Temp_Encrypted = E_K(S)
k_i = selectLeft_r(Temp_Encrypted)
// Encryption
C_i = P_i XOR k_i
output(C_i)
// Shift Register Update
S = shiftLeft_r(S)
S = concatenate(S_shifted, C_i) // Append C_i to the right
i = i + 1
}
}
(Note: MathJax applied conceptually. Slide 24 has slightly different pseudocode structure but equivalent logic) Initialize while (more blocks to encrypt) { input () // -bit plaintext block output () // Simplified notation for shifting and inserting }
Security Issues
- Pattern Hiding: Like CBC, CFB generally hides patterns within the message, as the keystream depends on previous ciphertext.
- IV Requirement: More than one message can be encrypted with the same key, but the IV must be unique for each message to ensure the keystreams are different. Reusing an IV with the same key compromises security (e.g., allows recovery of XOR of plaintexts).
- Ciphertext Manipulation: Similar to CBC, an attacker might append blocks to the ciphertext stream. Also, manipulating ciphertext bits will affect decryption (see Error Propagation). Requires integrity protection.
Error Propagation
- Effect of Error in : A single-bit error in an -bit ciphertext segment has the following effects:
- On : It causes a single-bit error (in the same position) in the corresponding plaintext segment , because .
- On Subsequent Plaintext ( to ): The incorrect enters the shift register. It will remain in the register and affect the generation of the next keystream segments (). This will corrupt the decryption of the corresponding plaintext segments (). The corruption is typically widespread within these segments (approx. 50% bit errors).
- Recovery: After the erroneous bits from have been completely shifted out of the register (which takes steps), the system recovers and subsequent plaintext segments are decrypted correctly, assuming no further ciphertext errors occur. This is the self-synchronizing property.
Applications
- Stream-oriented Encryption: Useful for encrypting data streams where processing must happen in smaller units (e.g., characters, single bytes, or even bits if ) without waiting for a full block.
- No Padding Needed: Since it operates on -bit segments, there’s no need for message padding, as the last segment can be processed regardless of its size (up to bits, though typically used with fixed ). Common values for are (byte-oriented) or (full block feedback).
CFB as a Stream Cipher (Diagram - Slide 28)
- Shows sender (Encryption) and receiver (Decryption).
- Both use the same Key Generator logic (Shift Register + Block Cipher Encryption ).
- Encryption: Generates keystream , XORs with to get . is sent over insecure channel AND fed back into the shift register.
- Decryption: Generates the same keystream (using the received in its shift register), XORs with received to recover . The received is also fed back into the shift register.
- Highlights that only the encryption function of the block cipher is needed for both encryption and decryption.
Discussion on CFB (Slide 29)
- Decryption using Encryption: A key feature is that the decryption process uses only the encryption function () of the underlying block cipher. The decryption function () is never needed.
- Role of Encryption Algorithm: The block cipher encryption is not used directly on plaintext but acts as a keystream generator. The generated keystream () is then XORed with the plaintext/ciphertext.
Advantage (Slide 30)
- Hides Patterns: Same plaintext block/segment will likely produce different ciphertext segments due to the changing state of the shift register.
- No Padding Essential: Can process data in smaller units ( bits), avoiding the need for padding the message to a multiple of the block size . Example: Encrypting 400 bits with AES (128-bit block, ). If using CFB-16 (), the last 16 bits () can be encrypted directly. (Example needs clarification: . If using CFB-128, padding might still be considered conceptually, but CFB allows operating on the final partial block, effectively generating only 16 bits of keystream for the last step if is flexible or handled appropriately.) The key point is CFB can naturally handle streams that don’t end on a block boundary.
Limitation (Slide 31)
- Decryption Dependency: Decryption of depends on . Since depends on , decryption has a dependency on several preceding ciphertext segments. (Note: Slide 16 said CBC decryption is message dependent, Slide 31 seems to imply CFB encryption process dependence affects decryption. Let’s stick to the mechanism: depends on and . depends on , which depends on previous ‘s. So correct.)
- Error Propagation: Errors in ciphertext propagate to multiple subsequent plaintext segments, as described previously.
Output Feedback Mode (OFB)
Operation
-
Stream Cipher Emulation: Similar to CFB, OFB turns a block cipher into a stream cipher by generating a keystream that is XORed with plaintext.
-
Key Difference from CFB: The output of the block cipher encryption () is fed back into the shift register, not the ciphertext ().
-
Shift Register: Uses an -bit shift register (initially containing the IV).
-
Parameter : Can conceptually operate on -bit segments (), but typically used with (full block feedback). The diagram implies bits of keystream are used, but the feedback loop uses the full -bit output . We’ll assume for simplicity based on common usage and the diagram’s implication for feedback, though bits are XORed. Slide 40 implies . Let’s assume the keystream generation uses full block output feedback, but bits are selected for XOR.
-
Encryption:
- Encrypt the current content of the shift register () using key : .
- Select the leftmost bits of : .
- XOR with the -bit plaintext segment : .
- Update the shift register with the output of the encryption: . (If , . If , the update rule needs clarification, but standard OFB uses full block feedback: ). Let’s assume standard full-block feedback OFB ().
-
Decryption:
- Generate the keystream exactly as in encryption (it’s independent of ciphertext). , , .
- XOR with the -bit ciphertext segment : .
-
Formulas (Assuming , Full Block Feedback):
- Register Update: (Starting with )
- Keystream generation: (The entire output is the keystream block)
- Encryption:
- Decryption:
-
Definitions: (Similar to CFB, but update differs)
- : State of the -bit register (or input block) for step . .
- : -bit Keystream block .
Diagram Description (Based on Slide 32 - Encryption, assuming r=n)
- Starts with IV in the position of .
- For step (generating block ):
- (output from previous encryption, or IV for ) is encrypted using with key to produce (which is also and ).
- is XORed with plaintext block to produce ciphertext block .
- The output (which is ) becomes the input for the next encryption step. The ciphertext is not part of the feedback loop.
OFB as a Stream Cipher (Diagram - Slide 33)
- Shows sender and receiver generating the exact same keystream () independently of the data being transmitted (once initialized with the same IV).
- The keystream generator involves the register () and the block cipher encryption ().
- The generated keystream is XORed with for encryption and with for decryption.
- The process is identical to a synchronous stream cipher where the keystream is pre-computable.
OFB Encryption Algorithm (Pseudocode - Slide 34, assuming r=n)
OFB_Encryption (IV, K, Plaintext P) // P is sequence of n-bit blocks
{
S = IV // Current input to encryption
i = 1
while (more n-bit blocks P_i in P)
{
// Keystream Generation & Register Update
k_i = E_K(S) // Keystream block is the output
S = k_i // Output is the next input
// Encryption
C_i = P_i XOR k_i
output(C_i)
i = i + 1
}
}
(Note: MathJax applied conceptually. Slide 34 pseudocode uses slightly different variable names and logic flow, including concatenation with which seems incorrect for standard OFB. Standard OFB uses the full block output as the next state . Let’s stick to the standard definition as described above and matching slide 32/33 diagrams)
OFB Scheme Explanation (Slide 35)
- Similarity to CFB: Generates a keystream using the block cipher.
- Key Difference: In OFB, the input to the encryption function at each step is the output from the previous step’s encryption. In CFB, the input includes the ciphertext from the previous step.
- Independence from Ciphertext: The keystream generation in OFB is independent of both the plaintext and the ciphertext.
- No Error Propagation: This is the main advantage. A bit error in the ciphertext only affects the corresponding bit in the decrypted plaintext . It does not affect the decryption of any other blocks because the keystream generation is independent of the ciphertext.
Advantages of OFB
- No Error Propagation: Bit errors in ciphertext do not propagate.
- Pre-computation: The keystream can be pre-computed independently of the plaintext, which can be useful if the plaintext arrives later or if high speed is needed.
- No Padding: Like CFB, operates as a stream cipher, naturally handling messages of any length.
Disadvantages of OFB
- Synchronous Stream Cipher Issues: More susceptible to attacks involving modification or replay if IVs are reused or if the stream synchronization is lost. If a ciphertext block is lost or inserted, synchronization is lost permanently for the rest of the message (unlike CFB which can resynchronize).
- IV Uniqueness Critical: Reusing the same IV with the same key is catastrophic, as it reproduces the exact same keystream, allowing attackers to obtain the XOR of two plaintexts ().
Counter Mode (CTR)
Operation
-
Stream Cipher Emulation: Like OFB, CTR mode turns a block cipher into a synchronous stream cipher.
-
Counter: Uses a “counter” block for each plaintext block. The counter value must be unique for each block encrypted with the same key.
-
Process:
- Initialize a counter (often derived from a nonce or IV).
- For each block , encrypt the current counter value: .
- XOR the result (, the keystream block) with the plaintext block : .
- Increment the counter for the next block (, or some other deterministic sequence).
-
Decryption: Identical to encryption, except XOR the keystream with the ciphertext block : . The keystream is generated the same way using the counter sequence.
-
Formulas:
- Keystream generation:
- Encryption:
- Decryption:
- Counter Update: (e.g., )
-
Definitions:
- : Encryption function (Decryption not used)
- : Plaintext block
- : Ciphertext block
- : Secret key
- : Keystream block
- : Value of the counter for block . Often formed by combining a nonce and a block index . Must be unique per block per key.
- /Nonce: Used to initialize the counter sequence, ensuring uniqueness across messages.
Diagram Description (Based on Slide 36 - Encryption)
- An initial counter value is established (e.g., from an IV/Nonce).
- For each block :
- The current counter value () is encrypted using with key to produce keystream block .
- is XORed with plaintext block to produce ciphertext block .
- The counter is incremented (or updated deterministically) for the next block.
- The diagram shows separate counters for each block, implying is typically .
Discussion (Slide 37)
- No Message Dependency: Keystream generation depends only on the key and the unique counter value for that block, not on plaintext or ciphertext.
- Parallelizable: Encryption (and decryption) of blocks can be done in parallel because the keystream generation for block () does not depend on the results from block . This is a significant advantage for performance.
- Encryption Only: Only the encryption function of the block cipher is needed for both CTR encryption and decryption.
CTR Encryption and Decryption Diagram (Slide 38)
- Shows parallel structures.
- Encryption: , , …, are each encrypted with to produce . Each is XORed with to get .
- Decryption: , , …, are each encrypted with to produce the same . Each is XORed with to get .
Advantages of CTR
- Efficiency: Can be highly parallelized for high throughput.
- Random Access: Encryption/Decryption of any block can be done independently if the counter value is known/calculable.
- Simplicity: Requires only the encryption function. No padding needed (operates as stream cipher).
- Provable Security: Strong security properties (if block cipher is secure and counters are unique).
- No Error Propagation: Like OFB, ciphertext errors don’t propagate.
Disadvantages of CTR
- Nonce/Counter Uniqueness is Critical: Reusing a counter value for two different blocks with the same key is catastrophic (allows recovery of ). The nonce/IV part of the counter must be unique for each message.
- Synchronous Stream Cipher Issues: Susceptible to ciphertext manipulation (bit-flipping attacks) if integrity is not separately ensured. Loss of synchronization requires re-initialization.
CBC and CTR Comparison (Slide 39)
| Feature | CBC | CTR |
|---|---|---|
| Padding | Needed if message not multiple of | No padding needed |
| Parallel Processing | No (Encryption is sequential) | Yes (Encryption/Decryption) |
| Block Cipher Functions | Requires both Encryption () & Decryption () | Requires only Encryption () |
| Initialization | Random IV or Nonce | Unique Nonce (forms part of counter) |
| Nonce/IV Reuse Impact | Leaks if messages are identical | Leaks XOR of plaintexts () |
| Error Propagation (Ciphertext) | Affects (fully) and (single bit) | Affects only (single bit) |
| Random Access | No (Decryption needs ) | Yes (If counter value is known) |
Comparison of Different Modes (Summary Table - Slide 40)
| Operation Mode | Description | Type of Result | Data Unit Size | Parallelizable (Encrypt) | Error Propagation (Ciphertext) | Function(s) Needed | Padding Needed |
|---|---|---|---|---|---|---|---|
| ECB | Each -bit block encrypted independently with same key. | Block cipher | Yes | Affects only | Yes | ||
| CBC | Block is encrypted. | Block cipher | No | Affects | Yes | ||
| CFB | -bit XORed with bits from ; fed back. | Stream cipher | No | Affects & next P’s | only | No | |
| OFB | -bit XORed with bits from ; output fed back. | Stream cipher | No | Affects only | only | No | |
| CTR | XORed with . | Stream cipher | (or ) | Yes | Affects only | only | No |
(Note: Parallelizability & Data Unit Size for CTR adjusted based on common usage & potential for partial blocks)
Galois Counter Mode (GCM)
Introduction
- Goal beyond Confidentiality: While ECB, CBC, CFB, OFB, CTR provide confidentiality (encrypt data), GCM provides both confidentiality and data authenticity (integrity).
- Authentication: Ensures the receiver (Bob) that the message genuinely originated from the sender (Alice) who shares the key, and that it hasn’t been tampered with in transit.
- AEAD: GCM is an Authenticated Encryption with Associated Data (AEAD) scheme.
GCM Components (Slides 41-43)
- Encryption: Uses Counter (CTR) mode for encryption, providing confidentiality.
- Authentication: Computes a Message Authentication Code (MAC) called an “authentication tag”.
- Uses chained Galois Field multiplication () for efficient MAC computation.
- The specific field uses the irreducible polynomial: .
- Associated Data (AAD): Allows authentication of additional data (like headers) that is not encrypted but needs integrity protection.
- MAC (Tag): A cryptographic checksum computed by the sender (Alice) based on the key, nonce, plaintext (via ciphertext), and AAD. It’s appended to the message. The receiver (Bob) recomputes the MAC based on the received data and compares it with the received tag. A match confirms authenticity and integrity.
GCM High-Level Process (Diagram Slide 44)
- Inputs: Plaintext (), Key (), Nonce (IV), Additional Authenticated Data (AAD).
- Encryption Path (Top):
- Generates keystream blocks () using CTR mode based on the nonce/IV.
- XORs keystream with plaintext blocks () to produce ciphertext blocks ().
- Authentication Path (Bottom/Chaining):
- Generates an authentication subkey (encrypting the all-zero block).
- Initializes accumulator (multiplication in ).
- For each ciphertext block : .
- Computes final tag based on the final accumulator value (), the lengths of AAD and ciphertext, and the encrypted initial counter value . The formula is (simplified view, actual GHASH involves lengths).
- Output: Ciphertext () and Authentication Tag ().
GCM Definition and Algorithm Steps (Slide 45)
- Let be the block cipher (e.g., AES) with block size bits.
- Let plaintext be blocks .
- Let AAD be the additional authenticated data.
- Let be the initialization vector (nonce).
-
Encryption (CTR part):
- a. Derive initial counter from . Compute subsequent counters (typically).
- b. Compute ciphertext blocks: , for .
-
Authentication (GMAC/GHASH part):
- a. Generate authentication subkey: .
- b. Compute initial hash value from AAD: (Galois field multiplication). Pad AAD if necessary.
- c. Compute intermediate hash values: , for . Pad last if partial. (This forms the GHASH function).
- d. Compute final authentication tag: . (Slide formula: is a slight simplification, GHASH includes length block).
Receiver Steps (Slide 46)
- Receive Packet: Gets .
- Decrypt: Uses CTR mode with the shared key and the IV (to reconstruct ) to decrypt back to potential plaintext . ().
- Verify Authenticity:
- Recomputes the authentication tag using the received ciphertext , the received , the shared key , and the IV (nonce). This uses the same authentication steps (GHASH) as the sender.
- Compares the computed tag with the received tag .
- Validation: If , the receiver is assured:
- The message came from the legitimate sender (who knows ).
- The ciphertext and the AAD were not tampered with during transit.
- If the tags do not match, the decryption should be discarded, and the message rejected as invalid/tampered.
Conclusions (Slide 47)
- Variety: Many modes exist for using block ciphers, each with pros and cons.
- Stream Ciphers: Several modes (CFB, OFB, CTR, GCM via CTR) effectively turn block ciphers into stream ciphers.
- ECB Weakness: Straightforward ECB mode is insecure due to pattern preservation, regardless of the underlying block cipher’s strength.
- CTR Parallelism: Counter mode allows high-speed implementation due to parallelizable encryption/decryption.
- Double Encryption: Generally, applying the same block cipher twice (e.g., double DES with the same key) provides only marginal improvement against brute-force attacks (related to meet-in-the-middle attacks). Proper modes or longer keys are better solutions. GCM provides a standardized way to achieve both confidentiality and integrity.