GNUPG or GPG for short

By Robert Spotswood

Table of Contents

  1. GNU Privacy Guard
  2. Introduction
  3. About GPG
  4. Why? (part 1)
  5. Why? (part 2)
  6. Why? (part 3)
  7. Why? (part 4)
  8. Theory - Pieces
  9. Theory - One Way Hashes
  10. Theory - Algorithms
  11. Theory - Keys Part 1
  12. Theory - Keys Part 2
  13. Theory - Keys Part 3
  14. Theory - Symmetric keys
  15. Theory - Asymmetric keys
  16. Theory - Key Signing (Part 1)
  17. Theory - Key Signing (Part 2)
  18. Theory - Encrypting/Decrypting
  19. Theory - Digital Signatures
  20. Theory - Certificates
  21. Theory - Vulnerabilities
  22. Practice - The tasks
  23. Practice - Listing the keys on your keyring
  24. Practice - Encrypting a message
  25. Practice - Decrypting a message
  26. Practice - Signing a message
  27. Practice - Signing a message (con't)
  28. Practice - Verifying the signature
  29. Practice - Generating a key pair
  30. Practice - Generating a revocation certificate
  31. Practice - Exporting your public key
  32. Practice - Importing (adding to your keyring) the public keys of others
  33. Practice - Validating a key
  34. Practice - Signing a key
  35. Practice - Checking a key's signatures
  36. Practice - Deleting keys from your keyring
  37. Practice - GUI Frontends
  38. ROT13 Explained

Introduction

GNU Privacy Guard     Table of Contents   About GPG


About GPG

Introduction     Table of Contents   Why? (part 1)


Why? (part 1)

When I (and others who think like me) try to convince others to start using encryption to protect themselves, the most common response is "Why should I worry about my privacy? I have nothing to hide?"

My response is this:

In addition, gpg isn't just about privacy. It does other tricks too.

About GPG     Table of Contents   Why? (part 2)


Why? (part 2)

This brings us to the next objection: "To enjoy the benefits of modern society, we must necessarily relinquish some degree of privacy."

My response is this:

Why? (part 1)     Table of Contents   Why? (part 3)


Why? (part 3)

The next objection heard is "I'll use encryption only when I need it. Only when I have something sensitive."

My response is this:

Why? (part 2)     Table of Contents   Why? (part 4)


Why? (part 4)

Now the objection heard might be, "Ok, so it is useful, but it's too much trouble to bother with."

My response is this:

Why? (part 3)     Table of Contents   Theory - Pieces


Theory - The Pieces

GPG has many "pieces" that make it up. To understand how they work together, you first should understand what each piece does. The following "pieces" are going to be described:

After you understand the pieces, next will be how the pieces fit and work together:

Why? (part 4)     Table of Contents   Theory - One Way Hashes


Theory - One way hashes

Here is a very simple example of a one way hash. Take every third letter of each word. If there is no third letter, starting with 0, substitute a digit, increasing the digit by one each time. Once you reach 10, start over with 0 again. For example given the following text:

Mary had a little lamb
the hash would be rd0tm. Given rd0tm, could you figure out the original phrase if you didn't already know it?

Theory - Pieces     Table of Contents   Theory - Algorithms


Theory - Algorithms

Theory - One Way Hashes     Table of Contents   Theory - Keys Part 1


Theory - Keys Part 1

Theory - Algorithms     Table of Contents   Theory - Keys Part 2


Theory - Keys Part 2

Theory - Keys Part 1     Table of Contents   Theory - Keys Part 3


Theory - Keys Part 3

Theory - Keys Part 2     Table of Contents   Theory - Symmetric keys


Theory - Symmetric keys

Theory - Keys Part 3     Table of Contents   Theory - Asymmetric keys


Theory - Asymmetric keys

Theory - Symmetric keys     Table of Contents   Theory - Key Signing (Part 1)


Theory - Key Signing (Part 1)

Theory - Asymmetric keys     Table of Contents   Theory - Key Signing (Part 2)


Theory - Key Signing (Part 2)

Theory - Key Signing (Part 1)     Table of Contents   Theory - Encrypting/Decrypting


Theory - Encrypting/Decrypting

Theory - Key Signing (Part 2)     Table of Contents   Theory - Digital Signatures


Theory - Digital Signatures

Theory - Encrypting/Decrypting     Table of Contents   Theory - Certificates


Theory - Certificates

Theory - Digital Signatures     Table of Contents   Theory - Vulnerabilities


Theory - Vulnerabilities

Theory - Certificates     Table of Contents   Practice - The tasks


Practice - The tasks

In GPG, there are only a few operations you will perform with any regularity. They are:

There are also a few other operations that while only needed once in a while, are also important. They are:

The following describes how to use GPG from the command line. However, for those that like GUI's, there are numerous frontends to GPG. They are listed at the end of this presentation. They making using GPG much easier. However, by learning the command line, you are not stuck if a GUI (or X) isn't available or working. Not every option can be presented (time!). See the official docs if you are interested in more options.

Theory - Vulnerabilities     Table of Contents   Practice - Listing the keys on your keyring


Practice - Listing the keys on your keyring

Listing keys is important, because other operations will often ask you what key to use. The simplest way to list the keys on your public keyring use the command-line option --list-keys. For example:

[robert@linux]#  gpg --list-keys
gpg: Warning: using insecure memory!
/home/robert/.gnupg/pubring.gpg
pub  1024D/38952095 2000-08-27 Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>
sub  1024g/0D2EF746 2000-08-27

pub  1024D/9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys) <mandrake@mandrakesoft.com>
sub  1024g/686FF394 2000-01-06

pub  1024R/98ABFE7D 1996-08-25 Craig H. Rowland <crowland@psionic.com>

pub  1024D/DB42A60E 1999-09-23 Red Hat, Inc <security@redhat.com>
sub  2048g/961630A2 1999-09-23
<snip>

The part after the / on the lines that start with pub is the key's name. For instance, for my key (the first one), the key's ID (or name) is 38952095. If you don't want to see all the keys, you can add a name after the --list-keys. The name can be the key's ID, fingerprint (covered later), or any part of the descriptive text (i.e. for me, it would be "Robert Spotswood (New gpg key and new address) ". For example:


[robert@linux robert]$ gpg --list-keys key
gpg: Warning: using insecure memory!
pub  1024D/38952095 2000-08-27 Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>
sub  1024g/0D2EF746 2000-08-27

pub  1024D/9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys) <mandrake@mandrakesoft.com>
sub  1024g/686FF394 2000-01-06

Practice - The tasks     Table of Contents   Practice - Encrypting a message


Practice - Encrypting a message

Practice - Listing the keys on your keyring     Table of Contents   Practice - Decrypting a message


Practice - Decrypting a message

Here is a sample decryption:

[robert@linux robert]$ gpg --decrypt junk.txt.gpg
gpg: Warning: using insecure memory!

You need a passphrase to unlock the secret key for
user: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
1024-bit ELG-E key, ID 0D2EF746, created 2000-08-27 (main key ID 38952095)

This is a test encryption. <----This was the encrypted text.

Practice - Encrypting a message     Table of Contents   Practice - Signing a message


Practice - Signing a message

Here is an example of signing and encrypting and using the output option:

[robert@linux robert]$ gpg --output junk.gpg --sign --encrypt junk.txt
gpg: Warning: using insecure memory!

You need a passphrase to unlock the secret key for
user: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
1024-bit DSA key, ID 38952095, created 2000-08-27

You did not specify a user ID. (you may use "-r")

Enter the user ID: 38952095
gpg: using secondary key 0D2EF746 instead of primary key 38952095

Practice - Decrypting a message     Table of Contents   Practice - Signing a message (con't)


Practice - Signing a message (con't)

Here is an example of just clearsigning:

[robert@linux robert]$ gpg --output junk.clear.gpg --clearsign junk.txt
gpg: Warning: using insecure memory!

You need a passphrase to unlock the secret key for
user: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
1024-bit DSA key, ID 38952095, created 2000-08-27

The file junk.clear.gpg (clearsigned message) is:


Hash: SHA1

This is a test encryption.
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6WVkDXPYCfjiVIJURAkllAKCmlKtCnlIZvB92E7lsnU3Dv+X7rwCfdJFu
mWcXQYxGOWUqaj6jcXpsN9Q=
=+D/K

Practice - Signing a message     Table of Contents   Practice - Verifying the signature


Practice - Verifying the signature

Here is an example of verifying with an unaltered file:

[robert@linux robert]$ gpg --verify junk.clear.gpg
gpg: Warning: using insecure memory!
gpg: Signature made Mon 08 Jan 2001 12:06:59 AM CST using DSA key ID 38952095
gpg: Good signature from "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"

Here is an example of verifying when I added a space before " encryption.". This is something only a few people would ever notice.

[robert@linux robert]$ gpg --verify junk.clear.gpg
gpg: Warning: using insecure memory!
gpg: Signature made Mon 08 Jan 2001 12:06:59 AM CST using DSA key ID 38952095
gpg: BAD signature from "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"

Practice - Signing a message (con't)     Table of Contents   Practice - Generating a key pair


Practice - Generating a key pair

Practice - Verifying the signature     Table of Contents   Practice - Generating a revocation certificate


Practice - Generating a revocation certificate

Here is an example of me generating a revocation certification:

[robert@linux robert]$ gpg --gen-revoke berzerke@swbell.net
gpg: Warning: using insecure memory!

sec  1024D/38952095 2000-08-27   Robert Spotswood (New gpg key and new address) 

Create a revocation certificate for this key? y
Please select the reason for the revocation:
  1 = Key has been compromised
  2 = Key is superseded
  3 = Key is no longer used
  0 = Cancel
(Probably you want to select 1 here)
Your decision? 3
Enter an optional description; end it with an empty line:
> test revocation
>
Reason for revocation: Key is no longer used
test revocation
Is this okay? y

You need a passphrase to unlock the secret key for
user: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
1024-bit DSA key, ID 38952095, created 2000-08-27

ASCII armored output forced.
Revocation certificate created.

Please move it to a medium which you can hide away; if Mallory gets
access to this certificate he can use it to make your key unusable.
It is smart to print this certificate and store it away, just in case
your media become unreadable.  But have some caution:  The print system of
your machine might store the data and make it available to others!
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
Comment: A revocation certificate should follow

gFi<snip>gTy
C<snip>ZsrI
=RguI

P.S. That's not my real revocation certificate above!

Practice - Generating a key pair     Table of Contents   Practice - Exporting your public key


Practice - Exporting your public key

Here is an example:

[robert@linux robert]$ gpg --output robert.key --armor --export berzerke@swbell.net

Practice - Generating a revocation certificate     Table of Contents   Practice - Importing (adding to your keyring) the public keys of others


Practice - Importing (adding to your keyring) the public keys of others

Here is an example:

robert@linux robert]$ gpg --import cert_pgp_key.asc
gpg: Warning: using insecure memory!
gpg: key 20B19259: public key imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Practice - Exporting your public key     Table of Contents   Practice - Validating a key


Practice - Validating a key

Here is an example of fingerprinting a key:

[robert@linux robert]$ gpg --fingerprint CERT
gpg: Warning: using insecure memory!
pub  1024R/20B19259 2000-09-20 CERT Coordination Center <cert@cert.org>
     Key fingerprint = 6D DB 09 5E 34 8A C5 60  11 57 0D D1 1E 43 FD 1D

Practice - Importing (adding to your keyring) the public keys of others     Table of Contents   Practice - Signing a key


Practice - Signing a key

Here is an example of signing a key:

[robert@linux robert]$ gpg --sign-key CERT
gpg: Warning: using insecure memory!

pub  1024R/20B19259  created: 2000-09-20 expires: 2001-10-01 trust: -/q
(1)  CERT Coordination Center 

pub  1024R/20B19259  created: 2000-09-20 expires: 2001-10-01 trust: -/q
             Fingerprint: 6D DB 09 5E 34 8A C5 60  11 57 0D D1 1E 43 FD 1D
     CERT Coordination Center <cert@cert.org>

Are you really sure that you want to sign this key
with your key: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
Really sign? y

You need a passphrase to unlock the secret key for
user: "Robert Spotswood (New gpg key and new address) <berzerke@swbell.net>"
1024-bit DSA key, ID 38952095, created 2000-08-27

Practice - Validating a key     Table of Contents   Practice - Checking a key's signatures


Practice - Checking a key's signatures

Here is an example of checking signatures on a key:

[robert@linux robert]$ gpg --check-sigs network
gpg: Warning: using insecure memory!
pub  1024D/A70A8463 1999-08-20 Networked Systems Survivability Master Key 
sig!       A70A8463 1999-08-20  Networked Systems Survivability Master Key 
sig?       F414952B 1999-08-24
sig!       38952095 2001-01-11  Robert Spotswood (New gpg key and new address) 
sub  3072g/3A526935 1999-08-20 [expires: 2004-09-30]
sig!       A70A8463 1999-08-20  Networked Systems Survivability Master Key 

Practice - Signing a key     Table of Contents   Practice - Deleting keys from your keyring


Practice - Deleting keys from your keyring

Here is an example of deleting a key:


[robert@linux robert]$ gpg --delete-key crowland
gpg (GnuPG) 1.0.4; Copyright (C) 2000 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
 
gpg: Warning: using insecure memory!
pub  1024R/98ABFE7D 1996-08-25   Craig H. Rowland <crowland@psionic.com>
 
Delete this key from the keyring? y

Practice - Checking a key's signatures     Table of Contents   Practice - GUI Frontends


Practice - GUI Frontends

Want to use GPG but hate the command line? You're in luck! There are a number of GUI front-ends for GPG. Here are links to some of them:

All of these frontends will require some degree of cut and paste to use with email programs such as Netscape and Mozilla. The following programs are available to help eliminate the cut and paste:

Practice - Deleting keys from your keyring     Table of Contents   ROT13 Explained


ROT13 Explained

To manually encrypt or decrypt a ROT13 message, for each letter in the first line of the chart below, replace it with the letter on the second line:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY
nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKL

For example, the text "Linux" would encrypt as "Yvahk".

Practice - GUI Frontends     Table of Contents