Assignment 9 - due Friday, December 3, midnight, by email

Please do work on your own - no group work. If you are stuck, contact me. Collaborating on this assignment will be viewed as cheating.

Problem 1

We will work on the Diffie-Helman shared-key cryptosystem first. See my slides from last week.

Part a. For this part, we will use last week's lecture on Diffie-Helman. See slides. What I am going to do is email with one of my graduate students, Jason. We are going to use Diffie-Helman to agree on a shared key. You will see all the transactions between us. Your job is to write a program that will crack Diffie-Helman, and hence, obtain our shared key.

You can see a rough algorithm for the cracking problem off last week's slides. Here is a start:

Below is the correspondence between Jason and I that you were able to capture. Note that before the first email I send, I have (secretly) chosen an A. I don't send this, but keep it locked away somewhere. Before Jason sends his message, he chooses his secret number B and locks it away. Your job is to discover these two numbers we have locked up. At this point, we both calculate our shared key and can then use that to start sending encrypted messages. I won't carry on that conversation here, because you have all you need to get A and B. You don't need to see the encrypted messages that follow.

Turn-in: Your code and the secret values of A and B.

Problem 2

Ok, on to the main event: Chapter 37 - public key cryptography.

Read chapter 37 in Dewdney. However, note that we will *not* be using the knapsack algorithm, but instead, the RSA cryptosystem. So you can read the pages up to 256 to get a general understanding of the early days of public key cryptography. But page 256 describes the actual concept we will be using.

Part a. Jason and I suspect that you have been able to crack our shared key system. So we have chosen to use the RSA algorithm. I would like you to write a program that will crack RSA. More specifically, I would you to guess my private key. Here is a start. (This program can be found in the code directory. Don't copy and paste this. Instead, download the one in code directory.)

Here is the email between Jason and I. Turn-in: a program that can be used to find my secret key (values of p and q). Note, you do not have to turn this in as a separate program if you solve part b below. But it would be a good idea to save your solution here in PartASolution so you have it in case you cannot get part b working. Please tell me how many seconds it takes you to crack my code (use your watch to count seconds).

Part b. This is optional. I will give you 50 extra points if you take it on. Think about ways to make your code run faster, i.e., optimize the loop. I can think of at least two ways to cut the amount of looping in half. Go ahead and make one or more changes, and then time your code again. Report results.

Turn-in: your modified code and timing results. Note that it is not required that your optimization produces any speed-up. As long as it makes logical sense.