Block ciphers and key size

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

Block ciphers and key size

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A block cipher encrypts data in...
A One random-length chunk that changes each time
B Fixed-size blocks, such as 128 bits at a time
2. Which is the block size of AES?
A 128 bits
B 256 bits only
3. Which statement is correct?
A Key length is how many bits are in the key
B Key length is how many bits are in each block
4. What does adding one extra bit to a key length do to the number of possible keys?
A It adds one more possible key
B It doubles the number of possible keys
5. Which key is harder to break by brute force?
A A 256-bit key
B A 56-bit key

Match the Pairs

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

Left columnRight column
1blockSize <- 128 Ablocks <- 1024 / 128
2possibleKeys <- 2 ^ keyLength BFOR round <- 1 TO 14: block <- scramble(block, key)
3A block cipher splits data into fixed-size blocks, so a 1024-bit message with 128-bit blocks makes 8 blocks. CEach block of data is 128 bits long, so the cipher encrypts the message one 128-bit block at a time.
4Each block is scrambled over several rounds, and the key is used in every round. DBlock size and key length are separate values. For example, AES uses 128-bit blocks but accepts 128, 192 or 256-bit keys.
5possibleKeys = 2 * keyLength EThe number of possible keys is 2 to the power of the key length (2 ^ keyLength), not 2 multiplied by it. Each extra bit doubles the number of keys.
6keyLength = blockSize FA key of n bits gives 2^n possible keys, so each extra bit doubles how many keys a brute-force attacker must try.

Definitions

block cipher

Fill in the Blanks

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

1.
keyBits = 128 keys = 2 __ keyBits print(keys)
2.
for r in _____(rounds): block = scramble(block, key)
3.
blockBits = 16 * _ print(blockBits)
4.
print(2 ** 128 _ 2 ** 64)
5.
key = "0123456789abcdef" keyBits = ___(key) * 8 print(keyBits)

Spot the Error

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

Question 1
A short_key = 128
B long_key = 256
C if long_key > short_key:
D print('Fewer keys to try')
Question 2
A block_size = 16
B data = 'Hello'
C extra = block_size - len(data)
D data += '0' * block_size
Question 3
A rounds = 10
B block = data
C for r in range(1):
D block = mix(block, key)
E print(block)
Question 4
A key_bits = 128
B total_keys = key_bits ** 2
C print(total_keys)
Question 5
A cipher = 'AES'
B block_bits = 256
C key_bits = 256
D rounds = 14

Answer Key

Block ciphers and key size
Section A: Quick Questions
Q1
B — Fixed-size blocks, such as 128 bits at a time
Q2
A — 128 bits
Q3
A — Key length is how many bits are in the key
Q4
B — It doubles the number of possible keys
Q5
A — A 256-bit key
Section B: Match the Pairs
Q1
blockSize <- 128 → Each block of data is 128 bits long, so the cipher encrypts the message one 128-bit block at a time.
Q2
possibleKeys <- 2 ^ keyLength → A key of n bits gives 2^n possible keys, so each extra bit doubles how many keys a brute-force attacker must try.
Q3
A block cipher splits data into fixed-size blocks, so a 1024-bit message with 128-bit blocks makes 8 blocks. → blocks <- 1024 / 128
Q4
Each block is scrambled over several rounds, and the key is used in every round. → FOR round <- 1 TO 14: block <- scramble(block, key)
Q5
possibleKeys = 2 * keyLength → The number of possible keys is 2 to the power of the key length (2 ^ keyLength), not 2 multiplied by it. Each extra bit doubles the number of keys.
Q6
keyLength = blockSize → Block size and key length are separate values. For example, AES uses 128-bit blocks but accepts 128, 192 or 256-bit keys.
Section C: Definitions
Q1
block cipher — Encrypts data in fixed-size blocks (e.g. 128 bits) using a key, scrambling each block in rounds. A longer key means more possible keys, so brute force takes longer.
Section D: Fill in the Blanks
Q1
keyBits = 128 keys = 2 ** keyBits print(keys)
Q2
for r in range(rounds): block = scramble(block, key)
Q3
blockBits = 16 * 8 print(blockBits)
Q4
print(2 ** 128 > 2 ** 64)
Q5
key = "0123456789abcdef" keyBits = len(key) * 8 print(keyBits)
Section E: Spot the Error
Q1
D — A longer key (256 bits) gives more possible keys than a shorter one (128 bits), so an attacker has more keys to try. The message should say 'More keys to try'.
Q2
D — A block cipher needs the last block filled to the fixed block size. Pad with only the missing characters ('extra'), not a whole extra block_size.
Q3
C — A block cipher scrambles each block in several rounds. The loop must run 'rounds' times, so it should be range(rounds), not just one round.
Q4
B — Each key bit can be 0 or 1, so the number of possible keys is 2 to the power of the key length: 2 ** key_bits, not key_bits ** 2.
Q5
B — AES always uses a 128-bit block size. 256 bits is one of its key lengths, which is a separate setting from block size.