0% found this document useful (0 votes)
10 views29 pages

Honor Htcs501

The document outlines the importance of cybersecurity, emphasizing the need for confidentiality, integrity, and availability of data. It discusses various security approaches, principles, types of attacks, and encryption techniques, including symmetric and asymmetric cryptography. Additionally, it highlights the significance of key size and management in resisting attacks and ensuring secure communications.

Uploaded by

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

Honor Htcs501

The document outlines the importance of cybersecurity, emphasizing the need for confidentiality, integrity, and availability of data. It discusses various security approaches, principles, types of attacks, and encryption techniques, including symmetric and asymmetric cryptography. Additionally, it highlights the significance of key size and management in resisting attacks and ensuring secure communications.

Uploaded by

shivani.248206
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit -01

Data Encryption and Compression (HTCS501)

(i) Introduction to Security- Need for security

Here are the main reasons why security is needed in cyber security:

1. Protection of Confidentiality

 Prevents unauthorized access to sensitive information (personal data, trade secrets, medical records,
financial details).
 Protects individuals’ privacy and organizations’ competitive advantage.

2. Ensuring Integrity

 Prevents tampering, modification, or corruption of data.


 Ensures that information remains accurate, reliable, and trustworthy.

3. Maintaining Availability

 Ensures that systems, applications, and data are accessible to authorized users when needed.
 Protects against denial-of-service (DoS) and ransomware attacks that disrupt services.

4. Preventing Financial Loss

 Cybercrime (fraud, phishing, ransomware, identity theft) can cause huge monetary damages.
 Security reduces the risk of business disruptions and costly breaches.

5. Safeguarding Reputation and Trust

 A single breach can damage the reputation of a business or institution.


 Strong security builds customer trust and brand credibility.

6. Legal and Regulatory Compliance

 Organizations must comply with laws like GDPR, HIPAA, or PCI DSS to protect customer data.
 Non-compliance can result in fines and penalties.

7. National Security and Critical Infrastructure Protection

 Cybersecurity protects military systems, power grids, healthcare, transportation, and other vital services.
 Prevents cyber warfare, espionage, and terrorism.

8. Adapting to Evolving Threats

 Hackers constantly develop new methods (malware, social engineering, AI-powered attacks).
 Continuous security is needed to keep pace with emerging risks.

 In short: Cybersecurity is essential to protect people, organizations, and nations from digital
threats, ensuring confidentiality, integrity, and availability of systems and data.
(i) Security approaches

Here are the main security approaches:

1. Preventive Approach

 Focus: Stopping attacks before they happen.


 Methods:
o Firewalls, intrusion prevention systems (IPS)
o Strong authentication & access control
o Encryption of sensitive data
o Security policies & awareness training
2. Detective Approach

 Focus: Identifying threats or breaches when they occur.


 Methods:
o Intrusion detection systems (IDS)
o Security Information and Event Management (SIEM)
o Log monitoring & audits
o Honeypots and deception technologies
3. Corrective Approach

 Focus: Responding to and fixing issues after an attack.


 Methods:
o Incident response plans
o Backup & recovery systems
o Applying security patches & updates
o Forensic analysis to find root cause

4. Deterrent Approach

 Focus: Discouraging attackers from targeting the system.


 Methods:
o Legal actions & penalties
o Security warnings and banners
o Visible monitoring systems (e.g., surveillance, intrusion alarms)

5. Compensatory Approach

 Focus: Adding extra controls when the primary ones are not sufficient.
 Methods:
o Redundant firewalls or servers
o Multi-factor authentication (MFA)
o Additional security policies or manual checks

(ii) Principles of security

Here are the main principles of security:

1. Confidentiality
 Ensures that information is only accessible to authorized users.
 Prevents unauthorized disclosure of sensitive data.
 Methods: Encryption, access controls, authentication.

2. Integrity

 Ensures that data is accurate, consistent, and not altered without authorization.
 Protects against tampering, modification, or corruption.
 Methods: Hashing, digital signatures, checksums.

3. Availability

 Ensures that data, applications, and systems are accessible when needed.
 Protects against downtime and denial-of-service (DoS) attacks.
 Methods: Redundancy, backups, disaster recovery, load balancing.

(iii) Types of attacks.

1. Passive Attacks

Attacker only monitors or eavesdrops on data transmission but does not alter it.

 Goal: To gain information without detection.


 Characteristics: Hard to detect (since no data is modified), but can be prevented with encryption.

Examples of Passive Attacks:

1. Eavesdropping / Traffic Monitoring – Listening to network traffic to capture sensitive info like
passwords.
2. Traffic Analysis – Studying communication patterns (who is talking to whom, frequency, and duration)
to gather intelligence.

2. Active Attacks

Attacker modifies, disrupts, or damages data or system resources.

 Goal: To alter, destroy, or disrupt communication or operations.


 Characteristics: Easier to detect than passive attacks, but more harmful.

Examples of Active Attacks:

1. Masquerade Attack – Attacker pretends to be an authorized user.


2. Replay Attack – Captured data (like login details) is retransmitted to gain unauthorized access.
3. Modification of Messages – Changing data packets during transmission.
4. Denial of Service (DoS/DDoS) – Flooding a network/system to make it unavailable.

In short:

 Passive Attack = “Listening secretly” (stealing info, no change).


 Active Attack = “Attacking directly” (altering or disrupting data/services).
(V) Encryption Techniques: Plaintext Cipher text

Cryptography Terminology

1. Plaintext

 The original readable message or data before encryption.


 Example: HELLO123.

2. Ciphertext

 The scrambled, unreadable message after encryption.


 Example: XQFZL98@!.

3. Encryption

 The process of converting plaintext into ciphertext using an algorithm + key.


 Formula:

C=EK(P)C = E_K(P)C=EK​(P)

Where PPP=Plaintext, CCC=Ciphertext, KKK=Key.

4. Decryption

 The process of converting ciphertext back to plaintext using a decryption algorithm + key.
 Formula:

P=DK(C)P = D_K(C)P=DK​(C)

5. Key

 A piece of information used in encryption/decryption.


 Two main types:
o Symmetric Key – same key for encryption & decryption.
o Asymmetric Key – uses public key (for encryption) and private key (for decryption).

6. Cipher

 The algorithm used to perform encryption and decryption.


 Types:
o Classical Ciphers: Caesar cipher, Vigenère cipher.
o Modern Ciphers: AES, RSA.

7. Cryptanalysis

 The study of analyzing cryptographic systems to break ciphers or recover plaintext without knowing
the key.
 Example: Brute force attack, frequency analysis.
8. Digital Signature

 A cryptographic technique that ensures authenticity, integrity, and non-repudiation of data.


 Example: Used in emails, financial transactions.

9. Hash Function

 A one-way function that converts data into a fixed-size string (hash).


 Properties: Irreversible, unique, fast.
 Example: SHA-256, MD5.

10. Public Key Infrastructure (PKI)

 A framework for managing digital certificates and public/private keys.


 Example: SSL/TLS certificates for websites.

11. Steganography

 Hiding messages inside other data (like an image, audio, or video).


 Example: A secret text hidden inside a picture.

Summary:
In cryptography:

 Plaintext → (Encryption + Key) → Ciphertext


 Ciphertext → (Decryption + Key) → Plaintext
using Ciphers, Keys, and Algorithms, with support from concepts like Hashing, Digital Signatures,
and PKI for security.

(VI) Difference Between Substitution and Transposition Techniques

Feature Substitution Technique Transposition Technique


Replaces each character (or group of characters) Rearranges (shuffles) the positions of
Definition in plaintext with another character/symbol characters in plaintext without changing the
according to a rule. actual characters.
Letters are substituted with other letters, numbers, The order of plaintext letters is changed
How it Works
or symbols. (permutation).
Effect on
Characters are modified. Characters are not modified, only reordered.
Characters
Caesar Cipher: HELLO → KHOOR (shift each Rail Fence Cipher: HELLO → HLOEL
Example
letter by 3). (letters rearranged).
Easier to break using frequency analysis (since Harder to break by frequency analysis, but
Security Level
letter patterns remain). vulnerable to pattern analysis.
Monoalphabetic (one-to-one mapping),
Rail Fence Cipher, Columnar Transposition,
Types Polyalphabetic (multiple mappings, e.g.,
Route Cipher.
Vigenère).
Focus Focuses on substitution of symbols. Focuses on permutation of positions.
In short:

 Substitution = Change the letters (A → D, B → E, etc.)


 Transposition = Change the order of letters (HELLO → HLOEL).
(VII) Encryption & Decryption

Difference Between Encryption and Decryption


Feature Encryption Decryption
Process of converting plaintext → ciphertext Process of converting ciphertext →
Definition
using an algorithm + key. plaintext using an algorithm + key.
To protect confidentiality by making data To make encrypted data readable again for
Purpose
unreadable to unauthorized users. authorized users.
Input Plaintext (original readable message). Ciphertext (scrambled unreadable message).
Output Ciphertext (encrypted form). Plaintext (original message restored).
Performed By Sender (before transmitting or storing data). Receiver (after receiving or retrieving data).
Algorithms AES, DES, RSA, Caesar Cipher, Vigenère Cipher, Same algorithms but applied in reverse
Used etc. process.
Plaintext: HELLO → Encryption → Ciphertext: Ciphertext: KHOOR → Decryption →
Example
KHOOR (Caesar Cipher shift 3). Plaintext: HELLO.

Summary in one line:

 Encryption = Locking the message 🔒 (readable → unreadable).


 Decryption = Unlocking the message 🔑 (unreadable → readable).
(IX) Types of attacks Key range & Size

1. Brute-force / Exhaustive search

 Try every possible key until one works.


 Defense: large keyspace (long keys), rate-limiting, KDFs, salts.

2. Dictionary / Password-guessing

 Try likely passwords/phrases rather than all possible keys.


 Defense: enforce strong passwords, use MFA, password hashing (bcrypt/Argon2).

3. Cryptanalytic attacks (mathematical)

 Exploit algorithm weaknesses (e.g., linear/differential cryptanalysis on block ciphers, number-theory


attacks on RSA).
 Defense: use well vetted, modern algorithms (AES, ECC, RSA with safe parameters).

4. Chosen-plaintext / Chosen-ciphertext / Known-plaintext

 Attacker can obtain ciphertexts for chosen or known plaintexts to break key/algorithm.
 Defense: authenticated encryption (AEAD), avoid deterministic encryption without integrity.

5. Meet-in-the-middle & Birthday attacks


 Meet-in-the-middle reduces effective work against double encryption; birthday attacks affect hash
collision resistance.
 Defense: use algorithms with appropriate design and sufficient size (e.g., SHA-256+).

What is key size / key range?

 Key size = number of bits in a key (e.g., 128-bit, 2048-bit).


 Key range / keyspace = total number of possible keys = 2key_size2^{\text{key\_size}}2key_size.
o Example: for a 128-bit key, keyspace = 21282^{128}2128 possible keys (an astronomically
large number).

Why key size matters

 Security against brute-force is directly tied to keyspace size. Doubling bits squares the work exponent:
each extra bit doubles the keyspace.
 For asymmetric algorithms (RSA/ECC), security is about the hardness of some mathematical problem
(integer factorization or discrete log), so comparisons use equivalent symmetric key strength.
Quick summary

 Types of attacks include brute-force, cryptanalysis, side-channel, MITM, replay, dictionary attacks, and
key-management/collusion attacks.
 Key size (bits) determines the keyspace (2n2^n2n). Use AES-128/256, RSA-2048/3072, ECC P-256/P-
384 depending on required lifetime and threat model.
 Large key sizes + good key management + secure implementations are the recipe for resisting both
classical and many future attacks.
UNIT-02

(i) Symmetric & Asymmetric Key Cryptography

Symmetric Key Cryptography

Uses one single key for both encryption and decryption.

 Process:

C=EK(P),P=DK(C)C = E_K(P), \quad P = D_K(C)C=EK​(P),P=DK​(C)

(Same key KKK used in both directions)

 Features:
o Fast, efficient (suitable for large data).
o Key distribution is difficult (sender & receiver must share the same secret key securely).
 Examples:
o AES (Advanced Encryption Standard)
o DES, 3DES
o Blowfish, RC4
 Use cases:
o Encrypting files, databases, hard drives.
o Securing communication inside a closed system.

Asymmetric Key Cryptography

Uses a pair of keys:

 Public Key → for encryption (shared openly).


 Private Key → for decryption (kept secret).
 Process:

C=EKpub(P),P=DKpriv(C)C = E_{K_{pub}}(P), \quad P =


D_{K_{priv}}(C)C=EKpub​​(P),P=DKpriv​​(C)

 Features:
o Slower than symmetric (more computationally heavy).
o Solves key distribution problem (public key can be shared freely).
o Enables digital signatures, authentication, and secure key exchange.
 Examples:
o RSA
o ECC (Elliptic Curve Cryptography)
o Diffie-Hellman (key exchange)
 Use cases:
o Digital signatures & certificates (SSL/TLS for HTTPS).
o Email encryption (PGP, S/MIME).
o Secure key exchange before starting symmetric encryption.
Comparison Table
Feature Symmetric Key Asymmetric Key

Keys Used One key (same for encryption & decryption) Two keys (public & private pair)

Speed Fast Slower

Security Key distribution is a challenge More secure for key distribution

Data Size Best for large amounts of data Better for small amounts (or exchanging keys)

Examples AES, DES, 3DES, Blowfish RSA, ECC, Diffie-Hellman

Use cases Bulk data encryption Digital signatures, secure key exchange, certificates

(ii) DES (Data Encryption Standard)

 DES (Data Encryption Standard) is a symmetric-key block cipher.


 Developed by IBM in the 1970s, adopted as a U.S. standard by NIST in 1977.
 Now considered outdated/insecure because of its short key size.

Key Features of DES

1. Symmetric Key Algorithm → same key for encryption & decryption.


2. Block Cipher → operates on 64-bit blocks of data.
3. Key Size → effective key length is 56 bits (8 extra bits are for parity).
4. Rounds → uses 16 rounds of encryption (Feistel structure).
5. Structure → Based on Substitution-Permutation Network (SPN) using Feistel rounds.

How DES Works

1. Input: 64-bit plaintext + 56-bit key.


2. Initial Permutation (IP): Rearranges the plaintext bits.
3. 16 Feistel Rounds: Each round consists of:
o Expansion (32 → 48 bits)
o XOR with subkey
o Substitution (S-boxes) → reduces 48 bits back to 32 bits
o Permutation (P-box)
o Swap halves
4. Final Permutation (IP⁻¹): Rearranges bits again → Ciphertext output.

Advantages of DES

 Simple and easy to implement.


 Was widely adopted and tested → foundation for modern cryptography.
Weaknesses of DES

1. Short key length (56 bits): vulnerable to brute-force attacks (broken in 1999 by EFF’s Deep Crack in
less than a day).
2. Not suitable for modern security (computers are too powerful).
3. Vulnerable to differential & linear cryptanalysis.

Variants of DES

 3DES (Triple DES): Encrypts data 3 times with 2 or 3 keys (effective key size: 112–168 bits). More
secure, but slower.
 AES (Advanced Encryption Standard): Chosen in 2001 to replace DES/3DES, offering 128, 192, or
256-bit keys.

(iii) IDEA (International Data Encryption Algorithm)

 IDEA (International Data Encryption Algorithm) is a symmetric-key block cipher.


 Developed by Xuejia Lai and James Massey in 1991 (improved version of PES).
 Designed to be secure against both differential and linear cryptanalysis.
 Widely used in the past (e.g., in PGP – Pretty Good Privacy).

Key Features of IDEA

1. Symmetric Algorithm → same key for encryption & decryption.


2. Block Cipher → operates on 64-bit blocks.
3. Key Size → 128-bit key.
4. Rounds → 8 identical rounds + 1 output transformation.
5. Operations used:
o Modular addition (addition mod 2¹⁶)
o Modular multiplication (multiplication mod 2¹⁶+1)
o Bitwise XOR
o (Mixing three algebraic groups makes attacks much harder).

How IDEA Works (Simplified)

1. Input: 64-bit plaintext split into four 16-bit sub-blocks.


2. Key Mixing: 128-bit key expanded into 52 subkeys (16-bit each).
3. Each Round (8 rounds):
o Combination of modular multiplication, addition, and XOR.
o Strong mixing of data and keys.
4. Output Transformation (Final Round): Special key mixing step.
5. Output: 64-bit ciphertext.

Advantages of IDEA

 Much stronger than DES (due to 128-bit key).


 Resistant to brute-force attacks (huge keyspace).
 Resistant to linear and differential cryptanalysis.
 Was heavily used in PGP (for email and file security).
Weaknesses of IDEA

 Patented until 2012 (limited adoption at first).


 Slower compared to modern ciphers like AES.
 Fixed block size of 64 bits (not ideal for large modern data volumes).
 Now considered obsolete for modern standards (AES is preferred).

(iv) Differential & Linear Cryptanalysis

Differential Cryptanalysis (DC)

Introduced by Eli Biham and Adi Shamir (1990s) – first major generic attack on block ciphers.

Concept

 Studies how differences in plaintext inputs can affect the differences in ciphertext outputs.
 The attacker looks for patterns in how input differences propagate through the cipher.
 Goal: Deduce information about the secret key.

How it works

1. Take two plaintexts with a specific difference (ΔP).


2. Encrypt both using the same key.
3. Analyze the difference in outputs (ΔC).
4. If the cipher is weak, predictable patterns appear → attacker narrows down possible keys.

Best against:

 Feistel structure ciphers (like DES, if rounds are too few).

Defense:

 More rounds, S-boxes designed to resist DC.


 Example: DES with 16 rounds resists differential cryptanalysis, but fewer rounds can be broken.

Linear Cryptanalysis (LC)

Introduced by Mitsuru Matsui (1993).

Concept

 Approximates the behavior of the cipher using linear equations.


 Tries to find linear relationships between plaintext bits, ciphertext bits, and key bits.
 Goal: Use these approximations to recover parts of the key.

How it works

1. Find linear expressions of the form:

P[i]⊕P[j]⊕C[k]=K[l]P[i] \oplus P[j] \oplus C[k] = K[l]P[i]⊕P[j]⊕C[k]=K[l]


where PPP = plaintext bits, CCC = ciphertext bits, KKK = key bits.

2. If the probability of this relation holding is significantly different from 50%, attacker can exploit it.
3. Collect a large number of plaintext-ciphertext pairs to solve for key bits.

Best against:

 Block ciphers with poorly designed S-boxes.

Defense:

 Use complex S-boxes with good linear properties.


 Increase the number of rounds (DES with <14 rounds is vulnerable, but 16 rounds resists).

Comparison: Differential vs Linear Cryptanalysis


Feature Differential Cryptanalysis Linear Cryptanalysis

Linear approximations between plaintext,


Focus Input–output differences
ciphertext, and key

Introduced
Biham & Shamir (1990) Matsui (1993)
by

Target Weakness in how differences propagate Weakness in S-box linearity

Chosen plaintext attack (need pairs of Known plaintext attack (large number of
Data Needed
plaintexts with differences) plaintext–ciphertext pairs)

Works Best
Feistel ciphers (like reduced-round DES) Substitution-permutation ciphers
On

Defense Strong S-box design + more rounds Strong non-linear S-box design + more rounds

(v) RSA (Rivest–Shamir–Adleman)

 RSA is the most famous asymmetric key cryptography algorithm.


 Invented in 1977 by Rivest, Shamir, and Adleman.
 Based on the mathematical difficulty of factoring large prime numbers.
 Used for encryption, digital signatures, and secure key exchange.

Key Features of RSA

1. Asymmetric algorithm → uses two keys:


o Public Key → for encryption (shared openly).
o Private Key → for decryption (kept secret).
2. Mathematical Basis → relies on the difficulty of factoring the product of two large prime numbers.
3. Block Cipher → but typically encrypts only small data (like keys), not bulk data.
4. Key Sizes → 1024, 2048, 3072, 4096 bits (2048 bits is common today).
How RSA Works (Simplified)

RSA has three main steps: Key Generation, Encryption and Decryption.

Key Generation

1. Choose two large prime numbers ppp and qqq.


2. Compute n=p×qn = p \times qn=p×q (modulus).
3. Compute Euler’s totient: φ(n)=(p−1)(q−1)\varphi(n) = (p-1)(q-1)φ(n)=(p−1)(q−1).
4. Choose encryption exponent eee (public key), such that 1<e<φ(n)1 < e < \varphi(n)1<e<φ(n), and gcd(e,
φ(n)) = 1.
(Common choice: e=65537e = 65537e=65537).
5. Compute decryption exponent ddd (private key), such that:

d×e≡1(modφ(n))d \times e \equiv 1 \pmod{\varphi(n)}d×e≡1(modφ(n))

(i.e., ddd is modular inverse of eee).

 Public Key = (e,n)(e, n)(e,n)


 Private Key = (d,n)(d, n)(d,n)

2 Encryption

To encrypt plaintext message MMM:

C=Memod nC = M^e \mod nC=Memodn

where CCC = ciphertext.

3 Decryption

To decrypt ciphertext CCC:

M=Cdmod nM = C^d \mod nM=Cdmodn

where MMM = plaintext.

Example (Small Numbers)

1. Choose p=17,q=11p = 17, q = 11p=17,q=11.


o n=17×11=187n = 17 \times 11 = 187n=17×11=187.
o φ(n) = (16 × 10) = 160.
2. Choose e=7e = 7e=7 (since gcd(7,160)=1).
3. Compute ddd:
d×e≡1(mod160)d × e ≡ 1 (mod 160)d×e≡1(mod160).
d=23d = 23d=23.

 Public key = (7, 187).


 Private key = (23, 187).
4. Encrypt message M=88M = 88M=88:
C=887mod187=11C = 88^7 mod 187 = 11C=887mod187=11.
5. Decrypt C=11C = 11C=11:
M=1123mod187=88M = 11^23 mod 187 = 88M=1123mod187=88.

Applications of RSA

 Secure websites (SSL/TLS certificates).


 Email encryption (PGP, S/MIME).
 Digital signatures and authentication.
 Key exchange (used to exchange symmetric session keys)

Strengths of RSA

 Very secure (factoring large primes is extremely hard).


 Enables secure communication without prior key sharing.

Weaknesses of RSA

 Very slow for large data (so mostly used for exchanging symmetric keys).
 Security depends on choosing large primes (2048+ bits recommended).
 Vulnerable if implemented poorly (small keys, weak padding).

(vi) Symmetric & Asymmetric key

Symmetric Key Cryptography

Uses one single key for both encryption and decryption.

How it works

 Sender encrypts plaintext with the key.


 Receiver decrypts ciphertext with the same key.

C=EK(P),P=DK(C)C = E_K(P), \quad P = D_K(C)C=EK​(P),P=DK​(C)

Features

 Fast → suitable for large amounts of data.


 Problem → secure key distribution (how to share the secret key safely).

Examples

 DES, 3DES, AES, Blowfish, RC4.

Use cases

 Encrypting files, databases, hard drives.


 Securing communication inside closed systems (e.g., VPN).

Asymmetric Key Cryptography

Uses a pair of keys:

 Public Key → for encryption (shared openly).


 Private Key → for decryption (kept secret).

How it works

 Sender encrypts using receiver’s public key.


 Receiver decrypts using their private key.

C=EKpub(P),P=DKpriv(C)C = E_{K_{pub}}(P), \quad P = D_{K_{priv}}(C)C=EKpub​​(P),P=DKpriv​​(C)

Features

 Secure key distribution (public key can be shared freely).


 Slower than symmetric algorithms.
 Supports digital signatures & authentication.

Examples

 RSA, ECC, Diffie-Hellman, ElGamal.

Use cases

 Digital signatures & certificates (SSL/TLS for HTTPS).


 Email encryption (PGP, S/MIME).
 Secure key exchange before starting symmetric encryption.

Comparison Table
Feature Symmetric Key Asymmetric Key

Keys Used One key (same for encryption & decryption) Two keys (public & private)

Speed Fast (low computation) Slow (high computation)

Security Key distribution is difficult More secure for key distribution

Data Size Best for large data Best for small data/key exchange

Examples AES, DES, 3DES, RC4 RSA, ECC, Diffie-Hellman

Use Cases File encryption, bulk data Digital signatures, key exchange, SSL/TLS
Feature Symmetric Key Asymmetric Key

(vii) Digital signature

In normal communication:

 A message can be intercepted, modified, or faked.


 Encryption alone ensures confidentiality but doesn’t guarantee integrity or authentication.

Digital signatures solve this by ensuring:

 Only the real sender created the message (Authentication).


 Message is not altered (Integrity).
 Sender cannot deny sending it (Non-repudiation).

Digital Signature Process (Detailed)

Step 1: Signature Creation (Sender)

1. Write message → "Pay $500 to Alice".


2. Hash it using SHA-256 → H(M).
3. Encrypt the hash with private key → Digital Signature.
4. Send (Message + Signature).

Step 2: Signature Verification (Receiver)

1. Receive (Message + Signature).


2. Decrypt signature with public key → H(M1).
3. Hash the received message again → H(M2).
4. Compare:
o If H(M1) = H(M2) → ✅ Valid, message is authentic.
o If not → ❌ Message altered or signature forged.

Algorithms Used for Digital Signatures

 RSA → Most common, based on prime factorization.


 DSA (Digital Signature Algorithm) → U.S. Federal standard.
 ECDSA (Elliptic Curve DSA) → More efficient, used in blockchain (Bitcoin, Ethereum).
 EdDSA (Edwards-Curve Digital Signature Algorithm) → Modern, faster, secure.

Applications of Digital Signatures

✔️Email security → PGP, S/MIME.


✔️Software distribution → Verify authenticity of updates/drivers (Microsoft, Apple).
✔️Digital certificates → SSL/TLS (HTTPS websites).
✔️E-documents → Legal, government contracts, e-signatures.
✔️Blockchain & Cryptocurrency → Every Bitcoin/Ethereum transaction is signed.
✔️Authentication systems → Smart cards, secure tokens.

Advantages

 Ensures Authentication, Integrity, Non-repudiation.


 Prevents man-in-the-middle and data tampering attacks.
 Provides trust in digital communication.

Disadvantages / Challenges

 Requires Public Key Infrastructure (PKI) → certificate authorities (CAs) must be trusted.
 Computationally heavier than symmetric cryptography.
 If the private key is stolen, signatures can be forged.
 Relies on strong hash functions (e.g., SHA-256; MD5 is broken).

(viii) Knapsack algorithm

 The Knapsack Algorithm (also called the Merkle–Hellman Knapsack Cryptosystem) is an


asymmetric encryption algorithm.
 Proposed by Ralph Merkle and Martin Hellman in 1978.
 Based on the Subset Sum (Knapsack) Problem, which is NP-complete (hard to solve in general).

It was one of the first public-key cryptosystems, but today it is considered insecure because it was broken in
the 1980s.

Background: Knapsack (Subset Sum) Problem

 Given a set of numbers, is there a subset that adds up to a specific value?


 Example: Numbers = {2, 4, 6, 9}, Target = 15 → subset {6, 9} works.

This problem is computationally hard, which is why it was used for cryptography.

How the Knapsack Cryptosystem Works

It uses a special “super-increasing sequence” to make encryption/decryption easier.

1. Key Generation

1. Choose a super-increasing sequence (each number is greater than the sum of all previous numbers).
Example: {2, 3, 7, 14, 30}.
2. Pick a modulus m (greater than sum of all numbers). Example: m = 61.
3. Pick a multiplier a that is coprime to m. Example: a = 17.
4. Compute the public key sequence:
o bi=(a×wi)modmb_i = (a × w_i) mod mbi​=(a×wi​)modm.
o This hides the original sequence.

 Private Key = (super-increasing sequence, m, a).


 Public Key = {b₁, b₂, b₃, …}.
2. Encryption

 Convert plaintext into binary (e.g., "10101").


 Multiply each bit by the corresponding public key element.
 Add the results → ciphertext.

3. Decryption

 Multiply ciphertext by the modular inverse of a mod m.


 This recovers the sum in terms of the super-increasing sequence.
 Since the sequence is super-increasing, it’s easy to backtrack and recover the original binary message.

Example

1. Private sequence: {2, 3, 7, 14, 30}


o m = 61, a = 17
o Public sequence = {34, 51, 58, 55, 22}
2. Message = "10011"
o Ciphertext = 34×1 + 51×0 + 58×0 + 55×1 + 22×1 = 111
3. Receiver decrypts using private key to recover "10011".

Advantages

 First practical public-key system after RSA.


 Based on an NP-complete problem (subset sum).
 Easy to understand and implement.

Disadvantages

 Broken in 1982 by Adi Shamir (using lattice reduction attacks).


 Not used in practice today.
 Replaced by stronger algorithms like RSA, ECC, AES.

Unit-03
Case Studies of Cryptography

1. Denial of Service (DoS) Attacks

 Definition: Attack that aims to make a system or network resource unavailable to users.
 How it works: Floods the target with excessive traffic or requests, causing system overload.
 Examples:
o Ping of Death: Sending oversized packets to crash the target system.
o SYN Flood: Exploiting the TCP handshake by sending multiple SYN requests but not
completing the connection.
o Distributed DoS (DDoS): Multiple systems (botnets) attack a single target.
 Goal: Affects availability of system or service.

2. IP Spoofing Attacks

 Definition: Attacker disguises their IP address to appear as a trusted source.


 Purpose: Gain unauthorized access or perform DoS attacks.
 How it works:
o Attacker sends packets with a forged source IP address.
o The receiver believes the packet came from a trusted host.
 Prevention:
o Packet filtering (e.g., ingress/egress filtering).
o Authentication at application level.
o Use of encryption and digital signatures.

3. Conventional Encryption and Message Confidentiality

 Conventional (Symmetric) Encryption:


o Same key used for encryption and decryption.
o Fast and suitable for large data.
o Example: DES, AES, IDEA.
 Message Confidentiality:
o Ensures only authorized users can read the message.
o Achieved by encrypting the message before transmission.

Formula:

 Encryption: C = E(K, P)
 Decryption: P = D(K, C)

Where:
C = Ciphertext, P = Plaintext, K = Secret key.

4. Conventional Encryption Algorithms

Algorithm Type Key Size Description

Block
DES (Data Encryption Standard) 56-bit Operates on 64-bit blocks; now considered weak.
Cipher

Block
3DES (Triple DES) 168-bit Applies DES three times for stronger encryption.
Cipher

IDEA (International Data Encryption Block Uses substitution and transposition with multiple
128-bit
Algorithm) Cipher rounds.

Block 128/192/256- Most widely used modern symmetric encryption


AES (Advanced Encryption Standard)
Cipher bit standard.
5. Key Distribution

Problem: How to securely share the secret key between sender and receiver.

Methods of Key Distribution:

1. Physical delivery: Manually exchange keys (not practical for large networks).
2. Using a trusted third party (Key Distribution Center - KDC): KDC generates and distributes session
keys.
3. Public key encryption: Encrypt symmetric key using recipient’s public key.
4. Session key exchange protocols: Like Diffie-Hellman.

Public Key Cryptography and Message Authentication

1. Approaches to Message Authentication

Ensures that message is from a genuine sender and not modified.

Approaches:

1. Message Authentication Code (MAC):


o Short piece of information (tag) added to the message.
o Computed using a shared secret key.
o Used in symmetric cryptography.
2. Hash Function:
o Converts message into a fixed-size digest (hash value).
o Used for integrity verification.
o Examples: SHA-1, MD5.
3. Digital Signature:
o Created using sender’s private key.
o Verified using sender’s public key.
o Provides authentication, integrity, and non-repudiation.

2. SHA-1 (Secure Hash Algorithm - 1)

 Produces a 160-bit (20-byte) message digest.


 Used in SSL, SSH, and PGP.
 Steps:
1. Padding
2. Divide message into 512-bit blocks
3. Process each block with logical functions and bitwise operations.
 Note: SHA-1 is now considered weak; replaced by SHA-2 / SHA-3.

3. MD5 (Message Digest 5)

 Produces a 128-bit (16-byte) hash value.


 Faster but less secure (vulnerable to collisions).
 Used for integrity checking, not recommended for cryptographic use.
4. Public-Key Cryptography Principles

 Uses two keys:


o Public key: Shared openly.
o Private key: Kept secret.
 Encryption/Decryption:
o Message encrypted with receiver’s public key → only receiver can decrypt using private key.
 Authentication:
o Sender encrypts with their private key → receiver verifies with sender’s public key.
 Examples: RSA, ECC, ElGamal.

5. RSA Algorithm (Rivest–Shamir–Adleman)

Steps:

1. Key Generation:
o Select two large primes, p and q.
o Compute n = p × q.
o Compute ϕ(n) = (p−1)(q−1).
o Choose e (public exponent) such that gcd(e, ϕ(n)) = 1.
o Compute d ≡ e⁻¹ mod ϕ(n). (Private key)
2. Encryption:
o C = Pᵉ mod n
3. Decryption:
o P = Cᵈ mod n

Uses: Encryption, Digital Signatures, Key Exchange.

6. Digital Signatures

 Provides authentication, integrity, non-repudiation.


 Created using sender’s private key.
 Verified by receiver using sender’s public key.

Process:

1. Sender creates a hash of the message.


2. Hash is encrypted with sender’s private key → digital signature.
3. Receiver decrypts using sender’s public key to verify.

7. Key Management

 Refers to the creation, distribution, storage, usage, rotation, and destruction of cryptographic keys.
 Goals:
o Keep keys secret.
o Replace expired or compromised keys.
o Ensure proper access control.
 Components:
o Key generation
o Key distribution
o Key storage
o Key backup and recovery
o Key revocation

8. Firewall

 Definition: Hardware or software system that controls incoming and outgoing network traffic based on
security rules.
 Purpose: Protect internal network from external threats.
 Types of Firewalls:
1. Packet Filtering Firewall: Filters packets based on IP, port, protocol.
2. Stateful Inspection Firewall: Tracks state of active connections.
3. Proxy Firewall: Acts as intermediary between users and internet.
4. Next-Gen Firewall: Combines traditional firewall with intrusion prevention and application
awareness.

Unit-04
Introduction to Data Compression

1.1 Need for Data Compression

Data compression is required to reduce the size of data so that it can be stored efficiently and transmitted
faster over networks.

Main reasons:

 Storage Efficiency: Reduces memory or disk space requirements.


 Transmission Efficiency: Decreases bandwidth usage and transmission time.
 Cost Reduction: Saves storage and network costs.
 Improved Performance: Faster data transfer and retrieval.
 Multimedia Handling: Helps store large audio, video, and image files efficiently.

Example:

 Text files → ZIP compression


 Images → JPEG/PNG
 Audio → MP3
 Video → MP4

1.2 Fundamental Concept of Data Compression & Coding

 Data Compression: Process of reducing the number of bits needed to represent data.
 Coding: Assigning shorter binary codes to frequently used symbols and longer codes to less frequent
ones.

Goal: Represent the same information using fewer bits.

General Idea:

1. Identify redundancy in data.


2. Remove or encode redundancy efficiently.
3. Reconstruct (decompress) the original data when needed.

1.3 Communication Model of Data Compression

Model:

Source → Encoder (Compression) → Channel → Decoder (Decompression) → Destination

Explanation:

 Source: Original data or message (e.g., text, image).


 Encoder: Compresses data into a smaller form.
 Channel: Medium of transmission (e.g., network).
 Decoder: Reconstructs the original data.
 Destination: Receives the decompressed data.

Example:
When you send a ZIP file via email:
File → ZIP encoder → Internet → ZIP decoder → Receiver.

1.4 Compression Ratio

Measures how effectively data is compressed.

Compression Ratio=Original SizeCompressed Size\text{Compression Ratio} = \frac{\text{Original Size}}{\text{Compressed


Size}}Compression Ratio=Compressed SizeOriginal Size

Example:
If original file = 1000 KB and compressed file = 250 KB
→ Compression Ratio = 1000 / 250 = 4:1

Higher ratio = better compression.

1.5 Requirements of Data Compression

A good compression system should have:

1. High Compression Ratio: Efficient space reduction.


2. Fast Compression/Decompression: Real-time performance.
3. Low Complexity: Should not consume excessive CPU or memory.
4. Error Resilience: Ability to handle transmission errors.
5. Scalability: Suitable for various types of data.
6. Reversibility (for Lossless): Original data must be exactly recovered.

1.6 Classification of Data Compression

Data compression can be broadly classified as:

Type Description Example Algorithms


Type Description Example Algorithms

Lossless No loss of information. Decompressed data is identical to Huffman Coding, Run Length
Compression original. Encoding (RLE), LZW

Lossy Some information is lost. Used for multimedia where exact JPEG (images), MP3 (audio), MPEG
Compression reproduction isn’t required. (video)

Methods of Data Compression

2.1 Lossless Data Compression

 No information is lost during compression.


 Used where accuracy is critical (e.g., text, executable files, source code).
 Data after decompression = exactly same as original.

Techniques:

1. Run-Length Encoding (RLE):


o Replaces repeated data with a single value and count.
o Example:
 Original: AAAAABBBCC → A5B3C2
o Used in BMP, TIFF.
2. Huffman Coding:
o Variable-length codes for symbols based on frequency.
o Frequently used symbols → shorter codes.
o Used in ZIP, PNG, GZIP.
3. LZW (Lempel–Ziv–Welch) Coding:
o Builds a dictionary of data patterns.
o Common in GIF, TIFF, and UNIX compress.
4. Arithmetic Coding:
o Represents entire message as a single fraction (0 to 1).
o Used in modern codecs like JPEG and MPEG.

2.2 Lossy Data Compression

 Some information is discarded during compression.


 Used for audio, video, and images where small losses are acceptable.
 Achieves higher compression ratios than lossless methods.

Techniques:

1. Transform Coding (e.g., DCT – Discrete Cosine Transform):


o Converts spatial data into frequency components.
o Used in JPEG, MPEG.
2. Predictive Coding:
o Predicts next sample from previous ones; stores only difference (error).
o Used in speech/audio compression.
3. Vector Quantization:
o Divides data into small blocks (vectors) and replaces them with representative codewords.
Example Applications:

 JPEG (Image Compression) – Reduces color & spatial redundancy.


 MP3 (Audio Compression) – Removes inaudible frequencies.
 MPEG (Video Compression) – Uses inter-frame redundancy removal.

Summary Table
Aspect Lossless Compression Lossy Compression

Data Recovery Exact Approximate

Use Cases Text, Database, Executables Audio, Image, Video

Compression Ratio Moderate High

Techniques Huffman, LZW, RLE JPEG, MP3, MPEG

Information Loss None Some loss

Reversibility Fully reversible Irreversible

Example:

File Type Original Size Compressed Size Compression Type Compression Ratio

Text File 2 MB 1 MB Lossless (ZIP) 2:1

Image File 5 MB 1 MB Lossy (JPEG) 5:1

Uint-05
1. Entropy Encoding

Definition:

Entropy encoding is a lossless compression method that removes redundancy by assigning shorter codes to
frequently occurring data symbols and longer codes to less frequent ones.

1.1 Repetitive Character Encoding

 Simplest form of compression.


 Repeated characters are replaced by a single character followed by its count.
 Similar to Run-Length Encoding (RLE).

Example:

Original: AAAAAABBBBCCCC
Encoded: A6B4C4

Used in: Simple text compression, fax transmission.

1.2 Run-Length Encoding (RLE)

 Represents runs of identical data values as a single value and count.


 Works best for data with long sequences of repeating values (low entropy).

Example:

Original: 00000011111000
Encoded: 0×6, 1×5, 0×3

Applications:
BMP, TIFF, fax, monochrome images.

1.3 Zero/Blank Encoding

 Specialized form of RLE for zero values or blanks (common in sparse data).
 Stores positions or counts of zeros instead of actual zeros.

Example:

Original: 10000001
Encoded: 1(5 zeros)1

Used in:

 Sparse matrices,
 Image compression,
 Data transmission protocols.

2. Statistical Encoding

Definition:

Statistical encoding uses symbol probability to assign code lengths — symbols with higher probability get
shorter codes.

2.1 Huffman Coding

 Based on frequency of symbols.


 Creates a binary tree where low-frequency symbols have longer codes.

Steps:

1. Count frequency of each symbol.


2. Build Huffman tree by combining lowest frequencies.
3. Assign 0 and 1 to branches.
4. Generate variable-length codes.
Example:

Symbol Frequency Code

A 5 0

B 2 10

C 1 110

D 1 111

Used in: ZIP, PNG, JPEG, GZIP.

2.2 Arithmetic Coding

 Represents an entire message as a single fraction (between 0 and 1).


 More efficient than Huffman for data with fractional probabilities.
 No need to assign discrete codes per symbol.

Process:

1. Assign probability ranges to symbols.


2. Represent message as a subrange within [0,1).
3. Output is the unique code representing that range.

Used in: JPEG2000, MPEG, H.264.

2.3 Lempel–Ziv (LZ) Coding

 Dictionary-based lossless compression.


 Builds a dictionary of repeating patterns (substrings).
 Replaces repeating patterns with references (pointers) to earlier occurrences.

Variants:

 LZ77: Sliding window dictionary.


 LZ78: Dictionary stored separately.
 LZW (Lempel-Ziv-Welch): Improved version — used in GIF, TIFF, Unix compress.

Example:

Input: ABABABA
Output: AB(2,5)

3. Source Encoding

Definition:
Source encoding represents data in efficient codewords to minimize average bits per symbol — often used in
multimedia compression.

3.1 Vector Quantization (VQ)

 Groups data samples (like pixels, sound samples) into vectors.


 Each vector is mapped to a codeword from a predefined codebook.
 Reduces storage by replacing each block with a code index.

Steps:

1. Divide image/audio into vectors.


2. Create a codebook of representative vectors (using algorithms like Linde–Buzo–Gray).
3. Replace each input vector with closest codebook entry.

Example:
For an image, each 4×4 pixel block is represented by 1 index → reduces data size.

Used in:
Speech coding, image compression (e.g., JPEG).

3.2 Vector Quantization with Error Term

 Similar to simple VQ but stores the difference (error term) between the original vector and the
quantized vector for better reconstruction quality.

Process:

1. Encode each vector with the nearest codeword.


2. Calculate error (difference) = Original − Quantized.
3. Transmit both codeword index + error term.

Result:

 Slightly higher bit rate,


 Much better reconstruction accuracy (useful for hybrid compression).

4. Recent Trends in Encryption and Data Compression

4.1 Trends in Encryption

1. Advanced Encryption Standard (AES):


o Replaced DES; highly secure and efficient.
o Widely used in Wi-Fi (WPA3), HTTPS, VPNs.
2. Elliptic Curve Cryptography (ECC):
o Offers strong encryption with smaller key sizes (used in mobile and IoT).
3. Quantum-Resistant Cryptography:
o Research on post-quantum algorithms (e.g., lattice-based cryptography) to resist quantum
computer attacks.
4. Blockchain Encryption:
o Uses asymmetric cryptography and hash functions for decentralized security.
5. Homomorphic Encryption:
o Enables computation on encrypted data without decrypting it (useful in cloud computing).

4.2 Trends in Data Compression

1. Hybrid Compression Techniques:


o Combining lossless + lossy (e.g., JPEG2000 uses DWT + Arithmetic coding).
2. AI and Neural Compression:
o Machine learning models (autoencoders) used for compressing images, audio, and text.
o Example: Google’s “Learned Image Compression”.
3. Context-based Adaptive Compression:
o Uses prediction from previous data (e.g., CABAC in H.264 video coding).
4. 3D and Video Compression Advances:
o Use of motion estimation and inter-frame redundancy removal (HEVC, AV1).
5. Cloud and Real-time Compression:
o Compression algorithms optimized for streaming and IoT data transfer.

Summary Table
Category Technique Type Use/Example

Entropy Encoding RLE, Zero Encoding Lossless Repetitive data

Statistical Encoding Huffman, Arithmetic, LZW Lossless ZIP, JPEG, MPEG

Source Encoding Vector Quantization Lossy Image, Audio

Encryption Trend AES, ECC, Quantum-safe Secure Transmission Wi-Fi, Cloud

Compression Trend AI-based, Hybrid, Real-time Lossy/Lossless Multimedia, IoT

You might also like