WWII Code Breaking at Bletchley Park

Adversary Games

by: burt rosenberg
at: university of miami
date: feb 2018

Overview

There are three problems in the project. The first is paper-and-pencil. You will draw some graphs and calculate a probability.

The next two use python. The starting templates with makefile are found in the class folder of the course repository. The python code follows the class text proofs of security, the adversary game and the reduction from pseudorandomness to the unbreakability of a cipher, by doing the mathematical construction in code. I hope this make the rather complicated construction more understandable.

In the last project, you will also be introduced to the LFSR, and their use as a PRG. Although there are strong PRG's based on LFSR, see Trivium, three of the ones I present are easily broken, and these make a good exercise finding the weakness. The fourth, I'm not so sure about. It is based on a typically considered extension to LFSR's, and I leave it to you to explore for a weakness.

Problem 1: Discriminating probability distributions

In this problem you draw probability distribution functions and describe ways to discriminate between two distribution functions; also calculate the advantage in determining for which of the two distribution functions was drawn a sample.

The probability distribution is P(C|M=m) for a shift cipher on the with keys 0 through 25 and messages m a single letter, "a" through "z". Hence the distribution is a bar chart of 26 value, for each of the ciphertext c, of the probability (over the probability space of key choice) that m enciphers to c. We will assume the message texts are chosen uniformly at random.

In the spirit of the indistinguishability game, give a method for predicting which of m0 or m1 was enciphered given c, and calculate the advantage.

  1. Consider a perfect cipher were keys are chosen uniformly at random. Draw P(C|M=m) for m is "p" and "q". Why is it impossible to win the indistinguishability game?
  2. Suppose the key 0 is not allowed — for some reason the user of the cipher does not want c to equal m. Maybe they think this will be more secure?
    Draw P(C|M=m) for m is "p" and "q". Describe how the two distributions can be distinguished. Give the m0, m1 and decision rule for guessing the bit in the indistinguishability game; calculate the advantage.
  3. Consider then the key is not allowed to be 1, 2 or 3. Draw two probability distributions with m such at the distributions are maximally distinguishable. What was the criteria for you choice of m's? Continue as above to give the bit guessing rule and calculate the advantage.
  4. Consider when the key is only allowed to be even. Continue as above to show two maximally distinguishable P(C|M=m), the decision rule, and the advantage.

Problem 2: Indistinguishability for Vigenere

We will construct in Python the adversarial indistinguishability game that is the subject of Definition 2.5 in the class text, and described on page 31. We will run the code to verify and experiment with the problem given as Exercise 2.8 on page 39.

The code template is given in [repo]/class/proj2/adv-indistin.py; comments indicate where you are to complete the code. Copy to your [repo]/[user]/proj2 along with the Makefile, complete and submit. A fully correct solution completes part (a) of the exercise by both calculating the theoretic advantage of the method given, and comparing with the experimental result; also by completely part (b) and finding a stronger method, with greater advantage, showing that in the code, and running for an experimental result.

Note that this is 2.6 code; please make changes after copying to you folder if you are using 3.0.

The adversary_advantage function repeatedly runs adversary_sample to get the probability that the adversary wins the indistinguishability game, i.e. that the adversary can distinguish whether it was message 0 or message 1 that was encrypted. The adversary provides the messages by the return value of adversary_challenge and the logic to decide based on the ciphertext is in adversary_decision. The cipher logic needs to be completed; the key generator is complete.

Problem 3: Distinguishability for PRGs

We will construct in Python the reduction of Theorem 3.18 in the class text, and perform experiments.

The code template is given in [repo]/class/proj2/prg-distingu.py; comments indicate where you are to complete the code. Copy to your [repo]/[user]/proj2 along with the Makefile, complete and submit. A fully correct solution should show advantage when the A generator is run against a truly random generator; and likewise for the B generator.

Note that this is 2.6 code; please make changes after copying to you folder if you are using 3.0.

The function adversary_sample is a presented with a generator of pseudorandom bits and returns true or false based on advice from a further function adversary_decision, which is the decision of an adversary playing the indistinguishability game for a vernon cipher. The connection between the pseudorandom bits and the vernon cipher, is that the vernon cipher enciphers using the given pseudorandom generator. In particular, a "true" (by our low standards) random string is provided to the vernon cipher, for which the adversary must have no advantage; then a string generated by a Linear Feedback Shift Register (LFSR) are given, and your programming of the decision function should be able to have an advantage in the indistinguishability game.

The code for the generators is supplied. We will talk in class about the LFSR's and their possible weaknesses for random bit generation. There are four generators provided. The first task is to work against the generator "A". The second task is a challenge problem to work against generator "B". The B generator combines short generators S and T by stepping one or the other depending on the next bit drawn from generator A.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 4 feb 2018
update: 5 feb 2018