rfc-4880

OpenPGP Message Format

J. Callas, L. Donnerhacke, H. Finney, D. Shaw, R. Thayer
date2007-11 streamIETF areasec wgopenpgp statusPROPOSED STANDARD pages90 canonicalhttps://www.rfc-editor.org/rfc/rfc4880 doi10.17487/RFC4880 errataview
This document is maintained in order to publish all necessary information needed to develop interoperable applications based on the OpenPGP format. It is not a step-by-step cookbook for writing an application. It describes only the format and methods needed to read, check, generate, and write conforming packets crossing any network. It does not deal with storage and implementation questions. It does, however, discuss implementation issues necessary to avoid security flaws. OpenPGP software uses a combination of strong public-key and symmetric cryptography to provide security services for electronic communications and data storage. These services include confidentiality, key management, authentication, and digital signatures. This document specifies the message formats used in OpenPGP. [STANDARDS-TRACK]

obsoleted by

obsoletes

updated by

Extracted elements (31)

design-rationale §2.1

A new random session key is generated for each encrypted message and encrypted separately to each recipient's public key. This hybrid encryption model limits exposure: compromise of one recipient's private key only reveals messages addressed to that recipient, not a long-term symmetric key.

crypto, security

design-rationale §5.2.1

The vagueness of OpenPGP signature semantics (0x10–0x13 certification levels) is intentional, not a flaw. Because OpenPGP places final authority for validity upon the receiver, one signer's casual act may be more rigorous than another authority's positive act.

security, crypto

interoperability-note §4.2

PGP 2.6.x only accepts Version 3 signatures and only uses old-format packet headers. Software that must interoperate with PGP 2.6.x MUST use old format packets and may only generate Version 3 signatures. The One-Pass Signature packet (Tag 4) does not interoperate with PGP 2.6.x or earlier.

security, crypto

normative-requirement §5.2.1 MUST

A Subkey Binding Signature (0x18) that binds a signing subkey MUST have an Embedded Signature subpacket containing a 0x19 Primary Key Binding Signature made by that signing subkey.

crypto, security

normative-requirement §5.2.3.1 SHOULD

An implementation SHOULD ignore any Signature subpacket of a type it does not recognize. If an unrecognized subpacket has the critical bit (bit 7 of type octet) set, the evaluator SHOULD consider the signature to be in error.

crypto, security

normative-requirement §5.2.2 MUST

DSA signatures MUST use hashes that are equal in size to the number of bits of q. If the hash output is larger, the leftmost bits equal to q's bit size are used.

crypto, security

normative-requirement §5.2 SHOULD

Implementations SHOULD accept V3 signatures and SHOULD generate V4 signatures. V4 is the preferred format due to its extensible subpacket structure.

crypto, security

normative-requirement §2.3 SHOULD

Implementations SHOULD compress the message after applying the signature but before encryption.

security

normative-requirement §3.3 SHOULD NOT

Implementations SHOULD NOT assume that Key IDs are unique; Key IDs are only eight octets and collisions are possible.

security

normative-requirement §3.7.2 SHOULD

Implementations SHOULD use salted or iterated-and-salted S2K specifiers, as simple S2K specifiers are more vulnerable to dictionary attacks.

crypto, security

normative-requirement §4.2 MUST

Packets with a tag greater than or equal to 16 MUST use new format packets, since old format packet tags are only four bits wide.

security

normative-requirement §5.2.3.4 MUST

The Signature Creation Time subpacket MUST be present in the hashed area of a signature.

crypto, security

normative-requirement §5.3 MUST

When a Symmetric-Key ESK packet uses an encrypted session key, the S2K specifier MUST use a salt value (Salted or Iterated-Salted S2K), because an all-zero IV is used for the session key decryption.

crypto, security

normative-requirement §5.1 MUST

When multiple PKESKs are formed with one session key, the implementation MUST make a new PKCS#1 EME-PKCS1-v1_5 encoding for each recipient key.

crypto, security

protocol-element §5.1

A Public-Key Encrypted Session Key (PKESK) packet (Tag 1) holds a session key encrypted to one recipient's public key. Its body contains: version (1 octet, currently 3), Key ID (8 octets), public-key algorithm (1 octet), and the encrypted session key MPI(s).

crypto, security

protocol-element §5.2.3.21

Key flags (signature subpacket type 27) are N-octet flag fields indicating key capabilities: 0x01 certify, 0x02 sign data, 0x04 encrypt communications, 0x08 encrypt storage, 0x10 split key, 0x20 authentication, 0x80 group key. Implementations MUST NOT assume a fixed size.

crypto, security

protocol-element §4.3

Packet tags identify packet types. Defined tags include: 1 (Public-Key ESK), 2 (Signature), 3 (Symmetric-Key ESK), 4 (One-Pass Signature), 5 (Secret-Key), 6 (Public-Key), 7 (Secret-Subkey), 8 (Compressed Data), 9 (Symmetrically Encrypted Data), 11 (Literal Data), 13 (User ID), 14 (Public-Subkey), 17 (User Attribute), 18 (Sym. Encrypted Integrity Protected Data), 19 (MDC). Tag 0 is reserved and MUST NOT be used.

security

protocol-element §5.2.1

Signature types (0x00–0x50) encode the meaning of a Signature packet. Key types include: 0x10–0x13 (User ID certifications of increasing rigor), 0x18 (Subkey Binding), 0x19 (Primary Key Binding), 0x20 (Key Revocation), 0x28 (Subkey Revocation), 0x30 (Certification Revocation), 0x50 (Third-Party Confirmation).

crypto, security

protocol-element §3.7.1

String-to-Key (S2K) specifiers convert passphrases to symmetric keys. Three types are defined: Simple S2K (0x00, hash only), Salted S2K (0x01, 8-octet salt + hash), and Iterated and Salted S2K (0x03, salt + hash with repeated hashing). Values 100–110 are private/experimental.

crypto, security

protocol-element §5.4

The One-Pass Signature packet (Tag 4) precedes signed data and contains: version (1 octet, currently 3), signature type, hash algorithm, public-key algorithm, signing Key ID (8 octets), and a nesting flag. Multiple one-pass signatures bracket the message data such that Signature packets appear in reverse order.

crypto, security

protocol-element §5.13

The Sym. Encrypted Integrity Protected Data Packet (Tag 18) wraps encrypted content with a Modification Detection Code. It supersedes the bare Symmetrically Encrypted Data Packet (Tag 9) by prepending an encrypted MDC packet to detect tampering.

crypto, security

registry §10

IANA maintains registries for OpenPGP: Public-Key Algorithm IDs (Section 9.1), Symmetric-Key Algorithm IDs (Section 9.2), Compression Algorithm IDs (Section 9.3), Hash Algorithm IDs (Section 9.4), S2K Specifier Types (Section 10.1), Packet Tags (Section 10.2), Signature Subpacket Types (Section 10.2.2), and User Attribute Types (Section 10.2.1).

registry, security, crypto

security-consideration §14

Key IDs are only 64 bits and are not guaranteed unique; an attacker may create a key with the same Key ID as a target key. Implementations relying on Key ID alone for key lookup without verifying fingerprints are vulnerable to Key ID substitution attacks.

security, crypto

security-consideration §14

The Symmetrically Encrypted Data Packet (Tag 9) provides no integrity protection and is vulnerable to modification. Implementations SHOULD use the Sym. Encrypted Integrity Protected Data Packet (Tag 18) with a Modification Detection Code (Tag 19) instead, to detect ciphertext tampering.

security, crypto

state-machine §5.2.3.23

Key revocation states are encoded in the Reason for Revocation subpacket (type 29): code 0 (unspecified), 1 (superseded), 2 (compromised), 3 (retired), 32 (User ID no longer valid). A compromised key makes all prior signatures suspect, whereas superseded/retired keys leave old signatures valid.

crypto, security

wire-format §4.2

A packet header begins with a Packet Tag octet where bit 7 is always 1, bit 6 distinguishes new (1) from old (0) format. Old format encodes the tag in bits 5-2 and the length-type in bits 1-0; new format encodes the tag in bits 5-0.

security

wire-format §5.2.3.1

A Signature subpacket header uses the same length encoding as new-format packets (1, 2, or 5 octets) but cannot use Partial Body Lengths. The length includes the type octet. Bit 7 of the type octet is the 'critical' flag.

crypto, security

wire-format §3.7.1.3

Iterated and Salted S2K (type 0x03) encodes: one octet type (0x03), one octet hash algorithm, 8-octet salt, one octet coded count where count = (16 + (c & 15)) << ((c >> 4) + 6). The count is total octets to hash, not an iteration count.

crypto, security

wire-format §3.2

Multiprecision integers (MPIs) consist of a two-octet bit-length scalar followed by the integer octets in big-endian order. Unused bits in the most significant octet MUST be zero. The total size is ((MPI.length + 7) / 8) + 2 octets.

crypto, security

wire-format §4.2.2

New format packet lengths use a variable-length encoding: one-octet (0–191), two-octet (192–8383, decoded as ((first-192)<<8)+second+192), five-octet (first octet = 255, followed by four-octet scalar), or partial body (224–254, length = 1 << (octet & 0x1F)).

security

wire-format §5.2.3

The Version 4 Signature packet body contains: version (1 octet), signature type (1), public-key algorithm (1), hash algorithm (1), two-octet hashed subpacket length, hashed subpackets, two-octet unhashed subpacket length, unhashed subpackets, left 16 bits of hash (2 octets), then the signature MPI(s).

crypto, security