Information Security ยท Unit 2
Cryptographic Foundations
Exam-focused notes for Cryptographic Foundations (Information Security, BIT303): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
Cryptographic Foundations in short
Cryptography depends on mathematics. This chapter covers the number theory, algorithms and classical ciphers that later chapters (DES, RSA, hashing) build on.
What this unit covers
- Number theory basics
- Euler totient function
- Extended Euclidean algorithm
- Primality testing algorithms
- Finite fields and polynomial operations
- Substitution and transposition ciphers
Substitution and transposition ciphers
2082
Distinction between Substitution and Transposition Cipher, DES Sub-Key Generation, and Finite Fields
Finite fields and polynomial operations
2082 ยท 5 marks
Perform polynomial addition, subtraction and multiplication of $2x^2 + 4x + 2$ and $5x + 6$ over $GF(7)$. [5]
Show solved answerHide answer
Polynomial Arithmetic over GF(7)
Given
$$A(x) = 2x^2 + 4x + 2$$ $$B(x) = 5x + 6$$
Field: $GF(7)$, so all coefficients reduced $\bmod 7$.
Coefficient vectors:
- $A: [x^2, x^1, x^0] = [2, 4, 2]$
- $B: [x^2, x^1, x^0] = [0, 5, 6]$
Solution
1. Addition $A(x) + B(x)$
| Degree | A | B | Sum | mod 7 |
|---|---|---|---|---|
| $x^2$ | 2 | 0 | 2 | 2 |
| $x^1$ | 4 | 5 | 9 | 2 |
| $x^0$ | 2 | 6 | 8 | 1 |
$$\boxed{A(x) + B(x) = 2x^2 + 2x + 1}$$
2. Subtraction $A(x) - B(x)$
| Degree | A | B | Diff | mod 7 |
|---|---|---|---|---|
| $x^2$ | 2 | 0 | 2 | 2 |
| $x^1$ | 4 | 5 | -1 | 6 |
| $x^0$ | 2 | 6 | -4 | 3 |
$$\boxed{A(x) - B(x) = 2x^2 + 6x + 3}$$
3. Multiplication $A(x) \times B(x)$
Expand: $$(2x^2 + 4x + 2)(5x + 6)$$ $$= 10x^3 + 12x^2 + 20x^2 + 24x + 10x + 12$$
Collect: $$= 10x^3 + 32x^2 + 34x + 12$$
Reduce $\bmod 7$:
| Degree | Raw | mod 7 |
|---|---|---|
| $x^3$ | 10 | 3 |
| $x^2$ | 32 | 4 |
| $x^1$ | 34 | 6 |
| $x^0$ | 12 | 5 |
$$\boxed{A(x) \times B(x) = 3x^3 + 4x^2 + 6x + 5}$$
Summary
| Operation | Result over $GF(7)$ |
|---|---|
| $A + B$ | $2x^2 + 2x + 1$ |
| $A - B$ | $2x^2 + 6x + 3$ |
| $A \times B$ | $3x^3 + 4x^2 + 6x + 5$ |
Primality testing algorithms
2081 ยท 5 marks
Write Rabin Miller Algorithm for primality testing. Test whether 341 is prime or not using the algorithm. [5]
2079 ยท 5 marks
Define Euler Totient function. Determine whether 37 is Composite or not using Miller Rabin Primality testing. [5]
Show solved answerHide answer
Euler Totient Function & Miller-Rabin Primality Test
Part 1: Euler Totient Function
The Euler Totient Function, denoted $\phi(n)$, is defined as the number of positive integers less than or equal to $n$ that are relatively prime (coprime) to $n$.
$$\phi(n) = |{ k : 1 \le k \le n,\ \gcd(k, n) = 1 }|$$
Key properties:
- If $p$ is prime: $\phi(p) = p - 1$
- For a prime power: $\phi(p^k) = p^k - p^{k-1}$
- Multiplicative: $\phi(mn) = \phi(m)\cdot\phi(n)$ when $\gcd(m,n) = 1$
Example: $\phi(37) = 36$ since 37 is prime.
Part 2: Miller-Rabin Test on $n = 37$
Algorithm
To test $n$ with a chosen witness $a$:
- Write $n - 1 = 2^s \cdot d$ with $d$ odd.
- Compute $x = a^d \bmod n$.
- If $x \equiv 1$ or $x \equiv -1 \pmod n$ โ probably prime.
- Otherwise square $x$ repeatedly (for $r = 1, \dots, s-1$); if any gives $-1 \pmod n$ โ probably prime.
- If none hold โ composite.
Step 1: Express $n - 1 = 2^s \cdot d$
$$n - 1 = 36 = 2^2 \cdot 9$$
So $s = 2$, $d = 9$.
Step 2: Choose witness $a = 2$, compute $a^d \bmod n$
$$2^9 \bmod 37$$
- $2^1 = 2$
- $2^2 = 4$
- $2^4 = 16$
- $2^8 = 256 = 6\times 37 + 34 \equiv 34 \pmod{37}$
- $2^9 = 2^8 \cdot 2 = 34 \times 2 = 68 \equiv 68 - 37 = 31 \pmod{37}$
$$x = 2^9 \equiv 31 \pmod{37}$$
Step 3: Check conditions
Initial check: Is $x \equiv 1$ or $x \equiv 36\ (\equiv -1)$? $$31 \ne 1, \quad 31 \ne 36 \quad \Rightarrow \text{ not yet passed}$$
Square once ($r = 1$): compute $2^{18} = x^2 \bmod 37$ $$31^2 = 961, \quad 961 = 25\times 37 + 36 = 925 + 36$$ $$2^{18} \equiv 36 \equiv -1 \pmod{37} \quad \checkmark$$
Condition satisfied.
Conclusion
Since $2^{18} \equiv -1 \pmod{37}$, the test passes for witness $a = 2$.
$$\boxed{37 \text{ is PROBABLY PRIME (not composite)}}$$
37 is in fact a prime number, so Miller-Rabin correctly reports it as not composite.
Euler totient function
2080 ยท 10 marks
Define Euler totient function with an example. Find the GCD of 12 and 32 using Extended Euclidean algorithm.[10]
Extended Euclidean algorithm
0 ยท 5 marks
Write an algorithm for Extended Euclidean Algorithm. Illustrate the algorithm for a=84 and b=320. [5]
Make Unit 2 stick
Practice BIT303 with flashcards & quizzes