Public Key Encryption Part 2

Class Lab 8-1: Part 2 - Public Key Encryption

COUNTERMEASURES AGAINST CYBERATTACKS

ASYMMETRIC CRYPTOGRAPHY

PUBLIC KEY ENCRYPTION

Lab Description: For this lab you will work with a partner to implement asymmetric encryption using Gnu Privacy Guard (gpg), an open-source implementation of Pretty-Good Privacy (pgp).

There are two parts to this lab. In Part 1 practiced encrypting and decrypting messages independently. Now in Part 2 you will apply that skill to sending/receiving messages with another group.

You will

1) Exchange Public Keys with another group

2) Encrypt messages with the appropriate public key

3) Decrypt messages with the corresponding private key

Lab Environment: This Partner Lab uses Kali Live from the bootable Thumbdrives

EXERCISE: SENDING AND RECEIVING MESSAGES WITH A PARTNER

Now that you have a handle on encrypting and decrypting messages, you’ll send and receive messages with another group.

1. Now that you know that your key works for encryption and decryption, you can share your public key with others so that they can encrypt files to be decrypted with your private key. Use the following syntax to export your key to a text file.

$ gpg --export -a your-email-address > YOURNAMEpublic.key

Examine the key using ‘cat’. The ‘-a’ flag you used above has the key encoded in ASCII (text). Some people append a text version of their public key to their email signatures, making it easy for others to use to encrypt files and send to them.

$ cat YOURNAMEpublic.key

2. Email / share your public key to another group in class, and they need to send you theirs. Create a text file with a message to send to them and follow the instructions below to encrypt the message using their public key.

3. You need to import the other group’s public key so you can send them a message. To do this run the following command.

$ gpg --import PARTNERNAMEpublic.key

4. Create a text file with a message to send to the other group. Call this file messageToNAME.txt.

$ leafpad messageToNAME.txt

Write your secret message to encrypt and save the file.

5. Now run the command to encrypt the file to the other group. Notice the similarity to the command you used before to encrypt a message to yourself.

$ gpg –e –r partner-email-address messageToNAME.txt

SCREENSHOT 1: Take a screenshot of the terminal showing the encryption process with the other’s public key for your submission

6. Similar to before, this will generate a file called messageToNAME.txt.gpg. Run the cat command on this file to view and confirm that it has been encrypted. It should not look like plain text when you run

$ cat messageToNAME.txt.gpg.

Email the other group the encrypted message as an attachment, they should send you a message as well. Using your own private key, decrypt the message they sent you.

$ gpg -d name-of-message-received.txt.gpg

SCREENSHOT 2: Take one final screenshot of your terminal window demonstrating you have decrypted the message from the other group.

WHAT TO SUBMIT

SUBMISSION: Screenshot 1 of your terminal showing the encryption process with the other group’s public key.

SUBMISSION: Screenshot 2 of your terminal window demonstrating you have decrypted the message from the other group.

REFLECTION QUESTION 1: Describe the process of encrypting a message using public key encryption if Sydney is sending a message to Jasmine.

If Sydney is sending an encrypted message, encrypted with her own private key. Sydney sends her public key to Jasmine which she uses to encrypt a file. Jasmine sends the file back to Sydney who uses her own private key to decrypt the file or vice versus.

REFLECTION QUESTION 2: How did you know that the public key you were given by the other group actually belonged to the other group? How might you verify this in more complex situations?

You don't actually know that the public key sent by the other group actually belongs to the other group. A CA (Certificate Authority) can sign it to authorize it's legitimacy.

Last updated