pgp in five minutes

PGP, and its open standard OpenPGP, encrypts and signs files and email. GnuPG (gpg) is the tool most people use. It is old, powerful and famously awkward, but the ideas are simple.

encrypting

PGP is hybrid. The message is encrypted with a random one-time session key, and that small key is then encrypted to the recipient's public key.

message          session key (random)
   |              |            |
   v              |            v
[ aes ] <---------'  [ bob's public key ]
   |                           |
   v                           v
ciphertext            wrapped session key
   |                           |
   '-------------+-------------'
                 v
            message.gpg

Sending to three people only wraps the session key three times. The message itself is encrypted once. Bob uses his private key to unwrap the session key, then decrypts the message.

signing

            document
                |
                v
           [ sha-256 ]
                |
                v
             digest
                |
                v
[ sign with alice's private key ]
                |
                v
          signature.asc

To verify, anyone with the document, the signature and Alice's public key can check that the signature matches. Change one byte of the document and verification fails.

a key is a bundle

A PGP key is really a set of keys. A primary key certifies your identity and subkeys do the daily work. You can keep the primary key offline and replace subkeys without losing your identity.

primary key  [C]  certify        your identity, keep offline
   |
   +-- subkey [S]  sign
   +-- subkey [E]  encrypt
   '-- subkey [A]  authenticate   can be used for ssh

the essentials

gpg --full-generate-key
gpg --list-keys --keyid-format long
gpg --armor --export you@example.com > pub.asc
gpg --import friend.asc
gpg --encrypt --recipient friend@example.com file.txt
gpg --decrypt file.txt.gpg
gpg --clearsign note.txt
gpg --verify note.txt.asc

Always check a key's fingerprint through a separate channel before you trust it. Anyone can publish a key with your friend's name on it.

trust without a ca

PGP was designed around the web of trust: people sign each other's keys, and you trust keys signed by people you already trust. Few people use it in practice. Most compare fingerprints directly, or fetch keys from the owner's domain with WKD (Web Key Directory).

limits

For files, age is a simpler modern alternative. For chat, use Signal. For signing releases, minisign or SSH signatures are lighter. PGP is still the common language for signed software, Linux package repositories and encrypted email.