CSE 247 Module 12: Diffie–Hellman


Abstract: A one-time pad (OTP) is a provably unbreakable encryption scheme. Alice and Bob each have identical copies of the OTP, and they use the OTP's values to communicate secretly. Messages can be encrypted and decrypted using exclusve-or as shown in lecture.

The key problem, so to speak, in using an OTP is distribution of the pad. Transport of the pad admits the possibility of Eve seeing its contents, and once known, Eve can decrypt messages sent by Alice and Bob.

We solve the OTP distribution problem here by using Diffie–Hellman to compute the OTP by Alice and Bob simultaneously. The values are computed by generating (most likely different) random values separately by Alice and Bob, which are turned into agreement on each side using Diffie–Hellman.

Overview of the software for this assignment

This program demonstrates the Caesared class,which rotates certain characters of a message. You looked at this in studio, but run it again here to make sure you understand its effects. In particular, it rotates only lower-case characters, so that punctuation and upper-case letters are preserved in the rotation.
As described in lecture, this class generates powers of a base to a specified modulus. The class can be used in two ways:
It is often the case that we want all results computed for a certain base and modulus. The DHFactory captures the base and modulus and ensures that each call to nextDH(long privKey) returns a Diffie–Hellman object with the agreed upon base and modulus.
This is the only class you must complete for this assignment. The constuctor accepts the base, privKey (private key), and modulus. Your solution must arrange for the following:
In the running example from lecture, Alice and Bob agreed upon a base and modulus of 5 and 23, respectively.

Alice's privKey was 6, and so a call to getPubKey() would return 8 for her, which is 56 mod 23.

Bob's public key was 19, so a call on Alice's DH object of getAgreedNum(19) would return 2, computed as 196 mod 23—the number upon which Alice and Bob agreed in lecture.

is the unit test for your DH implementation. Make sure you pass this test before submitting your work.
computes the Alice and Bob results described above, as well as the results of a random computation.
is a participant in using a one-time pad to rotate and unrotate text for encryption and decryption, respectively. The agents are used by…
demonstrates the SendMessage class with two messages, one all caps (so nothing is rotated) and one with all lower case.

In studio, all characters were rotated the same amount and you determined that rotation value by analysis. Here, each character is rotated a different amount, depending on the Diffie–Hellman agreement integers.

Thus, a given character (such as e) will not be rotated the same amount throughout the message.

allows you to type in a string and see it sent via the one-time pad rotational cipher.
This seems like a perfect encryption scheme, because it apparently uses a one-time pad between the sender and receiver. Below is a sample of output from my solution:
Looking at the first three letters of the lower case alphabet portion, which were received properly as a, b, and c, they were sent as r, y, and r. So a was sent as r, but two characters later, c was also sent as r. This is because the rotation amount changes for each character according to the one-time pad computed by the sender and receiver.

Is this a perfect encryption scheme? Why or why not?

Submitting your work (read carefully)

Last modified 14:14:23 CST 01 December 2016