قبل ما تبدا سمي الله و صلي عالنبي
Welcome 👋
This interactive study guide is designed to help you master Cryptography — classical ciphers, number theory, finite fields, DES and AES — built on Paar & Pelzl's Understanding Cryptography, Stallings' number-theory chapters, and the TA's hand-written notes. Navigate through the modes below:
- 📖 Tutorial Mode: Socratic walkthroughs of modular arithmetic, the Extended Euclidean table, CRT, Miller-Rabin, Galois fields, the Feistel round, S-box lookups and the AES layers — with try-it checks and worked examples.
- 🎴 Flash Cards: Quick-recall decks of definitions, theorems, parameters and one-liner facts.
- 🎯 Professor's Focus: Exam-style theory answers and fully worked sheet problems — Part 1 (math foundations) and Part 2 (block ciphers).
- ⚡ Practice Quiz: Exam-style MCQs drawn from lectures, problem sheets & notes.
💡 Pro-Tip: Press Ctrl+K to search across tutorials and questions. The floating 📋 Cheat Sheet at the bottom-right has the EEA table rule, CRT recipe, Fermat/Euler, the S-box lookup and AES layers.
Tutorial Mode
Socratic walkthroughs of every chapter with try-it checks
0 / 0
Flash Cards
Quick-recall decks of definitions, theorems & parameters
0 / 0
Professor's Focus
Exam-style theory answers and fully worked sheet problems
Practice Quiz
Exam-style MCQs with hints, explanations & mistake tracking
Professor's Focus
Pick a revision part
Each part is a self-contained Q & A + worked-numerical deck built from the lecture slides, problem sheets and course notes.
P1
Part 1 · Math Foundations
Ch 1, 2, 5 — classical ciphers, modular arithmetic, EEA, CRT, Miller-Rabin, groups, rings & fields.
P2
Part 2 · Block Ciphers
Ch 3, 4 — confusion & diffusion, Feistel, the f-function, S-boxes, key schedule, AES layers.
Sheet questions only
Restrict the pool to questions that came directly from the practice sheets
10
15
20
All
of 0
Practice modeShow the correct answer & explanation after each question
Shuffle questionsRandomize the order each attempt
Sheet questions only
Restrict the pool to coding tasks pulled from the practice sheets
5
10
15
All
of 0
Mix question stylesInterleave fill, line builder, and scratch coding questions
Shuffle questionsRandomize the order each attempt
Shuffle cardsRandomize the order each session
📋 Cheat Sheet
Check theorems, tables and worked recipes anytime!
25:00
Start focus timer
🍅 Focus Timer
Pomodoro / break / stopwatch — keeps counting across pages and refreshes.
🍅 Focus Timer
25:00
Focus Session
Sound chime
Play a gentle tone when the timer ends
📋 Exam Reference Sheet
Classical Ciphers (A = 0 … Z = 25)
- Shift:
y = x + k mod 26,x = y − k mod 26. 26 keys. - Affine:
y = a·x + b mod 26,x = a⁻¹(y − b) mod 26, needsgcd(a, 26) = 1. 12 × 26 = 312 keys. - Valid a: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.
- Substitution: 26! ≈ 288 keys, broken by letter frequency (E > T > A > O …).
- Kerckhoffs: only the key is secret.
Modular Arithmetic
a ≡ r (mod m)⇔m | (a − r). Reduce intermediate results early.- Inverse in Zm exists ⇔
gcd(a, m) = 1. Negative inverse → add m. - Square-and-multiply: binary exponent, square each step, multiply the needed powers.
GCD & Inverses
- Division:
a = q·b + r,0 ≤ r < b. - Euclid:
gcd(a, b) = gcd(b, a mod b); stop when r = 0. - EEA:
a·x + b·y = gcd(a, b). Table:T = t1 − t2·q, startt1 = 0, t2 = 1; t beside remainder 1 = b⁻¹ mod a.
Primes
- Fermat:
ap−1 ≡ 1 (mod p); any a:ap ≡ a. - Totient:
φ(p) = p−1,φ(pq) = (p−1)(q−1). - Euler:
aφ(n) ≡ 1 (mod n)if gcd(a, n) = 1 → reduce exponents mod φ(n). - Miller-Rabin:
n−1 = 2kq;x = aq mod n; x = ±1 or n−1 after ≤ k−1 squarings → inconclusive; else composite.
Chinese Remainder Theorem
- Pairwise coprime mi;
M = Πmi,Mi = M/mi,xi = Mi⁻¹ mod mi. x = (Σ Mi·xi·ai) mod M.
Algebraic Structures
- Group: A1 closure, A2 associativity, A3 identity, A4 inverse. Abelian: + A5 commutativity.
- Ring: abelian group under + ; M1 closure, M2 associativity of ×, M3 distributive.
- Commutative ring: + M4
ab = ba. - Integral domain: + M5 identity 1, M6 no zero divisors.
- Field: + M7 inverse for every a ≠ 0.
- Cyclic group: all elements are powers of one generator → always abelian.
Finite Fields
- GF(p): integers mod prime p. GF(pn): polynomials mod p, reduced by an irreducible polynomial.
- GF(2): addition = XOR, multiplication = shift + XOR.
- Polynomial GCD: Euclid on polynomials; reduce coefficients mod p every step.
- GF(5) inverses: 1→1, 2→3, 3→2, 4→4.
DES Parameters
- 64-bit block · 56-bit key (+8 parity at 8, 16, …, 64) · 16 rounds · 16 × 48-bit subkeys.
- Feistel:
Li = Ri−1,Ri = Li−1 ⊕ f(Ri−1, ki). - Decrypt: same structure, subkeys k16 … k1.
f-Function
E32→48 →⊕ ki→S1–S8(6→4 each) →P32→32.- S-box: row =
b1b6, column =b2b3b4b5. - S1 row 0: 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
- S1 row 1: 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
- S1…S8 at (0,0): 14 15 10 7 2 12 4 13
- P: 16 7 20 21 29 12 28 17 · 1 15 23 26 5 18 31 10 · 2 8 24 14 32 27 3 9 · 19 13 30 6 22 11 4 25
Key Schedule
PC-1: 64→56, split C0, D0 (28 each).- Left-rotate 1 bit in rounds 1, 2, 9, 16; 2 bits otherwise (total 28).
PC-2: 56→48 = ki.
AES
- 128-bit block; keys 128 / 192 / 256 → 10 / 12 / 14 rounds, 11 / 13 / 15 subkeys.
- Round: ByteSub → ShiftRows → MixColumn → Key Addition (last round: no MixColumn).
- ShiftRows: row i rotated left i bytes.
- MixColumn: rows [02 03 01 01], [01 02 03 01], [01 01 02 03], [03 01 01 02] in GF(28).
- Inv MixColumn: [0E 0B 0D 09] circulant.
- Key schedule (128): W[0..43]; g = RotWord + S-box + RC[i] (01, 02, 04, … 36).
- Not Feistel: every layer is inverted to decrypt; key addition is self-inverse.
Final answers (each one is worked step by step in the tutorials and Professor's Focus)
- 1.1 substitution: THE first, then IS/OF/AND… (Shoshin Nagamine)
- 1.2 shift: k = 15 (only one letter needed)
- 1.3 AES-128 ASICs: 10,000 ASICs, ≈ 1.1e+18 years, Moore ≈ 103 years
- 1.4 passwords: 56 bits; lowercase ≈ 37.6 bits; 19 / 28 characters for 128 bits
- 1.5: all four products ≡ 6 (mod 13)
- 1.6: 8, 3, 4
- 1.7: no inverse: Z₄ {2}, Z₆ {2, 3, 4}
- 1.8: 5⁻¹ = 9, 5, 8 in Z₁₁, Z₁₂, Z₁₃
- 1.9: 9, 10, 3, 9, x = 5
- 1.10: φ = 2, 4, 6, 12
- 1.11 affine (7, 22): first the sentence and then the evidence said the queen
- 1.12 German affine: 240 keys; FRODO (Hobbiton)
- 1.13 chosen plaintext: a = 3, b = 5; needs gcd(x₁ − x₂, 26) = 1
- 1.14 double affine: (a₃, b₃) = (7, 10); still 312 keys
- 3.1 S1 non-linear: 1110 vs 0000 · 1001 vs 1000 · 1010 vs 1101
- 3.2 IP⁻¹(IP(x)): x₁→40→1, x₂→8→2, x₃→48→3, x₄→16→4, x₅→56→5
- 3.3 all zeros: L₁ = 0, R₁ = D8D8DBBC
- 3.4 all ones: L₁ = FFFFFFFF, R₁ = 27272443
- 3.5 bit 57: S1 and S8; L₁ = 80000000, R₁ = D0585B9E; 6 bits
- 3.7 weak keys: 4 keys, probability 2⁻⁵⁴
- 3.9 / 3.11 brute force: 2⁵⁶ worst, 2⁵⁵ average; COPACOBANA ≈ 8.7 days, 209 machines for 1 h
- 3.10 clock: f = r/4: 250 MHz, 2 GHz
- 3.12 passwords: ≈ 1,142 years · 4.5 years · 12 minutes
- 3.13 PRESENT: F000 0000 0000 000F; K₂ = 7FFF F777 6AAA AAAA
- 4.6: 0x13 / 0xCC = 0x86
- 4.7: x⁻¹ = x³ + 1, (x² + x)⁻¹ = x² + x + 1
- 4.9 all ones: E9 in every byte
- 4.10 diffusion: only column 0 changes: 10 bits
- 4.12 gates: 0 / 3 / 11; 152 per column; 608 total
- 4.13 / 4.14: 29⁻¹ = 0A, F3⁻¹ = 34, 01⁻¹ = 01; S = A5, 0D, 7C; S(00) = 63
- 4.15: RC[8] = 80, RC[9] = 1B, RC[10] = 36
- 5.9 gcds: x² + x + 1 · 1 · x + 3 · x² + 5