Encryption, Decryption, and Overview of Symmetric Key Cryptography
Overview: If two offices share one secret key, each can encrypt and decrypt messages with that secret.
What are Encryption and Decryption?
- In modern computer networks, data travels across public wires, Wi-Fi routers, and internet service providers.
- 1. Definition: Process of converting readable Plain Text into unreadable Cipher Text
- 2. Performed By: Performed by the Sender before sending data over the network
- 3. Purpose: To hide secret information from unauthorized hackers
- 4. Input & Output: Input: Plain Text + Key → Output: Cipher Text
- 5. Formula: C = EK(P)
View diagram · The Encryption and Decryption Process
Overview of Symmetric Key Cryptography
- Symmetric Key Cryptography (also called Secret-Key, Single-Key, or Private-Key Cryptography) is an encryption method where **the…
- Imagine a wooden treasure box with a padlock.
-
-
-
- That is Symmetric Key Cryptography.
Five Essential Ingredients of Symmetric Encryption
- A symmetric encryption scheme has 5 core components:
- Plain Text (P): The original intelligible message or data fed into the algorithm.
- Encryption Algorithm (E): Performs various substitutions and transformations on the plain text.
- Secret Key (K): A value independent of the plain text and algorithm.
- Cipher Text (C): The scrambled message produced as output.
- Decryption Algorithm (D): The Encryption algorithm run in reverse using the same Secret Key (K) to produce the original Plain Text.
Types of Symmetric Key Ciphers: Stream vs. Block Ciphers
- All modern Symmetric Key Algorithms are divided into two categories based on how they process data:
View diagram · Two Types of Symmetric Ciphers
Advantages and Limitations of Symmetric Key Cryptography
- ✅ Advantages: Extremely Fast: Symmetric algorithms use simple bitwise operations (XOR, shifts, table lookups), making them 100 to 1000 times faster…
- Ideal for Bulk Data: Can easily encrypt huge files, 4K movies, and entire 1TB hard drives without slowing down the computer.
- Low CPU & Battery Usage: Requires very little processing power.
- ❌ Limitations (Disadvantages): The Key Distribution Problem: Before Rahul and Priya can communicate, how does Rahul safely send the secret key to Priya?
- The N(N-1)/2 Key Explosion Problem: In a company with N employees where everyone wants to communicate privately with everyone else, each pair needs a unique…
- Formula: Total Keys Required = (N(N - 1)) / (2)
- No Non-Repudiation: Since both sender and receiver have the exact same key, the receiver could create a fake message and claim the sender sent…
Data Encryption Standard (DES)
Overview: DES has a 64-bit block but only 56 effective key bits.
What is DES?
- The Data Encryption Standard (DES) is one of the most famous Symmetric Block Ciphers in the history of computer security.
Key Facts About DES (Must Memorize for Exams!)
- Whenever a question on DES appears in your exam, write these 5 golden numbers in your first paragraph:
- Block Size: 64 Bits Takes 64 bits of Plain Text and outputs 64 bits of Cipher Text
- Key Size: 56 Bits Input key is 64 bits, but 8 bits are parity bits = 56-bit effective key
- Rounds: 16 Rounds Runs 16 identical Feistel rounds using 16 48-bit subkeys
- S-Boxes: 8 S-Boxes Each S-Box shrinks 6 bits into 4 bits (48 bits ➔ 32 bits)
- Why is the DES Key 56 bits instead of 64 bits?: The user provides a 64-bit key (8 bytes).
- However, every 8th bit (bits 8, 16, 24, 32, 40, 48, 56, 64 — total 8 bits) is used only for error checking (parity) and is…
- Therefore, the actual secret key length of DES is 64 - 8 = 56 bits.
View diagram · DES Algorithm Specifications at a Glance
Overall Structure of DES (Step-by-Step Working)
- DES is built on a mathematical design called the Feistel Cipher Structure, which mixes Substitution and Transposition (Permutation)…
- 64-Bit Plain Text Block Raw 64-bit input block
- 16 Identical Feistel Rounds Each Round (1 to 16) uses a unique 48-bit Subkey (K1 to K16)
- 32-Bit Swap Left (L16) and Right (R16) halves are swapped after Round 16
- Final Permutation (IP⁻¹) Inverse Initial Permutation produces 64-Bit Cipher Text
- How a Single Round of DES Works (The Feistel Round): After the Initial Permutation (IP), the 64-bit block is split into two equal 32-bit halves:
- Left Half (Li-1) 32 bits
- Right Half (Ri-1) 32 bits
View diagram · Step-by-Step Architecture of DES Encryption
Inside the DES Round Function F(R, K)
- What happens inside the Round Function F during each of the 16 rounds?
- Expansion Permutation (E-Box) [32 bits → 48 bits]:
- Key Mixing (XOR with 48-bit Subkey):
- Substitution via 8 S-Boxes [48 bits → 32 bits]:
- The 48-bit result is divided into eight 6-bit chunks.
- Each 6-bit chunk enters its own S-Box (S1, S2, …, S8).
- Each S-Box converts a 6-bit input into a 4-bit output (8 × 4 = 32 bits).
- Note: The S-Boxes are the heart of DES security because they provide non-linear confusion!
How DES Decryption Works
- Because DES uses the Feistel Structure, you do NOT need a separate circuit for decryption!
- Decryption uses the exact same algorithm and steps as Encryption.
- The only difference is that the 16 subkeys are applied in reverse order (K16, K15, …, K1).
The Avalanche Effect & Weakness of DES
- What is the Avalanche Effect?: A desirable property of any strong encryption algorithm where changing just 1 single bit in the Plain Text (or Key) causes…
- Why did DES become insecure? (56-Bit Key Weakness): A 56-bit key means there are 2^56 ≈ 7.2 × 10^16 possible keys.
- In 1977, that seemed huge.
Double DES and Triple DES (3DES)
- To extend the life of DES without replacing bank hardware, Triple DES (3DES) was introduced:
- Double DES (2DES): Encrypts twice with two keys (56 × 2 = 112 bits), but fails due to a clever attack called the Meet-in-the-Middle Attack.
- Triple DES (3DES): Applies the DES algorithm three times to each data block (Encrypt → Decrypt → Encrypt, or EDE mode) using 2 or 3…
- Ultimately, both DES and 3DES were replaced by the much faster and stronger AES (Advanced Encryption Standard).
Symmetric Key Algorithms and AES (Advanced Encryption Standard)
Overview: AES always processes blocks of 128 bits.
What is AES?
- When DES became too weak due to its small 56-bit key and Triple DES (3DES) proved too slow in software, the US National Institute of…
- 💡 Real-Life Relevance:
- Today, AES is the #1 most widely used symmetric encryption algorithm on Earth.
Key Specifications of AES
- Unlike DES (which uses a Feistel structure), AES is a Substitution-Permutation Network (SPN) that operates on a 128-bit block (16 bytes)…
- AES-128: 128 bits (16 bytes)
- AES-192: 128 bits (16 bytes)
- AES-256: 128 bits (16 bytes)
The 4 × 4 Byte “State Matrix”
- AES takes 128 bits of Plain Text (which equals 128 ÷ 8 = 16 bytes: b0, b1, …, b15) and places them column by column into a **4 × 4 square…
View diagram · The 4 × 4 Byte "State Matrix"
The 4 Operations Inside Each AES Round
- Before Round 1 starts, AES performs an initial AddRoundKey step (XORing the State Matrix with Key K0).
- 1. SubBytes (Substitute Bytes — Non-Linear Substitution): Each of the 16 bytes in the 4 × 4 State Matrix is independently replaced by looking it up in a fixed 16 × 16 lookup table called the **AES…
- For example, if a byte is
53(in hex), the S-Box looks up Row5, Column3and replaces it withED. - Purpose: Provides Confusion (hides the relationship between the Plain Text and Cipher Text).
- 2. ShiftRows (Row Permutation): The rows of the 4 × 4 State Matrix are cyclically shifted to the Left:
- Row 0 (1st row): Not shifted at all (0 bytes shift).
- Row 1 (2nd row): Shifted left by 1 byte.
- Row 2 (3rd row): Shifted left by 2 bytes.
View diagram · The 4 Transformations Inside an AES Round
Comparison: DES vs. AES (100% Exam Favorite!)
- This comparison table is one of the most frequently asked questions in DAVV BCA Unit 2:
- 1. Year Adopted: 1977 (Developed by IBM)
- 2. Block Size: 64 bits (8 bytes)
- 3. Key Length: 56 bits (effective key from 64-bit input)
- 4. Design Structure: Feistel Cipher Structure (splits block into Left & Right halves)
- 5. Number of Rounds: 16 Rounds (fixed)
- 6. Round Operations: Expansion, Key XOR, 8 S-Boxes, P-Box
Brief History and Overview of Asymmetric Key Cryptography
Overview: To send a private message to Meera, use Meera’s authenticated public encryption key.
What is Asymmetric Key Cryptography?
- In Symmetric Key Cryptography (like DES and AES), both the sender and receiver must share the exact same secret key.
- A Public Key (PU): Shared openly with the entire world (like your email address or UPI ID).
- A Private Key (PR): Kept 100% secret by the owner and never shared with anyone (like your ATM PIN).
- 💡 The Golden Rule of Asymmetric Cryptography:
- Anything locked (encrypted) with a person’s Public Key can ONLY be unlocked (decrypted) by that same person’s Private Key—not…
Brief History of Asymmetric Key Cryptography
- For over 2,000 years (from Julius Caesar’s time until the mid-1970s), every single encryption system in human history was Symmetric.
- The Historic Breakthrough Timeline: Public-key methods let participants publish one key and protect its partner.
- GCHQ (Classified British Intelligence) James Ellis, Clifford Cocks & Malcolm Williamson secretly conceived non-secret encryption (kept classified until 1997)
- Diffie-Hellman Revolution (“New Directions in Cryptography”) Whitfield Diffie & Martin Hellman (with Ralph Merkle) publicly invented Public-Key Cryptography & Key Exchange
- Invention of RSA Algorithm at MIT Ron Rivest, Adi Shamir & Leonard Adleman created the first practical Public-Key encryption & digital signature system
- Elliptic Curve Cryptography (ECC) & Modern Web Neal Koblitz & Victor Miller introduced ECC, enabling fast public-key security on smartphones and HTTPS
- The Diffie-Hellman Breakthrough (1976):
- The RSA Invention (1977):
View diagram · Evolution of Asymmetric (Public-Key) Cryptography
Overview: How Asymmetric Key Cryptography Works
- Suppose Rahul (Sender) wants to send a confidential message to Priya (Receiver):
- Anyone on the street can drop a letter into the slot (Encrypt with Priya’s Public Key).
- Once the letter drops inside, nobody on the street can reach in and steal it.
- Only Priya, who holds the Private Key to the postbox door, can open the box and read the letters!
View diagram · Asymmetric Encryption Workflow (Confidentiality)
Two Modes of Asymmetric Cryptography
- Asymmetric cryptography can be used in two different ways depending on which key is used first:
- 1. Confidentiality Mode (Encryption): Receiver’s Public Key (PUreceiver)
- 2. Authentication Mode (Digital Signature): Sender’s Private Key (PRsender)
Comparison: Symmetric vs. Asymmetric Key Cryptography
- This comparison table is a guaranteed question in DAVV BCA Cyber Security exams:
- 1. Number of Keys: Uses 1 single shared key
- 2. Key Used for Encryption & Decryption: Same key is used for both Encryption and Decryption
- 3. Key Sharing: Secret key must be shared privately (risky over internet)
- 4. Number of Keys for N Users: Requires (N(N-1) / 2) keys (scales poorly)
- 5. Speed & Performance: Very Fast (uses simple bitwise XOR/substitutions)
- 6. Best Used For: Encrypting large volumes of data (files, databases, streaming)
RSA Algorithm: Working and Solved Numerical Example
Overview: For a small classroom example take p = 3 and q = 11, giving n = 33 and φ(n) = 20.
What is the RSA Algorithm?
- The RSA Algorithm is the world’s most famous and widely used Asymmetric (Public-Key) Cryptographic Algorithm.
- R Ron Rivest
- S Adi Shamir
- A Leonard Adleman
- What Makes RSA Secure? (The Prime Factorization Problem): RSA’s security is based on a simple mathematical fact:
- It is very easy for a computer to multiply two large prime numbers together (p × q = n).
- However, if someone gives you only the huge product n (say, a 600-digit number / 2048 bits), it is practically impossible even for…
The 3 Phases of the RSA Algorithm
- The RSA Algorithm consists of three main phases:
- Key Generation (Creating the Public Key and Private Key)
- Encryption (Locking the message M into Cipher Text C)
- Decryption (Unlocking the Cipher Text C back into message M)
- Choose Two Distinct Prime Numbers (p and q) Keep p and q secret (e.g., p = 3, q = 11)
- Calculate Modulus n = p × q n is used in both Public and Private keys
- Calculate Euler’s Totient φ(n) = (p − 1) × (q − 1) Keep φ(n) strictly secret
- Choose Public Exponent e 1 < e < φ(n) such that gcd(e, φ(n)) = 1 (co-prime)
View diagram · Complete 5-Step RSA Key Generation & Encryption Flow
Mathematical Formulas of RSA (Must Write in Exams!)
- Phase A: Key Generation Steps: Select two large, distinct prime numbers p and q (p ≠ q).
- Calculate the system modulus n:
- Formula: n = p × q
- Calculate Euler’s Totient Function φ(n):
- Formula: φ(n) = (p - 1) × (q - 1)
- Choose an integer e (the Public Key exponent) such that:
- 1 < e < φ(n)
- \gcd(e, φ(n)) = 1 (meaning e and φ(n) share no common factor other than 1).
📝 Solved Numerical Example 1 (Easy Exam Example)
- Question: Perform encryption and decryption using the RSA Algorithm for the following values:
- Prime numbers: p = 3, q = 11
- Public key exponent: e = 7
- Plain Text message: M = 2
- Step 1: Given Prime Numbers: Formula: p = 3, q = 11
- Step 2: Calculate n = p × q: Formula: n = 3 × 11 = 33
- Step 3: Calculate φ(n) = (p - 1) × (q - 1): Formula: φ(n) = (3 - 1) × (11 - 1) = 2 × 10 = 20
- Step 4: Verify Public Key Exponent e: Given e = 7.
📝 Solved Numerical Example 2 (Practice Question)
- Question: In an RSA system, p = 5, q = 11, e = 3, and Plain Text M = 9.
- n = p × q = 5 × 11 = 55
- φ(n) = (5 - 1)(11 - 1) = 4 × 10 = 40
- Given e = 3.
- Try d = 27: 27 × 3 = 81, and 81 mod 40 = 1 ✅.
- Public Key: {3, 55}, Private Key: {27, 55}.
- Encryption (M = 9):
- Formula: C = M^e mod n = 9^3 mod 55 = 729 mod 55 = 14