Lab 04 - Public Key Encryption

Before starting the labs, download openssl 1.1.1 from here. Save the file to some local folder accessible by you, then compile it and install it to some folder. Open the unpacked folder from bash, and run the following commands:

linux$ ./config --prefix=/home/student/local --openssldir=/home/student/local/openssl
linux$ make
linux$ make test
linux$ make install

(in case of trouble, check also the instructions at the end of this lab).

Exercise 1: Diffie Hellman (8p + 2p)

As we discussed in class, Diffie and Hellman proposed the first public key exchange mechanism such that two parties, that did not share any previous secret could establish a common secret. This allows the parties to have a shared key that only they know (except if there is an active man in the middle attack, which is usually solved by using TLS/certificates, but we shall not focus on that here).

Download the lab code from here. After unzipping, you'll find the source code for a client (dhe.c) and a server (dhe_server.c), along with a Makefile and fixed Diffie-Hellman p and g params in the files dhparam.pem.

Update the Makefile with the paths relevant to your installation folders if you didn't use /home/student/local as installation place for openssl.

The client and server have a similar structure. Each of them should build a public key, then send it to the other party, receive the public key from the other party and finally compute the secret key. Your task is to complete the missing parts. For this, consult the openssl documentation here. Since the client and server are similar, focus only on one of them and then do similarly on the other one.

The makefile should help you build both. Just type 'make all'. After completing the necessary todo's in the file, you can start the server by typing 'make start_server' and the client with 'make start_client'.

If all goes well, you should see the same secret key on both client and server.

Bonus 1

Perform the DH key exchange between two teams, sending the public key values over the network and verify that you get the same secret key.

Bonus 2

Use the secret key to encrypt some data and check that the other party can decrypt it. You can use the code available here.

ac/laboratoare/04.txt ยท Last modified: 2022/10/27 15:58 by marios.choudary
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0