← QCE Digital Solutions Unit 4

Block ciphers and key size

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.

Understanding Block ciphers and key size in QCE Digital Solutions Unit 4

What it does: Dividing the message size by the block size gives the number of blocks the cipher must encrypt. AES always uses a 128-bit block. Its key can be 128, 192 or 256 bits, so don't mix up block size and key length. Each extra bit has 2 values (0 or 1), so the number of possible keys doubles with every added bit. A longer key means far more possible keys to try, so brute force takes much longer. This is why DES's 56-bit key is considered weak. Each round scrambles the block further, making the ciphertext harder to link back to the plaintext.

Common mistakes: 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'. 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.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 17–88) and word search (Modules 17–125).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A block cipher encrypts data in...
One random-length chunk that changes each timeFixed-size blocks, such as 128 bits at a time
Matches
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.
Applying
Meanings
Term
block cipher
Meaning
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.
Practice
block_bits = 128
Testing
Gaps
keys = 2 keyBits
Check Answer
Spots
3if long_key > short_key:
4 print('Fewer keys to try')

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Dolphin' badge — Reef Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

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 ✓
A block cipher splits the data into blocks of a fixed size (e.g. 128 bits) and encrypts each block using the key.
2. Which is the block size of AES?
A. 128 bits ✓
B. 256 bits only
AES always uses a 128-bit block. Its key can be 128, 192 or 256 bits, so don't mix up block size and key length.
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
Key length measures the secret key. Block size measures the chunk of data encrypted at one time.
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 ✓
Each extra bit has 2 values (0 or 1), so the number of possible keys doubles with every added bit.
5. Which key is harder to break by brute force?
A. A 256-bit key ✓
B. A 56-bit key
A longer key means far more possible keys to try, so brute force takes much longer. This is why DES's 56-bit key is considered weak.

Match the Pairs

blockSize <- 128 → Each block of data is 128 bits long, so the cipher encrypts the message one 128-bit block at a time.
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.
A block cipher splits data into fixed-size blocks, so a 1024-bit message with 128-bit blocks makes 8 blocks. → blocks <- 1024 / 128
Each block is scrambled over several rounds, and the key is used in every round. → FOR round <- 1 TO 14: block <- scramble(block, key)
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.
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.

Key Term

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.

Fill in the Blanks

1. keyBits = 128 keys = 2 ** keyBits print(keys)
Hint: Type the operator that raises 2 to a power, giving the number of possible keys for a key length in bits.
2. for r in range(rounds): block = scramble(block, key)
Hint: Type the built-in function that repeats the scrambling step once for each round.
3. blockBits = 16 * 8 print(blockBits)
Hint: Type the number of bits in one byte, used to convert a 16-byte block size into bits.
4. print(2 ** 128 > 2 ** 64)
Hint: Type the comparison operator that shows the longer key has more possible keys to try.
5. key = "0123456789abcdef" keyBits = len(key) * 8 print(keyBits)
Hint: Type the function that counts the characters in the key, so multiplying by 8 gives the key length in bits.

Spot the Error

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

Student with a class code? Join your class →