1 Introduction And Classical Ciphers

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.

Introduction and Classical Ciphers: notes

Security: Computer Security, Information Security, Network Security, CIA Triad, Cryptography, Cryptosystem, Cryptanalysis, Security Threats and Attacks, Security Services, Security Mechanisms

Computer security is the protection given to an automated information system so that it preserves the integrity, availability and confidentiality of its resources. Information security narrows this to protecting information and information systems themselves from unauthorized access, use, modification or destruction, while network security is the set of physical and software measures that protect the networking infrastructure that carries that information from unauthorized access, misuse or modification.

These three goals are usually summarized as the CIA triad. Confidentiality covers data confidentiality (private information is not disclosed to unauthorized individuals) and privacy (an individual controls what personal information is collected and to whom it is disclosed). Integrity covers data integrity (information and programs are changed only in an authorized manner) and system integrity (a system performs its intended function free of unauthorized manipulation). Availability assures that systems work promptly and are not denied to authorized users.

Cryptography (from the Greek kryptos, hidden, and graphein, to write) is the art and science of hiding information. Its central operations are encryption, converting readable plaintext into unreadable ciphertext, and decryption, the reverse. Cryptanalysis is the set of techniques for recovering plaintext or key from ciphertext without authorization; the combined study of cryptography and cryptanalysis is cryptology. Formally, a cryptosystem is a five-tuple $(M, C, K, E, D)$: $M$ is the set of possible plaintexts, $C$ the set of possible ciphertexts, $K$ the set of possible keys, $E = {E_k \mid k \in K}$ the family of encryption functions $E_k: M \to C$, and $D = {D_k \mid k \in K}$ the family of decryption functions $D_k: C \to M$, with $D_k(E_k(m)) = m$ for every plaintext $m$. The Caesar cipher fits this template with $M$ the set of letter sequences, $K = {k \mid 0 \le k \le 25}$, $E_k(m) = (m+k) \bmod 26$ and $D_k(c) = (c-k) \bmod 26$. A key is the piece of information, separate from the algorithm itself, that determines the output of a cryptographic transformation, which is what allows the algorithm to be public while the communication stays secure.

A security threat is a potential circumstance, capability or event that could breach security and cause harm; a security attack is the actual assault that tries to realize a threat. Attacks are grouped as passive or active. Passive attacks only observe: release of message contents lets an eavesdropper read the transmitted data (wiretapping a call, reading intercepted email), and traffic analysis infers the identity, location, and communication pattern of the parties even when the content itself is encrypted, from the frequency, length and timing of the messages alone. Active attacks modify data or manufacture false data: masquerade is one entity pretending to be another, replay is capturing a message and retransmitting it later to cause an unauthorized effect, modification of messages alters, delays or reorders part of a legitimate message, and denial of service prevents or degrades the normal use of a communication facility, from targeting one destination to overloading an entire network.

A security service, in the X.800 sense, is a service offered by a protocol layer of a system that ensures adequate security of the system or its data transfers, implemented through one or more security mechanisms. The core services are authentication (peer entity authentication, confidence in the identity of the two ends of a connection, and data origin authentication, assurance that received data really came from the claimed source), access control (limiting who may use a resource, which requires the entity first to be authenticated), and non-repudiation (neither sender nor receiver can later deny having sent or received a message). A security mechanism is the design used to detect, prevent or recover from an attack; cryptography secures confidentiality and integrity, authentication protocols and digital signatures secure integrity and identity, and access control lists secure authorization.

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 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

C1C2C3C4C5
R1HELOW
R2RDABC
R3FGI/JKM
R4NPQST
R5UVXYZ

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 pairCipher pair
TUNZ
RIAF
NGPF
TEPW
STTN

$$\boxed{\text{Ciphertext} = \text{NZAFPFPWTN}}$$

Open this answer on its own page โ†’

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 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'.

Open this answer on its own page โ†’

2081 ยท 5 marks

Show the encryption of plain text "ALGORITHM" using the key "PSEUDOCODE" using playfair cipher. [5]

Show solved 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:

Col1Col2Col3Col4Col5
Row1PSEUD
Row2OCABF
Row3GHI/JKL
Row4MNQRT
Row5VWXYZ

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

DigramCipher
ALFI
GOMG
RIQK
THNL
MXQV

$$\boxed{\text{Ciphertext} = \text{FIMGQKNLQV}}$$

Open this answer on its own page โ†’

2081 ยท 5 marks

Using Vigenere cipher with key = โ€œworldsโ€, encrypt the plain text โ€œhello everyoneโ€. [5]

  • Plaintext: hello everyone โ†’ letters only: helloeveryone (13 letters) - Key: worlds - Formula: $Ci = (Pi + Ki) \bmod 26$, with A=0, ..., Z=25 Pos 1 2 3 4 5 6 7 8 9 10 11 12 13 ------------------------------------------------ P h e l l o e v e r y o n e K w o r l d s w o r l d s w P h=7 e=4 l=11 ...
Open this answer on its own page โ†’

2080 ยท 5 marks

Show encryption and decryption of "csit" using hill cipher having key, [5]

  • Plaintext: "csit" - Cipher method: Hill cipher - Key matrix: NOT provided in the question (the LaTeX/image key is missing). Missing data note: The actual key matrix is not readable in the question. Without the key, the exact ciphertext cannot be uniquely determined. To demonstrate the full meth...
Open this answer on its own page โ†’

2079 ยท 5 marks

The message โ€œIMOGUNโ€ was encrypted with a Playfair cipher using keyword โ€œGALOISโ€. Decrypt the message. [5]

  • Ciphertext: IMOGUN - Keyword: GALOIS - Convention: I/J combined into a single cell. Keyword unique letters: G, A, L, O, I, S. Then fill remaining alphabet (I/J shared, skip already-used letters): Remaining after G,A,L,O,I,S: B, C, D, E, F, H, K, M, N, P, Q, R, T, U, V, W, X, Y, Z C1 C2 C3 C4 C5...
Open this answer on its own page โ†’

2078 ยท 5 marks

Decrypt the message 'GVPJ' using Hill cipher taking the key as {Row1 = 3 7, Row2= 5 12}. [5]

  • Ciphertext: GVPJ - Key matrix: $K = \begin{pmatrix} 3 & 7 \ 5 & 12 \end{pmatrix}$ - Letter encoding: A=0, B=1, ..., Z=25 - Decryption: $P = K^{-1} \cdot C \pmod{26}$ --- G V P J ------------ 6 21 15 9 Pairs (column vectors): $$C1 = \begin{pmatrix} 6 \ 21 \end{pmatrix}, \quad C2 = \begin{pmatr...
Open this answer on its own page โ†’

2078 ยท 5 marks

Differentiate between Symmetric and Asymmetric cipher. Encrypt the message 'HELL' using the key 'FAIL' using Vernam cipher. [5]

  • Plaintext: HELL - Key: FAIL - Cipher: Vernam cipher - Letter mapping used: $A=0, B=1, \dots, Z=25$ --- Feature Symmetric Cipher Asymmetric Cipher --------- Keys used Single shared secret key for both encryption and decryption Two keys: a public key and a private key Key distribution Difficult; ...
Open this answer on its own page โ†’

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]

Feature Substitution Cipher Transposition Cipher --------- Basic idea Each plaintext character is replaced by another character/symbol Character identity is retained but its position is changed Operation Maps letters to other letters via a key/rule Rearranges (permutes) the sequence of letters Le...

Open this answer on its own page โ†’

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]

  • Plaintext: LEARNING AND TEACHING ARE DIFFERENT - Number of rails: 3 - Task 1: Compare security of monoalphabetic vs polyalphabetic cipher. - Task 2: Encrypt using rail fence with 3 rails. --- Polyalphabetic cipher is more secure than monoalphabetic cipher. Feature Monoalphabetic Polyalphabetic ...
Open this answer on its own page โ†’

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]

  • Message: WE ARE IN SAME RACE UNTILL OVER LIVE END - Number of rails: 4 - Task: distinguish stream vs block cipher; encrypt using Rail Fence cipher. First extract and verify the letters (spaces removed): W E A R E I N S A M E R A C E U N T I L L O V E R L I V E E N D Concatenated: WEAREINSAMERAC...
Open this answer on its own page โ†’