Unit 3 cryptography and network security
1. Authentication Requirements(very imp)
Message authentication ensures that the received message is genuine, has not been
modified, and actually comes from the claimed sender.
Main authentication requirements include:
• Authenticity – Confirms that the message comes from a genuine sender.
• Integrity – Guarantees that the message content has not been altered during
transmission.
• Non-repudiation – Ensures that the sender cannot deny sending the message later.
• Timeliness – Prevents reuse or replay of old messages.
2. Authentication Functions
Authentication functions are mathematical algorithms used to verify message integrity and
authenticity.
The main types are:
• Message Encryption – Encrypts the entire message for confidentiality and
authentication.
• Message Authentication Code (MAC) – Generates a short code using a secret key and
message.
• Hash Function – Converts message into a fixed-length digest for integrity verification.
3. Message Authentication Code (MAC)(very imp)
A Message Authentication Code (MAC) is a cryptographic checksum generated using a
message and a secret key. It ensures both message integrity and authentication.
Working process:
1. 1. Sender computes MAC using secret key K and message M: MAC = F(K, M).
2. 2. Sender sends message M along with MAC to receiver.
3. 3. Receiver recomputes MAC' using same key and message.
4. 4. If MAC' = MAC, message is authentic and unaltered.
Advantages:
• Provides integrity and authentication.
• Faster and simpler than full encryption.
• Widely used in protocols like TLS, SSL, and IPSec.
4. Hash Functions
A hash function maps input data of arbitrary size to a fixed-length output called hash value
or message digest. It provides a digital fingerprint of the message.
Properties of a good hash function:
• Fixed output length.
• Easy to compute for any input.
• Preimage resistance – Hard to find message M from hash h.
• Second preimage resistance – Hard to find M' such that H(M) = H(M').
• Collision resistance – Hard to find two different messages with same hash.
Applications:
• Digital signatures.
• Password storage.
• File integrity verification.
5. Birthday Attacks
A birthday attack exploits the probability principle known as the birthday paradox to find
two different messages with the same hash value (collision).
For an n-bit hash function, collision can be found in approximately 2^(n/2) operations.
Example:
• For a 64-bit hash, collision found in ~2^32 operations.
• For a 128-bit hash, collision found in ~2^64 operations.
Protection:
• Use large hash sizes (≥256 bits).
• Employ modern algorithms (SHA-2, SHA-3).
6. Security of Hash Functions
Hash function security depends on its resistance to the following attacks:
• Preimage Attack – Finding a message that produces a given hash.
• Second Preimage Attack – Finding another message that gives same hash as a specific
message.
• Collision Attack – Finding any two messages with same hash value.
A secure hash function must make all the above attacks computationally infeasible.
7. Secure Hash Algorithm (SHA)
The Secure Hash Algorithm (SHA) is a family of cryptographic hash functions developed by
NIST for ensuring message integrity and authentication.
Versions of SHA include:
• SHA-1 – Produces 160-bit hash; now insecure due to collision attacks.
• SHA-2 – Includes SHA-224, SHA-256, SHA-384, SHA-512; provides strong resistance.
• SHA-3 – Based on Keccak algorithm; secure and flexible.
SHA works by padding the message, dividing it into blocks, and processing each block
through a series of bitwise and modular arithmetic operations.
……………………………………………………………………………………………………………………………………….
1. Digital Signatures(v imp)
A Digital Signature is a cryptographic technique used to verify the authenticity, integrity,
and non-repudiation of a digital message or document. It serves the same purpose as a
handwritten signature but in electronic form.
1.1 Definition:
A Digital Signature is a mathematical scheme for verifying the authenticity of digital
messages or documents using cryptographic algorithms.
1.2 Working Principle:
The process of generating and verifying a digital signature involves the following steps:
5. 1. Sender generates a message digest using a hash function (e.g., SHA).
6. 2. The hash value is then encrypted with the sender’s private key to form the digital
signature.
7. 3. The signature is sent along with the message.
8. 4. Receiver decrypts the signature using sender’s public key to obtain the original hash.
9. 5. Receiver generates a new hash from the received message and compares both hash
values.
10. 6. If both are equal, authenticity and integrity are confirmed.
1.3 Requirements of Digital Signature:
• Authentication – Verifies the sender’s identity.
• Integrity – Ensures the message is not altered.
• Non-repudiation – Prevents sender from denying authorship.
1.4 Techniques Used for Digital Signatures:
Common algorithms used include:
• RSA Digital Signature
• ElGamal Digital Signature
• Digital Signature Algorithm (DSA)
• Elliptic Curve Digital Signature Algorithm (ECDSA)
1.5 Advantages:
• Provides strong security and authenticity.
• Detects message tampering and forgery.
• Reduces need for physical verification of documents.
• Legally accepted in many countries.
1.6 Disadvantages:
• Requires proper key management.
• Dependent on reliable certificate authorities (CA).
• Implementation can be complex and costly.
1.7 Applications:
• Secure emails and digital documents.
• Software distribution and updates.
• E-commerce transactions.
• Online contracts and e-governance.
2. ElGamal Digital Signature Technique(v imp)
The ElGamal Digital Signature is a public key cryptographic algorithm based on the Discrete
Logarithm Problem. It provides message authentication and integrity without revealing the
private key.
2.1 Principle:
The ElGamal signature scheme is based on modular arithmetic and the difficulty of finding
discrete logarithms in a finite field.
2.2 Key Generation:
11. 1. Choose a large prime number p.
12. 2. Select a primitive root g modulo p.
13. 3. Choose a private key x (1 < x < p−1).
14. 4. Compute public key y = g^x mod p.
• Public key: (p, g, y)
• Private key: x
2.3 Signature Generation:
To sign a message M:
15. 1. Choose a random integer k such that 1 < k < p−1 and gcd(k, p−1) = 1.
16. 2. Compute r = g^k mod p.
17. 3. Compute hash h = H(M).
18. 4. Compute s = (h − x·r) * k^(-1) mod (p−1).
19. 5. The signature is (r, s).
2.4 Signature Verification:
Receiver verifies signature using:
20. 1. Compute v1 = y^r * r^s mod p.
21. 2. Compute v2 = g^h mod p, where h = H(M).
22. 3. If v1 = v2, the signature is valid.
2.5 Advantages:
• Provides high security based on discrete logarithm problem.
• Signature cannot be forged without private key.
• Flexible and used in many cryptographic systems.
2.6 Disadvantages:
• Requires generation of a random number for each signature.
• Computationally intensive for large values of p.
• Vulnerable if random number k is reused.
2.7 Applications:
• Secure message authentication.
• Digital certificates and document signing.
• Used in some blockchain-based security systems.