Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:OpenPGP

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

RFC 4880 packet stream: tag byte with bit 7 set, old or new format length rules, packet tags 1-19, and ASCII armor with BEGIN PGP lines.

Packet header (RFC 4880 section 4.2-4.3)

First octet: bit 7 always 1; bit 6 set means new format. Old format: bits 5-2 = packet tag (so tags up to 15), bits 1-0 = length type: 0 one-octet length, 1 two-octet, 2 four-octet, 3 indeterminate. New format: bits 5-0 = tag (up to 63); length encodings are one octet up to 191, two octets 192-8383, and further forms (RFC section 4.2.2). Tags 16 and above must use the new format.

Tags: 1 Public-Key Encrypted Session Key, 2 Signature, 3 Symmetric-Key Encrypted Session Key, 4 One-Pass Signature, 5 Secret-Key, 6 Public-Key, 7 Secret-Subkey, 8 Compressed Data, 9 Symmetrically Encrypted Data, 10 Marker, 11 Literal Data, 12 Trust, 13 User ID, 14 Public-Subkey, 17 User Attribute, 18 Sym. Encrypted and Integrity Protected Data, 19 Modification Detection Code, 60-63 private/experimental, 0 reserved.

Therefore a binary public keyring commonly starts with 0x99 (old format, tag 6, two-octet length) and a new-format public key with 0xC6. Unverified: computed from the bit layout above: 0x80|(6<<2)|1 = 0x99; 0xC0|6 = 0xC6.

Armor

Text blocks start -----BEGIN PGP MESSAGE-----, PGP PUBLIC KEY BLOCK, PGP PRIVATE KEY BLOCK, PGP SIGNATURE, or PGP SIGNED MESSAGE for cleartext signatures (RFC 4880 section 6.2). Unverified: RFC 9580 (the 2024 revision) changes versions and adds tags; it was not read here.

Technique:Recognizing embedded keys and certificates