Lab2 PGP
Lab2 PGP
Objectives
Understand the concept of public keys, signing, and encrypting email with PGP.
Background
GNUPG (or GNU Privacy guard) is a free implementation of the OpenPGP standard (RFC 4880) as a
tool for secure communication. It is a method for digitally signing messages.
Note: The instructions that follow are specific to the software applications specified. This is only one of
many ways to accomplish this exercise.
Steps:
I. Installation
A. Installing PGP
• GPGTools - https://www.gpgtools.org/
Note: make sure to verify the hash after download (this is good practice)
If using Windows, install GPG4Win. The current version is gpg4win-2.2.1, a complete package
with Kleopatra and Compedium.
• GPG4Win - http://www.gpg4win.org/
As both of these are GUI-based, installation is straightforward. Simply follow the install
process.
To install on Linux (CentOS) or Ubuntu, this can be done from the command line.
To generate, click the New icon on the upper left menu. Input the following:
gpg –gen-key
II. Usage
a. Using your favourite text editor, create a text file. This file supposedly contains “sensitive
information” so you want to encrypt it.
vi my-secret-file.txt
If it asks for a recipient email, you may write your own email address.
c. Verify that you now have another file with extension .gpg in the same folder. This file is in
binary. If you try to open, it will only show garbage.
d. If you want something readable, encrypt using ASCII encoding. To do this, the command is
as follows:
gpg –a –e my-secret-file.txt
e. Check the contents of the folder and a .asc file should have been added. At this point, you
may delete your original .txt file.
You will be prompted to input your passphrase. After this, a .txt file will be created in the
same folder. Verify that this is the same as your original file.
If you do not have Thunderbird installed yet, please download and install from
https://www.mozilla.org/en-US/thunderbird/
On Thunderbird, select Tools, then Add-ons. When the Add-ons menu appear, either search
for Enigmail (this will download a new copy of Enigmail).
Alternatively, you can download the add-on from the link below. Then click on the gear icon,
then click “Install Add-on from file”
https://www.enigmail.net/download/
Notice the OpenPGP menu has been added to the top menu.
Compose an email. In the compose window, notice the OpenPGP button. Click on this, and
tick “Sign Message,” “Encrypt Message” or both.
This will create the .asc file in the same folder. The contents will look something like this:
B. Exchanging keys
Once exported, forward or email your public key to your to each other. This is not a secure way
to exchange keys, but will do for this lab.
Once you receive other people’s public keys, import them using the command:
gpg --import my-colleague-key.asc
If successful, this will be indicated as imported.
gpg --list-secret-keys
To encrypt key using your colleague’s key instead of yours, the command is as follows:
gpg –a –e –r [email protected] my-secret-file.txt
Make sure to replace the email with the email address of your colleague used in the public key
you imported.
Replace the KEYID with your own keyID. You can find this when you list your available keys in
the keyring.
You may also find the key ID using the fingerprint command.
D. Now verify whether you obtained the same key from what your colleague has by asking them to
read out their fingerprint. This is the key fingerprint value with the fingerprint command above.
See example below:
pub 2048R/2B058225 2011-06-18 [expires: 2016-06-16]
Key fingerprint = 27AF B7E0 123B 0896 BA06 2F1E F57A FB8F 2B05
8225
uid Sheryl Hermoso <[email protected]>
sub 2048R/7D20FAAC 2011-06-18 [expires: 2016-06-16]
E. Also verify the person’s identity. You may ask them to present a government ID or passport to
verify their name. If convinced, you may sign their key.
gpg --sign-key KEYID