CNS Unit 1(Solution)
CNS Unit 1(Solution)
Introduction to Cryptography
Cryptography is a technique used to secure information and communication by converting messages into a
coded format. This ensures that only authorized people can access and understand the information while
preventing unauthorized access.
• "Crypt" → Hidden
• "Graphy" → Writing
Cryptographic techniques rely on mathematical concepts and algorithms to transform data into an
unreadable form. These algorithms are used for:
Secure data storage and transmission
• Confidentiality: Information can only be accessed by the person for whom it is intended and no other
person except him can access it.
• Integrity: Information cannot be modified in storage or transition between sender and intended receiver
without any addition to information being detected.
• Non-repudiation: The creator/sender of information cannot deny his intention to send information at a
later stage.
• Authentication: The identities of the sender and receiver are confirmed. As well destination/origin of the
information is confirmed.
• Interoperability: Cryptography allows for secure communication between different systems and platforms.
• Adaptability: Cryptography continuously evolves to stay ahead of security threats and technological
advancements.
Key Features of Cryptography with Examples
Confidentiality
• Ensures that only the intended recipient can access the information.
• Example: When you send a message on WhatsApp, it is end-to-end encrypted, meaning only the sender
and receiver can read the message. Even WhatsApp itself cannot access it.
Integrity
• Ensures that the data is not altered during transmission or storage without detection.
• Example: When downloading software from a trusted website, a checksum (hash value) is provided. If the
downloaded file is altered, its hash value will not match, indicating tampering.
Non-repudiation
• Prevents the sender from denying that they sent the information.
• Example: In online banking, when a user makes a transaction, a digital signature is attached. This ensures
that the sender cannot deny authorizing the transaction later.
Authentication
Interoperability
Adaptability
Encipherment (Encryption): Converts data into a secure format (e.g., AES, RSA).
Conclusion:
OSI Security Architecture ensures safe communication over networks by preventing attacks, applying
security mechanisms, and using security services. It is widely adopted for building secure, reliable, and
scalable networks.
A type of encryption where the same key is used for both encryption and decryption. It is fast and efficient
but requires a secure way to share the key.
A type of encryption that uses two keys – a public key for encryption and a private key for decryption. It is
more secure but slower than symmetric encryption, as the private key remains confidential.
1. Passive Attack:
2. Active Attack:
Passive attacks are harder to detect, while active attacks are more destructive but can often be identified.
5. Write a short note on Security Services.
Security Services
Security services are essential mechanisms that ensure the protection of data, communication, and systems
from unauthorized access, tampering, and attacks. These services help in maintaining the confidentiality,
integrity, and availability of information in a secure environment.
1. Confidentiality:
o Ensures that sensitive information is accessible only to authorized users and remains hidden from
unauthorized parties.
o Example: Encryption techniques like AES and RSA protect data from being read by unauthorized users.
2. Integrity:
o Guarantees that data remains unchanged during transmission or storage unless modified by authorized
users.
o Example: Hash functions like SHA-256 verify data integrity by generating unique hashes that change if the
data is altered.
3. Authentication:
o Confirms the identity of users, devices, or systems before allowing access.
o Example: Username-password authentication, biometric verification, and digital certificates (e.g., SSL/TLS
certificates for secure websites).
4. Non-Repudiation:
o Prevents an entity (user or system) from denying their actions or transactions after they have taken place.
o Example: Digital signatures ensure that the sender of a message cannot deny sending it.
5. Access Control:
o Restricts access to resources based on user roles and permissions.
o Example: Role-Based Access Control (RBAC) allows only authorized users to access specific files or systems.
6. Availability:
o Ensures that data, systems, and services are accessible to authorized users whenever needed, even during
attacks or failures.
o Example: Protection against Denial of Service (DoS) attacks ensures continuous system operation.
6. Explain Playfair cipher substitution technique in detail. Find out cipher text for the given key and
plaintext:
o Key: ENGINEERING
o Plaintext: COMPUTER SCIENCE AND ENGINEERING
• Same Row → Replace each letter with the next right letter.
• Same Column → Replace each letter with the next below letter.
• Rectangle Rule → Swap letters in opposite corners.
4. Decryption Process
Block cipher modes define how large amounts of data are securely encrypted using a block cipher. Since a
block cipher processes fixed-size blocks (e.g., 128 bits), these modes help handle larger data securely.
• Each block is XORed with the previous ciphertext block before encryption.
• Uses an Initialization Vector (IV) for randomness.
• Usage: Secure file encryption, authentication.
Advantage: More secure than ECB, hides patterns.
• Similar to CFB, but sends encrypted output as feedback instead of actual ciphertext.
• Prevents error propagation across blocks.
• Usage: Secure transmission over noisy channels.
Advantage: Bit errors don’t spread across blocks.
Data Encryption – Protects sensitive data like passwords, credit card details.
Conclusion:
Each block cipher mode has different security properties. CTR and CBC are commonly used today, while
ECB is insecure and should be avoided.
12. Why is it important to study Feistel cipher?
The Feistel Cipher is a widely used symmetric key encryption technique that forms the basis for many
encryption algorithms like DES. Studying it is important for several reasons:
2. Security Analysis
Example: Cybersecurity experts study Feistel ciphers to detect weaknesses in old encryption methods.
Conclusion
Studying Feistel Cipher is essential for understanding encryption, improving security, and developing
future cryptographic methods.
DES operates on a 64-bit block of plaintext. After an initial permutation, the block is divided into two
halves:
1. Key Transformation:
o A 48-bit subkey is derived using the PC-2 (Permuted Choice-2) table.
2. Expansion Permutation (E-Table):
o The 3️2-bit right half is expanded to 48 bits using a predefined E-table.
o Each 4-bit group is expanded to 6-bit groups.
3. S-Box Substitution:
o The 48-bit expanded data is divided into 8 groups of 6 bits.
o Each group is passed through an S-box (Substitution box) which reduces it to 4 bits.
o There are 8 different S-boxes, each with a unique lookup table.
4. P-Box Permutation:
o The 3️2-bit output from the S-boxes is rearranged using the P-box permutation table.
o This step ensures better diffusion by mixing the bits.
5. XOR and Swap:
o The P-box output is XORed with the left half of the plaintext.
o The left and right halves are swapped, completing the round.
Final Step:
After 16 rounds, the left and right halves are joined and a Final Permutation (IP⁻¹) is applied, producing the
64-bit ciphertext.
14. Explain Byte substitution and Shift row operation of AES in detail.
https://www.geeksforgeeks.org/advanced-encryption-standard-aes/
16. Explain the avalanche effect in DES and discuss the strength of DES in brief.
The Avalanche Effect in cryptography means that a small change in the plaintext or key results in a
significant change in the ciphertext.
• DES (Data Encryption Standard) follows a Feistel structure with 16 rounds of encryption.
• A slight change in the input (even 1 bit) causes at least 50% of the output bits to flip, making it
highly unpredictable.
Why is it Important?
2. Strength of DES
Advantages of DES:
Weaknesses of DES:
Conclusion
17. Explain the function of S-BOX in DES and also explain the avalanche effect.
The S-Box (Substitution Box) is used in DES to make encryption more secure by changing some bits
unpredictably.
The Avalanche Effect means that a small change in input (plaintext or key) causes a big change in the
output (ciphertext).
Conclusion
Depending on the cryptographic system and the attacker's available information, encryption attacks can be
classified into six main types:
• The attacker tries all possible keys until the correct one is found.
• Effective Against: Weak encryption methods or short keys.
• Example: Guessing a 4-digit ATM PIN (0000-9999) by trying all combinations.
Defense: Use longer keys (e.g., 256-bit encryption in AES).
2. Ciphertext-Only Attack
• The attacker only has the encrypted message (ciphertext) but not the plaintext or key.
• Goal: Analyze the ciphertext to guess the plaintext or encryption key.
• Example: Observing repeated ciphertext patterns in ECB mode encryption.
Defense: Use strong encryption with randomness (e.g., AES in CBC or GCM mode).
• The attacker can choose plaintext and get its encrypted version (ciphertext).
• Goal: Use this knowledge to determine the encryption key.
• Example: Submitting known inputs to an encryption API and analyzing outputs.
Defense: Use randomized encryption schemes (e.g., AES-GCM with unique IVs).
• The attacker can choose a ciphertext and get its decrypted plaintext.
• Goal: Use the decrypted output to deduce the encryption key.
• Example: An attacker modifying an encrypted bank transfer request and observing the response.
Defense: Use secure padding schemes (e.g., RSA-OAEP) to prevent decryption attacks.
• The attacker has access to both plaintext and ciphertext and tries to infer the key.
• Example: If "HELLO" encrypts to "XGJ9K", patterns can be analyzed to break the cipher.
Defense: Use strong encryption algorithms with randomization (e.g., AES with a unique IV).
• The attacker has access to both the encryption key and the algorithm.
• Goal: Use this information to decrypt messages or find vulnerabilities.
• Example: Using weak keys in outdated encryption (e.g., DES, MD5).
Defense: Use secure key management and modern encryption standards (AES, SHA-256).
Conclusion
Encryption is critical for security, but attackers use various techniques to break it. Using strong encryption
methods, key management, and secure padding schemes can help defend against these attacks.
Blowfish is a symmetric key encryption algorithm designed by Bruce Schneier in 1993️. It is fast, secure,
and flexible, making it widely used in applications like password storage, VPNs, and secure file transfers.
Features of Blowfish
1. Key Expansion:
o The key is used to generate 18 subkeys (P-array) and 4 S-boxes (Each with 256 entries).
2. Feistel Network (16 Rounds):
o The 64-bit plaintext is divided into two 3️2-bit halves (Left & Right).
o Each round applies substitution, permutation, and XOR operations.
o The right half is modified using a complex F-function.
o The halves are swapped after each round (except the last round).
3. Final XOR & Combination:
o After 16 rounds, the halves are XORed with P-Array keys and combined to form the
ciphertext.
Conclusion
Blowfish is a fast and secure encryption algorithm that is widely used for protecting sensitive data. It is
flexible, efficient, and still relevant today despite newer algorithms like AES.
A Meet-in-the-Middle Attack (MITM) is a method used to break double encryption (e.g., Double DES)
faster than brute force. Instead of trying all key combinations, it splits the attack into two steps and finds a
match in the middle.
Formula:
C=E(K2,E(K1,P))
Conclusion
MITM attacks make double encryption weak by finding a match in the middle. This is why Double DES is
insecure, and modern encryption methods like AES are preferred.
A) Transposition Technique
1. Rail Fence Cipher – Writes text in a zigzag pattern and reads it row-wise.
2. Columnar Transposition – Writes text in a table and reads it in a scrambled column order.
3. Route Cipher – Arranges text in a grid and reads it in a specific pattern (e.g., spirals).
A Brute Force Attack, also called exhaustive search, is a method used by attackers to break encryption by
systematically trying every possible key or password until the correct one is found.
ii) Cryptography
Cryptography is the science of secure communication, ensuring that only the intended recipient can access
the message. It provides:
Types of Cryptography:
Conclusion
Triple DES (3️DES) is an improved version of the DES (Data Encryption Standard), designed to provide
stronger security. Since DES uses only a 56-bit key, it became vulnerable to brute-force attacks. 3️DES
enhances security by applying DES encryption three times in succession.
3DES encrypts data using three rounds of DES with either two or three keys:
Formula:
Where:
1. 3️-Key 3️DES: Uses three different keys (K₁, K₂, K₃) → 168-bit key (Most secure).
2. 2-Key 3️DES: Uses only two keys (K₁ = K₃, K₂ is different) → 112-bit key (Moderate security).
Stronger against Brute Force Attacks – Harder to crack than single DES.
Not Future-Proof – Considered outdated and replaced by AES (Advanced Encryption Standard).
Conclusion
Triple DES was a stronger alternative to DES, but due to its slow speed and increasing vulnerabilities, it is
now being replaced by AES for modern encryption needs.
4o
A Brute Force Attack is a trial-and-error method used by attackers to guess passwords or encryption keys.
How It Works?
• The attacker tries every possible combination until they find the correct one.
• If the password is short or simple, it can be cracked quickly.
• Longer and more complex passwords take much longer to break.
Example:
If a password is "123️4", the attacker will try:
"0000" → "0001" → "0002" → ... → "1234" (until they find a match).
ii) Cryptography
Cryptography is the science of securing information so that only authorized people can access it.
Types of Cryptography:
• Brute force attacks try all possible passwords to break security, but strong passwords and
encryption help prevent them.
• Cryptography protects data by ensuring security, privacy, and authentication in digital
communication.
Here’s a quick and easy-to-revise summary of all the topics covered in Unit 1 - CNS (Cryptography and
Network Security). Each topic is explained in simple terms with examples for better understanding.
Cryptography ensures secure communication by converting messages into a coded format. Its key
objectives are:
The OSI model ensures secure communication over networks. It focuses on:
1. Security Attacks:
o Passive (eavesdropping, traffic analysis).
o Active (masquerade, replay, DoS).
2. Security Mechanisms:
o Encryption, digital signatures, traffic padding.
3️. Security Services:
o Authentication, access control, data confidentiality, integrity, non-repudiation.
3️. Symmetric vs Asymmetric Encryption
5. Security Services
6. Playfair Cipher
• A substitution cipher that encrypts pairs of letters using a 5x5 key matrix.
• Example:
o Key: ENGINEERING
o Plaintext: COMPUTER SCIENCE AND ENGINEERING
o Ciphertext: Encrypted using Playfair rules.
7. Hill Cipher
Monoalphabetic Polyalphabetic
Uses one substitution alphabet. Uses multiple substitution alphabets.
Vulnerable to frequency analysis. More secure (e.g., Vigenère Cipher).
9. Vigenère Cipher
18. Blowfish
• A symmetric key encryption algorithm with 64-bit blocks and 448-bit keys.
• Uses 16 rounds of Feistel structure.
• Example: Used in VPNs and password hashing.
Diffusion Confusion
Spreads plaintext influence over ciphertext. Makes ciphertext-key relationship complex.
Example: AES MixColumns. Example: AES SubBytes.
20. Block Cipher vs Stream Cipher
25. Cryptography
This quick revision guide covers all the topics in a concise and easy-to-understand format. Use it to revise
key concepts and examples efficiently!