KEMBAR78
Cyber Security Unit 3 | PDF | Public Key Cryptography | Key (Cryptography)
0% found this document useful (0 votes)
9 views23 pages

Cyber Security Unit 3

Uploaded by

atmg54204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views23 pages

Cyber Security Unit 3

Uploaded by

atmg54204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Unit 3: Information Security and Cryptography (7 Hrs)

3.1. Cryptography Basics (1 Hr)


Definition:
Cryptography is the practice of securing information by converting it into a form that
unauthorized users cannot understand.
Main Goals:
1. Confidentiality
 Ensures that data is accessible only to authorized users.
 Only the intended person can read the data.
 Achieved using encryption to prevent unauthorized access.
2. Integrity
 Ensures that data is not altered during transmission or storage.
 Techniques like hashing (e.g., SHA-256) detect any changes.
3. Authentication
 Verifies the identity of a user or system.
 Confirms the sender is genuine.
 Achieved using passwords, biometrics, or digital certificates.
4.Non-repudiation – means that a sender cannot deny having sent a message or performed an
action. It ensures proof of origin, so the sender is held accountable.
Example:
In digital signatures, once a message is signed with someone's private key, they cannot
deny sending it, because only they have access to that key.

📝 Summary:
"Confidentiality protects data privacy, integrity ensures data accuracy, and authentication
confirms user identity."
Key Terms:
 Plaintext: The readable message before encryption.
 Ciphertext: The unreadable form after encryption.
 Encryption: The process of converting plaintext to ciphertext.
 Decryption: Changing ciphertext back to plaintext.
 Key: A secret code used for encryption and decryption.

3.2. Classical Encryption/Decryption Methods (1 Hr)

🔐 3.2. Classical Encryption and Decryption Methods


Classical encryption techniques are the oldest methods used to hide messages. These were used
long before computers and are mainly divided into:
➤ 1. Substitution Ciphers
These ciphers replace letters in the message with other letters, numbers, or symbols.

🔸 a) Caesar Cipher (Shift Cipher)


 One of the simplest and most famous encryption techniques.
 Each letter in the message is shifted by a fixed number of positions in the alphabet.
 Named after Julius Caesar, who used it in military communication.
Example (Shift = 3):
Plaintext: HELLO
Alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
After shifting by 3:
H → K, E → H, L → O, O → R
Ciphertext: KHOOR
Decryption: Subtract 3 positions to get the original message.
En(x)= (x+n) mod 26 (Encryption Phase with shift n & alphabet x)
Dn(x)= (x-n) mod 26 (Decryption Phase with shift n & alphabet x)
🟠 Weakness: Very easy to break by trying all possible shifts (only 25 options).
🔸 b) Monoalphabetic Cipher
 Each letter is replaced with another letter, but the mapping stays fixed for the entire
message.
 More secure than Caesar because the replacement is not in a pattern.
Example:
Plaintext: HELLO
Mapping: A → P, B → W, C → E, ..., H → T, E → G, L → M, O → Q
Ciphertext: TGMMQ
🟠 Weakness: Can be cracked using frequency analysis (e.g., 'E' is most common letter in
English).

🔸 c) Polyalphabetic Cipher (e.g., Vigenère Cipher)


 Uses multiple substitution alphabets instead of one.
 The letter replacement depends on a keyword.
How it works:
Let’s use the word "HELLO" as the plaintext and the keyword "KEY" to encrypt it using the
polyalphabetic cipher.

Step 1: Plaintext and Keyword


Plaintext:
HELLO

Keyword:
KEYKE
(The keyword is repeated to match the length of the plaintext.)

Step 2: Convert Letters to Numbers


(A = 0, B = 1, C = 2, ..., Z = 25)

Plaintext H E L L O

Number 7 4 11 11 14
Plaintext H E L L O

Keyword K E Y K E

Number 10 4 24 10 4

Step 3: Encryption Formula


Cipher Letter=(Plaintext Number+Keyword Number)mod 26

Plaintext Number 7 4 11 11 14

Keyword Number 10 4 24 10 4

Sum 17 8 35 21 18

Mod 26 Result 17 8 9 21 18

Cipher Letter R I J V S

Step 4: Cipher Text


Combining the resulting letters, we get:
RIJVS

Decryption Process
Let's decrypt the ciphertext "RIJVS" using the same keyword "KEY".

Step 1: Ciphertext and Keyword


Ciphertext:
RIJVS
Keyword: (repeated to match length)
KEYKE

Step 2: Convert Letters to Numbers


(A = 0, B = 1, ..., Z = 25)

Ciphertext R I J V S

Number 17 8 9 21 18

Keyword K E Y K E

Number 10 4 24 10 4

Step 3: Decryption Formula


Plaintext Letter=(Cipher Number−Keyword Number)mod 26

Cipher Number 17 8 9 21 18

Keyword Number 10 4 24 10 4

Subtraction 7 4 -15 11 14

Mod 26 Result 7 4 11 11 14

Plaintext H E L L O

Note:- The expression:


(9−24) mod 26
This equals:
−15 mod 26
Now, we can't have a negative result in modulo arithmetic (at least not in typical cipher
contexts), so we wrap it around by adding 26 until we get a non-negative number:
−15+26=11
Step 4: Plaintext
Combining the letters, we get:
HELLO
✅ Decryption successful!
The original plaintext "HELLO" is correctly retrieved.

🟢 Stronger than Caesar/Monoalphabetic ciphers.


➤ 2. Transposition Ciphers
These ciphers do not change the letters, but change their positions.

🔸 a) Rail Fence Cipher (Zig-Zag Cipher)


 Write the message in a zig-zag pattern over a number of lines (rails/rows), then read it
row by row.
Example (2 rails/rows):
Plaintext: HELLO WORLD
Write in zig-zag:
Rail 1: H L O O L
Rail 2: E L W R D
Read row by row:
Ciphertext: HLOOLELWRD(without spaces)
 Decryption of the Rail Fence Cipher using the example:
Encrypted text: HLOOLELWRD
Rails used: 2

🔓 Decryption of HLOOLELWRD using 2-Rail Cipher


🔐 Step 1: Understand the Zigzag Pattern
In a 2-rail cipher, characters are written in a zigzag like:
Rail 1: H . . L . . O . .O.. L → characters at even positions
Rail 2: . E . L . W . R . D → characters at odd positions
The pattern alternates:
 Rail 1 (Top): positions → 0, 2, 4, 6, 8
 Rail 2 (Bottom): positions → 1, 3, 5, 7, 9
So we’re reconstructing a message of length 10.

🧮 Step 2: Split the Cipher Text


Given:
Encrypted message: HLOOLELWRD
Length: 10
Rails: 2
Divide characters into rails:
 Top rail= 0 (positions 0,2,4,6,8) → 5 characters → H L O O L
 Bottom rail =1 (positions 1,3,5,7,9) → 5 characters → E L W R D

🔁 Step 3: Rebuild Zigzag


We reconstruct the message by alternating between top and bottom rails in zigzag order:

Index Rail Char

0 0 H

1 1 E

2 0 L

3 1 L

4 0 O

5 1 W

6 0 O

7 1 R

8 0 L

9 1 D

Putting it together:
Decrypted message:
HELLOWORLD
✅ Final Result: "HELLOWORLD" or "HELLO WORLD" if you restore the space.
🟠 Easy to implement, but not very secure.

🔸 b) Columnar Transposition Cipher


 Write the message in rows under column numbers (based on a keyword), then read the
columns in a specific order.
 Here’s the encryption process of "MEET AT DAWN" using the columnar
transposition cipher with the keyword "ZEBRA" presented in a grid format.

 Step 1: Prepare the Plaintext


o Plaintext:
MEET AT DAWN
o (Remove spaces)
MEETATDAWN

 Step 2: Arrange the Keyword in Alphabetical Order


o Keyword:
ZEBRA
o Order:

Z E B R A
5 3 2 4 1

 Step 3: Create the Grid


o Fill the message into rows according to the length of the keyword (5):

Z E B R A
M E E T A
T D A W N

 Step 4: Read Columns According to Keyword Order


o Rearrange the columns based on the keyword order:

A B E R Z
A E E T M
N A D W T
 Step 5: Combine the Columns for the Ciphertext
o Read column by column according to the ordered keyword:
AN EA ED TW MT
o Final ciphertext:
ANEAEDTWMT

 Summary
o The grid-based encryption process ensures that the order of columns matches the
alphabetical order of the keyword.

 Let's decrypt the ciphertext "ANEAEDTWMT" using the columnar transposition


cipher with the keyword "ZEBRA".

 Step 1: Keyword and Column Order


o Keyword:
ZEBRA
 Order of Keyword Alphabetically:

Z E B R A

5 3 2 4 1

 Step 2: Calculate Number of Rows


o length of the ciphertext is 10, and the keyword length is 5.
Number of rows:
Rows=Length of Ciphertext/Length of Keyword=10/5=2

 Step 3: Rearrange Ciphertext into Columns


o Place the ciphertext vertically according to the keyword order:

A B E R Z
A E E T M
N A D W T

 Step 4: Reorder the Columns Based on the Keyword

Z E B R A
M E E T A
Z E B R A
T D A W N

 Step 5: Read Row-Wise to Get Plaintext


o MEETATDAWN
 Add spaces back:
o MEET AT DAWN

 Summary
o The decrypted plaintext is:
o MEET AT DAWN

🔐 Summary Table

Columnar
Caesar Vigenère Rail Fence
Feature Monoalphabetic Cipher Transpositi
Cipher Cipher Cipher
on

Polyalphabe
Substituti Transpositi Transpositio
Cipher Type Substitution tic
on on n
Substitution

Keyword
Single
Substitution alphabet (26-letter Repeating Number of (used for
Key Type integer
mapping) keyword rails column
shift
order)

More
Very
Complexity Moderate secure than Simple Moderate
simple
Caesar

Example QWERTYUIOPASDFGHJKLZX
3 "KEY" 3 rails "ZEBRAS"
Key CVBNM

Write in
Shift each Letter shifts Write in
Pattern of Replace each letter with a fixed grid and
letter by vary based zigzag
Encryption different letter reorder
key on key pattern
columns

Letter Slightly
Preserved Distorted Preserved Preserved
Frequencies masked

Susceptible Yes Yes Less so No No


to
Columnar
Caesar Vigenère Rail Fence
Feature Monoalphabetic Cipher Transpositi
Cipher Cipher Cipher
on

Frequency
Analysis

Reversible Yes (if rail Yes (if


Yes
Without Hard (needs pattern recognition) Hard number keyword
(easily)
Key? known) known)

Used in
Modern
No No No No No
Cryptograp
hy?

✅ Key Takeaways:
 Classical methods are simple and good for basic learning.
 Substitution changes the letters; transposition changes the order.
 These methods are not secure in the modern world.
 But they form the foundation of modern cryptographic techniques.

3.3. Types of Cryptography (RSA, DES, AES) (2 Hrs)


Cryptography is broadly categorized into:
 Symmetric Key Cryptography: Same key for encryption and decryption.
 Asymmetric Key Cryptography: Uses a pair of public and private keys.
 Here is a simple comparison between Symmetric and Asymmetric Cryptography with
examples:

Feature Symmetric Cryptography Asymmetric Cryptography

Number of Uses one key for both Uses two keys – Public key
Keys encryption and decryption and Private key
Feature Symmetric Cryptography Asymmetric Cryptography

Speed Faster Slower

Less secure if the key is


Security More secure – uses two keys
shared

Public key can be shared


Key Sharing Key must be shared secretly
openly

Example AES, DES RSA, ECC

 Simple Example:
o Symmetric: You lock a box with a key and give both the box and the key to your
friend.
o Asymmetric: You lock a box with your friend’s public key. Only your friend can
open it using their private key.
 ✅ Use symmetric for speed, asymmetric for secure key exchange.

1. RSA (Asymmetric)
 Developed by Rivest, Shamir, and Adleman.
 Uses two keys: public and private.
 Public Key: Shared with everyone.
 Private Key: Kept secret by the owner.
 Used for secure communication and digital signatures.
 Slower but more secure than symmetric methods.
RSA Algorithm
RSA Algorithm is based on factorization of large number and modular arithmetic for encrypting
and decrypting data. It consists of three main stages:
1. Key Generation: Creating Public and Private Keys
2. Encryption: Sender encrypts the data using Public Key to get cipher text.
3. Decryption: Decrypting the cipher text using Private Key to get the original data.

RSA Implementation (Simple Explanation with Example)


RSA (Rivest–Shamir–Adleman) is a type of asymmetric cryptography. It uses two keys:
 Public Key (for encryption)
 Private Key (for decryption)

Steps to Implement RSA (Simple Concept)


1. Choose two prime numbers
Example: p = 3, q = 11
2. Calculate n
n = p × q = 3 × 11 = 33
3. Calculate ϕ(n)
ϕ(n) = (p − 1) × (q − 1) = 2 × 10 = 20
4. Choose a public key (e),1 < e < Φ(n)
e must be coprime with ϕ(n) and less than ϕ(n),gcd(e, Φ(n)) = 1
Let’s choose e = 7
5. Calculate the private key (d)
Find d such that:
(d × e) mod ϕ(n) = 1
(d × 7) mod 20 = 1 → d = 3

✅ Method 1: Trial & Error


Try multiplying 7 by different values:

d 7×d 7 × d mod 20

1 7 7

2 14 14

3 21 1✅

Keys:
 Public Key = (e = 7, n = 33)
 Private Key = (d = 3, n = 33)
Encryption Example:
Let’s encrypt message M = 2
Formula: C = M^e mod n
C = 2^7 mod 33 = 128 mod 33 = 29
🔒 Encrypted message = 29

Decryption Example:
Now decrypt C = 29
Formula: M = C^d mod n
M = 29^3 mod 33 = 24389 mod 33 = 2
🔓 Original message = 2

✅ RSA ensures secure communication using two keys.

2. DES (Symmetric)
 Data Encryption Standard.
 Here are the key points of DES (Data Encryption Standard) cryptography, explained
in a simple and clear way:

🔐 DES Cryptography – Key Points (Simplified)

 Key Point  Explanation

 Symmetric-key algorithm (same key used for encryption and


 Type
decryption)

 Block size  Works on 64-bit blocks of data at a time

 Uses a 56-bit key (plus 8 parity bits = 64 bits total, but only 56
 Key size
used)

 Rounds  DES performs 16 rounds of complex operations

 Based on Feistel Network (splits data into two halves and


 Structure
processes them)
 Key Point  Explanation

 Encryption
 Uses permutation, substitution, XOR, and bit shifting
process

 Decryption
 Same as encryption but with keys applied in reverse order
process

 Fast in hardware, slower in software. DES runs significantly


 Speed slower in software(general purpose processors) than in
dedicated/specialized hardware chips.

 Considered insecure today due to small key size (can be brute-


 Security
forced)

 Replaced by  Modern systems use AES instead of DES for better security

🔐 DES Encryption Algorithm – Step-by-Step Overview


🧩 Overview:
 Input: 64-bit plaintext and 64-bit key (only 56 bits used)
 Output: 64-bit ciphertext
 Process: 16 rounds of transformation using keys

🧭 SEQUENCE (Left to Right and Top to Bottom):

🔹 1. Initial Permutation (IP)


 The 64-bit plaintext is shuffled using a fixed Initial Permutation table.
 Purpose: No encryption, just rearrangement for diffusion.
📌 Example:
Plaintext = 011001... → IP = 110100...

🔹 2. Split the 64-bit block


 After IP, split into two 32-bit halves:
o Left Half (L0)
o Right Half (R0)
These halves will go through 16 rounds of encryption.

🔹 3. Key Generation (on the right side)


From the 64-bit key:
🧷 a. Permuted Choice 1 (PC-1)
 The 64-bit key is reduced to 56 bits by discarding every 8th bit (used for parity).
🔄 b. Left Circular Shifts
 The 56-bit key is split into two 28-bit halves.
 Each half is shifted left for every round (1 or 2 bit shifts depending on round).
🧮 c. Permuted Choice 2 (PC-2)
 48 bits are selected from the shifted halves to form a round key (K1 to K16).
✅ Now we have 16 different 48-bit keys — one for each round.
🔹 4. 16 Rounds of Encryption (Feistel rounds)
For each round (1 to 16):
1. Input: 64-bit block → L and R (32 bits each)
2. Use round key K1 to K16
3. Perform Feistel Function:
o Expand R from 32 → 48 bits
o XOR with round key
o Apply S-boxes → back to 32 bits
o Permute result
o XOR with L to get new R
o R becomes new L
📌 Feistel Structure ensures same logic can be used for decryption.

🔹 5. After Round 16 – Swap Halves


 The output of round 16 is swapped:
Final L16 and R16 are exchanged before the final step.

🔹 6. Inverse Initial Permutation (IP⁻¹)


 This is the reverse of the Initial Permutation done in step 1.
 It rearranges the 64 bits back to original positions (not original data, but same bit order as
initial).

🎯 Final Output: 64-bit Ciphertext


 This is your encrypted data ready to be transmitted securely.

📌 In Summary (Surface-Level Steps):

Step What Happens Purpose

1️ Initial Permutation (IP) Shuffle plaintext bits


Step What Happens Purpose

2️ Key → PC-1 → shift → PC-2 Generate 16 round keys

3️ Split into L and R Prep for rounds

4️ 16 Rounds (Feistel Function) Apply complex encryption steps

5️ 32-bit Swap Swap L and R

6️ Inverse Permutation (IP⁻¹) Rearrange to final ciphertext

🎉 Output: 64-bit ciphertext Encrypted message

🧠 Simple Concept
 DES takes 64 bits of plain text and encrypts it into 64 bits of ciphertext using a 56-bit
secret key.
 The data is processed in 16 rounds of operations to make it unreadable.
 The same key must be used to decrypt the data back into the original message.

 🔑 Real-Life Analogy
 Think of DES like a lockbox:
 You put a message in (plaintext),
 Lock it using a combination lock (the DES algorithm with a key),
 Only someone with the same combination (key) can unlock it and read the message.

3. AES (Symmetric)
📌 1. What is AES?
 AES stands for Advanced Encryption Standard.
 It is a symmetric key encryption algorithm (same key for encryption & decryption).
 Developed as a replacement for the older DES algorithm.
📌 2. Key Sizes
 AES supports 3 key sizes:
o 128 bits
o 192 bits
o 256 bits
 More bits = stronger security.
📌 3. Block Size
 AES works on blocks of 128 bits (16 bytes).
📌 4. Number of Rounds
 AES performs multiple rounds of encryption:
o 10 rounds for 128-bit key
o 12 rounds for 192-bit key
o 14 rounds for 256-bit key
📌 5. AES Encryption Process (Main Steps)
Each round (except the last one) includes:
1. SubBytes – Replace bytes using an S-box (substitution).
2. ShiftRows – Rows of the block are shifted.
3. MixColumns – Columns are mixed (like scrambling data).
4. AddRoundKey – XOR with a round key.
➡️Final round does not include MixColumns.
📌 6. Why is AES Secure?
 Uses complex mathematical transformations.
 Difficult to break without knowing the key.
 Resistant to all known practical attacks.
📌 7. Applications of AES
 Used in:
o Secure websites (HTTPS)
o Wi-Fi security (WPA2)
o File encryption tools (e.g., BitLocker, VeraCrypt)
o Mobile apps & banking
📌 8. Advantages of AES
 Fast and efficient in both software & hardware.
 Strong security with longer key lengths.
 Widely accepted and standardized (by NIST).

📚 Quick Revision Tip:


"AES is a block cipher using symmetric key encryption with 128-bit blocks and key sizes of
128, 192, or 256 bits. It replaces DES and is secure, fast, and widely used."

3.4. Asymmetric Key Cryptography (1 Hr)


 Also known as Public Key Cryptography.
 Uses two different keys:
o Public Key: Used to encrypt data.
o Private Key: Used to decrypt data.
Key Features:
 Solves the key distribution problem. Asymmetric key cryptography solves the key
distribution problem by using a pair of keys: a public key for encryption and a private key
for decryption. Since the public key can be shared openly, there is no need to securely
transmit a secret key between parties.
 Used in:
o Digital signatures
o Secure email
o Online banking (HTTPS)
o Blockchain and cryptocurrencies
Blockchain is like a digital notebook that everyone can see and no one can easily
change.
Example: It's like writing in a notebook that everyone trusts and can check
anytime.
Cryptocurrency is digital money you can send or receive using the blockchain.
Example: Bitcoin is like internet cash you can use without a bank.

Examples:
 RSA, ECC (Elliptic Curve Cryptography)
Advantages:
 More secure for communication.
 No need to share secret keys in advance.
Disadvantages:
 Slower compared to symmetric encryption.

3.5. Digital Signature (1 Hr)


Definition:
 A digital code attached to a message to verify:
o The identity of the sender.
o The message has not been altered.
How it Works:
1. Sender creates a hash of the message (using hashing algorithms like SHA).
2. The hash is encrypted with sender’s private key to create the digital signature.
3. Receiver:
o Decrypts the signature with sender’s public key.
o Hashes the received message again.
o Compares the two hashes. If they match, message is authentic.
Applications:
 E-mails
 Software distribution
 Legal documents
Benefits:
 Provides authentication, integrity, and non-repudiation.

Summary Table:

Topic Key Focus Examples

Secure data, confidentiality,


Cryptography Basics Plaintext, Ciphertext
keys

Classical Methods Simple encryption techniques Caesar, Substitution

RSA (public), AES (secure), DES


RSA / DES / AES Modern encryption
(obsolete)

Asymmetric Two-key encryption RSA, ECC


Topic Key Focus Examples

Cryptography

Digital Signature Verify sender and message Used in e-Governance, emails

You might also like