0% found this document useful (0 votes)
2 views37 pages

Cryptography Assignment

The document is an assignment on Cryptography and Network Security for B.Tech (AI & ML) students, covering topics such as Differential and Linear Cryptanalysis, block cipher modes of operation, the effectiveness of Triple DES and Blowfish, key distribution problems, and various types of cyber-attacks. It also includes questions on Euler's Theorem, Elliptic Curve Cryptography, RSA algorithm keys, and the Chinese Remainder Theorem. Each section provides detailed explanations and analyses relevant to modern cryptographic systems and security challenges.

Uploaded by

Akshit Rawat
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)
2 views37 pages

Cryptography Assignment

The document is an assignment on Cryptography and Network Security for B.Tech (AI & ML) students, covering topics such as Differential and Linear Cryptanalysis, block cipher modes of operation, the effectiveness of Triple DES and Blowfish, key distribution problems, and various types of cyber-attacks. It also includes questions on Euler's Theorem, Elliptic Curve Cryptography, RSA algorithm keys, and the Chinese Remainder Theorem. Each section provides detailed explanations and analyses relevant to modern cryptographic systems and security challenges.

Uploaded by

Akshit Rawat
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

JB INSTITUTE Of TECHNOLOGY

DEHRADUN, UTTARAKHAND

Cryptography and Network Security


[Link] (AI & ML)

Assignment

Year: 4th Semester: 7th

SUBMITTED BY: SUBMITTED TO:

Akshit Singh Rawat Mr. Mohit Kumar


Roll no: 220530122003 (Asst. Professor AI & ML)
ASSIGNMENT – 1

Q.1. Explain the principle of Differential and Linear


Cryptanalysis
and its impact on the security of DES.
Ans. 1. Differential Cryptanalysis:
Principle:
Differential Cryptanalysis is a chosen-plaintext attack that
studies how differences in input pairs affect the
differences in output pairs after encryption.
It focuses on tracking the propagation of differences (usually
XOR differences) through the S-boxes and rounds of a block
cipher.
How It Works:
1. The attacker selects pairs of plaintexts that differ in
specific bits.
2. These pairs are then encrypted under the same key.
3. The attacker observes how these input differences create
predictable patterns in the ciphertext differences.
4. By analyzing thousands or millions of such pairs, the
attacker identifies statistical biases in S-boxes.
5. These biases leak information about key bits used in
certain rounds.
Impact on DES:
 DES was specifically designed to resist differential
cryptanalysis, as IBM and the NSA already knew about this
attack in the 1970s.
 However, DES is not completely immune:
o A full differential attack on DES requires about 2⁴⁷
chosen plaintexts, which makes it theoretically
possible but practically difficult.
 Differential Cryptanalysis helped reveal that DES’s 16
rounds are just enough for security; fewer rounds would be
vulnerable.
2. Linear Cryptanalysis:
Principle:
Linear Cryptanalysis is a known-plaintext attack that
approximates the behaviour of a block cipher using linear
equations.
It attempts to find linear relationships between plaintext bits,
ciphertext bits, and key bits.
How It Works:
1. The attacker identifies linear expressions involving:
o Plaintext bits
o Ciphertext bits
o Key bits
2. These expressions hold true with a certain probability (not
exactly 0.5).
3. By gathering a large number of plaintext–ciphertext pairs,
the attacker detects small statistical biases.
4. These biases are used to recover key bits.
Impact on DES:
 DES is more vulnerable to linear attacks than to
differential attacks.
 A linear attack on DES requires about 2⁴³ known
plaintexts, making it computationally easier (but still
unrealistic in real-world scenarios).
 Linear cryptanalysis highlights that DES’s S-boxes and P-
boxes were carefully engineered to reduce linear
correlations.
 Similar to differential cryptanalysis, this attack shows
DES’s 56-bit key is insufficient for modern security needs.

Q. 2. Analyze the role of block cipher modes of operation in


achieving confidentiality and integrity in encrypted
communication.
Ans. Block ciphers like AES and DES operate only on fixed-size
blocks, so modes of operation are required to securely encrypt
data of any length. These modes determine how plaintext
blocks are processed and directly affect confidentiality,
integrity, and resistance to attacks.
1. Modes That Provide Only Confidentiality:
These modes protect data from being read but do not prevent
tampering.
a) ECB (Electronic Codebook Mode):
 Encrypts each block independently.
 Weak confidentiality because identical plaintext →
identical ciphertext.
 No integrity protection; an attacker can rearrange or
modify blocks.
b) CBC (Cipher Block Chaining Mode):
 XORs each plaintext block with previous ciphertext block.
 Prevents pattern leakage and improves confidentiality.
 Still lacks integrity—vulnerable to padding-oracle and bit-
flipping attacks.
c) CFB, OFB, CTR Modes:
 Convert block ciphers into stream-like ciphers.
 Eliminate plaintext patterns and support parallel or
streaming encryption.
 But still do not detect modifications to ciphertext.
Conclusion:
Confidentiality-only modes protect secrecy but allow
undetected tampering, making them insufficient for modern
secure communication.
2. Modes Providing Both Confidentiality and Integrity
(Authenticated Encryption):
Modern systems require not just privacy but also message
authenticity and tamper detection. Authenticated
Encryption (AE/AEAD) modes combine encryption with integrity
protection.
a) GCM (Galois/Counter Mode):
 Uses CTR mode for encryption + a Galois field-based MAC
for authentication.
 Provides confidentiality, integrity, and authentication in
one step.
 Widely used in TLS 1.3, IPsec, Wi-Fi.
b) CCM (Counter with CBC-MAC):
 Combines CTR mode with CBC-MAC.
 Used in resource-constrained systems (IoT, WPA2).
c) OCB, EAX:
 Provide authenticated encryption with high efficiency and
strong security.
How AEAD modes ensure security:
 Use nonces/IVs to ensure unique ciphertext.
 Generate authentication tags that detect any change in
ciphertext.
 Prevent replay and modification attacks.
Q.3. Evaluate the effectiveness of Triple DES and Blowfish in
modern cryptographic systems.
Ans. Triple DES (3DES) and Blowfish are two widely known
symmetric-key block ciphers that were considered secure for
many years. However, with rapid advancements in computing
power and the emergence of stronger algorithms like AES, their
effectiveness in modern cryptographic systems has significantly
changed.
1. Triple DES (3DES):
a) Strengths:
 Improved security over DES: By applying DES three
times with different keys, 3DES increases the effective key
size from 56 bits to 112 or 168 bits.
 Resistant to brute-force attacks compared to original
DES.
 Still supported in legacy systems, such as old banking
and financial infrastructures.
b) Limitations:
 Very slow performance: 3DES is computationally heavy
because it performs 48 rounds of DES operations (16
rounds × 3).
 Small block size (64 bits) makes it vulnerable to:
o Birthday attacks,
o Collision attacks,
o Sweet32 vulnerability in long sessions.
 Being deprecated: Organizations like NIST and major
browsers have recommended phasing it out due to
inefficiency and increasing attack feasibility.
c) Modern Evaluation:
3DES is not suitable for modern high-speed applications, secure
web communication, or large data encryption. It remains
functional for compatibility but is no longer recommended as a
primary security algorithm.
2. Blowfish:
a) Strengths:
 Fast and efficient in software implementations, especially
on older hardware.
 Variable key size (32 to 448 bits) allows flexible security
levels.
 Widely used in tools like bcrypt (for password hashing).
b) Limitations:
 64-bit block size, similar to 3DES, makes it vulnerable to
birthday and collision-based attacks.
 Key setup time is slow, which affects real-time encryption
systems.
 The algorithm's structure is now considered less secure
compared to modern ciphers like AES.
c) Modern Evaluation:
Blowfish is still secure for some applications but has mostly
been replaced by stronger and more efficient algorithms such
as AES and Twofish. Its successor, Twofish, offers better
performance and a 128-bit block size.

Q.4. Describe the key distribution problem in conventional


encryption and outline one method to address it.
Ans. In conventional (symmetric) encryption, the same secret
key is used for both encryption and decryption. The major
challenge is how to securely share this key between the sender
and the receiver before communication begins. This is known
as the key distribution problem.
Because the key must be exchanged through some
communication channel, there is a risk that:
 an attacker may intercept the key,
 the key may be copied or modified, or
 it may be exposed through insecure transmission
methods.
If an attacker obtains the key, they can decrypt all messages,
making the entire communication insecure. Thus, secure key
distribution is essential for the effectiveness of symmetric
encryption systems.
Method to Address the Key Distribution Problem: Diffie–
Hellman Key Exchange:
One widely used method to solve this problem is the Diffie–
Hellman key exchange protocol.
How it works:
 Both parties agree on public values (which can be safely
shared).
 Each party generates a private secret value.
 They exchange only the public components.
 Using mathematical operations, both parties
independently compute the same shared secret key.
 This key is never transmitted over the network.
Because an attacker can see only the public values and not the
private ones, it is computationally infeasible to derive the
shared key. This allows two parties to establish a secret key
securely over an insecure channel.

Q.5. How many kinds of cyber-attacks are there? What is the


aftermath of a cyber-attack?
Ans. Cyber-attacks come in many forms, each targeting
different weaknesses in systems, networks, and users. While
the exact number varies depending on classification, the major
types of cyber-attacks commonly recognized include:
1. Malware Attacks: Viruses, worms, trojans, ransomware,
and spyware that infect systems and damage or steal data.
2. Phishing and Social Engineering: Tricking users into
revealing passwords, OTPs, or financial information through
fake emails, messages, or websites.
3. Denial of Service (DoS/DDoS) Attacks: Overloading
servers with traffic to make services unavailable to legitimate
users.
4. Man-in-the-Middle (MITM) Attacks: Intercepting
communication between two parties to steal or alter
information.
5. SQL Injection: Injecting malicious SQL commands into a
website’s database to extract or manipulate data.
6. Password Attacks: Brute force, dictionary attacks, and
credential stuffing to break into accounts.
7. Zero-Day Exploits: Attacking vulnerabilities that are
unknown to developers or security teams.
8. Insider Attacks: Unauthorized actions by employees or
trusted individuals who have system access.
These represent the major categories, though many subtypes
and variations exist.
Aftermath of a Cyber-Attack:
A cyber-attack can have severe and long-lasting consequences.
The major impacts include:
1. Financial Loss: Organizations may lose money through
fraud, ransom payments, downtime, or recovery costs. For
businesses, cyber-attacks can cost millions.
2. Data Breach and Privacy Loss: Sensitive information such
as personal data, credit card numbers, and confidential
business files may be stolen or exposed.
3. Operational Disruption: Systems may become unusable,
services can shut down, and critical operations may be
interrupted—for example, hospitals, banks, or transport
systems.
4. Reputation Damage: Users lose trust in organizations that
suffer breaches, leading to customer loss and long-term brand
damage.
5. Legal and Regulatory Consequences: Companies may
face lawsuits, penalties, or compliance issues due to failure to
protect user data.
6. Intellectual Property Loss: Trade secrets, designs,
formulas, or research data can be stolen, affecting long-term
competitiveness.
7. Long-Term Security Risks: Once breached, attackers may
leave backdoors, leading to repeated attacks and persistent
threats.

ASSIGNMENT – 2

Q.1. State Euler's Theorem. How does it generalize Fermat's


Little Theorem?
Ans. Euler’s Theorem:
If n is a positive integer and a is an integer such that
gcd ⁡(a ,n)=1, then:
ϕ (n )
a ≡1 (mod n)

where ϕ (n)is Euler’s totient function.


How it generalizes Fermat’s Little Theorem (FLT):
Fermat’s Little Theorem is a special case of Euler’s theorem
when n is a prime number p.
For prime p:
ϕ ( p)= p−1

Substituting in Euler’s theorem:


p−1
a ≡1(mod p)

This is exactly Fermat’s Little Theorem.

Q.2. What is Elliptic Curve Cryptography? Also differentiate


between Elliptic Curve Cryptography and RSA.
Ans. Elliptic Curve Cryptography (ECC): ECC is a public-key
cryptographic technique based on the algebraic structure of
elliptic curves over finite fields.
Its security depends on the hardness of the Elliptic Curve
Discrete Logarithm Problem (ECDLP), which is computationally
much harder than the integer factorization problem used in
RSA.
ECC provides high security with much smaller key sizes, making
it efficient for mobile devices, IoT, and high-speed secure
communications.
Difference Between ECC and RSA:
Feature ECC RSA

Integer
Elliptic Curve Discrete
Security Basis Factorization
Logarithm Problem
Problem
Feature ECC RSA

Very small (e.g., 256-bit Very large keys


Key Size Needed
ECC ≈ 3072-bit RSA) required

Faster, efficient for low- Slower with large


Performance
power devices keys

Memory/
Low High
Computation

Mobile, IoT, modern Servers, legacy


Usage
SSL/TLS systems

Q.3. In the RSA algorithm, what constitutes the public key and
what constitutes the private key?
Ans. In the RSA algorithm, two mathematically related keys are
generated: a public key for general distribution and a private
key that must be kept secret. Both keys are created during the
key-generation process using two large prime numbers.
1. Public Key:
The public key is used for encryption (by others) and digital
signature verification.
It contains:
1. n (the modulus):
o Computed as n = p × q, where p and q are large
prime numbers.
o n is part of both the public and private keys.
2. e (the public exponent):
o A number chosen such that 1 < e < φ(n) and gcd(e,
φ(n)) = 1.
o Common values include 3, 17, or 65537 for efficiency.
Thus, the public key is (e, n).
This key can be published or shared freely.
2. Private Key
The private key is used for decryption and digital signature
generation.
It contains:
1. d (the private exponent):
o Computed as the modular multiplicative inverse of e:
−1
d ≡e mod ϕ( n)

o This ensures that RSA decryption is possible.


2. n (the modulus):
o The same modulus used in the public key.
Thus, the private key is (d, n).
This key must be kept secret to maintain security.

Q.4. Describe the three main uses of public-key cryptography:


Encryption/Decryption, Digital Signatures, and Key Exchange.
Ans. 1. Encryption/Decryption:
 The sender encrypts data using the receiver’s public key.
 Only the receiver can decrypt it using their private key.
This ensures confidentiality in communication.
2. Digital Signatures:
 The sender signs a message using their private key.
 Anyone can verify the signature using the sender’s public
key.
This provides authentication, integrity, and non-
repudiation.
3. Key Exchange:
Public-key techniques (e.g., Diffie–Hellman, RSA key transport)
help two parties establish a shared secret key over insecure
channels.
This key is later used for fast symmetric encryption such as
AES.
These three uses form the backbone of secure systems like
HTTPS, email security, and blockchain.

Q.5. (a)State the Chinese Remainder Theorem for a system of


two congruences with coprime moduli.
Ans. Let m1 and m2 be coprime integers
For the system:
x ≡ a1 (mod m1 )x ≡ a2 (mod m2)

there exists a unique solution modulo m1 m2.


The solution is:
x=a 1 M 1 y1 + a2 M 2 y 2 (mod m1 m2 )

where:
 M =m1 m2

 M 1=M /m1

 M 2=M /m2
−1
 y 1=M 1 (mod m1 )
−1
 y 2=M 2 (mod m2)

(b) Develop a method to integrate primality testing techniques


into a real-world cryptographic system, and assess its
efficiency.
Ans. Method to Integrate Primality Testing in
Cryptographic Systems:
1. Random large-number generation:
o Generate random odd integers of desired bit-length
(e.g., 1024/2048-bit).
2. Apply fast probabilistic primality tests:
o Use Miller–Rabin test with multiple rounds.
o Ensures high probability of primality.
3. Apply deterministic test for final check:
o Use deterministic variants for specific ranges (e.g.,
deterministic Miller–Rabin for < 2⁶⁴).
o Or use AKS for theoretical certainty (rarely used in
practice due to slow speed).
4. Use strong prime generation:
o Ensure primes meet cryptographic properties such
as:
 Sufficient size
 Avoid small factors
 Ensure p−1 or p+1has large prime factors
5. Integrate into key generation:
o For RSA: generate pand q using above steps.
o For ECC: ensure field prime or curve parameters
satisfy security guidelines.
6. Periodic re-testing:
o For long-lived systems, periodically revalidate primes
or rotate keys.
7. Efficiency Assessment:

Primality Test Type Speed Use Case


Standard for large primes (512–
Miller–Rabin Probabilistic Very fast
4096 bits)
Very
AKS Deterministic Not used in real systems
slow
Solovay–Strassen Probabilistic Fast Less common today
Primality Test Type Speed Use Case
Elliptic Curve Primality
Deterministic Medium Rare but strong applications
Proving (ECPP)

ASSIGNMENT – 3

Q.1. Illustrate how the Diffie-Hellman Key Exchange algorithm


establishes a shared secret over an insecure channel.
Ans. The Diffie–Hellman (DH) algorithm allows two parties to
establish a common secret key even if an attacker is listening
on the communication line.
Step-by-Step Process
1. Public Parameters (known to everyone):
o A large prime number p
o A primitive root modulo p: g
2. Private Keys (kept secret):
o Alice chooses private key a
o Bob chooses private key b
3. Compute Public Keys:
o Alice computes A=g a mod p
o Bob computes B=gb mod p
4. Exchange Public Keys Over Insecure Channel:
o Alice sends A to Bob
o Bob sends B to Alice
(Even if an attacker intercepts these, they cannot
compute the secret.)
5. Compute Shared Secret:
o Alice computes S=B a mod p=¿
o Bob computes S= A b mod p=¿
Both obtain the same shared secret S=g ab mod p .
An eavesdropper only knows g , p , A , B, but not the secret values a
or b , so cannot compute gab .

Q.2. Propose a secure key management scenario integrating


ECC and evaluate its effectiveness in a modern IoT
environment.
Ans. ECC-based Secure Key Management in IoT
1. Device Registration
o Each IoT device is provisioned with an ECC key pair
( PK , SK ) based on ECDSA/ECDH.

o Public key is stored in the cloud server.


2. Mutual Authentication
o Device signs a challenge using ECDSA and cloud
verifies.
o Cloud signs a challenge and device verifies.
3. Session Key Establishment
o Both perform Elliptic Curve Diffie–Hellman
(ECDH) to derive a shared symmetric key.
o The symmetric key (AES-128/256) is used for actual
data encryption.
4. Key Rotation
o Periodically, devices regenerate ephemeral ECC keys
to maintain forward secrecy.
5. Revocation Mechanism
o If a device is compromised, its public key is removed
from the cloud registry.
Effectiveness in IoT Environment:
 High security with small keys (e.g. 256-bit ECC =
3072-bit RSA) → Saves memory and bandwidth.
 Efficient computation → Lower battery consumption.
 Scalable → Thousands of IoT nodes can authenticate
quickly.
 Forward secrecy using ECDH ephemeral keys.
 Lightweight enough for microcontrollers (ESP32, ARM
Cortex-M, etc.)
Q.3. Assess the advantages of Elliptic Curve Cryptography
(ECC) over traditional public-key systems in the context of
resource-constrained devices.
Ans. Advantages of ECC
Traditional
Feature ECC
(RSA/DH)

Very large (2048–


Key Size Very small (256-bit)
4096 bit)

Computation Fast scalar Slow modular


Speed multiplication exponentiation

Low RAM + small


Memory Usage High RAM usage
certificates

Power Very low (great for


High
Consumption IoT)

Transmission
Small signatures Large signatures
Overhead

Security Level Very high per bit Lower per bit

Why ECC is ideal for resource-constrained devices:


 Requires less CPU cycles, conserving battery.
 Reduces network overhead due to small key/packet size.
 Works efficiently on microcontrollers and low-power chips.
 Enables security features (authentication, encryption) that
would be too heavy with RSA.

Q.4. Compare the roles of OAKLEY and ISAKMP in managing


cryptographic keys during secure communication.
Ans. OAKLEY
 A key-exchange protocol based on Diffie–Hellman.
 Defines how to:
o Select DH groups
o Perform authentication
o Protect against replay attacks
o Maintain perfect forward secrecy
 Generates keying material.
ISAKMP (Internet Security Association and Key
Management Protocol)
 A framework for:
o Establishing
o Negotiating
o Modifying
o Deleting
Security Associations (SAs).
 Does not specify how keys are generated; it only defines
the structure for exchanging them.

Comparison Table:
Feature OAKLEY ISAKMP

Performs secure Framework for negotiating


Purpose
key exchange SAs

No (relies on other
Uses DH? Yes
protocols like OAKLEY)

Handles
Yes Yes
Authentication

Produces Final
Yes No
Keys

Layer Key exchange Key management


Feature OAKLEY ISAKMP

protocol architecture

Q.5. Describe the Diffie-Hellman Key Exchange algorithm in


detail. Include the mathematical formulation and explain why it
is computationally infeasible for an eavesdropper to determine
the shared secret key.
Ans. Mathematical Formulation:
1. Public Values
o Large prime p
o Generator g(primitive root mod p)
2. Private Keys
o Alice chooses random a , Bob chooses random b .
3. Compute Public Keys
a b
A=g mod pB=g mod p

4. Exchange Public Keys


o Alice → Bob : A
o Bob → Alice : B
5. Compute Shared Secret
o Alice:
a
S=B mod p=¿

o Bob:
b
S= A mod p=¿

Both compute the same value S.


Why an Eavesdropper Cannot Determine the Shared
Secret
An eavesdropper knows:
a b
p , g , A=g mod p , B=g mod p

To compute the secret S=g ab mod p , the attacker would have to


determine either:
 a from ga mod p, or

 b from gb mod p.

This requires solving the Discrete Logarithm Problem


(DLP):
a
Given g , p , g mod p find a

DLP is computationally infeasible for large primes (e.g., 2048


bits).
 No known polynomial-time algorithm exists.
 Modern cryptosystems rely on this hardness.
Thus, even with access to all exchanged messages, the
eavesdropper cannot compute the shared key.

ASSIGNMENT - 4

Q.1. Describe how a Message Authentication Code (MAC) is


generated and verified. Use a diagram if necessary
Ans. A Message Authentication Code (MAC) is a short piece
of information (tag) used to authenticate a message and to
provide integrity and authenticity — i.e., it proves the message
came from someone who knows a shared secret key and that it
wasn’t altered.
Components
 K: symmetric secret key shared by sender and receiver.
 M: message to be protected.
 MAC(M,K): the tag computed from M and K using a MAC
algorithm (e.g., HMAC, CBC-MAC, CMAC).
Generation (Sender)
1. Input message M and key K .
2. Compute tag T =MAC ( K , M ).
3. Send the pair ( M ,T )to the receiver.
Verification (Receiver)
1. Receive ( M ' ,T ' ).
2. Compute T '' =MAC(K , M ' )using the same key and MAC
algorithm.
3. Accept if and only if T '' =T ' . Otherwise reject.
Security Intuition
An attacker without K cannot compute a valid tag for a modified
message (except with negligible probability).

[Link] how birthday attacks compromise the security of


hash functions and suggest preventive measures.
Ans. Birthday attack:
 Based on the birthday paradox: in a group of ~√N
randomly chosen items, there's a high chance of a
collision among N possible values.
 For an n-bit hash function, there are 2npossible outputs. A
generic collision attack requires about 2n /2hash operations
to find a collision (not 2n).
 Thus a hash of length n bits offers collision resistance
roughly equivalent to n /2bits of brute-force security.
Consequences
 For a 128-bit hash (e.g., MD5 output size = 128), collision
resistance is ~264 — which is reachable by modern
attackers, making collisions feasible.
 Collision attacks can be used to create two different files
with the same hash (dangerous for certificates, signatures,
software distribution).
Preventive measures
1. Use longer hash outputs: Prefer SHA-256 (256-bit) or
SHA-3-256 or larger. For collision resistance target 128+
bits, use 256-bit hashes (gives ~128-bit collision
resistance).
2. Deprecate weak hashes: Avoid MD5 and SHA-1 for
collision-sensitive uses (already broken/unsafe).
3. Use keyed hashes (HMAC) for authentication: HMAC
resists collision-based MAC forgery even if collisions exist
in plain hash (because attacker lacks the key).
4. Use digital signatures over hashed messages with
collision-resistant hashes: ensures an attacker cannot
produce two messages with same hash to fool a signer.
5. Include context and randomness: for protocols, include
timestamps, nonces, unique identifiers — reduces
exploitability of collision attacks.
6. Algorithm agility and timely migration: plan for
migration to stronger hash algorithms if weaknesses
found.
7. Use larger signature/hash parameters in long-lived
systems (e.g., certs valid many years).

Q.3. Demonstrate the process of generating a Message


Authentication Code (MAC) for ensuring data integrity.
Ans. HMAC-SHA256 algorithm:
Let:
 H be SHA-256 (output length = 256 bits).

 Bbe block size of the hash (for SHA-256, B=512bits = 64


bytes).
 K the secret key (if longer than B, use K=H (K ); if shorter,
pad with zeros to length B).
 Define ipad = 0x36 repeated B bytes, opad = 0x5c
repeated B bytes.
Steps to compute HMAC(K, M)
1. If ∣ K ∣> B , set K=H (K ). Pad K with zeros to length B.
2. Compute K ipad =K ⊕ ipad .
3. Compute K opad =K ⊕ opad .
4. Compute inner = H (K ipad ∥ M ). (\| denotes concatenation)
5. Compute outer = H (K opad ∥ inner).
6. Output tag T =outer (256-bit).
Example (conceptual)
 Key K = 0x0a0b0c... (padded to 64 bytes)
 Message M = "Pay $1000 to Alice"
 Compute inner hash => e.g. 0xabc...
 Compute outer hash => e.g. final MAC 0x9f3...
 Send (M, MAC).
Verification
Receiver repeats same steps with shared K and M' to compute
MAC' and checks equality.
Why HMAC is secure
 It combines keyed input and two hash computations; even
if internal hash collisions are found, HMAC remains secure
under standard assumptions.
 HMAC resists length-extension attacks that afflicted plain
hash-based MACs.

Q.4. Evaluate the differences between MD5 and SHA algorithms


in terms of collision resistance and overall security.
Ans. 1. Collision Resistance
 MD5:
o 128-bit output
o Collisions found easily
o Vulnerable to birthday attacks
o Not recommended for security
 SHA Family:
o SHA-1 (160-bit): Collisions found → insecure
o SHA-256/512: No practical collisions known → strong
o SHA-3: Most secure modern standard
2. Overall Security
Algorith Hash
Security Status
m Size

Broken (collisions
MD5 128 bits
easy)

Weak (collisions
SHA-1 160 bits
exist)

SHA-
256 bits Strong
256

SHA-3 Variable Very strong


3. Performance
 MD5 is fast but insecure.
 SHA-256 is slower but secure.
 SHA-3 is secure and flexible

Q.5. (a) Design a secure communication protocol using Digital


Signatures and justify its effectiveness in preventing
unauthorized access.
Ans. Secure Communication Protocol Using Digital
Signatures
Steps:
1. Key Generation
o Sender and receiver generate a public–private key
pair.
2. Message Composition
o Sender prepares a message M.
3. Hashing
o Compute hash:
h=H (M )

4. Digital Signature Creation


o Sender signs the hash using their private key
(K_priv):
S=Sign (h , K priv )

5. Send Message
o Sender sends M + Signature S.
6. Verification
o Receiver computes hash again:
'
h =H ( M )

o Receiver uses sender’s public key to verify:


'
Verify(S ,h , K pub )
Why It Prevents Unauthorized Access
 Only the legitimate sender can sign using their private
key.
 Receiver verifies authenticity using the public key.
 Any tampering changes the hash → verification fails.
Thus, it guarantees:
 Authentication
 Integrity
 Non-repudiation

(b) Explain the RSA digital signature scheme and the Digital
Signature Standard (DSS/DSA). Compare their operational
principles, security basis, and computational efficiency.
Ans. RSA Digital Signature Scheme
 Uses the RSA algorithm in reverse order of encryption:
1. Compute hash of message.
2. Sign hash using private key (d):
d
S=h mod n

3. Receiver verifies using public key (e):


e
h=S mod n

Properties
 Based on integer factorization problem.
 Can be used for both encryption & signature.
DSS/DSA Digital Signature Algorithm
 Standardized by NIST.
 Uses discrete logarithms over finite fields or elliptic
curves.
 Steps:
1. Generate a random number k for each signature.
2. Compute signature pair (r, s).
3. Verify using public key parameters.
Properties
 Based on Discrete Logarithm Problem (DLP).
 Used only for signatures, not encryption.
Comparison: RSA vs DSA
Feature RSA DSA

Security
Integer Factorization Discrete Logarithm
Basis

Encryption +
Use Cases Signature only
Signature

Signature Slower signing, fast Fast signing, slower


Speed verification verification

Key Sizes Larger Smaller

Requires random k for


Determinism Deterministic
each signature

Modern ECDSA (elliptic curve


RSA-PSS
Variant version)
ASSIGNMENT - 5

Q.1. Why does PGP compress data before encrypting it?


Ans. PGP (Pretty Good Privacy) compresses data before
encryption to improve both security and efficiency.
Reasons for Compression Before Encryption:
1. Reduces Data Size
o Compression decreases the size of the message.
o Faster transmission and reduced storage
requirements.
2. Enhances Security
o Compressing data removes patterns and
redundancies.
o This makes cryptanalysis harder because attackers
cannot identify repeated structures that usually exist
in plaintext.
3. Improves Encryption Performance
o Smaller data → faster encryption process.
4. Prevents Known-Plaintext Attacks
o By altering the structure of plaintext before
encryption, compression helps mask predictable
information.

Q.2. Assess the effectiveness of combining security


associations in IPsec for secure communication and propose an
optimization strategy.
Ans. In IPsec, a Security Association (SA) defines the
parameters (keys, algorithms, SPI) used for secure
communication. For full security, IPsec often uses multiple SAs
—one for each direction and sometimes one for Encapsulation
(ESP) and another for Authentication (AH).
Effectiveness of Combining SAs
1. Stronger Security
o Using separate SAs for encryption and authentication
adds layered protection.
o ESP + AH combination protects confidentiality,
integrity, and replay attacks.
2. Flexibility
o Administrators can choose different cryptographic
algorithms for different SAs.
3. Bidirectional Security
o Each direction has a different SA, reducing the risk of
key compromise.
Challenges
 Increased processing overhead.
 More memory usage on endpoints.
 More complex key management.
Optimization Strategy
Use “tunnel mode with ESP only” + “IKE for automatic
key refresh”
 ESP already provides:
o Encryption
o Integrity
o Anti-replay
 AH becomes unnecessary → reduces number of SAs.
Benefits
 Lower overhead and simpler configuration.
 Faster packet processing.
 Maintains strong confidentiality and integrity.

Q.3. Design a comprehensive firewall architecture incorporating


modern design principles and evaluate its effectiveness against
advanced persistent threats.
Ans. A modern firewall architecture should combine multiple
layers of protection.
Firewall Architecture:
1. Perimeter Firewall (Layer 1)
 Packet filtering
 Stateful inspection
 Blocks unauthorized traffic
 Basic DOS prevention
2. DMZ (Demilitarized Zone) (Layer 2)
 Hosts public-facing services (web, FTP, mail).
 Isolated from internal network to reduce risk.
3. Application-Layer Firewall / Web Application Firewall
(WAF) (Layer 3)
 Protects against:
o SQL injection
o XSS
o CSRF
 Deep packet inspection checks application-level behavior.
4. Intrusion Detection and Prevention Systems (IDS/IPS)
(Layer 4)
 Signature-based + anomaly detection
 Prevents:
o Malware
o Zero-day attacks
o Lateral movement
5. Next-Generation Firewall (Layer 5)
 DPI (Deep Packet Inspection)
 User identity and device profiling
 Sandboxing suspicious files
6. Internal Segmentation Firewall (Layer 6)
 Limits attacker movement across network.
 Protects sensitive segments such as:
o Database servers
o HR data
o Finance
Effectiveness Against Advanced Persistent Threats
(APTs):
Strengths
 Multi-layer (defense-in-depth) reduces chances of a single
point of failure.
 Segmentation slows down attackers, limiting breach
impact.
 NGFW + IDS/IPS detects zero-day behaviors.
 DMZ keeps critical systems isolated from external
exposure.
Limitations
 Requires skilled monitoring and configuration.
 Expensive to implement and maintain.
 APTs using social engineering may still bypass perimeter
defenses.

Q.4. Compare the roles of Secure Socket Layer (SSL) and


Transport Layer Security (TLS) in ensuring web security.
Ans. SSL and TLS are cryptographic protocols that secure
communication over networks.
SSL (Secure Socket Layer)
 Developed earlier (SSL 2.0, SSL 3.0).
 Provides:
o Encryption
o Server authentication
o Integrity
 Known vulnerabilities (POODLE).
 Deprecated—no longer considered secure.
TLS (Transport Layer Security)
 Successor to SSL (TLS 1.0 → 1.3).
 More secure and faster.
 Supports stronger ciphers (AES-GCM, ChaCha20).
 Reduces handshake overhead in TLS 1.3.
 Widely used in HTTPS today.
Key Differences
Feature SSL TLS

Security Weak,
Strong, modern
Level broken

Cipher
Outdated Strong modern encryption
Suites

Less
Handshake More secure and optimized
efficient

Usage Standard for all secure web


Deprecated
Today traffic

Q.5. Explain how Kerberos ensures mutual authentication


between a client and a server in a distributed environment.
Ans. Kerberos uses shared secrets and trusted third-party
authentication to provide mutual authentication.
How Kerberos Works
1. Authentication Server (AS)
 Client sends request to AS.
 AS verifies user credentials and issues a Ticket-Granting
Ticket (TGT) encrypted with TGS key.
2. Ticket-Granting Service (TGS)
 Client uses TGT to request access to a specific server.
 TGS issues a Service Ticket containing:
o Client identity
o Timestamp
o Session key
3. Mutual Authentication with Server
 Client sends the service ticket to the server.
 Server decrypts and gets the session key.
 Client sends an authenticator (timestamp encrypted with
session key).
 Server responds by sending back the timestamp + 1 (also
encrypted).
Why This Ensures Mutual Authentication
Client Authentication
 Server trusts that only the legitimate user could have
obtained the valid ticket from the TGS.
Server Authentication
 When the server proves it knows the session key by
returning the timestamp, the client knows it is
communicating with the correct server.
Benefits
 No passwords transmitted across network.
 Protects against replay attacks.
 Efficient for large distributed systems.
 Provides confidentiality and integrity.

You might also like