OpenPGP Message Format and Operations
What You'll Learn
You'll understand how OpenPGP structures encrypted and signed messages using packets, and the different ways to create verifiable signatures.
The Core Idea
OpenPGP doesn't just wrap your message in a single encryption blob—it uses a packet-based structure where each component (encryption info, signatures, compressed data, the actual message) lives in its own labeled container. Think of it like a Russian nesting doll made of labeled boxes, where each box has a specific job.
Packet Structure
Every OpenPGP message is a sequence of packets. Common packet types include:
- Public-Key Encrypted Session Key packets (hold the encrypted symmetric key)
- Signature packets (contain cryptographic signatures)
- Compressed Data packets (wrap compressed content)
- Literal Data packets (the actual message payload)
This modular design lets you combine operations—compress then encrypt, or sign then encrypt—in flexible ways.
Signing Operations
Inline Signatures: The signature packet wraps around the message data. Everything travels together in the packet structure.
Detached Signatures: The signature lives in a separate file from the message. Perfect for software distribution—you download program.exe and program.exe.sig separately, then verify them together. The signature doesn't modify the original file.
Clearsigned Messages: Human-readable text messages with ASCII-armored signatures appended below. The message remains readable even without GPG, but verification proves authenticity. You've seen these in mailing lists: plain text followed by -----BEGIN PGP SIGNATURE-----.
Encryption Operations
When encrypting, OpenPGP generates a random session key, encrypts your message with it (symmetric encryption), then encrypts that session key with the recipient's public key. The packet structure holds both encrypted components.
Key Takeaway: OpenPGP's packet-based architecture enables flexible composition of encryption, signing, and compression operations, with signature formats ranging from embedded inline signatures to detached files and human-readable clearsigned messages.