You may assume that the input is always 64 bits long: no need to worry about breaking apart long messages.
When the number of iterations is greater than one, you will use using the cipher-block chaining (CBC) method described in class and the text. Use C0 = 0. Since our message m is only 64 bits long, we will use it in each round. That is, use m for P1, P2, etc. in Figure 4.6 in the text.
You might be wondering why I am requiring you to encrypt for other than 16 rounds and other than 1 iteration. I will use the ability to change the number of rounds to test correctness. For example, if your answer is incorrect for 16 rounds, but correct for 1, it's probably a bug in how you are generating round keys. (If your code consistently works for 16 rounds, I won't bother checking fewer rounds.)
I will use the ability to change the number of iterations to test speed and correctness. Speed: I can run it enough times to isolate the runtime of the algorithm from the runtime of I/O. Correctness: I want to make sure that you aren't hard-coding anything specific to a given message or key.
If you want to display debugging output, please put a DEBUG flag of some type in your code that defaults to off. This is optional, and I won't use it unless your encryption is incorrect and you would like me to consider you for partial credit.
numIterations
),
using 16 rounds each, to determine runtimes.
In addition, the fastest program will receive 20 bonus points.
(Note that due to the CBC requirement, you will not be able to multithread or otherwise
parallelize iterations to gain efficiency, but you are welcome to try to
parallelize within a round if you like.1 iteration (from above): dc67f1c4f0d9a8da 1 1 0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 0 1 1 0 0 1 1 0 1 0 1 0 0 0 1 1 0 1 1 0 1 0
2 iterations: c97cde8c10d89bef 1 1 0 0 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1
20 iterations: 082b5e9b15a51b95 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 1 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 1 0 1 0 1
100,000 iterations: bdf34116e8564bae 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0 0 1 0 1 1 1 0 1 0 1 1 1 0