Key space: how many keys a cipher has

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Key space: how many keys a cipher has

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. How many useful keys does a Caesar cipher have?
A Millions
B 25
2. What does the term key space mean?
A The blank space between words in a message
B The total number of different keys a cipher allows
3. Why is a Caesar cipher easy to break by trying every key?
A Its key space is tiny, so all 25 keys can be tested quickly
B Its key space is huge, so attackers get lucky
4. Which cipher has the stronger key space?
A A cipher with 1 000 000 possible keys
B A cipher with 25 possible keys
5. An attacker intercepts a Caesar ciphertext. What is the simplest attack?
A Try all 25 shifts and look for readable text
B Guess one shift and give up if it fails

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1key_space = 25 AA Caesar cipher has only 25 useful keys, not 100. That small key space makes it easy to brute force.
2for key in range(1, 26): Bfor shift in range(1, 26): print(shift, decrypt(text, shift))
3A small key space means an attacker can try every key (brute force) CTries every possible Caesar key one after the other
4A bigger key space is stronger because there are far more keys to try Dkeys = 2 ** 128
5A Caesar cipher has 100 keys, so it is hard to brute force. EA Caesar cipher has 25 useful keys, so its key space is small
6Fewer keys make a cipher stronger because there is less to guess. FIt is the other way round. Fewer keys means a smaller key space, which is easier for an attacker to try in full.

Definitions

key space

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
keys = 26 _ 1
2.
for key in _____(1, 26): print(key)
3.
keyspace = __ print(keyspace)
4.
for key in range(1, 26): print(decrypt(msg, ___))
5.
keysA = 25 keysB = 2 ** 128 stronger = keysB _ keysA

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A letters = 26
B useless_key = 0
C keys = letters + 1
D print(keys)
Question 2
A caesar = 25
B bigger = 2 ** 128
C if bigger < caesar:
D print('Stronger')
Question 3
A alphabet = 26
B keys = alphabet - 1
C tried = 0
D while tried > keys:
E tried = tried + 1
Question 4
A text = 'KHOOR'
B for key in range(1, 25):
C print(key, dec(text, key))
Question 5
A caesar == 25
B other = 1000000
C print(other > caesar)

Answer Key

Key space: how many keys a cipher has
Section A: Quick Questions
Q1
B — 25
Q2
B — The total number of different keys a cipher allows
Q3
A — Its key space is tiny, so all 25 keys can be tested quickly
Q4
A — A cipher with 1 000 000 possible keys
Q5
A — Try all 25 shifts and look for readable text
Section B: Match the Pairs
Q1
key_space = 25 → A Caesar cipher has 25 useful keys, so its key space is small
Q2
for key in range(1, 26): → Tries every possible Caesar key one after the other
Q3
A small key space means an attacker can try every key (brute force) → for shift in range(1, 26): print(shift, decrypt(text, shift))
Q4
A bigger key space is stronger because there are far more keys to try → keys = 2 ** 128
Q5
A Caesar cipher has 100 keys, so it is hard to brute force. → A Caesar cipher has only 25 useful keys, not 100. That small key space makes it easy to brute force.
Q6
Fewer keys make a cipher stronger because there is less to guess. → It is the other way round. Fewer keys means a smaller key space, which is easier for an attacker to try in full.
Section C: Definitions
Q1
key space — The total number of different keys a cipher allows. A Caesar cipher has only 25 useful keys, so an attacker can try them all. More keys means a bigger key space and a stronger cipher.
Section D: Fill in the Blanks
Q1
keys = 26 - 1
Q2
for key in range(1, 26): print(key)
Q3
keyspace = 25 print(keyspace)
Q4
for key in range(1, 26): print(decrypt(msg, key))
Q5
keysA = 25 keysB = 2 ** 128 stronger = keysB > keysA
Section E: Spot the Error
Q1
C — Key 0 leaves the message unchanged, so a Caesar cipher has 26 - 1 = 25 useful keys. It should be keys = letters - 1.
Q2
C — A cipher with 2 ** 128 keys has a much bigger key space than a Caesar cipher with 25 keys. The test should be bigger > caesar.
Q3
D — The loop should keep trying keys while tried is less than keys. With > it never runs, so no keys are tried. It should be while tried < keys:
Q4
B — range() stops before its end value, so range(1, 25) only tries keys 1 to 24 and misses key 25. To try all 25 keys use range(1, 26).
Q5
A — A single = assigns a value to the variable. == compares two values, so caesar would be undefined. It should be caesar = 25.