23Z702 · Cryptography & Network Security

Units 1 & 2 — Complete Exam Study Deck

Every syllabus topic, taught step-by-step with worked examples and Bloom's-mapped practice questions.

50Total marks
2Sub-units
3·6·6·10Marks per sub-unit
25Topics covered

Tip: click any topic to expand. Sub-panels (Explanation / Formulas / Examples / Questions) collapse independently. Use the checkboxes to track revision — progress saves in this browser. Ctrl/Cmd-P prints the whole deck expanded.

Sub-Unit 1 · Security Concepts · Number Theory · Classical Ciphers
1

The OSI Security Architecture

▶
Explanation

The OSI Security Architecture (defined in ITU-T Recommendation X.800) is a systematic framework that lets managers and vendors talk about security in a common language. It organises the whole problem of information security into three pillars.

Definition A structured way of defining and providing security requirements, built around security attacks, security mechanisms, and security services.
  • Security attack — any action that compromises the security of information owned by an organisation.
  • Security mechanism — a process (or device) designed to detect, prevent, or recover from a security attack.
  • Security service — a processing/communication service that enhances security, using one or more mechanisms.
Why it matters X.800 is the scaffold for the next four topics — attacks, services, mechanisms and the network-security model all hang off it.
Key Definitions to Reproduce
Three pillars — memory hook ATTACK  →  MECHANISM  →  SERVICE

A 3-mark answer = name + one line each on the three pillars. A 6-mark answer = add the X.800 reference and one example per pillar.

Bloom's Practice Questions
Remember3
Define the OSI security architecture and name its three components.
Understand6
Distinguish between a security mechanism and a security service with examples.
Analyze6
Explain how the three pillars of X.800 relate to one another in securing an organisation.
2

Security Attacks (Passive & Active)

▶
Explanation

A security attack is any action that compromises information security. X.800 and RFC 4949 split attacks into two families.

Passive Attack The attacker only observes/monitors transmissions — the goal is to obtain information. Nothing is altered, so it is hard to detect but easy to prevent (encryption). Emphasis is on prevention.

Two sub-types of passive attack:

  • Release of message contents — the attacker reads the actual message payload (e.g., an intercepted email).
  • Traffic analysis — even if content is encrypted, the attacker studies patterns: who is talking to whom, frequency, length, timing.
Active Attack The attacker modifies the data stream or creates a false one. Easy to detect but hard to prevent. Emphasis is on detection + recovery.

Four sub-types of active attack:

  • Masquerade — one entity pretends to be a different entity.
  • Replay — capture data and re-transmit it later to produce an unauthorised effect.
  • Modification of messages — some portion of a legitimate message is altered, delayed, or reordered.
  • Denial of Service (DoS) — prevents normal use/management of communication facilities.
Compare Table
FeaturePassiveActive
Data altered?NoYes
DetectionVery hardEasier
PreventionEasier (encrypt)Very hard
EmphasisPreventionDetection & recovery
ExamplesRelease of contents, Traffic analysisMasquerade, Replay, Modification, DoS
Memory hook Passive = 2 types  ·  Active = 4 types (M-R-M-D)
Bloom's Practice Questions
Remember3
List the two categories of security attacks with one example each.
Understand6
Differentiate passive and active attacks on detection, prevention, and emphasis.
Apply6
Classify: (a) intercepting an encrypted call to see call frequency, (b) resending a captured bank transfer. Justify.
Analyze / Evaluate10
Explain all sub-types of active and passive attacks with diagrams, and evaluate why passive attacks are harder to detect but easier to prevent than active attacks.
10-mark = 6 sub-types fully + comparison table + reasoned evaluation paragraph.
3

Security Services

▶
Explanation

A security service (X.800) is a service that ensures adequate security of systems or data transfers, implemented by mechanisms. There are five categories.

  • Authentication — assurance that the communicating entity is who it claims to be. Two forms: peer-entity authentication and data-origin authentication.
  • Access Control — prevents unauthorised use of a resource (who can access what, under which conditions).
  • Data Confidentiality — protects data from unauthorised disclosure (includes protection against traffic analysis).
  • Data Integrity — assures data received is exactly as sent (no modification, insertion, deletion, replay).
  • Non-repudiation — prevents sender or receiver from denying a transmitted message.
Sometimes added Availability — the system remains accessible to authorised users (targeted by DoS).
Memory Hook
Five services A · A · C · I · N
Authentication · Access control · Confidentiality · Integrity · Non-repudiation
Bloom's Practice Questions
Remember3
List the five security services defined by X.800.
Understand6
Explain confidentiality, integrity, and non-repudiation with a real-world example each.
Apply6
For online banking, map each of the five services to a concrete threat it defends against.
Evaluate10
Describe all five security services in detail and evaluate which are most critical for (a) military comms and (b) e-commerce, with justification.
4

Security Mechanisms

▶
Explanation

A security mechanism is a technical tool that implements one or more security services. X.800 divides them into specific (tied to a protocol layer) and pervasive (not layer-specific).

Specific security mechanisms:

  • Encipherment — using maths (encryption) to hide data.
  • Digital signature — cryptographic proof of source & integrity.
  • Access control — mechanisms enforcing access rights.
  • Data integrity — mechanisms assuring integrity of a unit/stream.
  • Authentication exchange — ensuring identity via information exchange.
  • Traffic padding — inserting bits into gaps to foil traffic analysis.
  • Routing control — choosing secure routes for sensitive data.
  • Notarization — using a trusted third party to assure properties.

Pervasive security mechanisms: trusted functionality, security labels, event detection, security audit trails, security recovery.

Service ↔ Mechanism Confidentiality ← encipherment · Integrity ← digital signature + data integrity · Non-repudiation ← digital signature + notarization · Authentication ← authentication exchange.
Memory Hook
8 specific mechanisms E-D-A-D-A-T-R-N
Encipher · Digital-sig · Access · Data-integrity · Auth-exchange · Traffic-pad · Routing · Notarization
Bloom's Practice Questions
Remember3
Name any three specific security mechanisms.
Understand6
Explain encipherment, digital signature, and traffic padding.
Analyze10
Describe all specific and pervasive mechanisms, and map each of the five security services to the mechanism(s) that realise it.
5

A Model for Network Security

▶
Explanation

This model shows the general architecture for securing a message sent between two principals across an insecure channel in the presence of an opponent.

The four basic tasks in designing a security service:

  1. Design an algorithm for the security-related transformation.
  2. Generate the secret information (keys) used by the algorithm.
  3. Develop methods to distribute and share the secret information.
  4. Specify a protocol enabling the principals to use the transformation + secret for the service.
Trusted Third Party Often required — e.g., to distribute secret keys to both parties, or to arbitrate disputes over authenticity (notarization).

Network access security model: a related model where the threat is unwanted access (hackers, malware). Defence = gatekeeper function (login/password, firewalls) + internal security controls (monitoring, access control).

Sender ── transform(msg,key) ──► [ INSECURE CHANNEL ] ──► inverse-transform ──► Receiver
                    ▲                    ▲                         ▲
                 secret key          Opponent                  secret key
                    │                                              │
                    └──────── Trusted Third Party (key dist) ──────┘
Bloom's Practice Questions
Remember3
State the four tasks in designing a security service.
Understand6
Draw and explain the model for network security.
Analyze10
Explain both the network-security and network-access-security models, contrasting the roles of trusted third party and gatekeeper.
6

Fermat's Theorem (Fermat's Little Theorem)

▶
Explanation

Fermat's Little Theorem is a cornerstone of number theory used heavily in RSA and primality testing. It relates powers of a number to a prime modulus.

Condition p must be prime, and a must not be divisible by p (i.e. gcd(a,p)=1 for the second form).
Formulas
Form 1 ap−1 ≡ 1 (mod p)
Form 2 (always holds) ap ≡ a (mod p)
Worked Example
Example — compute 310 mod 11
Step 1 — Check conditions. p = 11 is prime, a = 3 not divisible by 11. ✓
Step 2 — Apply Form 1. ap−1 = 311−1 = 310 ≡ 1 (mod 11).
Answer. 310 mod 11 = 1 — no long multiplication needed.
Example 2 — compute 3201 mod 11
Step 1. Write 201 = 10×20 + 1.
Step 2. 3201 = (310)20 · 31 ≡ 120 · 3 ≡ 3 (mod 11).
Bloom's Practice Questions
Remember3
State Fermat's little theorem in both forms.
Apply6
Using Fermat's theorem, find 512 mod 13 and 2100 mod 13.
Apply6
Compute 7222 mod 11 showing the reduction of the exponent.
Understand10
State and prove Fermat's little theorem, then apply it to find the multiplicative inverse of 3 mod 11.
7

Euler's Theorem & Euler's Totient Function

▶
Explanation

Euler's theorem generalises Fermat's to any modulus n (not just primes). It needs the totient function φ(n) = count of integers in 1…n that are coprime to n.

Totient rules If p is prime: φ(p) = p−1.   If n = p·q (p,q distinct primes): φ(n) = (p−1)(q−1).   φ is multiplicative for coprime factors.
Formulas
Euler's Theorem aφ(n) ≡ 1 (mod n)   when gcd(a,n)=1
Totient of a prime φ(p) = p − 1
Totient of product of two primes φ(pq) = (p−1)(q−1)
Worked Example
Example — φ(35) and 4φ(35) mod 35
Step 1 — Factor. 35 = 5 × 7, both prime.
Step 2 — Totient. φ(35) = (5−1)(7−1) = 4 × 6 = 24.
Step 3 — Apply Euler. gcd(4,35)=1, so 424 ≡ 1 (mod 35).
Example 2 — find 74 mod 10
Step 1. φ(10)=φ(2)φ(5)=1×4=4.
Step 2. 74 ≡ 1 (mod 10). Check: 74=2401, 2401 mod 10 = 1. ✓
Bloom's Practice Questions
Remember3
Define Euler's totient function and give φ(p) for prime p.
Apply6
Compute φ(21), φ(40), and φ(13).
Apply6
Using Euler's theorem find 3φ(20) mod 20 and hence 39 mod 20.
Understand10
State and prove Euler's theorem; show Fermat's theorem is its special case; compute a modular inverse using it.
8

Euclidean & Extended Euclidean Algorithm

▶
Explanation

The Euclidean algorithm finds gcd(a,b) by repeated remainder. The Extended version also finds integers x,y with ax+by=gcd — which gives the modular inverse needed in Hill cipher & RSA.

Core idea gcd(a,b) = gcd(b, a mod b), repeated until the remainder is 0. The last non-zero remainder is the gcd.
Formulas
Euclid recurrence gcd(a, b) = gcd(b, a mod b),   gcd(a,0)=a
Bézout / inverse a·x + n·y = gcd(a,n); if gcd=1 then x = a−1 mod n
Worked Example
Example A — gcd(252, 198)
252 = 1×198 + 54
198 = 3×54 + 36
54 = 1×36 + 18
36 = 2×18 + 0 → last non-zero remainder = gcd = 18.
Example B — inverse of 3 mod 26 (Extended)
Goal. find x with 3x ≡ 1 (mod 26).
Trial via Bézout. 26 = 8×3 + 2 → 3 = 1×2 + 1 → back-substitute: 1 = 3 − 1×2, and 2 = 26 − 8×3, so 1 = 3 − (26 − 8×3) = 9×3 − 26.
Read coefficient of 3. x = 9 → 3−1 ≡ 9 (mod 26). Check 3×9=27≡1. ✓
Exam link This is exactly the step used in Hill-cipher decryption to invert the determinant.
Bloom's Practice Questions
Remember3
State the Euclidean algorithm recurrence for gcd.
Apply6
Find gcd(1970, 1066) using the Euclidean algorithm.
Apply6
Using the extended Euclidean algorithm, find the multiplicative inverse of 17 mod 26.
Apply10
Compute gcd(4864,3458), then find 11−1 mod 26 by the extended algorithm, showing every back-substitution.
9

Caesar Cipher

▶
Explanation

The Caesar cipher is the earliest substitution cipher: every letter is shifted a fixed number of places down the alphabet. It is monoalphabetic (one fixed mapping) with only 25 usable keys.

Mapping A=0, B=1, …, Z=25. The key k is the shift amount (Caesar himself used k=3).
Weakness Only 25 keys → trivially broken by brute force. Also vulnerable to frequency analysis.
Formulas
Encryption C = (P + k) mod 26
Decryption P = (C − k) mod 26
Worked Example
Encrypt "HELLO" with k = 3
Convert. H=7, E=4, L=11, L=11, O=14.
Add k=3 mod 26. 10, 7, 14, 14, 17.
Back to letters. 10=K, 7=H, 14=O, 14=O, 17=R → KHOOR.
Decrypt check. (10−3)=7=H, … recovers HELLO. ✓
Bloom's Practice Questions
Remember3
Write the encryption and decryption formulas of the Caesar cipher.
Apply6
Encrypt "NETWORK" with k=5 and decrypt the result to verify.
Analyze6
Explain why the Caesar cipher is insecure and how brute-force cryptanalysis breaks it.
Evaluate10
Define the Caesar cipher, encrypt a sample, and critically evaluate its security vs a monoalphabetic substitution cipher (key-space & frequency analysis).
10

Monoalphabetic Cipher

▶
Explanation

A monoalphabetic substitution cipher replaces each plaintext letter with a fixed but arbitrary ciphertext letter — the key is a full permutation of the 26 letters, not just a shift.

Key space 26! ≈ 4×1026 keys — far too many to brute force, yet still broken easily.
Weakness Frequency analysis: the fixed mapping preserves letter-frequency patterns of the language (E, T, A most common in English), so the cipher leaks structure.
Key Property
Key space 26! ≈ 4 × 1026 possible mappings

Contrast: Caesar has only 25 keys (a monoalphabetic cipher whose key is restricted to a shift).

Worked Example
Using a sample substitution key
Key map (plain→cipher). a→Q, b→W, c→E, … define a fixed permutation.
Encrypt "cab". c→E, a→Q, b→W → EQW.
Decrypt. Reverse the map: E→c, Q→a, W→b → cab. ✓
Cryptanalysis. Count ciphertext letter frequencies; match the most frequent to E, T, A… to recover the key without brute force.
Bloom's Practice Questions
Remember3
What is a monoalphabetic cipher? State its key space.
Understand6
Why does a 26! key space still fall to cryptanalysis? Explain frequency analysis.
Analyze10
Compare Caesar, monoalphabetic, and Playfair ciphers on key space and resistance to frequency analysis.
11

Playfair Cipher

▶
Explanation

The Playfair cipher is the best-known polygraphic cipher — it encrypts digrams (letter pairs) using a 5×5 key matrix, so it hides single-letter frequencies.

Building the 5×5 matrix:

  1. Write the keyword (drop repeated letters) into a 5×5 grid.
  2. Fill remaining cells with the rest of the alphabet in order.
  3. I and J share one cell (25 cells for 26 letters).

Encryption rules (per digram):

  • Same row → replace each letter with the one to its right (wrap around).
  • Same column → replace each with the one below (wrap around).
  • Rectangle → each letter is replaced by the letter in its own row at the other letter's column.
  • Repeated letter in a pair → insert filler X; pad final lone letter with X.
Rules Summary
Three digram rules Same Row → Right  ·  Same Column → Down  ·  Rectangle → swap columns
Worked Example
Keyword "MONARCHY", encrypt "HELLO"
Step 1 — Build matrix.
MONAR
CHYBD
EFGI/JK
LPQST
UVWXZ
Step 2 — Split into digrams. HE LL O → the LL repeats, insert X: HE LX LO.
Step 3 — Encrypt each pair.
HE → same? H(row2,col2), E(row3,col1) → rectangle → H→row2 col1 = C, E→row3 col2 = F → CF.
LX → L(row4,col1), X(row5,col4) → rectangle → L→row4 col4 = S, X→row5 col1 = U → SU.
LO → L(row4,col1), O(row1,col2) → rectangle → L→row4 col2 = P, O→row1 col1 = M → PM.
Ciphertext. CFSUPM.
Decryption Reverse rules: same row → left, same column → up, rectangle → same column-swap logic.
Bloom's Practice Questions
Remember3
State the three digram encryption rules of the Playfair cipher.
Apply6
Build the Playfair matrix for keyword "SECURITY" and encrypt "COMMUNICATE".
Apply10
Using keyword "MONARCHY", encrypt "INSTRUMENTS" and decrypt it back, showing matrix and every digram rule used.
12

Hill Cipher

▶
Explanation

The Hill cipher is a polygraphic substitution cipher based on linear algebra. It encrypts a block of letters at once by multiplying a plaintext column vector by a key matrix, mod 26.

Setup Letters → numbers (A=0…Z=25). For a 2×2 key, process 2 letters per block. Encryption is matrix × vector mod 26.
Decryption condition The key matrix must be invertible mod 26, i.e. gcd(det(K),26)=1. If gcd ≠ 1 there is no modular inverse and decryption is impossible.
Formulas
Encryption C = K · P (mod 26)
Decryption P = K−1 · C (mod 26)
Determinant (2×2) det(K) = ad − bc
Inverse (2×2) K−1 = (det K)−1 · [ d  −b ;  −c  a ] (mod 26)
Worked Example (from your notes)
Encrypt "HELP" with K = [[3,3],[2,5]]
Step 1 — Blocks. HE | LP (2 letters each for a 2×2 key).
Step 2 — Numbers. H=7, E=4, L=11, P=15.
Step 3 — Block 1 vector. P₁ = [7 ; 4].
Step 4 — Multiply. row1 = 3×7+3×4 = 33; row2 = 2×7+5×4 = 34 → [33 ; 34].
Step 5 — mod 26. 33 mod 26 = 7; 34 mod 26 = 8 → [7 ; 8] → HI.
Step 6 — Block 2. P₂=[11;15]; row1=3×11+3×15=78; row2=2×11+5×15=97 → [78;97] mod 26 = [0;19] → AT.
Ciphertext. HELP → HIAT.
Decrypt "HIAT" back
det(K). (3×5)−(3×2)=15−6=9.
det⁻¹ mod 26. 9×3=27≡1 → 9−1=3.
Adjugate. [d −b; −c a] = [5 −3; −2 3].
K⁻¹. 3×[5 −3; −2 3] = [15 −9; −6 9] → mod 26 → [15 17; 20 9].
Decrypt HI=[7;8]. row1=15×7+17×8=241≡7; row2=20×7+9×8=212≡4 → [7;4] → HE.
Decrypt AT=[0;19]. row1=17×19=323≡11; row2=9×19=171≡15 → [11;15] → LP. Recovers HELP. ✓
Negative mod trick −9 → −9+26 = 17; −6 → 20; −3 → 23. Always add 26 until positive.
Bloom's Practice Questions
Remember3
Write the Hill cipher encryption and decryption equations.
Apply6
Encrypt "ACT" using K=[[6,24,1],[13,16,10],[20,17,15]] mod 26 (3×3 block).
Apply10
Encrypt "HELP" with K=[[3,3],[2,5]], then fully decrypt — including det, det⁻¹, and K⁻¹ derivation.
Analyze6
Given det(K)=4, explain why the matrix cannot be used and what condition a valid Hill key must satisfy.
13

Vigenère Cipher

▶
Explanation

The Vigenère cipher is a polyalphabetic substitution cipher: it uses a keyword to apply different Caesar shifts to different positions, smoothing out letter frequencies.

Idea Repeat the keyword across the plaintext; each plaintext letter is shifted by the corresponding key letter's value (A=0…Z=25).
Formulas
Encryption Ci = (Pi + Ki) mod 26
Decryption Pi = (Ci − Ki) mod 26
Worked Example
Encrypt "HELLO" with keyword "KEY"
Step 1 — Repeat key. HELLO / KEYKE.
Step 2 — Numbers. P: 7 4 11 11 14 · K: 10 4 24 10 4.
Step 3 — Add mod 26. (7+10)=17, (4+4)=8, (11+24)=35→9, (11+10)=21, (14+4)=18.
Step 4 — Letters. 17=R, 8=I, 9=J, 21=V, 18=S → RIJVS.
Decrypt. Subtract key mod 26 → recovers HELLO. ✓
Vs Caesar Caesar = one shift for all letters. Vigenère = many shifts (one per key letter), so the same plaintext letter can map to different ciphertext letters.
Bloom's Practice Questions
Remember3
Define a polyalphabetic cipher and give the Vigenère encryption formula.
Apply6
Encrypt "SECURITY" with keyword "KEY".
Understand6
Explain how Vigenère resists the frequency analysis that breaks monoalphabetic ciphers.
Evaluate10
Encrypt & decrypt a sample with Vigenère, then evaluate its strength vs Caesar and the role of key length (Kasiski / repeating key weakness).
14

Vernam Cipher

▶
Explanation

The Vernam cipher is a symmetric stream cipher that combines each plaintext bit/character with a key using XOR. The same key operation both encrypts and decrypts.

XOR magic property (A ⊕ B) ⊕ B = A — so XOR-ing ciphertext with the same key restores the plaintext.
Formulas
Encryption C = P ⊕ K
Decryption P = C ⊕ K
Core identity X ⊕ K ⊕ K = X

Textbook character-based variant sometimes uses C = (P + K) mod 26 — know both the XOR (binary) and the mod-26 forms.

Worked Example
Binary XOR form
Plaintext. 10110010
Key. 01101101
XOR → Ciphertext. 11011111
Decrypt. 11011111 ⊕ 01101101 = 10110010 = original. ✓
Mod-26 character form — "HELLO" ⊞ "XMCKL"
(7+23)=30 mod 26=4=E, (4+12)=16=Q, (11+2)=13=N, (11+10)=21=V, (14+11)=25=Z → EQNVZ.
Bloom's Practice Questions
Remember3
State the encryption/decryption operation of the Vernam cipher.
Apply6
XOR-encrypt P=1010101 with K=1100110 and decrypt to verify.
Understand6
Explain why the same XOR operation works for both encryption and decryption.
Analyze10
Describe the Vernam cipher, give binary & mod-26 examples, and explain the exact conditions under which it becomes a One-Time Pad.
15

One-Time Pad (OTP)

▶
Explanation

A One-Time Pad is a Vernam cipher that achieves perfect secrecy — provably unbreakable — when four strict conditions hold.

The four OTP conditions 1) Key is truly random; 2) Key is as long as the plaintext; 3) Key is never reused; 4) Key is kept completely secret.
Perfect secrecy Ciphertext gives the attacker zero information about plaintext — every plaintext of that length is equally likely (Shannon).
Practical problems Key must equal message length → huge key; secure key distribution is hard; key must never repeat. This impracticality is why OTP is rarely used despite being unbreakable.
Formula & Conditions
Same as Vernam C = P ⊕ K  ·  P = C ⊕ K
Becomes OTP when Random + Length = message + Never reused + Secret
Bloom's Practice Questions
Remember3
List the four conditions that make a Vernam cipher a One-Time Pad.
Understand6
Explain the concept of perfect secrecy and why OTP achieves it.
Evaluate10
"The One-Time Pad is unbreakable yet impractical." Justify both halves of this statement with reasons and an example.
16

Rail Fence & Transposition Techniques

▶
Explanation

Transposition ciphers don't substitute letters — they rearrange their positions. The letters stay the same; only their order changes.

Rail Fence: write the plaintext in a zig-zag across a number of "rails" (rows), then read off row by row.

Columnar (Row) Transposition: write plaintext in rows under a keyword, then read columns in the order given by the alphabetical rank of the keyword letters.

Key Idea
Transposition Ciphertext = re-ordering of plaintext letters (positions change, letters don't)
Weakness Letter frequencies are unchanged, so transposition alone is detectable; strength improves with multiple rounds.
Worked Example
Rail Fence — "MEETMEAFTER" with 3 rails
Step 1 — Zig-zag placement.
Rail 1: M . . . M . . . T . .
Rail 2: . E . T . E . F . E .
Rail 3: . . E . . . A . . . R
Step 2 — Read row by row. Rail1: M M T · Rail2: E T E F E · Rail3: E A R.
Ciphertext. MMTETEFEEAR.
Decrypt. Rebuild the zig-zag frame of the same size, fill rows in read order, then read the zig-zag.
Columnar — key "4312567" on "ATTACKPOSTPONED..."
Write rows under the numbered key, then read columns in key-number order (1,2,3,…) to get ciphertext.
Bloom's Practice Questions
Remember3
What is a transposition cipher? How does it differ from substitution?
Apply6
Encrypt "WEAREDISCOVERED" using rail fence with 3 rails.
Apply10
Encrypt a message using columnar transposition with a keyword, then apply a second round and explain why double transposition is stronger.
17

Book Cipher

▶
Explanation

A Book cipher uses an agreed reference text/book as the key. Plaintext is represented by the locations of words or letters in that book, not by transformed letters.

Coordinates Typically Page : Line : Word or Page : Line : Word : Character. The receiver looks up each coordinate in the same book to recover the text.
Key = the book Both parties need the identical book and edition (page/line numbering must match).
Worked Example
Encode "MEET" from a shared page
Book line 3. "WE WILL MEET TOMORROW" → words: 1=WE, 2=WILL, 3=MEET, 4=TOMORROW.
Locate MEET. Page 1, Line 3, Word 3 → send 1:3:3.
Character-level. The letter E (2nd char of MEET) → 1:3:3:2.
Decrypt. Receiver opens same book at 1:3:3 → reads "MEET". ✓
Bloom's Practice Questions
Remember3
What is the key in a book cipher, and what coordinate format is used?
Understand6
Explain encryption and decryption in a book cipher and why the edition must match.
Evaluate6
Discuss the advantages (large key space, numeric ciphertext) and disadvantages of book ciphers.
Sub-Unit 2 · Symmetric Ciphers · PRNGs · DES
18

Block Ciphers vs Stream Ciphers

▶
Explanation

Two ways symmetric ciphers process plaintext.

Block cipher Encrypts a fixed-size block (e.g. 64 or 128 bits) at a time as a unit. Same key → same block mapping. Examples: DES, AES.
Stream cipher Encrypts one bit/byte at a time using a pseudorandom keystream XOR-ed with plaintext. Examples: RC4, Vernam.
Compare Table
FeatureBlockStream
UnitBlock (64/128 bits)Bit / byte
SpeedSlowerFaster
Core opSubstitution + permutationXOR with keystream
Error propagationHigher (whole block)Low (per bit)
ExamplesDES, AES, BlowfishRC4, Vernam, A5/1
Stream core Ci = Pi ⊕ keystreami
Bloom's Practice Questions
Remember3
Define block and stream ciphers with one example each.
Understand6
Compare block vs stream ciphers on unit size, speed, and error propagation.
Analyze6
For streaming video vs file storage, which cipher type suits each and why?
19

Random Bit Generation — Principles

▶
Explanation

Cryptography needs unpredictable numbers for keys, nonces, and IVs. Random sources fall into two classes.

TRNG (True RNG) Uses a physical source of entropy (thermal noise, radioactive decay, mouse jitter). Non-deterministic, non-reproducible.
PRNG (Pseudorandom RNG) Uses a deterministic algorithm + seed to produce a stream that looks random. Reproducible from the seed.

Two requirements for a cryptographic bit generator:

  • Randomness — the sequence passes statistical tests (uniform distribution, independence).
  • Unpredictability — even knowing previous bits, the next bit cannot be predicted (forward/backward unpredictability).
Key Terms
Two criteria Randomness  +  Unpredictability
Bloom's Practice Questions
Remember3
Differentiate TRNG and PRNG.
Understand6
Explain the two requirements (randomness, unpredictability) for cryptographic random bit generators.
Analyze6
Why is a TRNG unsuitable for reproducing a keystream at the receiver, and how do PRNGs solve this?
20

Principles of Pseudorandom Number Generation

▶
Explanation

A PRNG expands a short random seed into a long pseudorandom sequence via a deterministic function. Design goals ensure the output is usable in cryptography.

  • Uniformity — output bits are roughly 50/50, evenly distributed.
  • Scalability — any extracted subsequence also passes randomness tests.
  • Consistency — behaviour is consistent across seeds.
  • Long period — the sequence should not repeat for as long as possible.
Seed secrecy For cryptographic PRNGs (CSPRNGs), the seed must be secret and unpredictable; otherwise the whole stream is exposed.
Key Properties
General PRNG form Xn+1 = f(Xn),   output = g(Xn)
Period Because state is finite, every PRNG eventually cycles — a good PRNG maximises the period before repetition.
Bloom's Practice Questions
Remember3
What is a seed? Why must a PRNG have a long period?
Understand6
List and explain the design principles of a good PRNG.
Evaluate6
What extra property distinguishes a cryptographic PRNG from a general-purpose one?
21

Pseudorandom Number Generators (Types)

▶
Explanation

Two broad families of PRNG construction appear in the syllabus/Stallings:

  • Algorithmic (arithmetic) PRNGs — e.g. Linear Congruential Generator (next topic).
  • Cryptographic PRNGs — built from strong crypto primitives:
    • Cyclic encryption — encrypt a counter with a secret key.
    • ANSI X9.17 PRNG — uses triple-DES with date-time seed; a standard secure generator.
    • Output feedback (OFB) mode of a block cipher used as a keystream generator.
ANSI X9.17 Inputs: 64-bit date-time (DT) + secret seed V; uses 3DES with two keys; outputs a strong pseudorandom block and updates the seed. A common 6-mark "explain a secure PRNG" answer.
Key Generators
Cyclic encryption Outputi = E(K, counteri)
Bloom's Practice Questions
Remember3
Name two cryptographically secure PRNG constructions.
Understand6
Explain the ANSI X9.17 PRNG with its inputs and use of 3DES.
Apply6
Show how a block cipher in OFB/counter mode produces a keystream for a stream cipher.
22

Linear Congruential Generator (LCG)

▶
Explanation

The LCG is the classic algorithmic PRNG. Each number is derived from the previous one by a multiply-add-mod recurrence.

Parameters modulus m, multiplier a, increment c, seed X₀ — all non-negative integers with 0 < m, a < m, c < m.
Formula
LCG recurrence Xn+1 = (a · Xn + c) mod m
Full period conditions An LCG has maximum period m when: (1) gcd(c,m)=1; (2) a−1 divisible by every prime factor of m; (3) a−1 divisible by 4 if m divisible by 4.
Worked Example
a=5, c=3, m=16, X₀=7 — generate the sequence
X₁. (5×7+3) mod 16 = 38 mod 16 = 6.
X₂. (5×6+3) mod 16 = 33 mod 16 = 1.
X₃. (5×1+3) mod 16 = 8 mod 16 = 8.
X₄. (5×8+3) mod 16 = 43 mod 16 = 11.
Sequence. 7, 6, 1, 8, 11, … continue until it repeats to find the period.
Security note LCGs are not cryptographically secure — given a few outputs, a,c,m can be solved for. Fine for simulation, unsafe for keys.
Bloom's Practice Questions
Remember3
Write the LCG recurrence and name its four parameters.
Apply6
With a=7, c=0, m=32, X₀=1, generate the first six numbers.
Apply6
For a=5,c=3,m=16,X₀=7 list the sequence and state its period.
Analyze10
Explain the LCG, derive a sequence, state the full-period conditions, and analyse why LCGs are cryptographically insecure.
23

Block Cipher Modes of Operation

▶
Explanation

A block cipher only encrypts one fixed block. Modes of operation define how to securely encrypt messages longer than one block. Five standard modes:

  • ECB (Electronic Codebook) — each block encrypted independently with the same key. Simple but identical plaintext blocks → identical ciphertext (leaks patterns). Weakest.
  • CBC (Cipher Block Chaining) — each plaintext block XOR-ed with the previous ciphertext block before encryption; needs an IV. Hides patterns.
  • CFB (Cipher Feedback) — turns a block cipher into a self-synchronising stream cipher; encrypts previous ciphertext then XORs with plaintext.
  • OFB (Output Feedback) — like CFB but feeds back the cipher output (keystream), independent of plaintext; errors don't propagate.
  • CTR (Counter) — encrypts an incrementing counter to make a keystream; fully parallelisable, random access.
Formulas per Mode
ECB Ci = E(K, Pi)
CBC Ci = E(K, Pi ⊕ Ci−1),   C0=IV
CFB Ci = Pi ⊕ E(K, Ci−1)
OFB Oi=E(K,Oi−1),   Ci = Pi ⊕ Oi
CTR Ci = Pi ⊕ E(K, counteri)
Compare Table
ModeIV?Parallel enc?Pattern hidingError propagation
ECBNoYesPoor1 block
CBCYesNoGood2 blocks
CFBYesNoGoodSeveral
OFBYesNoGood1 bit
CTRNonceYesGood1 bit
Exam favourite "Why is ECB insecure?" → identical blocks encrypt identically, revealing structure (the classic encrypted-image demo).
Bloom's Practice Questions
Remember3
List the five block cipher modes of operation.
Understand6
Explain CBC mode with encryption/decryption equations and the role of the IV.
Analyze6
Why is ECB unsuitable for large or structured data? Contrast with CBC.
Evaluate10
Describe all five modes with diagrams/equations and evaluate them on parallelism, error propagation, and security.
24

Data Encryption Standard (DES)

▶
Explanation

DES is a symmetric block cipher using the Feistel structure. It encrypts 64-bit blocks with a 56-bit effective key (64 bits with 8 parity) over 16 rounds.

Structure Initial Permutation (IP) → 16 Feistel rounds (each with a 48-bit subkey) → 32-bit swap → Inverse Initial Permutation (IP⁻¹).

Feistel round function F: Expansion (32→48) → XOR round key → 8 S-boxes (48→32) → Permutation P.

Key schedule: 56-bit key → PC-1 → split into two 28-bit halves → circular left shifts each round → PC-2 → 48-bit subkey.

Feistel property The same structure does encryption and decryption — decryption applies the subkeys in reverse order (K16…K1).
Key Numbers & Formula
DES parameters 64-bit block · 56-bit key · 16 rounds · 48-bit subkeys
Feistel round Li = Ri−1
Ri = Li−1 ⊕ F(Ri−1, Ki)
Weakness 56-bit key is too small — brute-forced in practice. Fixed by 3DES (effective 112/168-bit) and superseded by AES.
Bloom's Practice Questions
Remember3
State DES block size, key size, and number of rounds.
Understand6
Explain the Feistel round function of DES (E, XOR, S-box, P).
Understand6
Describe the DES key schedule (PC-1, shifts, PC-2).
Analyze10
Explain the full DES encryption structure with a diagram, the round function, and why decryption reuses the same structure; discuss the key-size weakness and 3DES fix.
25

S-DES (Simplified DES) — Full Worked Problem

▶
Explanation

S-DES is the teaching version of DES: 8-bit plaintext, 10-bit key, 2 rounds, two 8-bit subkeys. It exercises the same ideas — permutation, XOR, S-box substitution, swap — at a size you can compute by hand.

PropertyValue
Plaintext / Ciphertext8 bits
Key10 bits
SubkeysK1, K2 (8 bits each)
Rounds2
S-boxesS0, S1
The Two Golden Sequences
Key schedule P10 → LS-1 → P8 = K1 → LS-2 → P8 = K2
Encryption IP → Round1(K1) → SW → Round2(K2) → IP⁻¹
Round function EP → XOR key → S0/S1 → P4 → XOR left
Feistel core Lnew = L ⊕ F(R,K),   Rnew = R
Complete Worked Example (from your notes)
Given

Key=1010000010 · PT=10101010 · P10=3 5 2 7 4 10 1 9 8 6 · P8=6 3 7 4 8 5 10 9 · IP=2 6 3 1 4 8 5 7 · IP⁻¹=4 1 3 5 7 2 8 6 · EP=4 1 2 3 2 3 4 1 · P4=2 4 3 1

Key Generation
P10 on key. 1010000010 → 1000001100 → halves 10000 | 01100.
LS-1 each half. 00001 | 11000 → 0000111000.
P8 → K1. = 10100100.
LS-2 from the LS-1 halves. 00001→00100, 11000→00011 → 0010000011.
P8 → K2. = 01000011.
Encryption
IP on PT. 10101010 → 00110011 → L0=0011, R0=0011.
Round 1 — EP(R0). 0011 → 10010110.
XOR K1. 10010110 ⊕ 10100100 = 00110010 → 0011 | 0010.
S0(0011). row 01=1, col 01=1 → value 2 → 10.   S1(0010). row 00=0, col 01=1 → 1 → 01.
Combine + P4. 1001 → P4 → 0101.
XOR L0. 0011 ⊕ 0101 = 0110. R unchanged = 0011 → 0110 | 0011.
Swap. → 0011 | 0110.
Round 2 — EP(0110). = 00111100. XOR K2 01000011 → 01111111 → 0111 | 1111.
S0(0111). row 01=1, col 11=3 → 0 → 00.   S1(1111). row 11=3, col 11=3 → 3 → 11.
Combine + P4. 0011 → P4 → 0110.
XOR L. 0011 ⊕ 0110 = 0101. R = 0110 → 0101 | 0110 (NO swap after round 2).
IP⁻¹ on 01010110. → 10001101.
Final Answer
K1=10100100 · K2=01000011 · Ciphertext = 10001101.
Top exam traps Generate K2 from the LS-1 halves (not the original key) · S-box row = first+last bit, col = middle two · Swap after round 1 only, never after round 2 · Don't forget IP⁻¹.
Bloom's Practice Questions
Remember3
State the block size, key size, and number of rounds of S-DES.
Understand6
Explain S-DES key generation (P10, LS, P8) producing K1 and K2.
Apply6
Given the round function components, compute one round of S-DES for a given R and subkey.
Apply10
Full problem: with Key=1010000010, PT=10101010 and the given tables, derive K1, K2 and the ciphertext, showing every step.
This is the exact 10-mark format — reproduce both golden sequences and every intermediate value.

★ Last-Minute Cheatsheet — All Cipher Formulas

Everything you need in the final 10 minutes. Encryption · Decryption · key facts.

Caesar

C = (P + k) mod 26
P = (C − k) mod 26

25 keys · brute-forceable.

Monoalphabetic

Fixed permutation of 26 letters

Key space 26! · broken by frequency analysis.

Playfair

5×5 matrix · digrams

Row→right · Col→down · Rectangle→swap columns. I/J share a cell.

Vigenère

Ci = (Pi + Ki) mod 26
Pi = (Ci − Ki) mod 26

Polyalphabetic · repeating keyword.

Hill

C = K·P mod 26
P = K⁻¹·C mod 26
K⁻¹ = (detK)⁻¹[d −b; −c a]

Needs gcd(detK,26)=1.

Vernam

C = P ⊕ K
P = C ⊕ K

X ⊕ K ⊕ K = X.

One-Time Pad

C = P ⊕ K (perfect secrecy)

Random + len=msg + never reused + secret.

Rail Fence / Transposition

Reorder positions, keep letters

Zig-zag over rails, read row by row.

Book Cipher

Coord = Page : Line : Word [: Char]

Key = shared book + edition.

Fermat

ap−1 ≡ 1 (mod p)
ap ≡ a (mod p)

Euler

aφ(n) ≡ 1 (mod n)
φ(pq) = (p−1)(q−1)

Euclid / Inverse

gcd(a,b)=gcd(b, a mod b)
ax + ny = 1 → x = a⁻¹ mod n

LCG

Xn+1 = (a·Xn + c) mod m

Not crypto-secure.

Block Modes

CBC: Ci=E(K,Pi⊕Ci−1)
CTR: Ci=Pi⊕E(K,ctri)

ECB leaks patterns.

DES

64-bit block · 56-bit key · 16 rounds
Li=Ri−1; Ri=Li−1⊕F(Ri−1,Ki)

S-DES

Keys: P10→LS1→P8=K1→LS2→P8=K2
Enc: IP→R1(K1)→SW→R2(K2)→IP⁻¹
Round: EP→⊕K→S0/S1→P4→⊕L

Letter ↔ Number (A=0 … Z=25)

A0 B1 C2 D3 E4 F5 G6 H7 I8 J9 K10 L11 M12 N13 O14 P15 Q16 R17 S18 T19 U20 V21 W22 X23 Y24 Z25

Negative mod 26: −1→25, −2→24, −3→23, −4→22, −5→21 (add 26).

End of deck · 25 topics · Units 1 & 2 · Best of luck in the exam.