Introduction
OpenPGP keys are used to encrypt and sign email and files, and to sign software releases. A key file holds a public key, or a whole key pair, together with the names and email addresses it belongs to and the signatures that bind them. The format is the OpenPGP standard, which grew out of Phil Zimmermann’s PGP program and is now defined in RFC 9580.
The same data can be saved as binary, usually .gpg or .pgp, or
as ASCII armour, usually .asc, which wraps it in base64 text that survives
email and web pages. The extension .asc is also used for armoured signatures
and messages, which are different data in the same wrapping.
Structure
Binary OpenPGP data is a sequence of packets. Each packet starts with a header byte whose top bit is set and which gives the packet type, then a length, then the body. A public key is a Public-Key packet (type 6), then one or more User ID packets (type 13), each followed by Signature packets (type 2) that certify it, then any subkeys (type 14) with their own binding signatures. A secret key uses Secret-Key packets (type 5) instead, with the private parts usually encrypted with a passphrase.
ASCII armour wraps the packets in a -----BEGIN PGP PUBLIC KEY BLOCK-----
line (or PRIVATE KEY BLOCK), optional header lines, a blank line, the base64
data, a checksum line starting with =, and the matching END line.
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZ…
…
-----END PGP PUBLIC KEY BLOCK-----
Links
Software
- GnuPG (Windows, macOS, Linux)
- Gpg4win, GnuPG with the Kleopatra key manager (Windows)
- GPG Suite (macOS)
- Thunderbird, which has OpenPGP built in (Windows, macOS, Linux)
Developers
- GPGME, C library for using GnuPG from programs, with bindings for other languages
- Sequoia PGP, OpenPGP library in Rust
- OpenPGP.js, OpenPGP library in JavaScript