Loading...
Development

Module 132

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.

TypeDescriptionExample
Passive AttackAttacker only observes (does not modify) data. Goal: obtain information.• Eavesdropping on Wi-Fi
• Traffic analysis (who talks to whom)
Active AttackAttacker modifies, deletes, or injects data.• Masquerade (pretend to be someone else)
• Replay attack
• Modification of message
• Denial of Service (DoS)

Security Services (CIA + AAA)

ServiceMeaningExample
ConfidentialityData is kept secret from unauthorized partiesEncrypting credit card numbers
IntegrityData cannot be altered undetectablyDigital signatures, hash functions
AuthenticationVerify the identity of sender/receiverPassword, biometric, certificates
Non-repudiationSender cannot deny having sent the messageDigital signature with timestamp
Access ControlOnly authorized users can access resourcesFile permissions, firewall rules
AvailabilitySystem/data must be available when neededProtection 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.

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

  2. 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).

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

  4. 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).

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

  2. 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 TypeWorks onMethod
Brute-forceAny cipher with small key spaceTry all keys
Frequency AnalysisMonoalphabetic substitutionMatch letter frequencies
Kasiski ExaminationVigenère (polyalphabetic)Find repeated trigram distance → key length
Known-plaintext attackAny cipherYou have P and C → deduce key
Chosen-plaintext attackBlock ciphersChoose 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

FeatureStream CipherBlock Cipher
Unit of encryption1 bit/byte at a timeFixed block (64/128/256 bits)
Example
ExampleRC4, Salsa20, A5/1 (GSM)DES, AES, Blowfish
SpeedVery fastSlower (but secure)
Error propagationOne bit error affects one bitOne bit error corrupts whole block
UsageReal-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):

  1. Confusion – Make relationship between plaintext, key, and ciphertext as complex as possible (achieved by substitution/S-boxes).
  2. 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.

ModeFull NameFeaturesUse Case
ECBElectronic Code BookEach block encrypted independently → identical blocks → identical ciphertextNot recommended (leaky)
CBCCipher Block ChainingXOR with previous ciphertext block + IVMost common, secure
CFBCipher FeedbackTurns block cipher into stream cipherStream data
OFBOutput FeedbackAlso stream mode, but no error propagationNoisy channels
CTRCounterParallelizable, turns block cipher into stream, no padding neededModern 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

TopicKey Point
Classical SubstitutionCaesar → Mono → Playfair → Vigenère (best)
Classical TranspositionRail fence, Columnar (rearrange letters)
CryptanalysisFrequency analysis breaks monoalphabetic easily
Stream vs BlockStream = bit-by-bit, Block = fixed chunks
Shannon’s PrinciplesConfusion + Diffusion
Feistel StructureBasis of DES, reversible encryption/decryption
DES64-bit block, 56-bit key, 16 rounds – now broken
Triple DES3×DES with 112–168 bit security – slow but safe
Best Mode TodayCBC 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!