LAB 7            Fall 2001            Michael Siff      

Diffie-Hellman Key Exchange

Lab Report due Tuesday, November 13

    Introduction

    The goal of this lab is to demonstrate Diffie-Hellman Key Exchange. Along the way, participants should hopefully learn about the relative efficiencies of computing modular exponents and discrete logarithms.


    Computing modular exponents

    Experiment with this modular-exponentiation servlet.

  1. Compare and contrast the three algorithms. Which one seems to be fastest? Which one seems to be slowest? Does your answer vary on the inputs?

    For each of the three algorithms, if possible, try and find values of g, e and m that cause the servlet to fail to give a result. (Either by responding something like:

      Fatal error: Maximum execution time of 5 seconds exceeded 
    
    or producing some other message. If it's another message, indicate what that message is.)

  2. Which of the three variables seems most important in determining the amount of time it takes each algorithm to execute?

  3. Use one of the algorithms to compute:

    22517583785227797626279515343958 mod 2517583785227797626279515343959.

    Indicate the answer and which algorithm you used to arrive at that answer. Pick one of the algorithms you did not use and estimate (roughly!) how long it would have taken to compute the answer using that algorithm. Finally, indicate how you might have arrived at the answer quite rapidly without using any of these three algorithms.


    Diffie-Hellman exchange

    Use the modular-exponentiation tool to compute shared keys following the Diffie-Hellman protocol. That is, choose two different values for private keys, a for a fictional Alice, b for a fictional Bob. Use the tool to compute:

      x = ga mod m
    
    and
      y = gb mod m
    
    Then use the tool and those values to find a shared key. Make sure and check that
      xb mod m = ya mod m.
    
  4. Report the five values (a, b, x, y, and xb mod m) that you arrive at when g=5 and m=1487.

  5. Use the shared key you just found to encrypt the plaintext "cat" using Vigenère style-XOR encryption. That is:


    Cracking Diffie-Hellman via discrete log

    Experiment with using this discrete-log tool.

  6. For what values of g, p and ge mod p cause the servlet to respond something like:
      Fatal error: Maximum execution time of 15 seconds exceeded
    

  7. Which of the three variables seems most important in determining the amount of time it takes to compute the discrete log?

  8. Fixing values of the other two variables, try and find the smallest value (to the nearest 1000) of the remaining variable for which it takes too long to get an answer. Record all three values for the variables you used. How does the efficiency of computing discrete log stack up to modular exponentiation? Comment on the relevance of this comparison.

    The best known method for foiling Diffie Hellman is to compute the discrete log of either

      ga mod p
    
    or
      gb mod p
    
    in order to recover one of the private keys so you can form the shared key.

    Suppose you have intercepted the following string of bits sent from Alice to Bob:

      11010101101111011011010100110111
    
    The bits have known to have been encrypted using a shared key generated via Diffie Hellman with g=103 and p=57143. While Alice and Bob were setting up their key, you eavesdropped that: Alice sent 33600 to Bob and Bob sent 28988 to Alice.

  9. Use the discrete-log tool to uncover the the shared key. (First by finding one of the private keys, then computing the shared key.) Then use that to decrypt the message: first from cipher bits to plain bits, then from bits to ASCII. Report the private key you found (and whose it is), the shared key, and the ASCII plaintext (i.e. what it says in English).


    DHeKE

    Meet DHeKE (pronounced "deek"), the Diffie-Hellman-Key-Exchange computer. To interact with DHeKE, you need a login (your regular Sarah Lawrence username) and a password (see me).

  10. Construct a shared key with DHeKE. Report your private key and the shared key you computed.

    Look at the public record: all the messages that DHeKE has exchanged with the class to date.

  11. Use your shared key to encrypt your password. Send the encrypted bits to DHeKE. (That is, convert your password from ASCII to binary. Encrypt the bits using XOR and the binary representation of your shared key, repeating the key if necessary.)

  12. Request that DHeKE send you an encrypted message. Decrypt that message using your shared key. Report the English plaintext of the message.

    Extra credit (due any time before end of the semester): Use DHeKE's public record and all your cryptanalytic skills to intercept and decrypt as many of the messages in the record as you can. If you decrypt all the messages, you will uncover a clue...


crypto home assignments labs notes tools contact instructor