**Post: #1**

Using Diffie-Hellman, Ciphers, and Hashes

Using Diffie-Hellman.pdf (Size: 561.17 KB / Downloads: 11)

Introduction: Sending Files Securely

A common issue when sending files over email is security. Say you want to email a sensitive file to somebody

else, but you don’t have any previously shared secret or code which will enable you to send it securely. The

tool you will develop for this assignment addresses this issue, allowing you to securely encrypt and send a

file to the other person without having any previously secure communication mechanism.

The fundamental steps in establishing a shared AES key and Initialization Vector (IV) is shown in

Figure 1.

What to do

Your job is to develop an application which will enable Alice and Bart to perform the above steps. To help

you get started, an empty version of the GUI shown below is provided on Moodle.

Let’s consider a sample run of the algorithm where p = 64601, g = 3, Alice chooses her password “Castor”

and Bart chooses his password as “Pollux”.

Testing Your Application

Your tool should be able to encrypt and decrypt both text and binary files. Managing binary files will require

you to use the BinaryWriter and BinaryReader stream management classes in C#. You can read more

about them in the online documentation.

To help you test your application, there are two encrypted files on the course web page. One is a text

file and one is a PDF (binary) file. They have been encrypted with the same keys that Alice and Bart used

in the above example (p = 64601, g = 3, Alice’s secret “Castor”, Bob’s secret “Pollux”). You may use them

to test your decryption routines.

Be sure to test your application with other example primes and primitive roots. Some useful links:

• Lists of prime numbers: http://primes.utm.edu/lists/small/

• A list of the first 10,000 prime numbers at: http://primes.utm.edu/lists/small/10000.txt.

• A helpful web site with a Java application to derive primitive roots of prime number is found at:

A Note on Modular Exponentiation

You will find that the standard data types in C# are not sufficient to calculate large modular exponents the

simple way (calculating g a and then calculating the modulus with p). You will end up with an overflow in

many cases. A more efficient, bit oriented algorithm exists (you can read about it online), but since we are

dealing with relatively small exponents (16 bits long) we can calculate modular exponents in a reasonable

amount of time recursively. A prepared function in C# to calculate recursive modular exponentiation is

given on the course web page. You may copy it into your application code and use