Hash functions, digital signatures and network security protocols notes — Unit 5
Free unit-wise study notes on hash functions, digital signatures and network security protocols for Cryptography and Network Security, Semester 7 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.
Hash functions, digital signatures and network security protocols
Notebook — 14 pages
Page 1
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
1. Cryptographic Hash Functions
A cryptographic hash function is a mathematical algorithm that maps data of arbitrary size (a small text message or a 10GB movie file) to a bit string of a fixed size (e.g., 256 bits). The output is called the hash value or message digest.
⇒1.1 The Purpose
Hashes are NOT encryption. There is no 'key', and you cannot reverse the hash to get the file back. Hashes provide Data Integrity. If you download a file and compute its hash, and it matches the hash provided by the author, you know the file wasn't corrupted or modified by a hacker.
Page 2
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
2. Properties of Cryptographic Hashes
Pre-image Resistance (One-Way): Given a hash value `h`, it is computationally infeasible to find the original message `m` that produced it.
Second Pre-image Resistance: Given a message `m1`, it is computationally infeasible to find a different message `m2` that produces the same hash.
Collision Resistance: It is computationally infeasible to find any two different messages `m1` and `m2` that produce the exact same hash.
Avalanche Effect: Changing a single bit in the 10GB input file should change roughly 50% of the bits in the output hash, making it look completely unrelated.
Page 3
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
3. The SHA Family
The Secure Hash Algorithm (SHA) family was developed by the NSA.
MD5 (Message Digest 5): An older algorithm producing a 128-bit hash. It is severely compromised—hackers can generate collisions on demand. Should never be used.
SHA-1: Produces a 160-bit hash. Deemed insecure in 2017 when Google demonstrated a practical collision attack.
SHA-2: A family containing SHA-256 and SHA-512. Currently the industry standard. Bitcoin uses SHA-256.
SHA-3: Adopted in 2015 based on the Keccak algorithm. It uses a completely different internal structure (sponge construction) to provide an alternative if SHA-2 is ever broken.
Page 4
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
4. Message Authentication Codes (MAC)
A hash ensures a file hasn't changed, but it doesn't prove who created the file. A hacker could modify your message, compute a new hash, and send both to the receiver.
⇒4.1 The Solution: HMAC
A MAC is a keyed hash. Alice and Bob share a symmetric secret key. Alice runs the hash algorithm not just on the message, but on `Hash(Key + Message)`. This outputs a MAC tag.
Bob receives the message and the tag. He recalculates `Hash(Key + Message)`. If it matches the tag, he knows the message wasn't altered AND it definitely came from Alice (since only she has the key).
Page 5
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
5. Digital Signatures
MACs provide authentication, but they use a symmetric key. Because both Alice and Bob have the same key, Bob could forge a message and claim Alice wrote it. MACs lack Non-Repudiation.
⇒5.1 Digital Signature Concept
A Digital Signature uses public-key cryptography. Alice encrypts the message with her Private Key. Because only Alice has the private key, no one else (not even Bob) could have created the signature. This provides absolute Non-Repudiation.
Page 6
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
6. Creating a Digital Signature
RSA encryption is slow. Encrypting a 1GB contract with a private key to sign it is impractical. Instead, we use hashes.
1. Alice runs the 1GB contract through SHA-256 to produce a 256-bit hash.
2. Alice encrypts ONLY the 256-bit hash using her RSA Private Key. This encrypted hash is the 'Digital Signature'.
3. Alice sends the plain 1GB contract along with the tiny Signature to Bob.
4. Bob runs the received contract through SHA-256 to get a hash.
5. Bob decrypts the Signature using Alice's Public Key to reveal the hash Alice computed.
6. If the two hashes match, the signature is valid.
Page 7
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
7. Digital Certificates and PKI
How does Bob know the Public Key he is using actually belongs to Alice, and not Darth the hacker?
⇒7.1 X.509 Certificates
A digital certificate binds an identity (Alice's name, email, or a website domain like google.com) to a specific Public Key. The certificate contains Alice's name, her public key, and validity dates.
Crucially, this certificate is digitally signed by a highly trusted third party known as a Certificate Authority (CA) (e.g., DigiCert or Let's Encrypt).
Page 8
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
8. The Role of Certificate Authorities
Your operating system and web browser come pre-installed with the public keys of hundreds of trusted Root Certificate Authorities.
⇒8.1 Trust Verification
When Bob connects to Alice's website, she sends her Certificate. Bob's browser sees it is signed by 'DigiCert'. Bob's browser already trusts DigiCert and has its public key. Bob's browser verifies DigiCert's signature on the certificate. If valid, Bob now completely trusts that the public key inside the certificate truly belongs to Alice.
Page 9
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
9. Network Security: IPsec
IPsec (Internet Protocol Security) provides security at the Network Layer (Layer 3). It encrypts and authenticates every IP packet sent across a network. It is the foundation of Virtual Private Networks (VPNs).
⇒9.1 Modes of Operation
Transport Mode: Encrypts only the payload of the IP packet. The IP header (source/dest IP addresses) remains in plain text. Fast, used for host-to-host communication.
Tunnel Mode: Encrypts the entire original IP packet (payload + header) and wraps it inside a completely new IP packet with new headers. Used for router-to-router VPNs, hiding internal network architectures.
Page 10
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
10. Transport Layer Security (TLS/SSL)
TLS (the successor to SSL) operates at the Transport Layer (Layer 4). It is the protocol that puts the 's' in HTTPS, securing web traffic.
⇒10.1 The TLS Handshake
Before data is exchanged, the client and server undergo a handshake:
2. Server picks an algorithm and sends its Digital Certificate.
3. Client verifies the Certificate via a CA.
4. They use Diffie-Hellman to generate a shared symmetric session key.
5. All future bulk HTTP traffic is encrypted using AES with that session key.
Page 11
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
11. Email Security: PGP and S/MIME
Email is inherently insecure; SMTP transmits text in plain sight.
⇒11.1 PGP (Pretty Good Privacy)
Created by Phil Zimmermann, PGP provides confidentiality and authentication for email. It generates a random session key, encrypts the email with AES using that key, and then encrypts the session key with the receiver's RSA Public Key.
⇒11.2 Web of Trust
Unlike S/MIME which relies on corporate Certificate Authorities, PGP relies on a decentralized 'Web of Trust'. Users physically meet and sign each other's keys, building a decentralized graph of verified identities.
Page 12
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
12. Firewalls
A firewall is a network security device that monitors and controls incoming and outgoing network traffic based on predetermined security rules.
⇒12.1 Types of Firewalls
Packet Filtering: Operates at Layer 3/4. Inspects IP addresses and port numbers. If a rule says 'Block port 23 (Telnet)', all packets to port 23 are dropped.
Stateful Inspection: Remembers the state of active connections. If an internal PC requests a web page, the firewall remembers the request and allows the inbound reply from the server. It blocks unsolicited inbound traffic.
Application Proxy: Operates at Layer 7. It understands application traffic (like HTTP or FTP). It can block specific URLs or strip malicious attachments from emails.
Page 13
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
13. Intrusion Detection Systems (IDS)
A firewall is like a guard at the door. An IDS is like the security camera inside the building. It assumes hackers will eventually bypass the firewall.
⇒13.1 Detection Methods
Signature-Based: Looks for specific patterns (signatures) of known malware or attack scripts in the network traffic. Fast, but cannot detect zero-day (brand new) attacks.
Anomaly-Based: Establishes a baseline of normal network behavior (e.g., Bob usually downloads 10MB a day). If Bob's PC suddenly starts uploading 50GB to Russia at 3 AM, the IDS flags an anomaly. Good at catching new attacks, but prone to false positives.
Page 14
Wink Notes
B.Tech CSE — 7th Semester
Cryptography and Network Security
— Unit - 5 —
14. Malicious Software (Malware)
Software designed to infiltrate or damage a computer system.
Virus: Malicious code that attaches itself to a legitimate executable program. Requires user action (running the program) to spread.
Worm: A standalone malicious program that actively scans the network for vulnerable machines and copies itself to them without human intervention.
Trojan Horse: A program that looks useful (like a game or utility) but carries a hidden malicious payload (like a backdoor).
Ransomware: Encrypts the user's files and demands payment in cryptocurrency for the decryption key.
Rootkit: A set of tools designed to hide the existence of a compromise and grant persistent administrator-level access to the attacker.