CYS401 · Annotated SlidesChapter 5 — Cryptography
Chapter 5 · Annotated slides

Cryptography

Terminology and Kerckhoffs’s principle, how ciphers are classified, the classical ciphers you must compute by hand (Caesar, keyword, Playfair, Vigenère, one-time pad, Hill, columnar transposition), block ciphers and padding, DES/3DES/AES, the modes (ECB, CBC, CFB, OFB, CTR) and the attacks. Every major exam had a cipher, a padding count and a modes figure from this deck.

Slide text Study notes Highlight: key words Tips, tricks & traps Seen again elsewhere How it can come up

Cryptography

CYS401 · Chapter 5
1
TipHand-cipher rules: CAESAR C = (P + k) mod 26 · VIGENÈRE add the repeated key letter (subtract to decrypt) · PLAYFAIR pairs: same row → right, same column → below, rectangle → own row, other letter’s column; X between doubles · HILL row vector × K mod 26, decrypt with K⁻¹ (det must be coprime with 26) · TRANSPOSITION write in rows, read columns in key order.

  • What is Encryption/Decription?
  • Foundations of Cryptology
  • Cipher Methods
  • Cryptographic Algorithm,
  • Cryptographic Tools,
  • Protocols for secure communication,
  • Attacks on cryptosystems
2
Exam weight Low
  1. Encryption/decryption → foundations → classical ciphers → block ciphers → modes → attacks.

Cryptography

  • Cryptography, a word with Greek origins, means “secret writing.” However, we use the term to refer to the science and art of transforming messages to make them secure and immune to attacks.
3
Exam weight Low
  1. Cryptography = “secret writing”: the science and art of transforming messages to make them secure.
Slide 4: Encryption in a nutshell
Exam weight Low
  1. Encryption in a nutshell: plaintext + key → ciphertext → (key) → plaintext.
Slide 5: Basic Concepts
Exam weight Low
  1. Encryption converts a message into a form unreadable by unauthorized people, giving confidential communication over an insecure channel.
Slide 6: Some Basic Terminology
Exam weight Low
  1. Plaintext, ciphertext, cipher (algorithm), key, encipher/decipher, cryptanalysis, cryptology.
Slide 7: Basic Concepts
Exam weight Low
  1. Notation: C = E_K(P), P = D_K(C).
Slide 8: Basic Concepts
Exam weight Medium
  1. Cryptography protects confidentiality and integrity, NOT availability.
🎯 How this can come up · 1 question
True / False

Cryptography can protect availability.

Kerckhoffs's principle in cryptography

  • Cryptography algorithm should be secure even if everyone knows how it works, the security of a cryptosystem should depend solely on the secrecy of the key and the private randomizer
  • Based on Kerckhoff s principle, one should always ’ assume that the adversary, Eve, knows the encryption/decryption algorithm. The resistance of the cipher to attack must be based only on the secrecy of the key.
  • In short:
    • Algorithm must be made public
    • Only the key is kept secret
9
Exam weight High
  1. Kerckhoffs’s principle: a cryptosystem must stay secure even if everything except the KEY is public. Assume Eve knows the algorithm.
🎯 How this can come up · 1 question
MCQ

Kerckhoffs’s principle says the security of a cryptosystem should depend only on:

Slide 10: Classifying Cryptographic Systems
Exam weight Low
  1. Three dimensions: operations used (substitution, transposition), number of keys (symmetric, asymmetric), how plaintext is processed (block, stream).

Classifying Cryptographic Systems

  • Number of Keys Used
    • Same secret key is used for encryption and decryption Symmetric/ → Conventional Encryption
    • Different keys for encryption and decryption Asymmetric/ Public → Key Encryption
  • Type of operation used for encryption
    • Substitution – Each letter in the plaintext (bit, letter, group of bits or letters) is mapped into another element
    • Transposition/Permutation – Rearranging elements of the plaintext
  • Plaintext processing
    • Blocks - Block ciphers processes one block of input at a time and produces an output for each input block
    • Bit by bit – Stream Cipher processes the input elements simultaneously, producing output one element at a time, as it goes along
11
Exam weight Low
  1. Same key for both = symmetric (conventional). Different keys = asymmetric (public-key).
Slide 12: Cipher Classification
Exam weight Low
  1. Cipher classification tree.
Slide 13: Cryptosystem Types
Exam weight Low
  1. Symmetric cryptosystems use substitution (replace) and transposition (rearrange).
Slide 14: Slide 14
Exam weight Low
  1. Symmetric key: one shared key encrypts and decrypts.
Slide 15: Slide 15
Exam weight Low
  1. Proof that decryption recovers P.
Slide 16: Slide 16
Exam weight Low
  1. Same key locks and unlocks.
★ Past exam

Symmetric Cryptosystem Characteristics

  • Efficiency
    • Functions E and D should have efficient algorithms K K
    • Symmetric key encryption is fast compared to public key encryption
    • How fast? Almost 30,000 times faster
  • Consistency
    • Decrypting the ciphertext yields the plaintext
    • D (E (P)) = P K K
17
Exam weight High
  1. Symmetric needs: efficient E and D, and the ciphertext must be hard to invert without the key. Problem: secure key distribution.
🎯 How this can come up · 2 questions
MCQ

The classic problem with symmetric encryption is:

Written

Why is symmetric encryption preferred for large amounts of data? (Major C)

★ Past exam
Slide 18: Substitution Ciphers: Caesar Cipher
Exam weight High
  1. Caesar: shift every letter by k: C = (P + k) mod 26.
TipHand-cipher rules: CAESAR C = (P + k) mod 26 · VIGENÈRE add the repeated key letter (subtract to decrypt) · PLAYFAIR pairs: same row → right, same column → below, rectangle → own row, other letter’s column; X between doubles · HILL row vector × K mod 26, decrypt with K⁻¹ (det must be coprime with 26) · TRANSPOSITION write in rows, read columns in key order.
🎯 How this can come up · 2 questions
MCQ

Plaintext GLOBAL… becomes QVYLKV…. What is the Caesar key?

MCQ

Caesar with shift 3 encrypts HELLO as:

Slide 19: Caesar Cipher
Exam weight Low
  1. Shift 3 example.
Slide 20: Caesar Cipher
Exam weight Low
  1. Shift 1 example.
Slide 21: Substitution Ciphers: ROT13
Exam weight Low
  1. ROT13; a general substitution cipher has 26! keys.
Slide 22: Substitution Ciphers : Keyword Ciphers
Exam weight Low
  1. Keyword cipher: write the keyword (no repeats) then the rest of the alphabet as the cipher alphabet.
Slide 23: Examples
Exam weight Low
  1. Keyword example (“zebras”).
Slide 24: Examples
Exam weight Low
  1. Keyword example, continued.

Playfair Cipher

  • not even the large number of keys in a monoalphabetic cipher provides security
  • one approach to improving security was to encrypt multiple letters
  • the Playfair Cipher is an example
  • invented by Charles Wheatstone in 1854, but named after his friend Baron Playfair
25
Exam weight Low
  1. Monoalphabetic ciphers fall to frequency analysis → encrypt pairs of letters (Playfair).

Playfair Key Matrix

  • a 5X5 matrix of letters based on a keyword
  • fill in letters of keyword (sans duplicates)
  • fill rest of matrix with other letters
  • eg. using the keyword MONARCHY
26
Exam weight Low
  1. Playfair 5×5 matrix: keyword letters (no repeats), then the remaining letters; I/J share a cell.
★ Past exam

Encrypting and Decrypting

  • plaintext is encrypted two letters at a time if a pair is a repeated letter, insert filler like 'X’ 1. if both letters fall in the same row, replace each 2. with letter to right (wrapping back to start from end) if both letters fall in the same column, replace 3. each with the letter below it (wrapping to top from bottom) otherwise each letter is replaced by the letter in 4. the same row and in the column of the other letter of the pair
27
Exam weight High
  1. Rules: pairs; X between doubled letters; same row → right; same column → below; rectangle → own row, other letter’s column.
TipHand-cipher rules: CAESAR C = (P + k) mod 26 · VIGENÈRE add the repeated key letter (subtract to decrypt) · PLAYFAIR pairs: same row → right, same column → below, rectangle → own row, other letter’s column; X between doubles · HILL row vector × K mod 26, decrypt with K⁻¹ (det must be coprime with 26) · TRANSPOSITION write in rows, read columns in key order.
🎯 How this can come up · 2 questions
Written

Encrypt COMMITTEES with Playfair, keyword EFFECTIVENESS (I/J together). (Major B)

MCQ

In Playfair, two letters in the same row are replaced by:

Slide 28: Playfair Encryption and Decryption
Exam weight Low
  1. HELLO → HE LX LO.

Security of Playfair Cipher

  • security much improved over monoalphabetic
  • since have 26 x 26 = 676 digrams
  • would need a 676 entry frequency table to analyse (verses 26 for a monoalphabetic)
  • and correspondingly more ciphertext
  • was widely used for many years eg. by US & British military in WW1 ⚫
  • it can be broken, given a few hundred letters
  • since still has much of plaintext structure
29
Exam weight Medium
  1. 26 × 26 = 676 digrams: much better than monoalphabetic, but still breakable with digram frequencies.
🎯 How this can come up · 1 question
Written

In Playfair, what does cryptanalysis depend on? (Major C)

★ Past exam
Slide 30: Vigenère Cipher (Encryption)
Exam weight High
  1. Vigenère: repeat the key; C = (P + K) mod 26.
🎯 How this can come up · 2 questions
MCQ

An advanced Caesar cipher that shifts each letter by a keyword letter is:

Written

Decrypt CMRUVLERMYOLRX with Vigenère key RIYADH. (Major B)

Slide 31: Vigenère Cipher (Decryption)
Exam weight Low
  1. Vigenère decryption: subtract the key letter.
Slide 32: How to attack substitution: Frequency Analysis
Exam weight Low
  1. Frequency analysis breaks substitution ciphers (E, T, A are most common in English).

Substitution Ciphers: One-Time Pads

  • There is one type of substitution cipher that is absolutely unbreakable.
    • The one-time pad was invented in 1917 by Joseph Mauborgne and Gilbert Vernam
    • We use a block of shift keys, (k, k, . . . , k ), to 1 2 n encrypt a plaintext, M, of length n, with each shift key being chosen uniformly at random.
  • Since each shift is random, every ciphertext is equally likely for any plaintext.
33
Exam weight High
  1. One-time pad (Vernam/Mauborgne 1917): a truly random key as long as the message, used once → unbreakable.
🎯 How this can come up · 1 question
MCQ

Which cipher is theoretically unbreakable?

Slide 34: Example
Exam weight Low
  1. One-time pad example.
★ Past exam

Substitution Ciphers: Hill Cipher

  • Developed by mathematician Lester Hill in 1929, the encryption algorithm takes m successive plaintext letters and substitutes with m ciphertext letters.
  • Each letter is represented by a number modulo 26. (E.g. A = 0, B = 1, ..., Z = 25) n
  • To encrypt a message, each block of letters is multiplied by an n × n invertible matrix, modulus 26.
  • To decrypt the message, each block is multiplied by the inverse of the matrix used for encryption.
35
Exam weight High
  1. Hill (1929): m letters at a time as a vector, multiplied by an m × m key matrix mod 26.
🎯 How this can come up · 2 questions
Written

Encrypt HE with a Hill key K = [[3, 3], [2, 5]] using the row approach. (Major A)

True / False

Any 2 × 2 matrix can be used as a Hill cipher key.

36
Exam weight Low
  1. Hill example.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

37
Exam weight Low
  1. Letter numbering A = 0 … Z = 25.

◼

38
Exam weight Low
  1. Hill matrix multiplication.
Slide 39: How to find the inverse key matrix
Exam weight Low
  1. Inverse key: K⁻¹ = det⁻¹ × adj(K) mod 26.

Transposition Cipher

40
★ Past exam

Transposition Cipher

  • In a transposition cipher, the characters retain their plaintext form but change their positions to create the ciphertext
  • The text is organized into a two-dimensional table, and the columns are interchanged according to a key
  • The key defines which columns should be swapped
41
Exam weight High
  1. Transposition keeps the letters but changes their positions: write in rows, permute/read columns by the key.
🎯 How this can come up · 1 question
MCQ

A cipher that keeps the letters but rearranges their positions is a:

Slide 42: Example
Exam weight Low
  1. Transposition example.
Slide 43: Example
Exam weight Low
  1. Example.
Slide 44: Example
Exam weight Low
  1. Example.
Slide 45: Example
Exam weight Low
  1. Example.
Slide 46: Slide 46
Exam weight Low
  1. Modern ciphers overview.
Slide 47: Slide 47
Exam weight Low
  1. A modern block cipher.
Slide 48: Block Ciphers
Exam weight Low
  1. Block ciphers.
Slide 49: Block Ciphers
Exam weight Low
  1. Block cipher: fixed-length blocks of b bits (e.g., 128).

Padding

  • Block ciphers require the length n of the plaintext to be a multiple of the block size b
  • Padding the last block needs to be unambiguous (cannot just add zeroes)
50
Exam weight Low
  1. Plaintext length must be a multiple of b → pad the last block unambiguously.
★ Past exam

Padding

  • Example for b = 64 bits (8 bytes) “ Roberto (7 bytes) ”
    • Plaintext: “ Roberto9 (8 bytes), where ”
    • Padded plaintext: 9 denotes the number and not the character
  • We need to always pad the last block, which may consist only of padding
51
Exam weight High
  1. Count characters as bytes; blocks = ceil(bytes / (b/8)); padding = blocks × (b/8) − bytes.
🎯 How this can come up · 2 questions
Written

b = 128 bits. Plaintext “Incomprehensibilities”. How many blocks and how many padded bits? (Major A)

MCQ

b = 64 bits, plaintext of 29 bytes. How many blocks?

Slide 52: Block Ciphers in Practice
Exam weight Low
  1. DES: IBM, adopted 1977, 56-bit key, 64-bit blocks; now broken by brute force.
Slide 53: Block Ciphers in Practice
Exam weight Low
  1. 3DES: three DES passes with three keys: C = E_K3(D_K2(E_K1(P))).
★ Past exam
Slide 54: Triple DES
Exam weight High
  1. 3DES decryption reverses it: P = D_K1(E_K2(D_K3(C))).
🎯 How this can come up · 1 question
MCQ

3DES decryption order is:

Block Ciphers in Practice

  • Advanced Encryption Standard (AES)
    • Selected by NIST in 2001 through open international competition and public discussion
    • 128-bit blocks and several possible key lengths: 128, 192 and 256 bits
    • Exhaustive search attack not currently possible
  • International Data Encryption Algorithm (IDEA)
    • Uses a 128-bit key and is used in Pretty Good Privacy (PGP) encryption for e-mail systems
  • RC5
    • Developed at MIT, and allows for variable length keys.
  • Blowfish
    • Designed by Bruce Schneier in 1993 allows for variable length keys up to 448 bits
55
Exam weight Medium
  1. AES: NIST 2001 (Rijndael), 128-bit blocks, 128/192/256-bit keys.
🎯 How this can come up · 1 question
MCQ

AES uses a block size of:

Slide 56: Block Cipher Modes
Exam weight Low
  1. A mode describes how a block cipher handles a sequence of blocks. ECB: each block alone (identical blocks → identical ciphertext).
TipModes: ECB C=E(P) · CBC C[i]=E(P[i] ⊕ C[i−1]), C[−1]=IV · CFB C[i]=E(C[i−1]) ⊕ P[i] · OFB keystream V[i]=E(V[i−1]) · CTR keystream E(counter).
★ Past exam
Slide 57: Cipher Block Chaining (CBC) Mode
Exam weight High
  1. CBC: XOR each plaintext block with the previous ciphertext block (IV first), then encrypt. Decrypt: P[i] = D_K(C[i]) ⊕ C[i−1].
🎯 How this can come up · 2 questions
Written

In CBC, write the decryption function for P[2]. (Major A)

MCQ

Which mode XORs each plaintext block with the previous ciphertext block before encryption?

★ Past exam
Slide 58: Cipher Feedback (CFB) Mode
Exam weight High
  1. CFB: encrypt the previous ciphertext block, then XOR with the plaintext: C[i] = E_K(C[i−1]) ⊕ P[i].
🎯 How this can come up · 1 question
MCQ

C[i] = E_K(C[i−1]) ⊕ P[i] describes:

Slide 59: Output Feedback (OFB) Mode
Exam weight Low
  1. OFB: keystream from repeatedly encrypting the IV; C[i] = V[i] ⊕ P[i].

Counter (CTR) Mode

  • Similar to OFB, but uses a seed s
  • V = E (s + i – 1) i k
  • CTR mode can be performed in parallel and can recover from dropped blocks
Counter (CTR) Mode
60
Exam weight Low
  1. CTR: keystream = E_K(counter); blocks can be processed in parallel.

ATTACKING CONVENTIONAL ENCRYPTION SCHEMES

Objective: To recover the key and not just the messages, so that the attacker can easily compromise all future and past cipher texts.

General Approaches

  • Cryptanalysis
  • Brute force attack
61
Exam weight Low
  1. Attacker’s objective: recover the KEY. Two approaches: cryptanalysis and brute force.

1. Cryptanalysis

  • Based on what is known to the attacker, cryptanalytic attempts are classified as:
    • Ciphertext Only
    • Known Plaintext
    • Chosen Plaintext
    • Chosen Ciphertext
  • Encryption algorithm is assumed to be known for all the attacks.
  • In each case, the object is to determine the key (and plaintext) that was used.
62
Exam weight Low
  1. Cryptanalysis by attacker knowledge: ciphertext only, known plaintext, chosen plaintext, chosen ciphertext.
Slide 63: Ciphertext only Attack
Exam weight Low
  1. Ciphertext only: the attacker has only ciphertext (hardest for the attacker).
Slide 64: Known Plaintext Attack
Exam weight Low
  1. Known plaintext: has plaintext–ciphertext pairs.
Slide 65: Chosen Plaintext Attack
Exam weight Medium
  1. Chosen plaintext: can encrypt texts of their choice.
🎯 How this can come up · 1 question
MCQ

An attacker who can get any plaintext of their choice encrypted is performing a:

Slide 66: Chosen Ciphertext Attack
Exam weight Low
  1. Chosen ciphertext: can get chosen ciphertexts decrypted.
Slide 67: 2. Brute Force Search
Exam weight Low
  1. Brute force: try every key; effort grows with key size.