PGP
Slide deck 20. Pretty Good Privacy: email security services, PGP operation, keys, key rings and the web of trust.
Email securitySearch on YouTube
The problemSearch on YouTube
Email is one of the most widely used and regarded network services. At present, the contents of a message are not secure:
| Who can read the email | Where |
|---|---|
| An eavesdropper | In transit, while the message crosses relays |
| Privileged users | On the destination system, with suitable rights |
Four security enhancementsSearch on YouTube
Four enhancements fix this problem. A secure email system must supply these services:
| Enhancement | Protection from |
|---|---|
| Confidentiality | Disclosure of contents |
| Authentication (of the sender) | A forged sender identity |
| Message integrity | Modification of contents |
| Non-repudiation of origin | Denial by the sender |
Learn the four enhancements in two pairs. The message pair is confidentiality and integrity: they protect the contents. The sender pair is authentication and non-repudiation of origin: they protect the claim "A sent this".
PGP overviewSearch on YouTube
What PGP isSearch on YouTube
PGP (Pretty Good Privacy) is widely used for secure email:
- Phil Zimmermann developed PGP.
- PGP selected the best available crypto algorithms and integrated them into a single program.
- PGP runs on Unix, PC, Macintosh and other systems.
- PGP was originally free. Commercial versions are also available.
Current applicationsSearch on YouTube
Today, PGP means the OpenPGP standard for encryption and digital signatures. The slide shows four use cases:
| Scenario | Flow on the slide | How PGP/OpenPGP is used |
|---|---|---|
| Secure email (Thunderbird) | Sender → encrypted email → recipient. Only the intended recipient can decrypt | Supports OpenPGP encryption and digital signatures when the user configures it |
| Protected file sharing (GnuPG) | Document → encrypted file → authorized recipient. Encrypt before sending or storing | Encrypts and signs files. GnuPG is an implementation, not a separate cryptographic standard |
| Software release verification (Linux kernel releases) | Release + signature → signature verification → integrity check | Uses detached PGP signatures to verify downloaded releases. The software itself is not encrypted |
| Signed development history (Git commits and tags) | Developer → signed commit/tag → signature verification | Can use OpenPGP signatures through GnuPG. Signing is optional, and Git also supports other signature formats |
This table has three exam traps. GnuPG implements OpenPGP; it is not a different algorithm. Linux releases use detached signatures, and the software is not encrypted. Git signing is optional and is not always OpenPGP.
The slide ends with one rule: the public-key identity must be verified. If you encrypt with the wrong public key, the wrong person can read the message. The section on key management returns to this problem.
PGP operationSearch on YouTube
AuthenticationSearch on YouTube
A digital signature gives authentication, integrity and non-repudiation of origin. The five steps are:
- The sender creates the message.
- The sender makes a SHA-1 160-bit hash of the message.
- The sender attaches the RSA-signed hash to the message.
- The receiver decrypts the signature and recovers the hash code.
- The receiver verifies the hash of the received message.
is the private key of the sender. Only the holder of can make a signature that the public key accepts. Thus, the signature also identifies the sender.
The receiver recovers the hash with the public key of the sender. Then the receiver hashes the received message again and compares the two values. Equal values show that the message did not change after signing.
ConfidentialitySearch on YouTube
Encryption of the contents gives confidentiality. The five steps are:
- The sender forms a 128-bit random session key for this message only.
- The sender encrypts the message with the session key (symmetric cipher).
- The sender attaches the session key, encrypted with RSA.
- The receiver decrypts and recovers the session key.
- The receiver uses the session key to decrypt the message.
is the session key and is the public key of the recipient. RSA carries the small secret, and the fast symmetric cipher carries the long message. Each message gets a new .
Both servicesSearch on YouTube
PGP can use both services on the same message:
- Create the signature and attach it to the message.
- Encrypt the message and the signature with the session key.
- Attach the session key, encrypted with RSA/ElGamal.
The signature is inside the encryption. Thus, an eavesdropper cannot see who signed the message.
CompressionSearch on YouTube
By default, PGP compresses the message after signing but before encrypting. The slide gives the reason:
| Point | Explanation |
|---|---|
| Storage for later verification | PGP can store the uncompressed message and the signature, and verify them later |
| Non-determinism | Compression is non-deterministic: the result depends on user preferences. A signature on compressed data may not verify after a new compression |
| Algorithm | PGP uses the ZIP compression algorithm |
The order is exam material: sign first, compress second, encrypt third. Compression before encryption also removes redundancy in the plaintext. Less redundancy makes cryptanalysis of the cipher more difficult.
Email compatibilitySearch on YouTube
PGP produces binary data (encrypted message, signature, encrypted session key). But email was designed only for text. Thus:
- PGP must encode the raw binary data into printable ASCII characters.
- PGP uses the radix-64 algorithm, also called "ASCII Armour".
- Radix-64 maps 3 bytes to 4 printable characters (it is the Base64 of MIME).
- Radix-64 also appends a 24-bit CRC.
- PGP also segments messages that are too big.
Armour makes the data about 33% larger (factor ). Compression recovers part of this increase.
Operation summarySearch on YouTube
The summary slide shows two flowcharts. Transmission (from A):
Reception (to B):
| Step | Transmission | Reception |
|---|---|---|
| 1 | Sign (optional) | Convert from radix-64 |
| 2 | Compress | Decrypt key, then message (optional) |
| 3 | Encrypt key and message (optional) | Decompress |
| 4 | Convert to radix-64 | Strip and verify signature (optional) |
Reception does the steps in the reverse order. Compression and radix-64 conversion always occur.
Transmission order: S-C-E-R, "Sign, Compress, Encrypt, Radix-64". Reception reads it backwards: R-E-C-S.
Keys and message formatSearch on YouTube
Session keysSearch on YouTube
PGP needs a session key for each message:
- Session keys have varying sizes: 56-bit DES, 128-bit CAST or IDEA, 168-bit Triple-DES.
- PGP generates them with the ANSI X12.17 mode (the slide name; Stallings calls it ANSI X9.17).
- The generator uses random inputs from previous uses and from the keystroke timing of the user.
A session key is like a hotel keycard for one night. It opens one message and then PGP discards it. If an attacker breaks one message, the attacker gets only that one key, not the long-term keys.
Key identifiersSearch on YouTube
One user may have many public/private key pairs in use. Thus, each message must identify which key encrypted the session key:
- PGP could send the full public key with every message, but this is inefficient.
- Instead, PGP uses a key identifier (key ID) based on the key.
- The key ID is the least significant 64 bits of the key. It is very likely unique.
- PGP also uses the key ID in signatures.
The session key component carries the key ID of the recipient. The signature carries the key ID of the sender. The receiver finds the correct key-ring entry with one lookup.
Message formatSearch on YouTube
A PGP message has three components:
| Component | Contents | Operation on it |
|---|---|---|
| Session key component | Key ID of the public key of the recipient (); session key () | is encrypted with |
| Signature | Timestamp; key ID of the public key of the sender (); leading two octets of the message digest; message digest | The digest is encrypted with |
| Message | Filename; timestamp; data | — |
The operations on the whole message are:
- ZIP and cover the signature and the message. They do not cover the session key component.
- R64 covers all three components.
| Symbol | Meaning |
|---|---|
| Encryption with the public key of user B | |
| Encryption with the private key of user A | |
| Encryption with the session key | |
| Zip compression function | |
| Radix-64 conversion function |
Learn the components top to bottom as K-Sig-M: Key component, Signature, Message.
- Signature: timestamp, key ID of , leading 2 octets, digest.
- Message: filename, timestamp, data.
Key rings and processingSearch on YouTube
Key ringsSearch on YouTube
Each PGP user has a pair of keyrings:
| Ring | Contains | Indexed by |
|---|---|---|
| Public-key ring | All the public keys of other PGP users that this user knows | Key ID (the table also marks User ID) |
| Private-key ring | The public/private key pair(s) of this user | Key ID and User ID |
The private-key ring stores each private key encrypted with a key from a hashed passphrase. Thus, the security of the private keys depends on the security of the passphrase.
The slide tables show these fields:
| Private-key ring fields | Public-key ring fields |
|---|---|
| Timestamp | Timestamp |
| Key ID* () | Key ID* () |
| Public key () | Public key () |
| Encrypted private key, | Owner trust () |
| User ID* | User ID* |
| — | Key legitimacy () |
| — | Signature(s) |
| — | Signature trust(s) |
* = field used to index the table.
Message generationSearch on YouTube
The generation slide connects the key rings to the operations (sign and encrypt):
- The sender enters a passphrase. PGP hashes it (H).
- The sender ID () selects the entry in the private-key ring. The passphrase hash decrypts (DC) the encrypted private key and gives .
- PGP hashes message (H) to get the message digest. encrypts the digest (EP).
- PGP joins the signature, the key ID of the sender and the message (concatenation).
- The RNG makes the session key . encrypts the signature and message (EC).
- The recipient ID () selects in the public-key ring. encrypts (EP).
- The output is the key ID of , the encrypted session key, and the encrypted signature + message.
Alice signs and encrypts a message for Bob. Her passphrase unlocks in her private-key ring. SHA-1 hashes the message, and signs the hash. A new encrypts the signed message. Bob's ID selects in her public-key ring, and encrypts .
Message receptionSearch on YouTube
The reception slide shows the reverse path:
- The key ID of the receiver selects the entry in the private-key ring.
- The hash (H) of the passphrase decrypts (DC) the encrypted private key. This gives .
- decrypts (DP) the encrypted session key. This gives .
- decrypts (DC) the encrypted message + signature.
- The key ID of the sender selects in the public-key ring.
- decrypts (DP) the encrypted digest.
- PGP hashes the message again (H) and compares the two digests. Equal values verify the signature.
| Field read at reception | Leads to |
|---|---|
| Key ID of the receiver | Private-key ring entry, unlocked by the passphrase |
| Encrypted session key | , through DP with |
| Key ID of the sender | Public-key ring entry, |
| Encrypted digest | Recovered hash, compared with a new hash of the message |
Key managementSearch on YouTube
Web of trustSearch on YouTube
PGP does not rely on certificate authorities (CAs). Instead:
- Each user is a CA. A user can sign keys for users that the user knows directly.
- This forms a "web of trust":
- Trust the keys that you signed.
- Trust keys that others signed if you have a chain of signatures to them.
- The key ring includes trust indicators (owner trust, key legitimacy, signature trust).
- Users can also revoke their keys.
| PGP | X.509 / CA model |
|---|---|
| Distributed: users sign the keys of users | Centralized: an authority issues certificates |
| Trust comes from personal knowledge | Trust comes from the authority |
| A chain of signatures gives legitimacy | A chain of certificates gives legitimacy |
Trust model exampleSearch on YouTube
The web-of-trust diagram uses this legend:
| Symbol | Meaning |
|---|---|
| Unknown signatory | |
| is signed by | |
| Grey node | You trust the owner of the key to sign keys |
| Half-grey node | You partly trust the owner of the key to sign keys |
| Dot in the node | You deem the key legitimate |
In the PGP trust model, a key becomes legitimate in these ways:
- You signed the key yourself.
- One owner that you fully trust signed the key.
- Two owners that you partly trust signed the key.
A signature from an unknown () signatory gives no legitimacy. A signature from a legitimate key whose owner you do not trust also gives no legitimacy.
You signed A to F, so all six keys are legitimate. You fully trust D, E, F and L, and you partly trust A and B. H is legitimate because both A and B signed it. G is not legitimate: only A (partly trusted) and an unknown signatory signed it. M, N and O are legitimate because E signed them. L is legitimate because D signed it. P and Q are legitimate because L signed them. You do not trust C, so I, J and K stay not legitimate. R (signed by N) and S (signed only by unknown signatories) are also not legitimate.
Quick self-testSearch on YouTube
Why is plain email not secure?
The contents of the message are not secure. An eavesdropper can inspect them in transit. Privileged users on the destination system can also inspect them.
List the four email security enhancements.
Confidentiality: protection from disclosure. Authentication: of the sender of the message. Message integrity: protection from modification. Non-repudiation of origin: protection from denial by the sender.
Give the five steps of PGP authentication.
- The sender creates the message. 2. The sender makes a SHA-1 160-bit hash. 3. The sender attaches the RSA-signed hash. 4. The receiver decrypts and recovers the hash code. 5. The receiver verifies the hash of the received message.
Give the five steps of PGP confidentiality.
- The sender forms a 128-bit random session key. 2. The sender encrypts the message with it. 3. The sender attaches the session key, encrypted with RSA. 4. The receiver decrypts and recovers the session key. 5. The receiver decrypts the message with the session key.
When PGP uses both services, what is the order?
PGP creates the signature and attaches it to the message. Then PGP encrypts the message and the signature with the session key. Then PGP attaches the session key, encrypted with RSA/ElGamal.
Why does PGP compress after signing but before encrypting?
PGP can then store the uncompressed message and the signature for later verification. Compression is non-deterministic, because the result depends on user preferences. PGP uses the ZIP algorithm.
What does radix-64 armour do?
Radix-64 (ASCII Armour) maps 3 bytes to 4 printable characters, so binary data can go through text-only email. It also appends a 24-bit CRC. PGP also segments messages that are too big.
Give the sizes and the random sources of PGP session keys.
Sizes: 56-bit DES, 128-bit CAST or IDEA, 168-bit Triple-DES. PGP generates the keys with ANSI X12.17 mode. The random inputs come from previous uses and from the keystroke timing of the user.
What is a PGP key ID, and how big is it?
A key ID is the least significant 64 bits of the public key. It is very likely unique. The session key component carries the key ID of the recipient, and the signature carries the key ID of the sender.
Name the three components of the PGP message format.
Session key component: key ID of and , encrypted with . Signature: timestamp, key ID of , leading two octets of the digest, and the digest encrypted with . Message: filename, timestamp, data. ZIP and cover the signature and message, and R64 covers all.
How does a key become legitimate in the PGP web of trust?
PGP has no certificate authority, and each user signs the keys of people that the user knows. A key is legitimate if you signed it, or one fully trusted owner signed it, or two partly trusted owners signed it. Unknown signatories give no legitimacy.
- Email contents are open in transit and on the destination system. PGP (Phil Zimmermann) gives confidentiality, sender authentication, message integrity and non-repudiation of origin.
- Authentication: a SHA-1 160-bit hash, signed with RSA. Confidentiality: a 128-bit random session key, encrypted with the public key of the recipient.
- Order: sign, compress (ZIP), encrypt, convert to radix-64. Radix-64 maps 3 bytes to 4 ASCII characters and adds a 24-bit CRC. Reception does the reverse.
- Session keys: one per message, 56-bit DES, 128-bit CAST/IDEA or 168-bit Triple-DES. A 64-bit key ID identifies each public key.
- Message format: session key component, signature, message. ZIP and cover the signature and message; R64 covers all.
- Each user has a public-key ring and a private-key ring. A hashed passphrase protects the private keys.
- Trust: no CA. Each user signs keys and builds a web of trust with trust indicators and revocation.
Pretty Good Privacy (PGP) Explained: How It Works & Why It Matters
PGP(Pretty Good Privacy) and Digital Signature