CNS Unit 3(Solution)
CNS Unit 3(Solution)
Think of a MAC as a digital seal that verifies a message is secure and untampered.
HMAC (Hash-based Message Authentication Code) is a special type of MAC that uses hash functions (like SHA-256) along
with a secret key to generate a secure code.
Example:
Imagine you send an email with a digital seal. If someone changes the message, the seal will no longer match, alerting the
receiver of tampering.
Real-World Example
• Online Banking: HMAC ensures that your transaction details are secure and cannot be altered.
• API Security: Many websites and services (like Amazon, Google) use HMAC for API authentication.
• Wi-Fi Security: WPA2 encryption uses HMAC to protect passwords.
Summary
SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function that converts an input message into a 160-bit (20-byte)
hash value. This hash is often represented as a 40-digit hexadecimal number and is known as a message digest.
HMAC is a cryptographic technique that ensures data integrity and authentication by using:
It is widely used in secure communications like HTTPS, API security, and online banking.
Advantages of HMAC
✔ Prevents Message Tampering – Even if someone intercepts the message, they cannot change it.
Disadvantages of HMAC
Key Management is Difficult – Secret keys must be securely stored and shared.
Not Suitable for Large-Scale Communication – Unlike public-key encryption, HMAC needs a shared secret key between
each sender and receiver.
Short Keys are Weak – If the secret key is too short, hackers can guess it using brute-force attacks.
Conclusion
HMAC is a powerful security method used in online authentication and data integrity. It ensures that messages are not
altered and that the sender is genuine. Due to its two-step hashing process, it provides better security than traditional
MACs and is widely used in secure web communication.
Kerberos provides a centralized authentication server whose function is to authenticate users to servers and servers to
users. In Kerberos Authentication server and database is used for client authentication. Kerberos runs as a third-party
trusted server known as the Key Distribution Center (KDC). Each user and service on the network is a principal.
• Authentication Server (AS): The Authentication Server performs the initial authentication and ticket for Ticket
Granting Service.
• Database: The Authentication Server verifies the access rights of users in the database.
• Ticket Granting Server (TGS): The Ticket Granting Server issues the ticket for the Server
Working of Kerberos
Step-1: User login and request services on the host. Thus user requests for ticket-granting service.
Step-2: Authentication Server verifies user’s access right using database and then gives ticket-granting-ticket and session
key. Results are encrypted using the Password of the user.
Step-3: The decryption of the message is done using the password then send the ticket to Ticket Granting Server. The Ticket
contains authenticators like user names and network addresses.
Step-4: Ticket Granting Server decrypts the ticket sent by User and authenticator verifies the request then creates the
ticket for requesting services from the Server.
Step-5: The user sends the Ticket and Authenticator to the Server.
Step-6: The server verifies the Ticket and authenticators then generate access to the service. After this User can access the
services.
Kerberos is a secure authentication system that allows users to securely access services on a network without repeatedly
entering their password. It uses a centralized authentication server called the Key Distribution Center (KDC) to verify
users and services.
Limitations of Kerberos
• Each service must be modified separately – Every application needs to support Kerberos authentication.
• Requires synchronized clocks – If the system clocks are out of sync, authentication may fail.
• Needs a dedicated Kerberos server – If the Kerberos server fails, no one can log in.
• Assumes workstations are secure – If a hacker steals a workstation, they can misuse the tickets.
• Scalability issues – Managing a large number of users can be challenging.
Conclusion
Kerberos is a powerful authentication system that allows secure access to network services using tickets instead of
passwords. However, it requires proper setup and security measures to work efficiently. It is widely used in corporate
networks, Windows Active Directory, and secure websites.
What is PGP?
PGP (Pretty Good Privacy) is a security tool used to protect emails, files, and digital communication by providing
encryption, authentication, and confidentiality. It ensures that only the intended recipient can read a message and
verifies that the sender is genuine.
1. Symmetric Encryption – Uses a single secret key to encrypt and decrypt data (faster).
2. Public Key Encryption – Uses a public key for encryption and a private key for decryption (more secure).
1. Authentication in PGP
What is Authentication?
Authentication ensures that a message really comes from the claimed sender and has not been tampered with.
Real-Life Example:
Imagine receiving a signed letter from your bank. The signature proves that it’s really from your bank and not someone
pretending to be them.
2. Confidentiality in PGP
What is Confidentiality?
Confidentiality ensures that only the intended recipient can read the message.
Real-Life Example:
Imagine you send a locked box containing a secret letter. The recipient has the only key to open it.
1. The receiver decrypts the session key using their private key.
2. The session key is used to decrypt the message.
3. The message is decompressed to restore the original content.
Even if an attacker intercepts the message, they can’t read it without the private key!
Advantages of PGP
✔ Protects Privacy – Only the intended recipient can read the message.
Disadvantages of PGP
If a Key is Lost, Data is Unreadable – Losing a private key means losing access to encrypted data.
Training Required – Organizations must train employees to use PGP correctly.
Conclusion
PGP is a powerful encryption tool that provides authentication (verifies sender) and confidentiality (secures messages).
Despite its complexity, it remains one of the most trusted methods for securing emails, files, and sensitive data in
personal, corporate, and government communications.
What is X.509?
X.509 is a digital certificate standard used for authentication and secure communication on the internet. It is part of
Public Key Infrastructure (PKI) and ensures data integrity, confidentiality, and authentication.
Think of an X.509 certificate like a digital ID card that proves your identity online, just like a passport verifies your identity
in real life.
1. Each user gets a digital certificate from a trusted Certificate Authority (CA).
2. The certificate contains the user’s public key and other identity details.
3. The certificate is stored in an online directory for easy access.
4. When a user wants to authenticate, they present their X.509 certificate (like showing an ID card).
5. The receiver verifies the certificate using the CA’s digital signature.
6. If the certificate is valid, secure communication is established.
Conclusion
X.509 digital certificates are essential for secure communication on the internet. They help verify identities and encrypt
data, making online transactions and communications safe and trustworthy.
MD5 is a cryptographic hash function algorithm that takes the message as input of any length and changes it into a fixed-
length message of 16 bytes. MD5 algorithm stands for the Message-Digest algorithm. MD5 was developed in 1991
by Ronald Rivest as an improvement of MD4, with advanced security purposes. The output of MD5 (Digest size) is
always 128 bits.MD5 is still the most commonly used message digest for non-cryptographic functions, such as used as a
checksum to verify data integrity, compressing large files into smaller ones securely, etc.
Overview Of MD5 Algorithm
1. Append Padding Bits: In the first step, we add padding bits in the original message in such a way that the total length of
the message is 64 bits less than the exact multiple of 512.
Suppose we are given a message of 1000 bits. Now we have to add padding bits to the original message. Here we will add
472 padding bits to the original message. After adding the padding bits the size of the original message/output of the first
step will be 1472 i.e. 64 bits less than an exact multiple of 512 (i.e. 512*3 = 1536).
2. Append Length Bits: In this step, we add the length bit in the output of the first step in such a way that the total number
of the bits is the perfect multiple of 512. Simply, here we add the 64-bit as a length bit in the output of the first step.
After adding both we will get 512 * n i.e. the exact multiple of 512.
3. Initialize MD buffer: Here, we use the 4 buffers i.e. A B, C, and D. The size of each buffer is 32 bits.
- A = 0x67425301
- B = 0xEDFCBA45
- C= 0x98CBADFE
- D = 0x13DCE476
4. Process Each 512-bit Block: This is the most important step of the MD5 algorithm. Here, a total of 64 operations are
performed in 4 rounds. In the 1st round, 16 operations will be performed, 2nd round 16 operations will be performed, 3rd
round 16 operations will be performed, and in the 4th round, 16 operations will be performed. We apply a different
function on each round i.e. for the 1st round we apply the F function, for the 2nd G function, 3rd for the H function, and
4th for the I function.
We perform OR, AND, XOR, and NOT (basically these are logic gates) for calculating functions. We use 3 buffers for each
function i.e. B, C, D.
Process P Operation
After applying the function now we perform an operation on each block. For performing operations we need
Now take input as initialize MD buffer i.e. A, B, C, D. Output of B will be fed in C, C will be fed into D, and D will be fed into
J. After doing this now we perform some operations to find the output for A.
• In the first step, Outputs of B, C, and D are taken and then the function F is applied to them. We will add modulo
232 bits for the output of this with A.
• In the second step, we add the M[i] bit message with the output of the first step.
• Then add 32 bits constant i.e. K[i] to the output of the second step.
• At last, we do left shift operation by n (can be any value of n) and addition modulo by 232.
After all steps, the result of A will be fed into B. Now same steps will be used for all functions G, H, and I. After performing
all 64 operations we will get our message digest.
Advantages of DSA
✔ Global Acceptance – Widely used in digital certificates, secure transactions, and software security.
Disadvantages of DSA
Slower than RSA – Signature verification takes more time.
Vulnerability to Key Leaks – If the private key is compromised, attackers can generate fake signatures.
Conclusion
DSA is a widely used digital signature method that ensures secure communication by verifying the sender’s identity and
protecting messages from tampering. Despite some limitations, it remains a trusted authentication method in
cybersecurity.
Hash Length 160 bits (20 bytes) 128 bits (16 bytes)
Security More secure than MD5 but still weak Less secure, prone to collisions
Speed Slower due to longer hash length Faster but weaker security
Collision
Weak (collisions found) Very weak (easier to break)
Resistance
Used in digital signatures, SSL certificates (now Used for checksums and data integrity (not for
Usage
replaced) security)
SHA-1 has been deprecated due to collision MD5 is highly vulnerable and should not be
Vulnerability
attacks used for cryptographic purposes
Example Hash
f572d396fae9206628714fb2ce00f72e94f2258f 8b1a9953c4611296a827abf8c47804d7
(for "Hello")
Conclusion:
• SHA-1 is more secure than MD5 but still not recommended for security purposes.
• MD5 is faster but has serious vulnerabilities and should only be used for basic integrity checks, not for encryption.
• Both are outdated, and modern applications use SHA-256 or SHA-3 for better security.