Cryptography ยท Unit 1 ยท 7 hrs
Introduction and Classical Ciphers
Exam-focused notes for Introduction and Classical Ciphers (Cryptography, CSC327): what the TU syllabus asks and how it has actually been tested, with 11 solved past questions from this unit.
Introduction and Classical Ciphers in short
Cryptography is the branch of information security that turns readable data into a form only an authorized party can recover. This unit lays out the vocabulary shared by computer, information and network security, then works through the classical substitution and transposition ciphers that predate computers, closing with the split between modern block/stream and symmetric/asymmetric ciphers that the rest of the course builds on. Throughout, letters are indexed A = 0, B = 1, ..., Z = 25, and all arithmetic on letters is taken modulo 26 unless stated otherwise.
What this unit covers
- Security: Computer Security, Information Security, Network Security, CIA Triad, Cryptography, Cryptosystem, Cryptanalysis, Security Threats and Attacks, Security Services, Security Mechanisms
- Classical Cryptosystems
- Substitution Techniques: Ceasar, Monoalphabetic, Playfair, Hill, Polyalphabetic ciphers, One-time pad
- Transposition Techniques: Rail Fence Cipher
- Modern Ciphers: Block vs. Stream Ciphers, Symmetric vs. Asymmetric Ciphers
Substitution Techniques
2082 ยท 5 marks
Given the key "HELLOWORLD", encrypt the plaintext "TURINGTEST" using Play fair cipher. [5]
Show solved answerHide answer
Playfair Cipher: Encrypting "TURINGTEST" with Key "HELLOWORLD"
Given
- Key: HELLOWORLD
- Plaintext: TURINGTEST
- Cipher: Playfair (5x5 matrix, I/J combined)
Solution
Build the 5x5 Matrix
Key letters, removing duplicates (keep first occurrence): H, E, L, O, W, R, D (HELLOWORLD โ H, E, L, [L dup], O, W, [O dup], R, [L dup], D)
Fill remaining alphabet (I/J together): A, B, C, F, G, I/J, K, M, N, P, Q, S, T, U, V, X, Y, Z
| C1 | C2 | C3 | C4 | C5 | |
|---|---|---|---|---|---|
| R1 | H | E | L | O | W |
| R2 | R | D | A | B | C |
| R3 | F | G | I/J | K | M |
| R4 | N | P | Q | S | T |
| R5 | U | V | X | Y | Z |
Split into digrams
TURINGTEST โ TU | RI | NG | TE | ST
No double letters within a pair, length is even, so no padding needed.
Apply rules
TU: T(R4,C5), U(R5,C1) โ rectangle T โ (R4, C1) = N; U โ (R5, C5) = Z โ NZ
RI: R(R2,C1), I(R3,C3) โ rectangle R โ (R2, C3) = A; I โ (R3, C1) = F โ AF
NG: N(R4,C1), G(R3,C2) โ rectangle N โ (R4, C2) = P; G โ (R3, C1) = F โ PF
TE: T(R4,C5), E(R1,C2) โ rectangle T โ (R4, C2) = P; E โ (R1, C5) = W โ PW
ST: S(R4,C4), T(R4,C5) โ same row (shift right, wrap) S โ C5 = T; T โ C1 (wrap) = N โ TN
Final Ciphertext
| Plain pair | Cipher pair |
|---|---|
| TU | NZ |
| RI | AF |
| NG | PF |
| TE | PW |
| ST | TN |
$$\boxed{\text{Ciphertext} = \text{NZAFPFPWTN}}$$
2082
Decrypt the ciphertext 'HI' using Hill Cipher where the key is. Ciphertext: HI, Key: $$\begin{bmatrix} 5 & 3 \ 4 & 3 \end{bmatrix}$$
Show solved answerHide answer
Hill Cipher Decryption of Ciphertext 'HI'
Given Data
- Ciphertext: HI
- Key Matrix:
$$K = \begin{bmatrix} 5 & 3 \ 4 & 3 \end{bmatrix}$$
- Alphabet mapping: A=0, B=1, ..., Z=25, modulus 26.
Step 1: Convert Ciphertext to Numbers
- H = 7
- I = 8
$$C = \begin{bmatrix} 7 \ 8 \end{bmatrix}$$
Step 2: Decryption Formula
$$P = K^{-1} C \pmod{26}$$
Step 3: Determinant of K
$$\det(K) = (5)(3) - (3)(4) = 15 - 12 = 3$$
Step 4: Inverse of Determinant mod 26
$$3 \cdot d^{-1} \equiv 1 \pmod{26}$$
$$3 \times 9 = 27 \equiv 1 \pmod{26} \Rightarrow d^{-1} = 9$$
Step 5: Adjugate of K
$$\text{adj}(K) = \begin{bmatrix} 3 & -3 \ -4 & 5 \end{bmatrix} \equiv \begin{bmatrix} 3 & 23 \ 22 & 5 \end{bmatrix} \pmod{26}$$
Step 6: Compute Kโปยน
$$K^{-1} = 9 \cdot \begin{bmatrix} 3 & 23 \ 22 & 5 \end{bmatrix} \pmod{26} = \begin{bmatrix} 27 & 207 \ 198 & 45 \end{bmatrix} \pmod{26}$$
- $27 \bmod 26 = 1$
- $207 \bmod 26 = 207 - 182 = 25$
- $198 \bmod 26 = 198 - 182 = 16$
- $45 \bmod 26 = 19$
$$K^{-1} = \begin{bmatrix} 1 & 25 \ 16 & 19 \end{bmatrix}$$
Check: $K^{-1}K \pmod{26}$:
- $(1)(5)+(25)(4)=5+100=105 \equiv 1$
- $(1)(3)+(25)(3)=3+75=78 \equiv 0$
- $(16)(5)+(19)(4)=80+76=156 \equiv 0$
- $(16)(3)+(19)(3)=48+57=105 \equiv 1$
Gives identity: inverse is correct.
Step 7: Multiply Kโปยน by C
$$P = \begin{bmatrix} 1 & 25 \ 16 & 19 \end{bmatrix}\begin{bmatrix} 7 \ 8 \end{bmatrix} \pmod{26}$$
- Row 1: $7 + 200 = 207 \equiv 207 - 182 = 25$
- Row 2: $112 + 152 = 264 \equiv 264 - 260 = 4$
$$P = \begin{bmatrix} 25 \ 4 \end{bmatrix}$$
Step 8: Convert to Letters
- 25 = Z
- 4 = E
Result
$$\boxed{\text{Plaintext} = \textbf{ZE}}$$
The ciphertext 'HI' decrypts to 'ZE'.
2081 ยท 5 marks
Show the encryption of plain text "ALGORITHM" using the key "PSEUDOCODE" using playfair cipher. [5]
Show solved answerHide answer
Playfair Cipher: Encryption of "ALGORITHM" using key "PSEUDOCODE"
Given
- Plaintext: ALGORITHM
- Key: PSEUDOCODE
- Convention: I/J share one cell (standard Playfair)
Solution
Construct the 5x5 Matrix
Key: P S E U D O C O D E
Remove duplicates (keep first occurrence): P, S, E, U, D, O, C (The second O, D, E are dropped.)
Fill remaining letters A, B, F, G, H, I/J, K, L, M, N, Q, R, T, V, W, X, Y, Z:
| Col1 | Col2 | Col3 | Col4 | Col5 | |
|---|---|---|---|---|---|
| Row1 | P | S | E | U | D |
| Row2 | O | C | A | B | F |
| Row3 | G | H | I/J | K | L |
| Row4 | M | N | Q | R | T |
| Row5 | V | W | X | Y | Z |
Prepare Digrams
Plaintext: A L G O R I T H M
No double letters within pairs. M is left alone, pad with X:
$$AL \mid GO \mid RI \mid TH \mid MX$$
Apply Rules
AL: A(2,3), L(3,5) โ rectangle โ Aโ(2,5)=F, Lโ(3,3)=I โ FI
GO: G(3,1), O(2,1) โ same column โ Gโ(4,1)=M, Oโ(3,1)=G โ MG
RI: R(4,4), I(3,3) โ rectangle โ Rโ(4,3)=Q, Iโ(3,4)=K โ QK
TH: T(4,5), H(3,2) โ rectangle โ Tโ(4,2)=N, Hโ(3,5)=L โ NL
MX: M(4,1), X(5,3) โ rectangle โ Mโ(4,3)=Q, Xโ(5,1)=V โ QV
Final Ciphertext
| Digram | Cipher |
|---|---|
| AL | FI |
| GO | MG |
| RI | QK |
| TH | NL |
| MX | QV |
$$\boxed{\text{Ciphertext} = \text{FIMGQKNLQV}}$$
2081 ยท 5 marks
Using Vigenere cipher with key = โworldsโ, encrypt the plain text โhello everyoneโ. [5]
2080 ยท 5 marks
Show encryption and decryption of "csit" using hill cipher having key, [5]
2079 ยท 5 marks
The message โIMOGUNโ was encrypted with a Playfair cipher using keyword โGALOISโ. Decrypt the message. [5]
2078 ยท 5 marks
Decrypt the message 'GVPJ' using Hill cipher taking the key as {Row1 = 3 7, Row2= 5 12}. [5]
2078 ยท 5 marks
Differentiate between Symmetric and Asymmetric cipher. Encrypt the message 'HELL' using the key 'FAIL' using Vernam cipher. [5]
Transposition Techniques
2080 ยท 5 marks
How substitution ciphers are different from transposition ciphers? Given a message M="CSIT PROGRAM IS A HOT CAKE", encrypt M using Rail Fence cipher with rail size 3. [5]
2079 ยท 5 marks
Which one is more secure, monoalphabetic cipher or poly alphabetic cipher? Justify. Using rail fence cipher encrypt the text 'LEARNING AND TEACHING ARE DIFFERENT' using 3 as rails. [5]
2076 ยท 5 marks
Distinguish between stream cipher and block cipher. Encrypt the message WE ARE IN SAME RACE UNTILL OVER LIVE END using Rail fence cipher using 4 as a number of rails. [5]
Make Unit 1 stick
Practice CSC327 with flashcards & quizzes