Lesson plan: Integrity Hashing

AP Cybersecurity · Unit 5 Securing Applications and Data · Topic 5.6 Detecting Attacks on Data and Applications · Practice set

At a glance

Suggested time
2 class periods (45 min)
Pacing
Second of three sets for Topic 5.6. The CED gives Topic 5.6 seven class periods; this plan suggests 2 for Detective Controls for Data, 2 for this set and 3 for Reading Application Logs. The split is this plan's suggestion; the CED sets only the topic's total.
Before this set
Detective Controls for Data (hash checks as one of the cheap detective controls, and that they find an attack after it has happened). Cryptography and Symmetric Encryption (a key undoes encryption). The lesson says hash (and hash output in its box "Comparing hashes over time"); the problems also say digest. Tell students before Day 1's problems that all three name the same value.
Skills
3.A Identify methods for monitoring systems, and explain how they detect attacks.
3.D Detect and classify cyberattacks by analyzing digital evidence with and without the support of AI.

The one idea: The same file run through the same hash function always gives the same digest. Record a file's digest, hash it again later with the same function, and compare: a match means the contents were the same at both hashings, and a mismatch means the file was altered in between. The digest says nothing about who made the change, what it was, or when it happened.

Day by day

Day 1 · Same input, same hash45 min

Day 2 · A record to compare against45 min

Differentiation

If students are struggling
Do Problem 3 🔒 as a class right after Day 2's reading, then have students label each part of the bookstore's checkout check with the step it matches. Pair Problem 4 🔒 and Problem 8 🔒: one match and one mismatch, with the same question of what each shows.
Extension
Hash a file, change one character, hash it again, and count how many of the 64 characters stayed in place. Or: the bookstore's checkout check would miss one kind of attack from Detective Controls for Data. Which kind, and which control there would catch it?
Vocabulary support
hash function; hash, digest and hash output (one value, three names); SHA-256 (Secure Hash Algorithm with a 256-bit output); MD5 (Message Digest 5, an older function); hexadecimal; repeatable; PowerShell, BASH and zsh.

From the course framework

LO 5.6.D Identify whether a file has been altered by verifying its hash.

  • 5.6.D.1 Cryptographic hash functions can help identify changes in a file because they are repeatable: the same input always produces the same output for a given hash function.
  • 5.6.D.2 Hashes can be calculated using the command line on a computer, a website, or specialized software. In Windows Powershell, if a user wanted to generate the SHA256 hash for a file named testfile, they would use the command: Get-FileHash testfile -Algorithm SHA256; In BASH the same could be accomplished with the command: sha256sum testfile; In zsh, the common command line terminal on Apple computers, this could be accomplished with the command: shasum -a 256 testfile
  • 5.6.D.3 A file can be hashed and its hash output recorded. Then it can be hashed again later, and the second hash output can be compared to the previous hash output for the same file. If a file's hash changes, then the file was altered between when the first and second hashes were generated.