CS 4363-001 Cryptography
Spring 2003 -- Mid-term Exam Answers

  1. What is wrong with using a 16-bit random number generator to generate 128-bit cryptographic keys, by calling the generator 8 times to get the needed 128 bits? (Why is this always bad?)
    It is ok to use a software random number generator to generate (pseudo-)random keys as long as there are enough bits in the seed to the generator and as long as the generator is cryptographically secure. One assumes that the code for the generator is available. With a 16-bit generator, there are only 216 possible starting points, and therefore the same number of possible 128-bit keys. This could be immediately searched. Notice that even a 16-bit generator might work if one used a new seed for each of the 8 calls to it. One could ask: if one has random seeds available, why not just use them for the keys? But the seed values may not be uniformly distributed and may have other unpleasant properties.
  2. This problem is concerned with Merkle's "puzzle" method of key distribution. Suppose Alice and Bob want to end up with a a cryptographic key in common, after communicating in public, with Boris listening in. Bob sends Alice a large number of "puzzles", that is, ways of sending information in a package that can be broken open with a fixed amount of execution time.
    1. What information (or data) is stored in each puzzle?
      A random key, a sequence number, and in our example enough redundant bits (such as a long string of 0's) to easily identify the broken puzzle.
    2. What does Alice do with all the puzzles?
      Alice picks a puzzle at random. (They have been sent in random order.) She breaks this one puzzle, retrieves the key and sequence number, and sends the sequence number back to Bob.
    3. What does Bob do in response to what Alice does?
      Bob uses the sequence number that Alice openly sent to retrieve the corresponding key, which Alice also has.
    4. Why is it hard for Boris to get the same information that Alice and Bob have in common?
      Boris doesn't know which puzzle Alice chose, so he has to break half of them on the average until he knows the secret key Alice and Bob are using.

  3. Suppose one has a random number generator rnd that returns 128 random bits each time it is called (say as an array of 16 bytes). There is also a function setRnd that takes 128 bits as input to work as a seed.
    1. Show with equations or with a diagram (or both), how one can use exclusive-or to turn this into a cryptosystem. (Assuming a 128-bit message m, how does one form the ciphertext and how does one decrypt?)

      As equations, encryption takes the form:
      setRnd(seed); c = rnd() xor m;
      transmit c openly, and seed securely;

      Decryption takes the form:
      receive seed securely and c openly;
      setRnd(seed); m = rnd() xor c;

    2. What does CBC stand for?
      Cipher Block Chaining
    3. Give a significant disadvantage that the system in a. would have that is not present when the CBC mode is used.
      See notes or the Handbook.

  4. This is a question about Fermat's Theorem and its use.
    1. State Fermat's Theorem.
      For a not 0 and p a prime, ap-1 mod p = 1.
    2. Use the theorem to simplify the expression 9111 mod 13.
      = 9(111 mod 12) mod 13
      = 93 mod 13 = 729 mod 13 = 1
    3. How can Fermat's theorem be used to prove (with certainty) that a number is not prime? Will this method work for any non-prime?
      If an-1 mod n is NOT 1 for some non-zero a, then n is definitely not a prime. However, this method doesn't always work, because there are numbers (Carmichael numbers) such that the equations works out to 1 for every a, yet still they are not prime.

  5. Consider the random codes that are used to prove Shannon's noisy coding theorem.
    1. What are the information words (or source words)?
      Pick a block size n, and the source words are all 2n strings of n 0's and 1's.
    2. What are the code words?
      Pick a length m greater than n, and for each source word choose a random bit string of length m as the corresponding code word. For the binary symmetric channel, the code words must be at least n/C long, where C is Shannon's channel capacity. If one wants to transmit a source word, one transmits the longer code word instead.
    3. Given a transmitted code word with errors introduced in the channel, say briefly how it is decoded.
      On receipt of a code word, with assumed errors, one searches all code words for the code word differing from the transmitted code word in the smallest number of bit positions (Hamming distance). The corresponding source word is then taken as what was originally transmitted. Of course this method doesn't always work. A give random code could be anything at all, but Shannon showed that the average over all codes has to satisfy his theorem, so therefore there is a code that satisfies it also.

  6. This problem is concerned with the following exp algorithm from the notes and discussed in class: Suppose one knows that the following equation is true, for integer variables x, y, z, X, and Y, and = is the mathematical equals: and suppose the following 2 assignment statements are executed, where = is assignment: a. Prove that the equation remains true (remains invariant) after the two assignments are executed.
    See the notes of proof of this part. Notice that it is not very satisfactory to use the same names z and y for the values of these variables before and after the assignments.

    b. At the point in the above algorithm just before the two assignments statements, it is also true that y%2 is not zero, that is, y is odd. Is this needed for the proof of invariance?
    The proof of the invariance after the two statements inside the inner while loop requires that one know the value of y is even. However, in this case, even though y is odd, the proof of invariance does not rely on y being odd.

    In light of the above two parts, consider the following C, C++, or Java function?

    c. Do you think this second function will correctly calculate XY ?
    The invariance result along with initial values, terminal values, and a proof that the loop terminates, proves that this simpler function also calculates the power.

    d. Do you think this version of exp is of any use?
    This latter version takes Y many steps, whereas the earlier version takes at most log2Y many steps (which are more complicated), a very much faster algorithm for large Y. This simpler algorithm is useless for cryptography and other similar applications because it is far too slow, but the algorithm is useful for small Y and for educational purposes (as here). Thus this question doesn't have a simple yes or no answer.


Points for each problem: 1-10, 2-20, 3-20, 4-20, 5-20, 6-30.