

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Block Ciphers
incomplete
2: Block vs. Stream
incomplete
3: Block Sizes
incomplete
4: Chunks Review
incomplete
5: Key Schedules
incomplete
6: Key Schedule Review
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The simplest versions of block ciphers operate on single blocks of data, however, those blocks of data typically go through many rounds of encryption. Each round of encryption needs its own key, but it's nearly impossible for users to keep track of more than a single key.
A key schedule is an algorithm that a block cipher employs to split an original key into multiple "round keys" or "subkeys". These round keys are deterministically derived from the original key, meaning that the same original key will always produce the same round keys.
For example the following "master key":
key = 1111011101010011
might produce the following 8 "round keys" in an 8-round block cipher:
roundKey0 = 1110001001111010
roundKey1 = 0100101101011100
roundKey2 = 0011110110101110
roundKey3 = 0101101011100010
roundKey4 = 1011100010010110
roundKey5 = 0010010110101110
roundKey6 = 0101011100010010
roundKey7 = 1101011111110010
In the real world, there are many different production algorithms for key schedules. At Passly, we've been asked to implement a simple key schedule that can be used in our test suite. It doesn't need to be "production-level-secure", it just needs to get the high-level idea across.
Complete the deriveRoundKey() function. It accepts a master key, which is 4 bytes long and represented as an array of bytes. It will also accept a "round number", which is just an int representing which round key is being derived. The key schedule produces a round key where each byte in the round key is the original byte from the master key XORed with the binary representation of the round number.
For example:
masterKey = 01101100 01110000...
roundNumber = 00000001
roundKey = 01101101 01110001...
or when roundNumber = 5
masterKey = 01101100 01110000...
roundNumber = 00000101
roundKey = 01101001 01110101...