Lesson plan: Key Length and Public Key Commands
AP Cybersecurity · Unit 5 Securing Applications and Data · Topic 5.4 Asymmetric Cryptography · Practice set
At a glance
- Suggested time
- 3 class periods (45 min)
- Pacing
- Second of two sets for Topic 5.4. The CED gives Topic 5.4 five class periods; this plan suggests 2 for Asymmetric Keys and 3 for this set, the third of them CED Scenario 5B. The CED does not divide the topic among sets; that split is this plan's suggestion.
- Before this set
- Asymmetric Keys (the key pair, encrypting with the receiver's public key, a leaked private key means a new pair; this lesson continues its online bookstore and book scouts). Cryptography and Symmetric Encryption (AES, one shared key, AES Crypt). The hash functions SHA-256 and MD5 from Hashing and Password Storage (Unit 4). Students should be able to read a power of 2.
- Skills
- 2.A Identify security controls, and explain how they mitigate risks.2.D Implement and log mitigations with and without the support of AI.
The one idea: Each bit added to a key doubles the keyspace, and a random search finds the key after half of it on average. Length means security, but only against keys of the same algorithm. On the command line, the public key file encrypts and the key pair file decrypts.
Day by day
Day 1 · Counting keys45 min
- Open (5 min)Write every 2-bit key on the board: 00, 01, 10, 11. Ask a student to list every 3-bit key, then ask how the list grew.
- Mini-lesson (18 min)Teach Key Length and Public Key Commands, the opening through the Deep Crack photos (everything before Comparing key lengths; Day 2 reads the next two sections and Day 3 the last). Stop after the paragraph that ends "Work out that number for Debian's broken generator" and have pairs work it out before anyone reads the next paragraph. Then read the figure of the four keyspaces and the two definition boxes.
- Do together (9 min)Problem 1 🔒 Problem 5 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (8 min)Problem 3 🔒 Problem 7 🔒: count the keys, then the average guesses.
- Exit check (5 min)🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
Day 2 · Comparing keys and the four commands45 min
- Mini-lesson (12 min)Teach Key Length and Public Key Commands, Comparing key lengths and The bookstore's commands. Stop after the paragraph that asks whether the 4096-bit RSA key is 16 times as strong as the 256-bit AES key, and take answers before reading on. In The bookstore's commands, have students name the files each of the four commands reads (none for
genrsa; a key file and an input file forpkeyutl) and the file it writes. - Do together (8 min)Problem 11 🔒 Problem 8 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (15 min)Problem 9 🔒 why lengths rise and what they cost · Problem 2 🔒 Problem 4 🔒 algorithms and tools · Problem 6 🔒 Problem 10 🔒 Problem 12 🔒 the commands.
- Discuss (6 min)Problem 10 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- Exit check (4 min)🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
Day 3 · CED Scenario 5B45 min
- Open (5 min)Read CED Scenario 5B (two security engineers at LightningGrid, a utility company). Project the CED's Figure 5.4: plaintext, public key, ciphertext, private key. Pair students at random, as the scenario says, and agree on where pairs will pass files (a shared class folder works).
- In pairs (28 min)Each student generates a key pair and shares the public key with the partner. Each encrypts a short secret message with the partner's public key, sends it, and decrypts the message they receive. The CED says PGP and names no tool. Use a PGP program the school allows, or the four OpenSSL commands from The bookstore's commands if students have a terminal. With OpenSSL, keep the message to a sentence or two, since RSA encrypts only a few hundred bytes directly. Each student logs every step: the command or button, the file it made, and who holds that file.
- Discuss (8 min)Read the lesson's Replacing the Debian keys together. Then ask: a student's private key file was left on a shared lab computer, so what does the pair do? (Treat the pair as compromised: delete it, generate a new one, and share the new public key; anything already encrypted to the old key may have been read.)
- Wrap (4 min)Students write one sentence naming the key they encrypted with, the key they decrypted with, and the file that never left their computer.
Differentiation
- If students are struggling
- Before Problem 3 🔒 and Problem 7 🔒, have students write out every 3-bit key, 000 to 111, and circle the middle of the list. Before Problem 6 🔒, Problem 8 🔒 and Problem 10 🔒, give a card with the lesson's four bookstore commands and have them label each file as key pair, public key, plaintext or ciphertext.
- Extension
- Deep Crack tested about 88 billion DES keys a second. How many bits must a key have so that, on average, Deep Crack would need more than a year to find it? (63 bits:
2^62is about 4.6 × 10^18 guesses, more than the 2.8 × 10^18 it tests in a year.) In Scenario 5B, pairs who finish repeat the exchange with the other tool (OpenSSL if they used a PGP program, or the reverse) and compare the two logs step by step. - Vocabulary support
- bit, keyspace, key pair, public key, private key, RSA, elliptic curve cryptography (ECC), OpenSSL, PEM file, plaintext, ciphertext.
🔒 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.4.B Explain why the length of a key impacts the security of encrypted data.
- 5.4.B.1 Longer keys result in larger keyspaces. For binary keys, an n-bit length key has a keyspace of 2^n.
- 5.4.B.2 Using an application to randomly guess an n-bit length encryption key means that on average an adversary will be able to guess the correct key in 2^n/2 or 2^(n-1) guesses.
- 5.4.B.3 Although longer keys are more secure, they also require more time to encrypt and decrypt messages.
- 5.4.B.4 Computational processing power and efficiency continue to improve, allowing software to guess keys faster. Key-length recommendations for both symmetric and asymmetric encryption algorithms are periodically increased to account for increased processing power.
- 5.4.B.5 Key-length comparison is only valid when comparing keys for the same cryptographic algorithm.
LO 5.4.C Apply asymmetric encryption algorithms to encrypt and decrypt data.
- 5.4.C.1 Common asymmetric encryption algorithms include RSA and elliptic curve cryptography (ECC). Asymmetric algorithms are used in many applications, including digital signatures and digital certificates.
- 5.4.C.2 As with symmetric encryption, asymmetric encryption and decryption can be performed using the command line, specialized software, or web-based tools. On a command line interface, users can encrypt or decrypt with OpenSSL. Specialized software like RSA Encryption Tool is an open source tool that can encrypt and decrypt files. There are many web-based tools for encrypting and decrypting files.
- 5.4.C.3 In a CLI, a user can generate an asymmetric key pair and encrypt or decrypt files as necessary.