Signature packets (type 2) bind user IDs and subkeys to a key, revoke them, and sign data. Much of what a key file says, such as what a key may be used for and when it expires, is in the subpackets of its self-signatures. Numbers are big-endian; this page follows RFC 9580 section 5.2 (Tables 4–10) and the IANA OpenPGP registries.
Signature packet
| Field | Version 4 | Version 6 |
|---|---|---|
| Version | 1 byte: 4 | 1 byte: 6 |
| Signature type | 1 byte; see types | Same |
| Public key algorithm | 1 byte | Same |
| Hash algorithm | 1 byte | Same |
| Hashed subpackets | 2-byte length, then subpackets | 4-byte length, then subpackets |
| Unhashed subpackets | 2-byte length, then subpackets | 4-byte length, then subpackets |
| Hash prefix | 2 bytes: the left 16 bits of the signed hash | Same; a verifier must reject the signature if they do not match |
| Salt | – | 1-byte size, which must match the hash algorithm (16 for SHA2-256, 32 for SHA2-512, …), then the random salt |
| Signature | Algorithm-specific: one MPI for RSA, two (r, s) for DSA and ECDSA, 64 bytes for Ed25519, 114 for Ed448 | Same |
Signature fields by algorithm (RFC 9580 sections 5.2.3.1 to 5.2.3.5): RSA one MPI, md mod n, where the hash is wrapped in the PKCS#1 v1.5 EMSA structure with the hash algorithm’s OID (RFC 8017 section 9.2); DSA and ECDSA two MPIs, r and s (a DSA hash must be at least as long as q, and a longer one is cut to the leftmost bits; an ECDSA hash must be at least the curve’s field size, 512 bits or more for P-521); EdDSALegacy two MPIs holding R and S as native little-endian strings of up to 32 bytes (Ed25519Legacy only; not in version 6 signatures), whose hash must be at least the curve’s size; Ed25519 64 bytes, with a hash of at least 256 bits; Ed448 114 bytes, with a hash of at least 512 bits. A version 3 signature must not be made with ECDSA, EdDSALegacy, Ed25519 or Ed448. The post-quantum signature fields (algorithms 30–34) are not laid out here.
What is hashed is the signed data, then the signature from the version through the hashed subpackets, then a 6-byte trailer (section 5.2.3.6). Hashed subpackets are covered by the signature; unhashed ones are not protected and should hold only advisory information. Version 3 signatures (a 5-byte hashed part: type and creation time, then an 8-byte key ID) must not be created with ECDSA, EdDSA, Ed25519 or Ed448.
Signature types
| Type | Meaning |
|---|---|
0x00 | Signature of a binary document |
0x01 | Signature of a canonical text document (CR LF line endings) |
0x02 | Standalone signature, of its own subpackets (as over an empty document) |
0x10 | Generic certification of a user ID and key: no claim about how well the identity was checked. RFC 9580: most implementations make their key signatures this type. |
0x11 | Persona certification (no checking of identity) |
0x12 | Casual certification (some checking) |
0x13 | Positive certification (substantial checking) |
0x18 | Subkey binding, by the primary key. Binding a signing subkey requires an embedded 0x19. |
0x19 | Primary key binding, by a signing subkey over the primary key and subkey |
0x1F | Direct key signature, over the key itself (for key flags and similar) |
0x20 | Key revocation |
0x28 | Subkey revocation |
0x30 | Certification revocation |
0x40 | Timestamp signature |
0x50 | Third-party confirmation |
0xFF | Reserved |
All other values are unassigned.
Subpackets
Each subpacket is a length (one, two or five bytes, as for packet lengths but without partial lengths; it counts the type byte and the data), a type byte and the data. Bit 7 of the type byte marks the subpacket critical: an evaluator that meets an unknown critical subpacket should consider the signature in error, and should ignore unknown non-critical ones (section 5.2.3.7).
| Type | Subpacket | Data |
|---|---|---|
| 0, 1 | Reserved | – |
| 2 | Signature creation time | 4-byte time |
| 3 | Signature expiration time | 4-byte seconds after creation; 0 never |
| 4 | Exportable certification | 1 byte: 0 local only |
| 5 | Trust signature | Level and amount |
| 6 | Regular expression | Zero-terminated expression limiting a trust signature |
| 7 | Revocable | 1 byte: 0 cannot be revoked |
| 8 | Reserved | – |
| 9 | Key expiration time | 4-byte seconds after key creation; 0 never |
| 10 | Placeholder for backward compatibility | – |
| 11 | Preferred symmetric ciphers for v1 SEIPD | List of cipher IDs |
| 12 | Revocation key (deprecated) | Class, algorithm and fingerprint of a key allowed to revoke this one |
| 13–15 | Reserved | – |
| 16 | Issuer key ID | 8-byte key ID of the signer |
| 17–19 | Reserved | – |
| 20 | Notation data | 4 flag bytes (0x80000000: human-readable), name length, value length, name, value |
| 21 | Preferred hash algorithms | List of hash IDs |
| 22 | Preferred compression algorithms | List of compression IDs |
| 23 | Key server preferences | Flags; 0x80 no-modify |
| 24 | Preferred key server | URI |
| 25 | Primary user ID | 1 byte: non-zero for the primary user ID |
| 26 | Policy URI | URI |
| 27 | Key flags | See key flags |
| 28 | Signer’s user ID | The user ID the signer signs as |
| 29 | Reason for revocation | Reason code and text; see reasons |
| 30 | Features | Flags: 0x01 version 1 SEIPD supported, 0x08 version 2 SEIPD supported; 0x02, 0x04 reserved |
| 31 | Signature target | Algorithms and hash of the signature this one refers to |
| 32 | Embedded signature | A whole signature packet body (the primary key binding) |
| 33 | Issuer fingerprint | Key version byte and the signer’s fingerprint |
| 34 | Reserved | – |
| 35 | Intended recipient fingerprint | Key version and fingerprint of an intended recipient |
| 36 | Not listed in RFC 9580 Table 5 | – |
| 37 | Reserved (attested certifications) | – |
| 38 | Reserved (key block) | – |
| 39 | Preferred AEAD ciphersuites | Pairs of cipher and AEAD mode IDs |
| 40–99, 111–127 | Not listed | – |
| 100–110 | Private or experimental | – |
Subpacket data in detail
| Subpacket | Layout and rules (RFC 9580 section 5.2.3) |
|---|---|
| 5 Trust signature | 1 byte level, 1 byte trust amount. Level 0 is an ordinary validity signature; level 1 asserts a trusted introducer; level 2 a “meta introducer” trusted to issue level 1 signatures; level n trusts level n − 1. Amount 0–255: below 120 partial trust, 120 or more complete; emit 60 and 120. |
| 6 Regular expression | UTF-8 regular expression (Henry Spencer’s syntax) limiting which user IDs a level above 0 trust signature covers, followed by a 0 byte that a reader must remove and a writer must add; a subpacket without it is rejected. Mark critical when writing. |
| 12 Revocation key (deprecated; not to be generated) | 1 byte class (bit 0x80 must be set, 0x40 marks sensitive information), 1 byte public key algorithm, 20-byte version 4 fingerprint of a key allowed to revoke this one; seen on direct key signatures (0x1F) only. |
| 20 Notation data | 4 flag bytes (only 0x80000000, human-readable UTF-8 value, is defined; others must be 0), 2-byte name length M, 2-byte value length N, the name, the value. Names are UTF-8 in two namespaces: the IETF namespace, registered with IANA, whose names must not contain @ (the registry is empty), and the user namespace, tag@domain, such as sample@example.com. A critical notation makes only that notation critical. |
| 31 Signature target | 1 byte public key algorithm, 1 byte hash algorithm, then the hash (the size of that hash, such as 20 bytes for SHA-1) of the signature being revoked, confirmed or timestamped. |
| 32 Embedded signature | One complete signature packet body. |
| 33 Issuer fingerprint | 1 byte key version, then the fingerprint (20 bytes for version 4, 32 for version 6). The version byte must equal the signature’s version or the signature is malformed. For a version 4 key it must agree with the low 64 bits in an issuer key ID subpacket. Should be in every signature. |
| 35 Intended recipient fingerprint | 1 byte key version, then the fingerprint of the recipient’s primary key. If present, the signature counts only in an encrypted context to one of those keys or their subkeys. Should be written for signed and encrypted messages, and marked critical in version 6 signatures. |
Key flags
| Bit (first byte) | The key may… |
|---|---|
0x01 | Make user ID certifications (0x10–0x13) or direct key signatures (0x1F) over other keys |
0x02 | Sign data |
0x04 | Encrypt communications |
0x08 | Encrypt storage |
0x10 | Be split by a secret-sharing mechanism (its private part) |
0x20 | Authenticate |
0x80 | Be in the possession of more than one person |
In the second byte, 0x04 and 0x08 are reserved (for ADSK
and timestamping). The list may be any length; missing flags are zero, and the
subpacket should be marked critical. The split-key (0x10) and group-key
(0x80) flags belong only on self-signatures (section 5.2.3.29).
Reasons for revocation
| Code | Reason |
|---|---|
| 0 | No reason specified (key or certification revocations) |
| 1 | Key is superseded (key revocations) |
| 2 | Key material has been compromised (key revocations) |
| 3 | Key is retired and no longer used (key revocations) |
| 32 | User ID information is no longer valid (certification revocations) |
| 100–110 | Private use |