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
- Open (5 min)Ask: you download a program, and someone may have swapped the file on its way to you. How could you tell whether the copy you got is the real one? Collect ideas on the board before the reading.
- Mini-lesson (12 min)Teach Integrity Hashing, from the top through the box "Computing a hash", stopping before "A record to compare against". At the bookstore's two download hashes, ask students to count the places where the two values share a character. There are four, about what chance gives with 16 possible characters in each place, so the values are unrelated.
- Do together (6 min)Problem 1 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (10 min)Problem 2 🔒: the PowerShell command · Problem 5 🔒: BASH on Linux and zsh on an Apple laptop · Problem 7 🔒: two hashes made by two different functions.
- Try it (8 min)If students have computers, each one saves a short text file, hashes it with the command for their own computer, changes one character, and hashes it again. Pairs compare the two values. Without a terminal, use a hashing website and a made-up file only.
- Exit check (4 min)Problem 7 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
Day 2 · A record to compare against45 min
- Open (5 min)Project the lesson's download page figure (the shop software link with its SHA-256 printed beside it). Ask: if an adversary could change this page, could they change the hash too? Collect answers and come back to them at "Trusted hashes".
- Mini-lesson (12 min)Teach Integrity Hashing, "A record to compare against" and "Trusted hashes", to the end. Stop at the lesson's question about the checkout.js mismatch (what does it tell the owner, and what doesn't it?) and have pairs answer before reading the next paragraph.
- Do together (10 min)Problem 6 🔒 Problem 1 🔒 Problem 8 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (10 min)Problem 3 🔒: put the four steps of a check in order · Problem 4 🔒: what a matching pair of digests shows.
- Discuss (5 min)Problem 4 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- Wrap (3 min)Students write one sentence on what a changed hash tells them and one thing it cannot tell them.
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.
🔒 Answer keyEvery problem's answer, the concept and essential knowledge it checks, and the trap it targets.Sign in as a teacher to see this🔒 Traps this set testsWhat each common wrong answer looks like, and one line to say when you see it.Sign in as a teacher to see this🔒 What to emphasizeThe points that decide the set's problems.Sign in as a teacher to see this🔒 Questions to ask aloudQuestions for the class discussion, with what to listen for.Sign in as a teacher to see this🔒 On the examHow the set's ideas appear on the AP exam, from the course framework.Sign in as a teacher to see this🔒 Your class so farLive results for your section: the problems a third or more missed on the first try, the most common wrong answer, and what it usually means.Sign in as a teacher to see this
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.