What to practice
- Contrast symmetric (AES), asymmetric (RSA, ECC, Diffie-Hellman), and hashing (SHA-256) algorithms.
- Explain how unique per-user salts and key stretching (Argon2, bcrypt, PBKDF2) protect stored passwords against rainbow tables and brute-force attacks.
- Distinguish plain cryptographic hashes from HMACs and digital signatures.
1. Core Concept Instruction
Modern cryptography combines three distinct primitives: (1) Symmetric Encryption (AES-128/256, ChaCha20) uses a single shared secret key for both encryption and decryption. It is computationally fast and ideal for bulk data encryption at rest and in transit, but suffers from the key-distribution problem (sharing the key over an untrusted channel). (2) Asymmetric / Public-Key Cryptography (RSA, Elliptic Curve Cryptography [ECC], Diffie-Hellman/ECDHE) uses a public key and private key pair. It solves key distribution and enables digital signatures, but is much slower than AES; therefore, protocols like TLS use hybrid cryptography (ECDHE/RSA to establish a shared session key, then AES-GCM to encrypt bulk traffic). (3) Cryptographic Hashing (SHA-256, SHA-3) maps arbitrary-length input to a fixed-length digest (256 bits for SHA-256). Hashing is ONE-WAY (non-reversible) and collision-resistant. When storing user passwords, NEVER store plaintext or unsalted hashes (which fall to precomputed Rainbow Tables); prepend a unique random per-user SALT and use a slow key-stretching algorithm (Argon2id, bcrypt, PBKDF2).
2. Worked Examples
Worked Salted Password Hashing Defense & HMAC vs. Plain Hash Analysis
(a) An attacker steals a database `users` table containing 100,000 password hashes computed as `SHA256(password)` without salts. Explain how a Rainbow Table cracks these hashes and how a unique 128-bit random salt per user + Argon2 defeats the attack. (b) Why does a plain SHA-256 hash downloaded from the same HTTP server as a software installer NOT prove authenticity against an attacker who compromised the web server?
Result:
Salted Password Hashing (Argon2id / bcrypt) vs. Rainbow-Table Precomputation
A legacy web app stores user passwords as unsalted SHA-256 digests. After a database breach, attackers immediately crack 40% of accounts using precomputed lookup tables, and two users with the same password share identical hashes.
Result: Unique per-user random salt + memory-hard Argon2id/bcrypt hashing defeats rainbow tables and brute force
Core Concept Review
Modern cryptography combines three distinct primitives: (1) Symmetric Encryption (AES-128/256, ChaCha20) uses a single shared secret key for both encryption and decryption. It is computationally fast and ideal for bulk data encryption at rest and in transit, but suffers from the key-distribution problem (sharing the key over an untrusted channel). (2) Asymmetric / Public-Key Cryptography (RSA, Elliptic Curve Cryptography [ECC], Diffie-Hellman/ECDHE) uses a public key and private key pair. It solves key distribution and enables digital signatures, but is much slower than AES; therefore, protocols like TLS use hybrid cryptography (ECDHE/RSA to establish a shared session key, then AES-GCM to encrypt bulk traffic). (3) Cryptographic Hashing (SHA-256, SHA-3) maps arbitrary-length input to a fixed-length digest (256 bits for SHA-256). Hashing is ONE-WAY (non-reversible) and collision-resistant. When storing user passwords, NEVER store plaintext or unsalted hashes (which fall to precomputed Rainbow Tables); prepend a unique random per-user SALT and use a slow key-stretching algorithm (Argon2id, bcrypt, PBKDF2).
Extended Concept Analysis
Modern cryptography combines three distinct primitives: (1) Symmetric Encryption (AES-128/256, ChaCha20) uses a single shared secret key for both encryption and decryption. It is computationally fast and ideal for bulk data encryption at rest and in transit, but suffers from the key-distribution problem (sharing the key over an untrusted channel). (2) Asymmetric / Public-Key Cryptography (RSA, Elliptic Curve Cryptography [ECC], Diffie-Hellman/ECDHE) uses a public key and private key pair. It solves key distribution and enables digital signatures, but is much slower than AES; therefore, protocols like TLS use hybrid cryptography (ECDHE/RSA to establish a shared session key, then AES-GCM to encrypt bulk traffic). (3) Cryptographic Hashing (SHA-256, SHA-3) maps arbitrary-length input to a fixed-length digest (256 bits for SHA-256). Hashing is ONE-WAY (non-reversible) and collision-resistant. When storing user passwords, NEVER store plaintext or unsalted hashes (which fall to precomputed Rainbow Tables); prepend a unique random per-user SALT and use a slow key-stretching algorithm (Argon2id, bcrypt, PBKDF2).
Worked Problem Walkthrough
Worked Salted Password Hashing Defense & HMAC vs. Plain Hash Analysis
(a) An attacker steals a database users table containing 100,000 password hashes computed as SHA256(password) without salts. Explain how a Rainbow Table cracks these hashes and how a unique 128-bit random salt per user + Argon2 defeats the attack. (b) Why does a plain SHA-256 hash downloaded from the same HTTP server as a software installer NOT prove authenticity against an attacker who compromised the web server?
Salted Password Hashing (Argon2id / bcrypt) vs. Rainbow-Table Precomputation
A legacy web app stores user passwords as unsalted SHA-256 digests. After a database breach, attackers immediately crack 40% of accounts using precomputed lookup tables, and two users with the same password share identical hashes.
Common Exam Traps & How to Avoid Them
-
Saying 'decrypt the SHA-256 hash' (cryptographic hashes are one-way functions and cannot be decrypted!).
-
Using a single static 'global salt' for all users (which still produces identical hashes for identical passwords) instead of a unique random salt per user.
Key Vocabulary
-
Cryptographic Salt: A unique, random value generated for each user and combined with their password prior to hashing to defeat precomputed rainbow-table attacks and conceal duplicate passwords.
-
HMAC (Hash-Based Message Authentication Code): A construction that combines a cryptographic hash function with a secret key to verify both the data integrity and the authenticity of a message.