UNIT I – Introduction to Security and Classical Encryption
Complete Study Notes with Examples, Explanations, and Best Learning Approach
Introduction to Security and Classical Encryption
UNIT I – Introduction to Security and Classical Encryption
Complete Study Notes with Examples, Explanations, and Best Learning Approach
1. Introduction to Security Attacks, Services, and Mechanisms
Security Attacks
Any action that compromises the security of information.
| Type | Description | Example |
|---|---|---|
| Passive Attack | Attacker only observes (does not modify) data. Goal: obtain information. | • Eavesdropping on Wi-Fi • Traffic analysis (who talks to whom) |
| Active Attack | Attacker modifies, deletes, or injects data. | • Masquerade (pretend to be someone else) • Replay attack • Modification of message • Denial of Service (DoS) |
Security Services (CIA + AAA)
| Service | Meaning | Example |
|---|---|---|
| Confidentiality | Data is kept secret from unauthorized parties | Encrypting credit card numbers |
| Integrity | Data cannot be altered undetectably | Digital signatures, hash functions |
| Authentication | Verify the identity of sender/receiver | Password, biometric, certificates |
| Non-repudiation | Sender cannot deny having sent the message | Digital signature with timestamp |
| Access Control | Only authorized users can access resources | File permissions, firewall rules |
| Availability | System/data must be available when needed | Protection against DoS attacks |
Security Mechanisms
Tools/techniques used to provide the above services:
- Encryption / Decryption
- Hash functions
- Digital signatures
- Authentication protocols
- Access control lists
- Firewalls, IDS/IPS
2. Classical Encryption Techniques
A. Substitution Ciphers
Each letter/plaintext symbol is replaced by another letter/ciphertext symbol.
- Caesar Cipher (Shift Cipher)
Key = 3 → A→D, B→E, …, Z→C
Encryption: C = (P + K) mod 26
Decryption: P = (C – K) mod 26
Example
Plaintext : HELLO
Key : 3
Ciphertext: KHOOR
Very weak – only 25 possible keys.
- Monoalphabetic Cipher
Arbitrary fixed substitution (not just shift).
Example mapping:
A→X, B→M, C→T, …, Z→Q
Plaintext : HELLO
Ciphertext: AXEEH (using some random mapping)
Still weak – frequency analysis can break it easily (E is most common in English → appears most in ciphertext).
- Playfair Cipher (Digraph substitution)
- 5×5 grid with I/J combined
- Encrypts two letters at a time
Example Keyword: MONARCHY
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Rules:
- Same row → right shift
- Same column → down shift
- Rectangle → swap columns
Stronger than monoalphabetic but still breakable.
- Polyalphabetic Cipher (Best classical substitution)
Uses multiple substitution alphabets.
Vigenère Cipher
Key repeated to match plaintext length.
Example
Plaintext : WEAREDISCOVEREDRUNATONCE
Key : APPLEAPPLEAPPLEAPPLEAPPL
Ciphertext: CIUIGFKWZVIGBUHXRQEMUWWTP
Much harder to break with frequency analysis because same letter can encrypt differently.
B. Transposition Ciphers
Letters are rearranged (no letter is replaced, only positions change).
- Rail Fence Cipher (Depth = 2 or 3)
Plaintext: MEET ME AFTER THE TOGA PARTY
Write in zigzag:
M . E . T . E . F . E . T . T . G . P . R . Y
. E . M . A . T . R . H . T . O . A . A . T .
Ciphertext: METEFTTGPREY EMA TRHTOAAT
- Columnar Transposition
Plaintext : ATTACK AT DAWN
Key : 3 1 4 2 (means column order 3-1-4-2)
Write row-wise:
3 1 4 2
A T T A
C K A T
D A W N
Read by key order: TADA KWTN TACA → TADAKWTNTACA
Double transposition (repeat twice) makes it much stronger.
C. Cryptanalysis (Code Breaking)
| Attack Type | Works on | Method |
|---|---|---|
| Brute-force | Any cipher with small key space | Try all keys |
| Frequency Analysis | Monoalphabetic substitution | Match letter frequencies |
| Kasiski Examination | Vigenère (polyalphabetic) | Find repeated trigram distance → key length |
| Known-plaintext attack | Any cipher | You have P and C → deduce key |
| Chosen-plaintext attack | Block ciphers | Choose P and get C |
D. Steganography
Hiding the existence of the message (unlike cryptography which hides the meaning).
Examples:
- Invisible ink
- LSB (Least Significant Bit) in image/audio pixels
- Hiding text in whitespace of documents
Cryptography + Steganography = very powerful.
E. Stream vs Block Ciphers
| Feature | Stream Cipher | Block Cipher |
|---|---|---|
| Unit of encryption | 1 bit/byte at a time | Fixed block (64/128/256 bits) |
| Example | ||
| Example | RC4, Salsa20, A5/1 (GSM) | DES, AES, Blowfish |
| Speed | Very fast | Slower (but secure) |
| Error propagation | One bit error affects one bit | One bit error corrupts whole block |
| Usage | Real-time (voice, video) | File/database encryption |
3. Modern Block Ciphers
A. Principles of Modern Block Ciphers
Designed according to two principles by Claude Shannon (1949):
- Confusion – Make relationship between plaintext, key, and ciphertext as complex as possible (achieved by substitution/S-boxes).
- Diffusion – Each plaintext bit should affect many ciphertext bits; each key bit should affect many ciphertext bits (achieved by permutation/P-boxes).
Good cipher alternates confusion and diffusion layers many times.
B. Feistel Structure (Basis of DES, Lucifer, Blowfish, etc.)
- Block split into Left (L) and Right (R) halves
- Each round:
Li = Ri-1 Ri = Li-1 ⊕ f(Ri-1, Ki) - f = round function (confusion + diffusion)
Advantages:
- Encryption and decryption almost same (just reverse key order)
- Proven design for many ciphers
C. Data Encryption Standard (DES)
- Block size: 64 bits
- Key size: 56 bits (64 bits with 8 parity bits parity)
- 16 Feistel rounds
- Adopted as US federal standard in 1977
DES Round Structure
IP → 16 rounds → FP (Final Permutation)
Each round:
- Expansion (32→48 bits)
- XOR with 48-bit round key
- 8 S-boxes (6→4 bits each) → 32 bits
- P-box permutation
Strength of DES
- 56-bit key → 2⁵⁶ ≈ 7.2 × 10¹⁶ keys
- 1998: EFF built “Deep Crack” machine – broke DES in <3 days
- Today: DES broken in hours on normal PCs or seconds on cloud GPUs
→ DES is completely insecure today
Differential Cryptanalysis (Biham & Shamir, 1990)
- Chosen-plaintext attack
- Studies how differences in plaintext pairs propagate through rounds
- DES can be broken with 2⁴⁷ chosen plaintexts (theoretical)
- But DES was actually designed to resist it (NSA influence)
Block Cipher Modes of Operation
How to encrypt data longer than one block.
| Mode | Full Name | Features | Use Case |
|---|---|---|---|
| ECB | Electronic Code Book | Each block encrypted independently → identical blocks → identical ciphertext | Not recommended (leaky) |
| CBC | Cipher Block Chaining | XOR with previous ciphertext block + IV | Most common, secure |
| CFB | Cipher Feedback | Turns block cipher into stream cipher | Stream data |
| OFB | Output Feedback | Also stream mode, but no error propagation | Noisy channels |
| CTR | Counter | Parallelizable, turns block cipher into stream, no padding needed | Modern favorite (AES-GCM) |
Triple DES (3DES or TDEA)
Because single DES is weak → run DES three times.
Most secure variant: E-D-E with three different keys (168-bit key)
Ciphertext = EK3(DK2(EK1(Plaintext)))
Effective key length ≈ 112 bits (due to meet-in-the-middle attack).
Still used in banking (EMV, older ATMs), but being replaced by AES.
Summary Table
| Topic | Key Point |
|---|---|
| Classical Substitution | Caesar → Mono → Playfair → Vigenère (best) |
| Classical Transposition | Rail fence, Columnar (rearrange letters) |
| Cryptanalysis | Frequency analysis breaks monoalphabetic easily |
| Stream vs Block | Stream = bit-by-bit, Block = fixed chunks |
| Shannon’s Principles | Confusion + Diffusion |
| Feistel Structure | Basis of DES, reversible encryption/decryption |
| DES | 64-bit block, 56-bit key, 16 rounds – now broken |
| Triple DES | 3×DES with 112–168 bit security – slow but safe |
| Best Mode Today | CBC or CTR (with authentication → GCM) |
These notes + solving 20–30 numerical/handwritten encryption examples of Caesar, Vigenère, Playfair, Rail Fence, and DES round calculations will give you complete mastery of Unit I.
Happy learning!
UNIT I – Introduction to Security and Classical Encryption
Complete Study Notes with Examples, Explanations, and Best Learning Approach
Introduction to Security and Classical Encryption
UNIT I – Introduction to Security and Classical Encryption
Complete Study Notes with Examples, Explanations, and Best Learning Approach
1. Introduction to Security Attacks, Services, and Mechanisms
Security Attacks
Any action that compromises the security of information.
| Type | Description | Example |
|---|---|---|
| Passive Attack | Attacker only observes (does not modify) data. Goal: obtain information. | • Eavesdropping on Wi-Fi • Traffic analysis (who talks to whom) |
| Active Attack | Attacker modifies, deletes, or injects data. | • Masquerade (pretend to be someone else) • Replay attack • Modification of message • Denial of Service (DoS) |
Security Services (CIA + AAA)
| Service | Meaning | Example |
|---|---|---|
| Confidentiality | Data is kept secret from unauthorized parties | Encrypting credit card numbers |
| Integrity | Data cannot be altered undetectably | Digital signatures, hash functions |
| Authentication | Verify the identity of sender/receiver | Password, biometric, certificates |
| Non-repudiation | Sender cannot deny having sent the message | Digital signature with timestamp |
| Access Control | Only authorized users can access resources | File permissions, firewall rules |
| Availability | System/data must be available when needed | Protection against DoS attacks |
Security Mechanisms
Tools/techniques used to provide the above services:
- Encryption / Decryption
- Hash functions
- Digital signatures
- Authentication protocols
- Access control lists
- Firewalls, IDS/IPS
2. Classical Encryption Techniques
A. Substitution Ciphers
Each letter/plaintext symbol is replaced by another letter/ciphertext symbol.
- Caesar Cipher (Shift Cipher)
Key = 3 → A→D, B→E, …, Z→C
Encryption: C = (P + K) mod 26
Decryption: P = (C – K) mod 26
Example
Plaintext : HELLO
Key : 3
Ciphertext: KHOOR
Very weak – only 25 possible keys.
- Monoalphabetic Cipher
Arbitrary fixed substitution (not just shift).
Example mapping:
A→X, B→M, C→T, …, Z→Q
Plaintext : HELLO
Ciphertext: AXEEH (using some random mapping)
Still weak – frequency analysis can break it easily (E is most common in English → appears most in ciphertext).
- Playfair Cipher (Digraph substitution)
- 5×5 grid with I/J combined
- Encrypts two letters at a time
Example Keyword: MONARCHY
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Rules:
- Same row → right shift
- Same column → down shift
- Rectangle → swap columns
Stronger than monoalphabetic but still breakable.
- Polyalphabetic Cipher (Best classical substitution)
Uses multiple substitution alphabets.
Vigenère Cipher
Key repeated to match plaintext length.
Example
Plaintext : WEAREDISCOVEREDRUNATONCE
Key : APPLEAPPLEAPPLEAPPLEAPPL
Ciphertext: CIUIGFKWZVIGBUHXRQEMUWWTP
Much harder to break with frequency analysis because same letter can encrypt differently.
B. Transposition Ciphers
Letters are rearranged (no letter is replaced, only positions change).
- Rail Fence Cipher (Depth = 2 or 3)
Plaintext: MEET ME AFTER THE TOGA PARTY
Write in zigzag:
M . E . T . E . F . E . T . T . G . P . R . Y
. E . M . A . T . R . H . T . O . A . A . T .
Ciphertext: METEFTTGPREY EMA TRHTOAAT
- Columnar Transposition
Plaintext : ATTACK AT DAWN
Key : 3 1 4 2 (means column order 3-1-4-2)
Write row-wise:
3 1 4 2
A T T A
C K A T
D A W N
Read by key order: TADA KWTN TACA → TADAKWTNTACA
Double transposition (repeat twice) makes it much stronger.
C. Cryptanalysis (Code Breaking)
| Attack Type | Works on | Method |
|---|---|---|
| Brute-force | Any cipher with small key space | Try all keys |
| Frequency Analysis | Monoalphabetic substitution | Match letter frequencies |
| Kasiski Examination | Vigenère (polyalphabetic) | Find repeated trigram distance → key length |
| Known-plaintext attack | Any cipher | You have P and C → deduce key |
| Chosen-plaintext attack | Block ciphers | Choose P and get C |
D. Steganography
Hiding the existence of the message (unlike cryptography which hides the meaning).
Examples:
- Invisible ink
- LSB (Least Significant Bit) in image/audio pixels
- Hiding text in whitespace of documents
Cryptography + Steganography = very powerful.
E. Stream vs Block Ciphers
| Feature | Stream Cipher | Block Cipher |
|---|---|---|
| Unit of encryption | 1 bit/byte at a time | Fixed block (64/128/256 bits) |
| Example | ||
| Example | RC4, Salsa20, A5/1 (GSM) | DES, AES, Blowfish |
| Speed | Very fast | Slower (but secure) |
| Error propagation | One bit error affects one bit | One bit error corrupts whole block |
| Usage | Real-time (voice, video) | File/database encryption |
3. Modern Block Ciphers
A. Principles of Modern Block Ciphers
Designed according to two principles by Claude Shannon (1949):
- Confusion – Make relationship between plaintext, key, and ciphertext as complex as possible (achieved by substitution/S-boxes).
- Diffusion – Each plaintext bit should affect many ciphertext bits; each key bit should affect many ciphertext bits (achieved by permutation/P-boxes).
Good cipher alternates confusion and diffusion layers many times.
B. Feistel Structure (Basis of DES, Lucifer, Blowfish, etc.)
- Block split into Left (L) and Right (R) halves
- Each round:
Li = Ri-1 Ri = Li-1 ⊕ f(Ri-1, Ki) - f = round function (confusion + diffusion)
Advantages:
- Encryption and decryption almost same (just reverse key order)
- Proven design for many ciphers
C. Data Encryption Standard (DES)
- Block size: 64 bits
- Key size: 56 bits (64 bits with 8 parity bits parity)
- 16 Feistel rounds
- Adopted as US federal standard in 1977
DES Round Structure
IP → 16 rounds → FP (Final Permutation)
Each round:
- Expansion (32→48 bits)
- XOR with 48-bit round key
- 8 S-boxes (6→4 bits each) → 32 bits
- P-box permutation
Strength of DES
- 56-bit key → 2⁵⁶ ≈ 7.2 × 10¹⁶ keys
- 1998: EFF built “Deep Crack” machine – broke DES in <3 days
- Today: DES broken in hours on normal PCs or seconds on cloud GPUs
→ DES is completely insecure today
Differential Cryptanalysis (Biham & Shamir, 1990)
- Chosen-plaintext attack
- Studies how differences in plaintext pairs propagate through rounds
- DES can be broken with 2⁴⁷ chosen plaintexts (theoretical)
- But DES was actually designed to resist it (NSA influence)
Block Cipher Modes of Operation
How to encrypt data longer than one block.
| Mode | Full Name | Features | Use Case |
|---|---|---|---|
| ECB | Electronic Code Book | Each block encrypted independently → identical blocks → identical ciphertext | Not recommended (leaky) |
| CBC | Cipher Block Chaining | XOR with previous ciphertext block + IV | Most common, secure |
| CFB | Cipher Feedback | Turns block cipher into stream cipher | Stream data |
| OFB | Output Feedback | Also stream mode, but no error propagation | Noisy channels |
| CTR | Counter | Parallelizable, turns block cipher into stream, no padding needed | Modern favorite (AES-GCM) |
Triple DES (3DES or TDEA)
Because single DES is weak → run DES three times.
Most secure variant: E-D-E with three different keys (168-bit key)
Ciphertext = EK3(DK2(EK1(Plaintext)))
Effective key length ≈ 112 bits (due to meet-in-the-middle attack).
Still used in banking (EMV, older ATMs), but being replaced by AES.
Summary Table
| Topic | Key Point |
|---|---|
| Classical Substitution | Caesar → Mono → Playfair → Vigenère (best) |
| Classical Transposition | Rail fence, Columnar (rearrange letters) |
| Cryptanalysis | Frequency analysis breaks monoalphabetic easily |
| Stream vs Block | Stream = bit-by-bit, Block = fixed chunks |
| Shannon’s Principles | Confusion + Diffusion |
| Feistel Structure | Basis of DES, reversible encryption/decryption |
| DES | 64-bit block, 56-bit key, 16 rounds – now broken |
| Triple DES | 3×DES with 112–168 bit security – slow but safe |
| Best Mode Today | CBC or CTR (with authentication → GCM) |
These notes + solving 20–30 numerical/handwritten encryption examples of Caesar, Vigenère, Playfair, Rail Fence, and DES round calculations will give you complete mastery of Unit I.
Happy learning!