Message Authentication and Digital Signatures · Cryptography and Network Security

Secure Hash Algorithm

Watch lectures

Secure Hash Algorithm

1. What Is SHA? (beginner family!)

SHA = NIST hash family: SHA-1 (160-bit, BROKEN!), SHA-2 (224/256/384/512 — SAFE!), SHA-3 (sponge backup!). SHA-256: 256-bit digest (64 hex chars!), 512-bit blocks, 64 rounds!

2. How SHA-256 Works (exam stages!)

1. PAD: message + 1-bit + zeros + 64-bit length → multiple of 512!
   ("abc" 24-bit → +1, +423 zeros, +64-bit 24 → 512!)
2. INIT: 8 words from sqrt(2..19) fractions (nothing-up-my-sleeve!)
   h0 = 6a09e667, ... (anyone can recompute — no trapdoor!)
3. EXPAND: 16 block words → 64 (mix with rotations/XOR!)
4. COMPRESS ×64 rounds: mix (Ch, Maj, Sigma) + constants (cbrt primes!) + W[i]
5. ADD to hash → next block! Final: concat 8 words = 256-bit digest!

"abc" → ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad (test vector — memorize prefix!).

3. Family Table (exam!)

Algorithm Digest Block Rounds Status
MD5 128 512 64 BROKEN!
SHA-1 160 512 80 BROKEN (2017)!
SHA-256 256 512 64 SAFE!
SHA-512 512 1024 80 SAFE (faster on 64-bit!)

4. Traps

  • SHA-256 for integrity/signatures/HMAC — NEVER raw passwords (fast = brute-forceable! use bcrypt!).
  • Always pad (even aligned messages!). Length-extension applies (use HMAC!).

5. Exam Points

  • Stages + table + "abc" vector — 7 marks, very frequent.
  • Broken vs safe + password warning — 3-5 marks, frequent.
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Cryptography and Network Security modules