idnits 2.17.1 draft-ietf-openpgp-crypto-refresh-00.txt: -(2747): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2749): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2751): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == There are 8 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document obsoletes RFC4880, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (29 January 2021) is 1176 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '0' on line 348 -- Looks like a reference, but probably isn't: '1' on line 3839 -- Looks like a reference, but probably isn't: '2' on line 348 -- Looks like a reference, but probably isn't: '3' on line 3848 == Missing Reference: 'Optional' is mentioned on line 2098, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3452, but not defined == Missing Reference: 'BS' is mentioned on line 3839, but not defined == Unused Reference: 'MAURER' is defined on line 4288, but no explicit reference was found in the text == Unused Reference: 'RFC1423' is defined on line 4301, but no explicit reference was found in the text -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. 'BLOWFISH' -- Possible downref: Non-RFC (?) normative reference: ref. 'BZ2' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' -- Possible downref: Non-RFC (?) normative reference: ref. 'IDEA' -- Possible downref: Non-RFC (?) normative reference: ref. 'ISO10646' -- Possible downref: Non-RFC (?) normative reference: ref. 'JFIF' ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Downref: Normative reference to an Informational RFC: RFC 1951 ** Downref: Normative reference to an Informational RFC: RFC 2144 ** Obsolete normative reference: RFC 2434 (Obsoleted by RFC 5226) ** Obsolete normative reference: RFC 2822 (Obsoleted by RFC 5322) ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) -- Possible downref: Non-RFC (?) normative reference: ref. 'SCHNEIER' -- Possible downref: Non-RFC (?) normative reference: ref. 'TWOFISH' -- Obsolete informational reference (is this intentional?): RFC 1991 (Obsoleted by RFC 4880) -- Obsolete informational reference (is this intentional?): RFC 2440 (Obsoleted by RFC 4880) Summary: 6 errors (**), 0 flaws (~~), 7 warnings (==), 21 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group W. Koch, Ed. 3 Internet-Draft GnuPG e.V. 4 Obsoletes: 4880 (if approved) P. Wouters, Ed. 5 Intended status: Standards Track 29 January 2021 6 Expires: 2 August 2021 8 OpenPGP Message Format 9 draft-ietf-openpgp-crypto-refresh-00 11 Abstract 13 This document is maintained in order to publish all necessary 14 information needed to develop interoperable applications based on the 15 OpenPGP format. It is not a step-by-step cookbook for writing an 16 application. It describes only the format and methods needed to 17 read, check, generate, and write conforming packets crossing any 18 network. It does not deal with storage and implementation questions. 19 It does, however, discuss implementation issues necessary to avoid 20 security flaws. 22 OpenPGP software uses a combination of strong public-key and 23 symmetric cryptography to provide security services for electronic 24 communications and data storage. These services include 25 confidentiality, key management, authentication, and digital 26 signatures. This document specifies the message formats used in 27 OpenPGP. 29 Status of This Memo 31 This Internet-Draft is submitted in full conformance with the 32 provisions of BCP 78 and BCP 79. 34 Internet-Drafts are working documents of the Internet Engineering 35 Task Force (IETF). Note that other groups may also distribute 36 working documents as Internet-Drafts. The list of current Internet- 37 Drafts is at https://datatracker.ietf.org/drafts/current/. 39 Internet-Drafts are draft documents valid for a maximum of six months 40 and may be updated, replaced, or obsoleted by other documents at any 41 time. It is inappropriate to use Internet-Drafts as reference 42 material or to cite them other than as "work in progress." 44 This Internet-Draft will expire on 2 August 2021. 46 Copyright Notice 48 Copyright (c) 2021 IETF Trust and the persons identified as the 49 document authors. All rights reserved. 51 This document is subject to BCP 78 and the IETF Trust's Legal 52 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 53 license-info) in effect on the date of publication of this document. 54 Please review these documents carefully, as they describe your rights 55 and restrictions with respect to this document. Code Components 56 extracted from this document must include Simplified BSD License text 57 as described in Section 4.e of the Trust Legal Provisions and are 58 provided without warranty as described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 63 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 2. General functions . . . . . . . . . . . . . . . . . . . . . . 5 65 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 6 66 2.2. Authentication via Digital Signature . . . . . . . . . . 6 67 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 7 68 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 7 69 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 8 70 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 8 71 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 8 72 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 8 73 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 9 74 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 9 75 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 9 76 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 9 77 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 9 78 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 9 79 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 12 80 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 13 81 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 13 82 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 13 83 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 14 84 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 14 85 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 16 86 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 16 87 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 17 88 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 18 89 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 19 90 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 19 91 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 21 92 5.2.3. Version 4 Signature Packet Format . . . . . . . . . . 24 93 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 39 95 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 41 96 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 42 97 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 43 98 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 43 99 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 43 100 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 45 101 5.6. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 47 102 5.7. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 48 103 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 48 104 5.9. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 49 105 5.10. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 50 106 5.11. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 50 107 5.12. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 50 108 5.12.1. The Image Attribute Subpacket . . . . . . . . . . . 51 109 5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 110 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 51 111 5.14. Modification Detection Code Packet (Tag 19) . . . . . . . 55 112 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 55 113 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 56 114 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 56 115 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 59 116 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 61 117 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 61 118 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 62 119 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 62 120 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 63 121 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 64 122 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 64 123 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 65 124 9.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 65 125 9.3. Compression Algorithms . . . . . . . . . . . . . . . . . 66 126 9.4. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 67 127 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 67 128 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 68 129 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 68 130 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 68 131 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 68 132 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 70 133 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 70 134 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 70 135 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 71 136 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 71 137 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 71 138 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 71 139 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 71 140 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 73 141 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 73 142 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 74 144 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 74 145 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 74 146 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 75 147 13. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 76 148 13.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 76 149 13.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 77 150 13.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 77 151 13.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 78 152 13.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 79 153 13.3. Other Algorithm Preferences . . . . . . . . . . . . . . 80 154 13.3.1. Compression Preferences . . . . . . . . . . . . . . 80 155 13.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 80 156 13.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 81 157 13.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 81 158 13.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 81 159 13.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 82 160 13.8. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 82 161 13.9. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 82 162 13.10. Private or Experimental Parameters . . . . . . . . . . . 83 163 13.11. Extension of the MDC System . . . . . . . . . . . . . . 84 164 13.12. Meta-Considerations for Expansion . . . . . . . . . . . 85 165 14. Security Considerations . . . . . . . . . . . . . . . . . . . 85 166 15. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 89 167 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 90 168 16.1. Normative References . . . . . . . . . . . . . . . . . . 90 169 16.2. Informative References . . . . . . . . . . . . . . . . . 92 170 Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 93 171 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 94 173 1. Introduction 175 This document provides information on the message-exchange packet 176 formats used by OpenPGP to provide encryption, decryption, signing, 177 and key management functions. It is a revision of RFC 2440, "OpenPGP 178 Message Format", which itself replaces RFC 1991, "PGP Message 179 Exchange Formats" [RFC1991] [RFC2440]. 181 1.1. Terms 183 * OpenPGP - This is a term for security software that uses PGP 5.x 184 as a basis, formalized in [RFC2440] and this document. 186 * PGP - Pretty Good Privacy. PGP is a family of software systems 187 developed by Philip R. Zimmermann from which OpenPGP is based. 189 * PGP 2.6.x - This version of PGP has many variants, hence the term 190 PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic 191 transforms. An informational RFC, [RFC1991], was written 192 describing this version of PGP. 194 * PGP 5.x - This version of PGP is formerly known as "PGP 3" in the 195 community and also in the predecessor of this document, [RFC1991]. 196 It has new formats and corrects a number of problems in the PGP 197 2.6.x design. It is referred to here as PGP 5.x because that 198 software was the first release of the "PGP 3" code base. 200 * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 201 implementation that avoids all encumbered algorithms. 202 Consequently, early versions of GnuPG did not include RSA public 203 keys. GnuPG may or may not have (depending on version) support 204 for IDEA or other encumbered algorithms. 206 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 207 Corporation and are used with permission. The term "OpenPGP" refers 208 to the protocol described in this and related documents. 210 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 211 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 212 document are to be interpreted as described in [RFC2119]. 214 The key words "PRIVATE USE", "HIERARCHICAL ALLOCATION", "FIRST COME 215 FIRST SERVED", "EXPERT REVIEW", "SPECIFICATION REQUIRED", "IESG 216 APPROVAL", "IETF CONSENSUS", and "STANDARDS ACTION" that appear in 217 this document when used to describe namespace allocation are to be 218 interpreted as described in [RFC2434]. 220 2. General functions 222 OpenPGP provides data integrity services for messages and data files 223 by using these core technologies: 225 * digital signatures 227 * encryption 229 * compression 231 * Radix-64 conversion 233 In addition, OpenPGP provides key management and certificate 234 services, but many of these are beyond the scope of this document. 236 2.1. Confidentiality via Encryption 238 OpenPGP combines symmetric-key encryption and public-key encryption 239 to provide confidentiality. When made confidential, first the object 240 is encrypted using a symmetric encryption algorithm. Each symmetric 241 key is used only once, for a single object. A new "session key" is 242 generated as a random number for each object (sometimes referred to 243 as a session). Since it is used only once, the session key is bound 244 to the message and transmitted with it. To protect the key, it is 245 encrypted with the receiver's public key. The sequence is as 246 follows: 248 1. The sender creates a message. 250 2. The sending OpenPGP generates a random number to be used as a 251 session key for this message only. 253 3. The session key is encrypted using each recipient's public key. 254 These "encrypted session keys" start the message. 256 4. The sending OpenPGP encrypts the message using the session key, 257 which forms the remainder of the message. Note that the message 258 is also usually compressed. 260 5. The receiving OpenPGP decrypts the session key using the 261 recipient's private key. 263 6. The receiving OpenPGP decrypts the message using the session key. 264 If the message was compressed, it will be decompressed. 266 With symmetric-key encryption, an object may be encrypted with a 267 symmetric key derived from a passphrase (or other shared secret), or 268 a two-stage mechanism similar to the public-key method described 269 above in which a session key is itself encrypted with a symmetric 270 algorithm keyed from a shared secret. 272 Both digital signature and confidentiality services may be applied to 273 the same message. First, a signature is generated for the message 274 and attached to the message. Then the message plus signature is 275 encrypted using a symmetric session key. Finally, the session key is 276 encrypted using public-key encryption and prefixed to the encrypted 277 block. 279 2.2. Authentication via Digital Signature 281 The digital signature uses a hash code or message digest algorithm, 282 and a public-key signature algorithm. The sequence is as follows: 284 1. The sender creates a message. 286 2. The sending software generates a hash code of the message. 288 3. The sending software generates a signature from the hash code 289 using the sender's private key. 291 4. The binary signature is attached to the message. 293 5. The receiving software keeps a copy of the message signature. 295 6. The receiving software generates a new hash code for the received 296 message and verifies it using the message's signature. If the 297 verification is successful, the message is accepted as authentic. 299 2.3. Compression 301 OpenPGP implementations SHOULD compress the message after applying 302 the signature but before encryption. 304 If an implementation does not implement compression, its authors 305 should be aware that most OpenPGP messages in the world are 306 compressed. Thus, it may even be wise for a space-constrained 307 implementation to implement decompression, but not compression. 309 Furthermore, compression has the added side effect that some types of 310 attacks can be thwarted by the fact that slightly altered, compressed 311 data rarely uncompresses without severe errors. This is hardly 312 rigorous, but it is operationally useful. These attacks can be 313 rigorously prevented by implementing and using Modification Detection 314 Codes as described in sections following. 316 2.4. Conversion to Radix-64 318 OpenPGP's underlying native representation for encrypted messages, 319 signature certificates, and keys is a stream of arbitrary octets. 320 Some systems only permit the use of blocks consisting of seven-bit, 321 printable text. For transporting OpenPGP's native raw binary octets 322 through channels that are not safe to raw binary data, a printable 323 encoding of these binary octets is needed. OpenPGP provides the 324 service of converting the raw 8-bit binary octet stream to a stream 325 of printable ASCII characters, called Radix-64 encoding or ASCII 326 Armor. 328 Implementations SHOULD provide Radix-64 conversions. 330 2.5. Signature-Only Applications 332 OpenPGP is designed for applications that use both encryption and 333 signatures, but there are a number of problems that are solved by a 334 signature-only implementation. Although this specification requires 335 both encryption and signatures, it is reasonable for there to be 336 subset implementations that are non-conformant only in that they omit 337 encryption. 339 3. Data Element Formats 341 This section describes the data elements used by OpenPGP. 343 3.1. Scalar Numbers 345 Scalar numbers are unsigned and are always stored in big-endian 346 format. Using n[k] to refer to the kth octet being interpreted, the 347 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 348 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 349 n[3]). 351 3.2. Multiprecision Integers 353 Multiprecision integers (also called MPIs) are unsigned integers used 354 to hold large integers such as the ones used in cryptographic 355 calculations. 357 An MPI consists of two pieces: a two-octet scalar that is the length 358 of the MPI in bits followed by a string of octets that contain the 359 actual integer. 361 These octets form a big-endian number; a big-endian number can be 362 made into an MPI by prefixing it with the appropriate length. 364 Examples: 366 (all numbers are in hexadecimal) 368 The string of octets [00 01 01] forms an MPI with the value 1. The 369 string [00 09 01 FF] forms an MPI with the value of 511. 371 Additional rules: 373 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 375 The length field of an MPI describes the length starting from its 376 most significant non-zero bit. Thus, the MPI [00 02 01] is not 377 formed correctly. It should be [00 01 01]. 379 Unused bits of an MPI MUST be zero. 381 Also note that when an MPI is encrypted, the length refers to the 382 plaintext MPI. It may be ill-formed in its ciphertext. 384 3.3. Key IDs 386 A Key ID is an eight-octet scalar that identifies a key. 387 Implementations SHOULD NOT assume that Key IDs are unique. 388 Section 12 describes how Key IDs are formed. 390 3.4. Text 392 Unless otherwise specified, the character set for text is the UTF-8 393 [RFC3629] encoding of Unicode [ISO10646]. 395 3.5. Time Fields 397 A time field is an unsigned four-octet number containing the number 398 of seconds elapsed since midnight, 1 January 1970 UTC. 400 3.6. Keyrings 402 A keyring is a collection of one or more keys in a file or database. 403 Traditionally, a keyring is simply a sequential list of keys, but may 404 be any suitable database. It is beyond the scope of this standard to 405 discuss the details of keyrings or other databases. 407 3.7. String-to-Key (S2K) Specifiers 409 String-to-key (S2K) specifiers are used to convert passphrase strings 410 into symmetric-key encryption/decryption keys. They are used in two 411 places, currently: to encrypt the secret part of private keys in the 412 private keyring, and to convert passphrases to encryption keys for 413 symmetrically encrypted messages. 415 3.7.1. String-to-Key (S2K) Specifier Types 417 There are three types of S2K specifiers currently supported, and some 418 reserved values: 420 +============+==========================+ 421 | ID | S2K Type | 422 +============+==========================+ 423 | 0 | Simple S2K | 424 +------------+--------------------------+ 425 | 1 | Salted S2K | 426 +------------+--------------------------+ 427 | 2 | Reserved value | 428 +------------+--------------------------+ 429 | 3 | Iterated and Salted S2K | 430 +------------+--------------------------+ 431 | 100 to 110 | Private/Experimental S2K | 432 +------------+--------------------------+ 434 Table 1: S2K type registry 436 These are described in the subsections below. 438 3.7.1.1. Simple S2K 440 This directly hashes the string to produce the key data. See below 441 for how this hashing is done. 443 Octet 0: 0x00 444 Octet 1: hash algorithm 446 Simple S2K hashes the passphrase to produce the session key. The 447 manner in which this is done depends on the size of the session key 448 (which will depend on the cipher used) and the size of the hash 449 algorithm's output. If the hash size is greater than the session key 450 size, the high-order (leftmost) octets of the hash are used as the 451 key. 453 If the hash size is less than the key size, multiple instances of the 454 hash context are created -- enough to produce the required key data. 455 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 456 is to say, the first instance has no preloading, the second gets 457 preloaded with 1 octet of zero, the third is preloaded with two 458 octets of zeros, and so forth). 460 As the data is hashed, it is given independently to each hash 461 context. Since the contexts have been initialized differently, they 462 will each produce different hash output. Once the passphrase is 463 hashed, the output data from the multiple hashes is concatenated, 464 first hash leftmost, to produce the key data, with any excess octets 465 on the right discarded. 467 3.7.1.2. Salted S2K 469 This includes a "salt" value in the S2K specifier -- some arbitrary 470 data -- that gets hashed along with the passphrase string, to help 471 prevent dictionary attacks. 473 Octet 0: 0x01 474 Octet 1: hash algorithm 475 Octets 2-9: 8-octet salt value 477 Salted S2K is exactly like Simple S2K, except that the input to the 478 hash function(s) consists of the 8 octets of salt from the S2K 479 specifier, followed by the passphrase. 481 3.7.1.3. Iterated and Salted S2K 483 This includes both a salt and an octet count. The salt is combined 484 with the passphrase and the resulting value is hashed repeatedly. 485 This further increases the amount of work an attacker must do to try 486 dictionary attacks. 488 Octet 0: 0x03 489 Octet 1: hash algorithm 490 Octets 2-9: 8-octet salt value 491 Octet 10: count, a one-octet, coded value 493 The count is coded into a one-octet number using the following 494 formula: 496 #define EXPBIAS 6 497 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 499 The above formula is in C, where "Int32" is a type for a 32-bit 500 integer, and the variable "c" is the coded count, Octet 10. 502 Iterated-Salted S2K hashes the passphrase and salt data multiple 503 times. The total number of octets to be hashed is specified in the 504 encoded count in the S2K specifier. Note that the resulting count 505 value is an octet count of how many octets will be hashed, not an 506 iteration count. 508 Initially, one or more hash contexts are set up as with the other S2K 509 algorithms, depending on how many octets of key data are needed. 510 Then the salt, followed by the passphrase data, is repeatedly hashed 511 until the number of octets specified by the octet count has been 512 hashed. The one exception is that if the octet count is less than 513 the size of the salt plus passphrase, the full salt plus passphrase 514 will be hashed even though that is greater than the octet count. 515 After the hashing is done, the data is unloaded from the hash 516 context(s) as with the other S2K algorithms. 518 3.7.2. String-to-Key Usage 520 Implementations SHOULD use salted or iterated-and-salted S2K 521 specifiers, as simple S2K specifiers are more vulnerable to 522 dictionary attacks. 524 3.7.2.1. Secret-Key Encryption 526 An S2K specifier can be stored in the secret keyring to specify how 527 to convert the passphrase to a key that unlocks the secret data. 528 Older versions of PGP just stored a cipher algorithm octet preceding 529 the secret data or a zero to indicate that the secret data was 530 unencrypted. The MD5 hash function was always used to convert the 531 passphrase to a key for the specified cipher algorithm. 533 For compatibility, when an S2K specifier is used, the special value 534 254 or 255 is stored in the position where the hash algorithm octet 535 would have been in the old data structure. This is then followed 536 immediately by a one-octet algorithm identifier, and then by the S2K 537 specifier as encoded above. 539 Therefore, preceding the secret data there will be one of these 540 possibilities: 542 0: secret data is unencrypted (no passphrase) 543 255 or 254: followed by algorithm octet and S2K specifier 544 Cipher alg: use Simple S2K algorithm using MD5 hash 546 This last possibility, the cipher algorithm number with an implicit 547 use of MD5 and IDEA, is provided for backward compatibility; it MAY 548 be understood, but SHOULD NOT be generated, and is deprecated. 550 These are followed by an Initial Vector of the same length as the 551 block size of the cipher for the decryption of the secret values, if 552 they are encrypted, and then the secret-key values themselves. 554 3.7.2.2. Symmetric-Key Message Encryption 556 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 557 at the front of a message. This is used to allow S2K specifiers to 558 be used for the passphrase conversion or to create messages with a 559 mix of symmetric-key ESKs and public-key ESKs. This allows a message 560 to be decrypted either with a passphrase or a public-key pair. 562 PGP 2.X always used IDEA with Simple string-to-key conversion when 563 encrypting a message with a symmetric algorithm. This is deprecated, 564 but MAY be used for backward-compatibility. 566 4. Packet Syntax 568 This section describes the packets used by OpenPGP. 570 4.1. Overview 572 An OpenPGP message is constructed from a number of records that are 573 traditionally called packets. A packet is a chunk of data that has a 574 tag specifying its meaning. An OpenPGP message, keyring, 575 certificate, and so forth consists of a number of packets. Some of 576 those packets may contain other OpenPGP packets (for example, a 577 compressed data packet, when uncompressed, contains OpenPGP packets). 579 Each packet consists of a packet header, followed by the packet body. 580 The packet header is of variable length. 582 4.2. Packet Headers 584 The first octet of the packet header is called the "Packet Tag". It 585 determines the format of the header and denotes the packet contents. 586 The remainder of the packet header is the length of the packet. 588 Note that the most significant bit is the leftmost bit, called bit 7. 589 A mask for this bit is 0x80 in hexadecimal. 591 ┌───────────────┐ 592 PTag │7 6 5 4 3 2 1 0│ 593 └───────────────┘ 594 Bit 7 -- Always one 595 Bit 6 -- New packet format if set 597 PGP 2.6.x only uses old format packets. Thus, software that 598 interoperates with those versions of PGP must only use old format 599 packets. If interoperability is not an issue, the new packet format 600 is RECOMMENDED. Note that old format packets have four bits of 601 packet tags, and new format packets have six; some features cannot be 602 used and still be backward-compatible. 604 Also note that packets with a tag greater than or equal to 16 MUST 605 use new format packets. The old format packets can only express tags 606 less than or equal to 15. 608 Old format packets contain: 610 Bits 5-2 -- packet tag 611 Bits 1-0 -- length-type 613 New format packets contain: 615 Bits 5-0 -- packet tag 617 4.2.1. Old Format Packet Lengths 619 The meaning of the length-type in old format packets is: 621 0 The packet has a one-octet length. The header is 2 octets long. 623 1 The packet has a two-octet length. The header is 3 octets long. 625 2 The packet has a four-octet length. The header is 5 octets long. 627 3 The packet is of indeterminate length. The header is 1 octet 628 long, and the implementation must determine how long the packet 629 is. If the packet is in a file, this means that the packet 630 extends until the end of the file. In general, an implementation 631 SHOULD NOT use indeterminate-length packets except where the end 632 of the data will be clear from the context, and even then it is 633 better to use a definite length, or a new format header. The new 634 format headers described below have a mechanism for precisely 635 encoding data of indeterminate length. 637 4.2.2. New Format Packet Lengths 639 New format packets have four possible ways of encoding length: 641 1. A one-octet Body Length header encodes packet lengths of up to 642 191 octets. 644 2. A two-octet Body Length header encodes packet lengths of 192 to 645 8383 octets. 647 3. A five-octet Body Length header encodes packet lengths of up to 648 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 649 encodes a four-octet scalar number.) 651 4. When the length of the packet body is not known in advance by the 652 issuer, Partial Body Length headers encode a packet of 653 indeterminate length, effectively making it a stream. 655 4.2.2.1. One-Octet Lengths 657 A one-octet Body Length header encodes a length of 0 to 191 octets. 658 This type of length header is recognized because the one octet value 659 is less than 192. The body length is equal to: 661 bodyLen = 1st_octet; 663 4.2.2.2. Two-Octet Lengths 665 A two-octet Body Length header encodes a length of 192 to 8383 666 octets. It is recognized because its first octet is in the range 192 667 to 223. The body length is equal to: 669 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 671 4.2.2.3. Five-Octet Lengths 673 A five-octet Body Length header consists of a single octet holding 674 the value 255, followed by a four-octet scalar. The body length is 675 equal to: 677 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 678 (4th_octet << 8) | 5th_octet 680 This basic set of one, two, and five-octet lengths is also used 681 internally to some packets. 683 4.2.2.4. Partial Body Lengths 685 A Partial Body Length header is one octet long and encodes the length 686 of only part of the data packet. This length is a power of 2, from 1 687 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 688 octet value that is greater than or equal to 224, and less than 255. 689 The Partial Body Length is equal to: 691 partialBodyLen = 1 << (1st_octet & 0x1F); 693 Each Partial Body Length header is followed by a portion of the 694 packet body data. The Partial Body Length header specifies this 695 portion's length. Another length header (one octet, two-octet, five- 696 octet, or partial) follows that portion. The last length header in 697 the packet MUST NOT be a Partial Body Length header. Partial Body 698 Length headers may only be used for the non-final parts of the 699 packet. 701 Note also that the last Body Length header can be a zero-length 702 header. 704 An implementation MAY use Partial Body Lengths for data packets, be 705 they literal, compressed, or encrypted. The first partial length 706 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 707 used for any other packet types. 709 4.2.3. Packet Length Examples 711 These examples show ways that new format packets might encode the 712 packet lengths. 714 A packet with length 100 may have its length encoded in one octet: 715 0x64. This is followed by 100 octets of data. 717 A packet with length 1723 may have its length encoded in two octets: 718 0xC5, 0xFB. This header is followed by the 1723 octets of data. 720 A packet with length 100000 may have its length encoded in five 721 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 723 It might also be encoded in the following octet stream: 0xEF, first 724 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 725 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 726 octets of data. This is just one possible encoding, and many 727 variations are possible on the size of the Partial Body Length 728 headers, as long as a regular Body Length header encodes the last 729 portion of the data. 731 Please note that in all of these explanations, the total length of 732 the packet is the length of the header(s) plus the length of the 733 body. 735 4.3. Packet Tags 737 The packet tag denotes what type of packet the body holds. Note that 738 old format headers can only have tags less than 16, whereas new 739 format headers can have tags as great as 63. The defined tags (in 740 decimal) are as follows: 742 +==========+====================================================+ 743 | Tag | Packet Type | 744 +==========+====================================================+ 745 | 0 | Reserved - a packet tag MUST NOT have this value | 746 +----------+----------------------------------------------------+ 747 | 1 | Public-Key Encrypted Session Key Packet | 748 +----------+----------------------------------------------------+ 749 | 2 | Signature Packet | 750 +----------+----------------------------------------------------+ 751 | 3 | Symmetric-Key Encrypted Session Key Packet | 752 +----------+----------------------------------------------------+ 753 | 4 | One-Pass Signature Packet | 754 +----------+----------------------------------------------------+ 755 | 5 | Secret-Key Packet | 756 +----------+----------------------------------------------------+ 757 | 6 | Public-Key Packet | 758 +----------+----------------------------------------------------+ 759 | 7 | Secret-Subkey Packet | 760 +----------+----------------------------------------------------+ 761 | 8 | Compressed Data Packet | 762 +----------+----------------------------------------------------+ 763 | 9 | Symmetrically Encrypted Data Packet | 764 +----------+----------------------------------------------------+ 765 | 10 | Marker Packet | 766 +----------+----------------------------------------------------+ 767 | 11 | Literal Data Packet | 768 +----------+----------------------------------------------------+ 769 | 12 | Trust Packet | 770 +----------+----------------------------------------------------+ 771 | 13 | User ID Packet | 772 +----------+----------------------------------------------------+ 773 | 14 | Public-Subkey Packet | 774 +----------+----------------------------------------------------+ 775 | 17 | User Attribute Packet | 776 +----------+----------------------------------------------------+ 777 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 778 +----------+----------------------------------------------------+ 779 | 19 | Modification Detection Code Packet | 780 +----------+----------------------------------------------------+ 781 | 60 to 63 | Private or Experimental Values | 782 +----------+----------------------------------------------------+ 784 Table 2: Packet type registry 786 5. Packet Types 787 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 789 A Public-Key Encrypted Session Key packet holds the session key used 790 to encrypt a message. Zero or more Public-Key Encrypted Session Key 791 packets and/or Symmetric-Key Encrypted Session Key packets may 792 precede a Symmetrically Encrypted Data Packet, which holds an 793 encrypted message. The message is encrypted with the session key, 794 and the session key is itself encrypted and stored in the Encrypted 795 Session Key packet(s). The Symmetrically Encrypted Data Packet is 796 preceded by one Public-Key Encrypted Session Key packet for each 797 OpenPGP key to which the message is encrypted. The recipient of the 798 message finds a session key that is encrypted to their public key, 799 decrypts the session key, and then uses the session key to decrypt 800 the message. 802 The body of this packet consists of: 804 * A one-octet number giving the version number of the packet type. 805 The currently defined value for packet version is 3. 807 * An eight-octet number that gives the Key ID of the public key to 808 which the session key is encrypted. If the session key is 809 encrypted to a subkey, then the Key ID of this subkey is used here 810 instead of the Key ID of the primary key. 812 * A one-octet number giving the public-key algorithm used. 814 * A string of octets that is the encrypted session key. This string 815 takes up the remainder of the packet, and its contents are 816 dependent on the public-key algorithm used. 818 Algorithm Specific Fields for RSA encryption 820 - multiprecision integer (MPI) of RSA encrypted value m**e mod n. 822 Algorithm Specific Fields for Elgamal encryption: 824 - MPI of Elgamal (Diffie-Hellman) value g**k mod p. 826 - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 828 The value "m" in the above formulas is derived from the session key 829 as follows. First, the session key is prefixed with a one-octet 830 algorithm identifier that specifies the symmetric encryption 831 algorithm used to encrypt the following Symmetrically Encrypted Data 832 Packet. Then a two-octet checksum is appended, which is equal to the 833 sum of the preceding session key octets, not including the algorithm 834 identifier, modulo 65536. This value is then encoded as described in 835 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 836 form the "m" value used in the formulas above. See Section 13.1 in 837 this document for notes on OpenPGP's use of PKCS#1. 839 Note that when an implementation forms several PKESKs with one 840 session key, forming a message that can be decrypted by several keys, 841 the implementation MUST make a new PKCS#1 encoding for each key. 843 An implementation MAY accept or use a Key ID of zero as a "wild card" 844 or "speculative" Key ID. In this case, the receiving implementation 845 would try all available private keys, checking for a valid decrypted 846 session key. This format helps reduce traffic analysis of messages. 848 5.2. Signature Packet (Tag 2) 850 A Signature packet describes a binding between some public key and 851 some data. The most common signatures are a signature of a file or a 852 block of text, and a signature that is a certification of a User ID. 854 Two versions of Signature packets are defined. Version 3 provides 855 basic signature information, while version 4 provides an expandable 856 format with subpackets that can specify more information about the 857 signature. PGP 2.6.x only accepts version 3 signatures. 859 Implementations SHOULD accept V3 signatures. Implementations SHOULD 860 generate V4 signatures. 862 Note that if an implementation is creating an encrypted and signed 863 message that is encrypted to a V3 key, it is reasonable to create a 864 V3 signature. 866 5.2.1. Signature Types 868 There are a number of possible meanings for a signature, which are 869 indicated in a signature type octet in any given signature. Please 870 note that the vagueness of these meanings is not a flaw, but a 871 feature of the system. Because OpenPGP places final authority for 872 validity upon the receiver of a signature, it may be that one 873 signer's casual act might be more rigorous than some other 874 authority's positive act. See Section 5.2.4 for detailed information 875 on how to compute and verify signatures of each type. 877 These meanings are as follows: 879 0x00: Signature of a binary document. 880 This means the signer owns it, created it, or certifies that it 881 has not been modified. 883 0x01: Signature of a canonical text document. 884 This means the signer owns it, created it, or certifies that it 885 has not been modified. The signature is calculated over the text 886 data with its line endings converted to . 888 0x02: Standalone signature. 889 This signature is a signature of only its own subpacket contents. 890 It is calculated identically to a signature over a zero-length 891 binary document. Note that it doesn't make sense to have a V3 892 standalone signature. 894 0x10: Generic certification of a User ID and Public-Key packet. 895 The issuer of this certification does not make any particular 896 assertion as to how well the certifier has checked that the owner 897 of the key is in fact the person described by the User ID. 899 0x11: Persona certification of a User ID and Public-Key packet. 900 The issuer of this certification has not done any verification of 901 the claim that the owner of this key is the User ID specified. 903 0x12: Casual certification of a User ID and Public-Key packet. 904 The issuer of this certification has done some casual verification 905 of the claim of identity. 907 0x13: Positive certification of a User ID and Public-Key packet. 908 The issuer of this certification has done substantial verification 909 of the claim of identity. Most OpenPGP implementations make their 910 "key signatures" as 0x10 certifications. Some implementations can 911 issue 0x11-0x13 certifications, but few differentiate between the 912 types. 914 0x18: Subkey Binding Signature 915 This signature is a statement by the top-level signing key that 916 indicates that it owns the subkey. This signature is calculated 917 directly on the primary key and subkey, and not on any User ID or 918 other packets. A signature that binds a signing subkey MUST have 919 an Embedded Signature subpacket in this binding signature that 920 contains a 0x19 signature made by the signing subkey on the 921 primary key and subkey. 923 0x19: Primary Key Binding Signature 924 This signature is a statement by a signing subkey, indicating that 925 it is owned by the primary key and subkey. This signature is 926 calculated the same way as a 0x18 signature: directly on the 927 primary key and subkey, and not on any User ID or other packets. 929 0x1F: Signature directly on a key 930 This signature is calculated directly on a key. It binds the 931 information in the Signature subpackets to the key, and is 932 appropriate to be used for subpackets that provide information 933 about the key, such as the Revocation Key subpacket. It is also 934 appropriate for statements that non-self certifiers want to make 935 about the key itself, rather than the binding between a key and a 936 name. 938 0x20: Key revocation signature 939 The signature is calculated directly on the key being revoked. A 940 revoked key is not to be used. Only revocation signatures by the 941 key being revoked, or by an authorized revocation key, should be 942 considered valid revocation signatures. 944 0x28: Subkey revocation signature 945 The signature is calculated directly on the subkey being revoked. 946 A revoked subkey is not to be used. Only revocation signatures by 947 the top-level signature key that is bound to this subkey, or by an 948 authorized revocation key, should be considered valid revocation 949 signatures. 951 0x30: Certification revocation signature 952 This signature revokes an earlier User ID certification signature 953 (signature class 0x10 through 0x13) or direct-key signature 954 (0x1F). It should be issued by the same key that issued the 955 revoked signature or an authorized revocation key. The signature 956 is computed over the same data as the certificate that it revokes, 957 and should have a later creation date than that certificate. 959 0x40: Timestamp signature. 960 This signature is only meaningful for the timestamp contained in 961 it. 963 0x50: Third-Party Confirmation signature. 964 This signature is a signature over some other OpenPGP Signature 965 packet(s). It is analogous to a notary seal on the signed data. 966 A third-party signature SHOULD include Signature Target 967 subpacket(s) to give easy identification. Note that we really do 968 mean SHOULD. There are plausible uses for this (such as a blind 969 party that only sees the signature, not the key or source 970 document) that cannot include a target subpacket. 972 5.2.2. Version 3 Signature Packet Format 974 The body of a version 3 Signature Packet contains: 976 * One-octet version number (3). 978 * One-octet length of following hashed material. MUST be 5. 980 - One-octet signature type. 982 - Four-octet creation time. 984 * Eight-octet Key ID of signer. 986 * One-octet public-key algorithm. 988 * One-octet hash algorithm. 990 * Two-octet field holding left 16 bits of signed hash value. 992 * One or more multiprecision integers comprising the signature. 993 This portion is algorithm specific, as described below. 995 The concatenation of the data to be signed, the signature type, and 996 creation time from the Signature packet (5 additional octets) is 997 hashed. The resulting hash value is used in the signature algorithm. 998 The high 16 bits (first two octets) of the hash are included in the 999 Signature packet to provide a quick test to reject some invalid 1000 signatures. 1002 Algorithm-Specific Fields for RSA signatures: 1004 * multiprecision integer (MPI) of RSA signature value m**d mod n. 1006 Algorithm-Specific Fields for DSA signatures: 1008 * MPI of DSA value r. 1010 * MPI of DSA value s. 1012 The signature calculation is based on a hash of the signed data, as 1013 described above. The details of the calculation are different for 1014 DSA signatures than for RSA signatures. 1016 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1017 type EMSA-PKCS1-v1_5 as described in Section 9.2 of [RFC3447]. This 1018 requires inserting the hash value as an octet string into an ASN.1 1019 structure. The object identifier for the type of hash being used is 1020 included in the structure. The hexadecimal representations for the 1021 currently defined hash algorithms are as follows: 1023 +============+======================================================+ 1024 | algorithm | hexadecimal represenatation | 1025 +============+======================================================+ 1026 | MD5 | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 | 1027 +------------+------------------------------------------------------+ 1028 | RIPEMD-160 | 0x2B, 0x24, 0x03, 0x02, 0x01 | 1029 +------------+------------------------------------------------------+ 1030 | SHA-1 | 0x2B, 0x0E, 0x03, 0x02, 0x1A | 1031 +------------+------------------------------------------------------+ 1032 | SHA224 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1033 | | 0x02, 0x04 | 1034 +------------+------------------------------------------------------+ 1035 | SHA256 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1036 | | 0x02, 0x01 | 1037 +------------+------------------------------------------------------+ 1038 | SHA384 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1039 | | 0x02, 0x02 | 1040 +------------+------------------------------------------------------+ 1041 | SHA512 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1042 | | 0x02, 0x03 | 1043 +------------+------------------------------------------------------+ 1045 Table 3: Hash hexadecimal representations 1047 The ASN.1 Object Identifiers (OIDs) are as follows: 1049 +============+========================+ 1050 | algorithm | OID | 1051 +============+========================+ 1052 | MD5 | 1.2.840.113549.2.5 | 1053 +------------+------------------------+ 1054 | RIPEMD-160 | 1.3.36.3.2.1 | 1055 +------------+------------------------+ 1056 | SHA-1 | 1.3.14.3.2.26 | 1057 +------------+------------------------+ 1058 | SHA224 | 2.16.840.1.101.3.4.2.4 | 1059 +------------+------------------------+ 1060 | SHA256 | 2.16.840.1.101.3.4.2.1 | 1061 +------------+------------------------+ 1062 | SHA384 | 2.16.840.1.101.3.4.2.2 | 1063 +------------+------------------------+ 1064 | SHA512 | 2.16.840.1.101.3.4.2.3 | 1065 +------------+------------------------+ 1067 Table 4: Hash OIDs 1069 The full hash prefixes for these are as follows: 1071 +============+==========================================+ 1072 | algorithm | full hash prefix | 1073 +============+==========================================+ 1074 | MD5 | 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, | 1075 | | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, | 1076 | | 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 | 1077 +------------+------------------------------------------+ 1078 | RIPEMD-160 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1079 | | 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, | 1080 | | 0x00, 0x04, 0x14 | 1081 +------------+------------------------------------------+ 1082 | SHA-1 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1083 | | 0x2b, 0x0E, 0x03, 0x02, 0x1A, 0x05, | 1084 | | 0x00, 0x04, 0x14 | 1085 +------------+------------------------------------------+ 1086 | SHA224 | 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, | 1087 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1088 | | 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C | 1089 +------------+------------------------------------------+ 1090 | SHA256 | 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, | 1091 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1092 | | 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 | 1093 +------------+------------------------------------------+ 1094 | SHA384 | 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, | 1095 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1096 | | 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 | 1097 +------------+------------------------------------------+ 1098 | SHA512 | 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, | 1099 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1100 | | 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 | 1101 +------------+------------------------------------------+ 1103 Table 5: Hash hexadecimal prefixes 1105 DSA signatures MUST use hashes that are equal in size to the number 1106 of bits of q, the group generated by the DSA key's generator value. 1108 If the output size of the chosen hash is larger than the number of 1109 bits of q, the hash result is truncated to fit by taking the number 1110 of leftmost bits equal to the number of bits of q. This (possibly 1111 truncated) hash function result is treated as a number and used 1112 directly in the DSA signature algorithm. 1114 5.2.3. Version 4 Signature Packet Format 1116 The body of a version 4 Signature packet contains: 1118 * One-octet version number (4). 1120 * One-octet signature type. 1122 * One-octet public-key algorithm. 1124 * One-octet hash algorithm. 1126 * Two-octet scalar octet count for following hashed subpacket data. 1127 Note that this is the length in octets of all of the hashed 1128 subpackets; a pointer incremented by this number will skip over 1129 the hashed subpackets. 1131 * Hashed subpacket data set (zero or more subpackets). 1133 * Two-octet scalar octet count for the following unhashed subpacket 1134 data. Note that this is the length in octets of all of the 1135 unhashed subpackets; a pointer incremented by this number will 1136 skip over the unhashed subpackets. 1138 * Unhashed subpacket data set (zero or more subpackets). 1140 * Two-octet field holding the left 16 bits of the signed hash value. 1142 * One or more multiprecision integers comprising the signature. 1143 This portion is algorithm specific, as described above. 1145 The concatenation of the data being signed and the signature data 1146 from the version number through the hashed subpacket data (inclusive) 1147 is hashed. The resulting hash value is what is signed. The left 16 1148 bits of the hash are included in the Signature packet to provide a 1149 quick test to reject some invalid signatures. 1151 There are two fields consisting of Signature subpackets. The first 1152 field is hashed with the rest of the signature data, while the second 1153 is unhashed. The second set of subpackets is not cryptographically 1154 protected by the signature and should include only advisory 1155 information. 1157 The algorithms for converting the hash function result to a signature 1158 are described in a section below. 1160 5.2.3.1. Signature Subpacket Specification 1162 A subpacket data set consists of zero or more Signature subpackets. 1163 In Signature packets, the subpacket data set is preceded by a two- 1164 octet scalar count of the length in octets of all the subpackets. A 1165 pointer incremented by this number will skip over the subpacket data 1166 set. 1168 Each subpacket consists of a subpacket header and a body. The header 1169 consists of: 1171 * the subpacket length (1, 2, or 5 octets), 1173 * the subpacket type (1 octet), 1175 and is followed by the subpacket-specific data. 1177 The length includes the type octet but not this length. Its format 1178 is similar to the "new" format packet header lengths, but cannot have 1179 Partial Body Lengths. That is: 1181 if the 1st octet < 192, then 1182 lengthOfLength = 1 1183 subpacketLen = 1st_octet 1185 if the 1st octet >= 192 and < 255, then 1186 lengthOfLength = 2 1187 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1189 if the 1st octet = 255, then 1190 lengthOfLength = 5 1191 subpacket length = [four-octet scalar starting at 2nd_octet] 1193 The value of the subpacket type octet may be: 1195 +============+========================================+ 1196 | Type | Description | 1197 +============+========================================+ 1198 | 0 | Reserved | 1199 +------------+----------------------------------------+ 1200 | 1 | Reserved | 1201 +------------+----------------------------------------+ 1202 | 2 | Signature Creation Time | 1203 +------------+----------------------------------------+ 1204 | 3 | Signature Expiration Time | 1205 +------------+----------------------------------------+ 1206 | 4 | Exportable Certification | 1207 +------------+----------------------------------------+ 1208 | 5 | Trust Signature | 1209 +------------+----------------------------------------+ 1210 | 6 | Regular Expression | 1211 +------------+----------------------------------------+ 1212 | 7 | Revocable | 1213 +------------+----------------------------------------+ 1214 | 8 | Reserved | 1215 +------------+----------------------------------------+ 1216 | 9 | Key Expiration Time | 1217 +------------+----------------------------------------+ 1218 | 10 | Placeholder for backward compatibility | 1219 +------------+----------------------------------------+ 1220 | 11 | Preferred Symmetric Algorithms | 1221 +------------+----------------------------------------+ 1222 | 12 | Revocation Key | 1223 +------------+----------------------------------------+ 1224 | 13 | Reserved | 1225 +------------+----------------------------------------+ 1226 | 14 | Reserved | 1227 +------------+----------------------------------------+ 1228 | 15 | Reserved | 1229 +------------+----------------------------------------+ 1230 | 16 | Issuer | 1231 +------------+----------------------------------------+ 1232 | 17 | Reserved | 1233 +------------+----------------------------------------+ 1234 | 18 | Reserved | 1235 +------------+----------------------------------------+ 1236 | 19 | Reserved | 1237 +------------+----------------------------------------+ 1238 | 20 | Notation Data | 1239 +------------+----------------------------------------+ 1240 | 21 | Preferred Hash Algorithms | 1241 +------------+----------------------------------------+ 1242 | 22 | Preferred Compression Algorithms | 1243 +------------+----------------------------------------+ 1244 | 23 | Key Server Preferences | 1245 +------------+----------------------------------------+ 1246 | 24 | Preferred Key Server | 1247 +------------+----------------------------------------+ 1248 | 25 | Primary User ID | 1249 +------------+----------------------------------------+ 1250 | 26 | Policy URI | 1251 +------------+----------------------------------------+ 1252 | 27 | Key Flags | 1253 +------------+----------------------------------------+ 1254 | 28 | Signer's User ID | 1255 +------------+----------------------------------------+ 1256 | 29 | Reason for Revocation | 1257 +------------+----------------------------------------+ 1258 | 30 | Features | 1259 +------------+----------------------------------------+ 1260 | 31 | Signature Target | 1261 +------------+----------------------------------------+ 1262 | 32 | Embedded Signature | 1263 +------------+----------------------------------------+ 1264 | 100 to 110 | Private or experimental | 1265 +------------+----------------------------------------+ 1267 Table 6: Subpacket type registry 1269 An implementation SHOULD ignore any subpacket of a type that it does 1270 not recognize. 1272 Bit 7 of the subpacket type is the "critical" bit. If set, it 1273 denotes that the subpacket is one that is critical for the evaluator 1274 of the signature to recognize. If a subpacket is encountered that is 1275 marked critical but is unknown to the evaluating software, the 1276 evaluator SHOULD consider the signature to be in error. 1278 An evaluator may "recognize" a subpacket, but not implement it. The 1279 purpose of the critical bit is to allow the signer to tell an 1280 evaluator that it would prefer a new, unknown feature to generate an 1281 error than be ignored. 1283 Implementations SHOULD implement the three preferred algorithm 1284 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1285 subpacket. Note, however, that if an implementation chooses not to 1286 implement some of the preferences, it is required to behave in a 1287 polite manner to respect the wishes of those users who do implement 1288 these preferences. 1290 5.2.3.2. Signature Subpacket Types 1292 A number of subpackets are currently defined. Some subpackets apply 1293 to the signature itself and some are attributes of the key. 1294 Subpackets that are found on a self-signature are placed on a 1295 certification made by the key itself. Note that a key may have more 1296 than one User ID, and thus may have more than one self-signature, and 1297 differing subpackets. 1299 A subpacket may be found either in the hashed or unhashed subpacket 1300 sections of a signature. If a subpacket is not hashed, then the 1301 information in it cannot be considered definitive because it is not 1302 part of the signature proper. 1304 5.2.3.3. Notes on Self-Signatures 1306 A self-signature is a binding signature made by the key to which the 1307 signature refers. There are three types of self-signatures, the 1308 certification signatures (types 0x10-0x13), the direct-key signature 1309 (type 0x1F), and the subkey binding signature (type 0x18). For 1310 certification self-signatures, each User ID may have a self- 1311 signature, and thus different subpackets in those self-signatures. 1313 For subkey binding signatures, each subkey in fact has a self- 1314 signature. Subpackets that appear in a certification self-signature 1315 apply to the user name, and subpackets that appear in the subkey 1316 self-signature apply to the subkey. Lastly, subpackets on the 1317 direct-key signature apply to the entire key. 1319 Implementing software should interpret a self-signature's preference 1320 subpackets as narrowly as possible. For example, suppose a key has 1321 two user names, Alice and Bob. Suppose that Alice prefers the 1322 symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the 1323 software locates this key via Alice's name, then the preferred 1324 algorithm is CAST5; if software locates the key via Bob's name, then 1325 the preferred algorithm is IDEA. If the key is located by Key ID, 1326 the algorithm of the primary User ID of the key provides the 1327 preferred symmetric algorithm. 1329 Revoking a self-signature or allowing it to expire has a semantic 1330 meaning that varies with the signature type. Revoking the self- 1331 signature on a User ID effectively retires that user name. The self- 1332 signature is a statement, "My name X is tied to my signing key K" and 1333 is corroborated by other users' certifications. If another user 1334 revokes their certification, they are effectively saying that they no 1335 longer believe that name and that key are tied together. Similarly, 1336 if the users themselves revoke their self-signature, then the users 1337 no longer go by that name, no longer have that email address, etc. 1338 Revoking a binding signature effectively retires that subkey. 1339 Revoking a direct-key signature cancels that signature. Please see 1340 Section 5.2.3.23 for more relevant detail. 1342 Since a self-signature contains important information about the key's 1343 use, an implementation SHOULD allow the user to rewrite the self- 1344 signature, and important information in it, such as preferences and 1345 key expiration. 1347 It is good practice to verify that a self-signature imported into an 1348 implementation doesn't advertise features that the implementation 1349 doesn't support, rewriting the signature as appropriate. 1351 An implementation that encounters multiple self-signatures on the 1352 same object may resolve the ambiguity in any way it sees fit, but it 1353 is RECOMMENDED that priority be given to the most recent self- 1354 signature. 1356 5.2.3.4. Signature Creation Time 1358 (4-octet time field) 1360 The time the signature was made. 1362 MUST be present in the hashed area. 1364 5.2.3.5. Issuer 1366 (8-octet Key ID) 1368 The OpenPGP Key ID of the key issuing the signature. 1370 5.2.3.6. Key Expiration Time 1372 (4-octet time field) 1374 The validity period of the key. This is the number of seconds after 1375 the key creation time that the key expires. If this is not present 1376 or has a value of zero, the key never expires. This is found only on 1377 a self-signature. 1379 5.2.3.7. Preferred Symmetric Algorithms 1381 (array of one-octet values) 1383 Symmetric algorithm numbers that indicate which algorithms the key 1384 holder prefers to use. The subpacket body is an ordered list of 1385 octets with the most preferred listed first. It is assumed that only 1386 algorithms listed are supported by the recipient's software. 1387 Algorithm numbers are in Section 9.2. This is only found on a self- 1388 signature. 1390 5.2.3.8. Preferred Hash Algorithms 1392 (array of one-octet values) 1394 Message digest algorithm numbers that indicate which algorithms the 1395 key holder prefers to receive. Like the preferred symmetric 1396 algorithms, the list is ordered. Algorithm numbers are in 1397 Section 9.4. This is only found on a self-signature. 1399 5.2.3.9. Preferred Compression Algorithms 1401 (array of one-octet values) 1403 Compression algorithm numbers that indicate which algorithms the key 1404 holder prefers to use. Like the preferred symmetric algorithms, the 1405 list is ordered. Algorithm numbers are in Section 9.3. If this 1406 subpacket is not included, ZIP is preferred. A zero denotes that 1407 uncompressed data is preferred; the key holder's software might have 1408 no compression software in that implementation. This is only found 1409 on a self-signature. 1411 5.2.3.10. Signature Expiration Time 1413 (4-octet time field) 1415 The validity period of the signature. This is the number of seconds 1416 after the signature creation time that the signature expires. If 1417 this is not present or has a value of zero, it never expires. 1419 5.2.3.11. Exportable Certification 1421 (1 octet of exportability, 0 for not, 1 for exportable) 1423 This subpacket denotes whether a certification signature is 1424 "exportable", to be used by other users than the signature's issuer. 1425 The packet body contains a Boolean flag indicating whether the 1426 signature is exportable. If this packet is not present, the 1427 certification is exportable; it is equivalent to a flag containing a 1428 1. 1430 Non-exportable, or "local", certifications are signatures made by a 1431 user to mark a key as valid within that user's implementation only. 1433 Thus, when an implementation prepares a user's copy of a key for 1434 transport to another user (this is the process of "exporting" the 1435 key), any local certification signatures are deleted from the key. 1437 The receiver of a transported key "imports" it, and likewise trims 1438 any local certifications. In normal operation, there won't be any, 1439 assuming the import is performed on an exported key. However, there 1440 are instances where this can reasonably happen. For example, if an 1441 implementation allows keys to be imported from a key database in 1442 addition to an exported key, then this situation can arise. 1444 Some implementations do not represent the interest of a single user 1445 (for example, a key server). Such implementations always trim local 1446 certifications from any key they handle. 1448 5.2.3.12. Revocable 1450 (1 octet of revocability, 0 for not, 1 for revocable) 1452 Signature's revocability status. The packet body contains a Boolean 1453 flag indicating whether the signature is revocable. Signatures that 1454 are not revocable have any later revocation signatures ignored. They 1455 represent a commitment by the signer that he cannot revoke his 1456 signature for the life of his key. If this packet is not present, 1457 the signature is revocable. 1459 5.2.3.13. Trust Signature 1461 (1 octet "level" (depth), 1 octet of trust amount) 1463 Signer asserts that the key is not only valid but also trustworthy at 1464 the specified level. Level 0 has the same meaning as an ordinary 1465 validity signature. Level 1 means that the signed key is asserted to 1466 be a valid trusted introducer, with the 2nd octet of the body 1467 specifying the degree of trust. Level 2 means that the signed key is 1468 asserted to be trusted to issue level 1 trust signatures, i.e., that 1469 it is a "meta introducer". Generally, a level n trust signature 1470 asserts that a key is trusted to issue level n-1 trust signatures. 1471 The trust amount is in a range from 0-255, interpreted such that 1472 values less than 120 indicate partial trust and values of 120 or 1473 greater indicate complete trust. Implementations SHOULD emit values 1474 of 60 for partial trust and 120 for complete trust. 1476 5.2.3.14. Regular Expression 1478 (null-terminated regular expression) 1480 Used in conjunction with trust Signature packets (of level > 0) to 1481 limit the scope of trust that is extended. Only signatures by the 1482 target key on User IDs that match the regular expression in the body 1483 of this packet have trust extended by the trust Signature subpacket. 1484 The regular expression uses the same syntax as the Henry Spencer's 1485 "almost public domain" regular expression [REGEX] package. A 1486 description of the syntax is found in Section 8. 1488 5.2.3.15. Revocation Key 1490 (1 octet of class, 1 octet of public-key algorithm ID, 20 octets of 1491 fingerprint) 1493 Authorizes the specified key to issue revocation signatures for this 1494 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1495 then this means that the revocation information is sensitive. Other 1496 bits are for future expansion to other kinds of authorizations. This 1497 is found on a self-signature. 1499 If the "sensitive" flag is set, the keyholder feels this subpacket 1500 contains private trust information that describes a real-world 1501 sensitive relationship. If this flag is set, implementations SHOULD 1502 NOT export this signature to other users except in cases where the 1503 data needs to be available: when the signature is being sent to the 1504 designated revoker, or when it is accompanied by a revocation 1505 signature from that revoker. Note that it may be appropriate to 1506 isolate this subpacket within a separate signature so that it is not 1507 combined with other subpackets that need to be exported. 1509 5.2.3.16. Notation Data 1511 (4 octets of flags, 2 octets of name length (M), 2 octets of value 1512 length (N), M octets of name data, N octets of value data) 1514 This subpacket describes a "notation" on the signature that the 1515 issuer wishes to make. The notation has a name and a value, each of 1516 which are strings of octets. There may be more than one notation in 1517 a signature. Notations can be used for any extension the issuer of 1518 the signature cares to make. The "flags" field holds four octets of 1519 flags. 1521 All undefined flags MUST be zero. Defined flags are as follows: 1523 First octet: 1525 +======+================+==========================+ 1526 | flag | shorthand | definition | 1527 +======+================+==========================+ 1528 | 0x80 | human-readable | This note value is text. | 1529 +------+----------------+--------------------------+ 1531 Table 7: Notation flag registry (first octet) 1533 Other octets: none. 1535 Notation names are arbitrary strings encoded in UTF-8. They reside 1536 in two namespaces: The IETF namespace and the user namespace. 1538 The IETF namespace is registered with IANA. These names MUST NOT 1539 contain the "@" character (0x40). This is a tag for the user 1540 namespace. 1542 Names in the user namespace consist of a UTF-8 string tag followed by 1543 "@" followed by a DNS domain name. Note that the tag MUST NOT 1544 contain an "@" character. For example, the "sample" tag used by 1545 Example Corporation could be "sample@example.com". 1547 Names in a user space are owned and controlled by the owners of that 1548 domain. Obviously, it's bad form to create a new name in a DNS space 1549 that you don't own. 1551 Since the user namespace is in the form of an email address, 1552 implementers MAY wish to arrange for that address to reach a person 1553 who can be consulted about the use of the named tag. Note that due 1554 to UTF-8 encoding, not all valid user space name tags are valid email 1555 addresses. 1557 If there is a critical notation, the criticality applies to that 1558 specific notation and not to notations in general. 1560 5.2.3.17. Key Server Preferences 1562 (N octets of flags) 1564 This is a list of one-bit flags that indicate preferences that the 1565 key holder has about how the key is handled on a key server. All 1566 undefined flags MUST be zero. 1568 First octet: 1570 +======+===========+============================================+ 1571 | flag | shorthand | definition | 1572 +======+===========+============================================+ 1573 | 0x80 | No-modify | The key holder requests that this key only | 1574 | | | be modified or updated by the key holder | 1575 | | | or an administrator of the key server. | 1576 +------+-----------+--------------------------------------------+ 1578 Table 8: Key server preferences flag registry (first octet) 1580 This is found only on a self-signature. 1582 5.2.3.18. Preferred Key Server 1584 (String) 1586 This is a URI of a key server that the key holder prefers be used for 1587 updates. Note that keys with multiple User IDs can have a preferred 1588 key server for each User ID. Note also that since this is a URI, the 1589 key server can actually be a copy of the key retrieved by ftp, http, 1590 finger, etc. 1592 5.2.3.19. Primary User ID 1594 (1 octet, Boolean) 1596 This is a flag in a User ID's self-signature that states whether this 1597 User ID is the main User ID for this key. It is reasonable for an 1598 implementation to resolve ambiguities in preferences, etc. by 1599 referring to the primary User ID. If this flag is absent, its value 1600 is zero. If more than one User ID in a key is marked as primary, the 1601 implementation may resolve the ambiguity in any way it sees fit, but 1602 it is RECOMMENDED that priority be given to the User ID with the most 1603 recent self-signature. 1605 When appearing on a self-signature on a User ID packet, this 1606 subpacket applies only to User ID packets. When appearing on a self- 1607 signature on a User Attribute packet, this subpacket applies only to 1608 User Attribute packets. That is to say, there are two different and 1609 independent "primaries" -- one for User IDs, and one for User 1610 Attributes. 1612 5.2.3.20. Policy URI 1614 (String) 1616 This subpacket contains a URI of a document that describes the policy 1617 under which the signature was issued. 1619 5.2.3.21. Key Flags 1621 (N octets of flags) 1623 This subpacket contains a list of binary flags that hold information 1624 about a key. It is a string of octets, and an implementation MUST 1625 NOT assume a fixed size. This is so it can grow over time. If a 1626 list is shorter than an implementation expects, the unstated flags 1627 are considered to be zero. The defined flags are as follows: 1629 First octet: 1631 +======+=================================================+ 1632 | flag | definition | 1633 +======+=================================================+ 1634 | 0x01 | This key may be used to certify other keys. | 1635 +------+-------------------------------------------------+ 1636 | 0x02 | This key may be used to sign data. | 1637 +------+-------------------------------------------------+ 1638 | 0x04 | This key may be used to encrypt communications. | 1639 +------+-------------------------------------------------+ 1640 | 0x08 | This key may be used to encrypt storage. | 1641 +------+-------------------------------------------------+ 1642 | 0x10 | The private component of this key may have been | 1643 | | split by a secret-sharing mechanism. | 1644 +------+-------------------------------------------------+ 1645 | 0x20 | This key may be used for authentication. | 1646 +------+-------------------------------------------------+ 1647 | 0x80 | The private component of this key may be in the | 1648 | | possession of more than one person. | 1649 +------+-------------------------------------------------+ 1651 Table 9: Key flags registry 1653 Usage notes: 1655 The flags in this packet may appear in self-signatures or in 1656 certification signatures. They mean different things depending on 1657 who is making the statement -- for example, a certification signature 1658 that has the "sign data" flag is stating that the certification is 1659 for that use. On the other hand, the "communications encryption" 1660 flag in a self-signature is stating a preference that a given key be 1661 used for communications. Note however, that it is a thorny issue to 1662 determine what is "communications" and what is "storage". This 1663 decision is left wholly up to the implementation; the authors of this 1664 document do not claim any special wisdom on the issue and realize 1665 that accepted opinion may change. 1667 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1668 self-signature only; they are meaningless on a certification 1669 signature. They SHOULD be placed only on a direct-key signature 1670 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1671 key the flag applies to. 1673 5.2.3.22. Signer's User ID 1675 (String) 1676 This subpacket allows a keyholder to state which User ID is 1677 responsible for the signing. Many keyholders use a single key for 1678 different purposes, such as business communications as well as 1679 personal communications. This subpacket allows such a keyholder to 1680 state which of their roles is making a signature. 1682 This subpacket is not appropriate to use to refer to a User Attribute 1683 packet. 1685 5.2.3.23. Reason for Revocation 1687 (1 octet of revocation code, N octets of reason string) 1689 This subpacket is used only in key revocation and certification 1690 revocation signatures. It describes the reason why the key or 1691 certificate was revoked. 1693 The first octet contains a machine-readable code that denotes the 1694 reason for the revocation: 1696 +=========+==================================+ 1697 | Code | Reason | 1698 +=========+==================================+ 1699 | 0 | No reason specified (key | 1700 | | revocations or cert revocations) | 1701 +---------+----------------------------------+ 1702 | 1 | Key is superseded (key | 1703 | | revocations) | 1704 +---------+----------------------------------+ 1705 | 2 | Key material has been | 1706 | | compromised (key revocations) | 1707 +---------+----------------------------------+ 1708 | 3 | Key is retired and no longer | 1709 | | used (key revocations) | 1710 +---------+----------------------------------+ 1711 | 32 | User ID information is no longer | 1712 | | valid (cert revocations) | 1713 +---------+----------------------------------+ 1714 | 100-110 | Private Use | 1715 +---------+----------------------------------+ 1717 Table 10: Reasons for revocation 1719 Following the revocation code is a string of octets that gives 1720 information about the Reason for Revocation in human-readable form 1721 (UTF-8). The string may be null, that is, of zero length. The 1722 length of the subpacket is the length of the reason string plus one. 1723 An implementation SHOULD implement this subpacket, include it in all 1724 revocation signatures, and interpret revocations appropriately. 1725 There are important semantic differences between the reasons, and 1726 there are thus important reasons for revoking signatures. 1728 If a key has been revoked because of a compromise, all signatures 1729 created by that key are suspect. However, if it was merely 1730 superseded or retired, old signatures are still valid. If the 1731 revoked signature is the self-signature for certifying a User ID, a 1732 revocation denotes that that user name is no longer in use. Such a 1733 revocation SHOULD include a 0x20 code. 1735 Note that any signature may be revoked, including a certification on 1736 some other person's key. There are many good reasons for revoking a 1737 certification signature, such as the case where the keyholder leaves 1738 the employ of a business with an email address. A revoked 1739 certification is no longer a part of validity calculations. 1741 5.2.3.24. Features 1743 (N octets of flags) 1745 The Features subpacket denotes which advanced OpenPGP features a 1746 user's implementation supports. This is so that as features are 1747 added to OpenPGP that cannot be backwards-compatible, a user can 1748 state that they can use that feature. The flags are single bits that 1749 indicate that a given feature is supported. 1751 This subpacket is similar to a preferences subpacket, and only 1752 appears in a self-signature. 1754 An implementation SHOULD NOT use a feature listed when sending to a 1755 user who does not state that they can use it. 1757 Defined features are as follows: 1759 First octet: 1761 +=========+============================================+ 1762 | feature | definition | 1763 +=========+============================================+ 1764 | 0x01 | Modification Detection (packets 18 and 19) | 1765 +---------+--------------------------------------------+ 1767 Table 11: Features registry 1769 If an implementation implements any of the defined features, it 1770 SHOULD implement the Features subpacket, too. 1772 An implementation may freely infer features from other suitable 1773 implementation-dependent mechanisms. 1775 5.2.3.25. Signature Target 1777 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1779 This subpacket identifies a specific target signature to which a 1780 signature refers. For revocation signatures, this subpacket provides 1781 explicit designation of which signature is being revoked. For a 1782 third-party or timestamp signature, this designates what signature is 1783 signed. All arguments are an identifier of that target signature. 1785 The N octets of hash data MUST be the size of the hash of the 1786 signature. For example, a target signature with a SHA-1 hash MUST 1787 have 20 octets of hash data. 1789 5.2.3.26. Embedded Signature 1791 (1 signature packet body) 1793 This subpacket contains a complete Signature packet body as specified 1794 in Section 5.2. It is useful when one signature needs to refer to, 1795 or be incorporated in, another signature. 1797 5.2.4. Computing Signatures 1799 All signatures are formed by producing a hash over the signature 1800 data, and then using the resulting hash in the signature algorithm. 1802 For binary document signatures (type 0x00), the document data is 1803 hashed directly. For text document signatures (type 0x01), the 1804 document is canonicalized by converting line endings to , and 1805 the resulting data is hashed. 1807 When a signature is made over a key, the hash data starts with the 1808 octet 0x99, followed by a two-octet length of the key, and then body 1809 of the key packet. (Note that this is an old-style packet header for 1810 a key packet with two-octet length.) A subkey binding signature 1811 (type 0x18) or primary key binding signature (type 0x19) then hashes 1812 the subkey using the same format as the main key (also using 0x99 as 1813 the first octet). Key revocation signatures (types 0x20 and 0x28) 1814 hash only the key being revoked. 1816 A certification signature (type 0x10 through 0x13) hashes the User ID 1817 being bound to the key into the hash context after the above data. A 1818 V3 certification hashes the contents of the User ID or attribute 1819 packet packet, without any header. A V4 certification hashes the 1820 constant 0xB4 for User ID certifications or the constant 0xD1 for 1821 User Attribute certifications, followed by a four-octet number giving 1822 the length of the User ID or User Attribute data, and then the User 1823 ID or User Attribute data. 1825 When a signature is made over a Signature packet (type 0x50), the 1826 hash data starts with the octet 0x88, followed by the four-octet 1827 length of the signature, and then the body of the Signature packet. 1828 (Note that this is an old-style packet header for a Signature packet 1829 with the length-of-length set to zero.) The unhashed subpacket data 1830 of the Signature packet being hashed is not included in the hash, and 1831 the unhashed subpacket data length value is set to zero. 1833 Once the data body is hashed, then a trailer is hashed. A V3 1834 signature hashes five octets of the packet body, starting from the 1835 signature type field. This data is the signature type, followed by 1836 the four-octet signature time. A V4 signature hashes the packet body 1837 starting from its first field, the version number, through the end of 1838 the hashed subpacket data. Thus, the fields hashed are the signature 1839 version, the signature type, the public-key algorithm, the hash 1840 algorithm, the hashed subpacket length, and the hashed subpacket 1841 body. 1843 V4 signatures also hash in a final trailer of six octets: the version 1844 of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, big- 1845 endian number that is the length of the hashed data from the 1846 Signature packet (note that this number does not include these final 1847 six octets). 1849 After all this has been hashed in a single hash context, the 1850 resulting hash field is used in the signature algorithm and placed at 1851 the end of the Signature packet. 1853 5.2.4.1. Subpacket Hints 1855 It is certainly possible for a signature to contain conflicting 1856 information in subpackets. For example, a signature may contain 1857 multiple copies of a preference or multiple expiration times. In 1858 most cases, an implementation SHOULD use the last subpacket in the 1859 signature, but MAY use any conflict resolution scheme that makes more 1860 sense. Please note that we are intentionally leaving conflict 1861 resolution to the implementer; most conflicts are simply syntax 1862 errors, and the wishy-washy language here allows a receiver to be 1863 generous in what they accept, while putting pressure on a creator to 1864 be stingy in what they generate. 1866 Some apparent conflicts may actually make sense -- for example, 1867 suppose a keyholder has a V3 key and a V4 key that share the same RSA 1868 key material. Either of these keys can verify a signature created by 1869 the other, and it may be reasonable for a signature to contain an 1870 issuer subpacket for each key, as a way of explicitly tying those 1871 keys to the signature. 1873 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 1875 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 1876 key encryption of a session key used to encrypt a message. Zero or 1877 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 1878 Encrypted Session Key packets may precede a Symmetrically Encrypted 1879 Data packet that holds an encrypted message. The message is 1880 encrypted with a session key, and the session key is itself encrypted 1881 and stored in the Encrypted Session Key packet or the Symmetric-Key 1882 Encrypted Session Key packet. 1884 If the Symmetrically Encrypted Data packet is preceded by one or more 1885 Symmetric-Key Encrypted Session Key packets, each specifies a 1886 passphrase that may be used to decrypt the message. This allows a 1887 message to be encrypted to a number of public keys, and also to one 1888 or more passphrases. This packet type is new and is not generated by 1889 PGP 2.x or PGP 5.0. 1891 The body of this packet consists of: 1893 * A one-octet version number. The only currently defined version is 1894 4. 1896 * A one-octet number describing the symmetric algorithm used. 1898 * A string-to-key (S2K) specifier, length as defined above. 1900 * Optionally, the encrypted session key itself, which is decrypted 1901 with the string-to-key object. 1903 If the encrypted session key is not present (which can be detected on 1904 the basis of packet length and S2K specifier size), then the S2K 1905 algorithm applied to the passphrase produces the session key for 1906 decrypting the file, using the symmetric cipher algorithm from the 1907 Symmetric-Key Encrypted Session Key packet. 1909 If the encrypted session key is present, the result of applying the 1910 S2K algorithm to the passphrase is used to decrypt just that 1911 encrypted session key field, using CFB mode with an IV of all zeros. 1912 The decryption result consists of a one-octet algorithm identifier 1913 that specifies the symmetric-key encryption algorithm used to encrypt 1914 the following Symmetrically Encrypted Data packet, followed by the 1915 session key octets themselves. 1917 Note: because an all-zero IV is used for this decryption, the S2K 1918 specifier MUST use a salt value, either a Salted S2K or an Iterated- 1919 Salted S2K. The salt value will ensure that the decryption key is 1920 not repeated even if the passphrase is reused. 1922 5.4. One-Pass Signature Packets (Tag 4) 1924 The One-Pass Signature packet precedes the signed data and contains 1925 enough information to allow the receiver to begin calculating any 1926 hashes needed to verify the signature. It allows the Signature 1927 packet to be placed at the end of the message, so that the signer can 1928 compute the entire signed message in one pass. 1930 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 1932 The body of this packet consists of: 1934 * A one-octet version number. The current version is 3. 1936 * A one-octet signature type. Signature types are described in 1937 Section 5.2.1. 1939 * A one-octet number describing the hash algorithm used. 1941 * A one-octet number describing the public-key algorithm used. 1943 * An eight-octet number holding the Key ID of the signing key. 1945 * A one-octet number holding a flag showing whether the signature is 1946 nested. A zero value indicates that the next packet is another 1947 One-Pass Signature packet that describes another signature to be 1948 applied to the same message data. 1950 Note that if a message contains more than one one-pass signature, 1951 then the Signature packets bracket the message; that is, the first 1952 Signature packet after the message corresponds to the last one-pass 1953 packet and the final Signature packet corresponds to the first one- 1954 pass packet. 1956 5.5. Key Material Packet 1958 A key material packet contains all the information about a public or 1959 private key. There are four variants of this packet type, and two 1960 major versions. Consequently, this section is complex. 1962 5.5.1. Key Packet Variants 1964 5.5.1.1. Public-Key Packet (Tag 6) 1966 A Public-Key packet starts a series of packets that forms an OpenPGP 1967 key (sometimes called an OpenPGP certificate). 1969 5.5.1.2. Public-Subkey Packet (Tag 14) 1971 A Public-Subkey packet (tag 14) has exactly the same format as a 1972 Public-Key packet, but denotes a subkey. One or more subkeys may be 1973 associated with a top-level key. By convention, the top-level key 1974 provides signature services, and the subkeys provide encryption 1975 services. 1977 Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet. 1978 This tag was selected for reuse because no previous version of PGP 1979 ever emitted comment packets but they did properly ignore them. 1980 Public-Subkey packets are ignored by PGP 2.6.x and do not cause it to 1981 fail, providing a limited degree of backward compatibility. 1983 5.5.1.3. Secret-Key Packet (Tag 5) 1985 A Secret-Key packet contains all the information that is found in a 1986 Public-Key packet, including the public-key material, but also 1987 includes the secret-key material after all the public-key fields. 1989 5.5.1.4. Secret-Subkey Packet (Tag 7) 1991 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 1992 packet and has exactly the same format. 1994 5.5.2. Public-Key Packet Formats 1996 There are two versions of key-material packets. Version 3 packets 1997 were first generated by PGP 2.6. Version 4 keys first appeared in 1998 PGP 5.0 and are the preferred key version for OpenPGP. 2000 OpenPGP implementations MUST create keys with version 4 format. V3 2001 keys are deprecated; an implementation MUST NOT generate a V3 key, 2002 but MAY accept it. 2004 A version 3 public key or public-subkey packet contains: 2006 * A one-octet version number (3). 2008 * A four-octet number denoting the time that the key was created. 2010 * A two-octet number denoting the time in days that this key is 2011 valid. If this number is zero, then it does not expire. 2013 * A one-octet number denoting the public-key algorithm of this key. 2015 * A series of multiprecision integers comprising the key material: 2017 - a multiprecision integer (MPI) of RSA public modulus n; 2019 - an MPI of RSA public encryption exponent e. 2021 V3 keys are deprecated. They contain three weaknesses. First, it is 2022 relatively easy to construct a V3 key that has the same Key ID as any 2023 other key because the Key ID is simply the low 64 bits of the public 2024 modulus. Secondly, because the fingerprint of a V3 key hashes the 2025 key material, but not its length, there is an increased opportunity 2026 for fingerprint collisions. Third, there are weaknesses in the MD5 2027 hash algorithm that make developers prefer other algorithms. See 2028 below for a fuller discussion of Key IDs and fingerprints. 2030 V2 keys are identical to the deprecated V3 keys except for the 2031 version number. An implementation MUST NOT generate them and MAY 2032 accept or reject them as it sees fit. 2034 The version 4 format is similar to the version 3 format except for 2035 the absence of a validity period. This has been moved to the 2036 Signature packet. In addition, fingerprints of version 4 keys are 2037 calculated differently from version 3 keys, as described in 2038 Section 12. 2040 A version 4 packet contains: 2042 * A one-octet version number (4). 2044 * A four-octet number denoting the time that the key was created. 2046 * A one-octet number denoting the public-key algorithm of this key. 2048 * A series of multiprecision integers comprising the key material. 2049 This algorithm-specific portion is: 2051 Algorithm-Specific Fields for RSA public keys: 2053 - multiprecision integer (MPI) of RSA public modulus n; 2055 - MPI of RSA public encryption exponent e. 2057 Algorithm-Specific Fields for DSA public keys: 2059 - MPI of DSA prime p; 2061 - MPI of DSA group order q (q is a prime divisor of p-1); 2063 - MPI of DSA group generator g; 2065 - MPI of DSA public-key value y (= g**x mod p where x is secret). 2067 Algorithm-Specific Fields for Elgamal public keys: 2069 - MPI of Elgamal prime p; 2071 - MPI of Elgamal group generator g; 2073 - MPI of Elgamal public key value y (= g**x mod p where x is 2074 secret). 2076 5.5.3. Secret-Key Packet Formats 2078 The Secret-Key and Secret-Subkey packets contain all the data of the 2079 Public-Key and Public-Subkey packets, with additional algorithm- 2080 specific secret-key data appended, usually in encrypted form. 2082 The packet contains: 2084 * A Public-Key or Public-Subkey packet, as described above. 2086 * One octet indicating string-to-key usage conventions. Zero 2087 indicates that the secret-key data is not encrypted. 255 or 254 2088 indicates that a string-to-key specifier is being given. Any 2089 other value is a symmetric-key encryption algorithm identifier. 2091 * [Optional] If string-to-key usage octet was 255 or 254, a one- 2092 octet symmetric encryption algorithm. 2094 * [Optional] If string-to-key usage octet was 255 or 254, a string- 2095 to-key specifier. The length of the string-to-key specifier is 2096 implied by its type, as described above. 2098 * [Optional] If secret data is encrypted (string-to-key usage octet 2099 not zero), an Initial Vector (IV) of the same length as the 2100 cipher's block size. 2102 * Plain or encrypted multiprecision integers comprising the secret 2103 key data. These algorithm-specific fields are as described below. 2105 * If the string-to-key usage octet is zero or 255, then a two-octet 2106 checksum of the plaintext of the algorithm-specific portion (sum 2107 of all octets, mod 65536). If the string-to-key usage octet was 2108 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2109 specific portion. This checksum or hash is encrypted together 2110 with the algorithm-specific fields (if string-to-key usage octet 2111 is not zero). Note that for all other values, a two-octet 2112 checksum is required. 2114 Algorithm-Specific Fields for RSA secret keys: 2116 - multiprecision integer (MPI) of RSA secret exponent d. 2118 - MPI of RSA secret prime value p. 2120 - MPI of RSA secret prime value q (p < q). 2122 - MPI of u, the multiplicative inverse of p, mod q. 2124 Algorithm-Specific Fields for DSA secret keys: 2126 - MPI of DSA secret exponent x. 2128 Algorithm-Specific Fields for Elgamal secret keys: 2130 - MPI of Elgamal secret exponent x. 2132 Secret MPI values can be encrypted using a passphrase. If a string- 2133 to-key specifier is given, that describes the algorithm for 2134 converting the passphrase to a key, else a simple MD5 hash of the 2135 passphrase is used. Implementations MUST use a string-to-key 2136 specifier; the simple hash is for backward compatibility and is 2137 deprecated, though implementations MAY continue to use existing 2138 private keys in the old format. The cipher for encrypting the MPIs 2139 is specified in the Secret-Key packet. 2141 Encryption/decryption of the secret data is done in CFB mode using 2142 the key created from the passphrase and the Initial Vector from the 2143 packet. A different mode is used with V3 keys (which are only RSA) 2144 than with other key formats. With V3 keys, the MPI bit count prefix 2145 (i.e., the first two octets) is not encrypted. Only the MPI non- 2146 prefix data is encrypted. Furthermore, the CFB state is 2147 resynchronized at the beginning of each new MPI value, so that the 2148 CFB block boundary is aligned with the start of the MPI data. 2150 With V4 keys, a simpler method is used. All secret MPI values are 2151 encrypted in CFB mode, including the MPI bitcount prefix. 2153 The two-octet checksum that follows the algorithm-specific portion is 2154 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2155 specific octets (including MPI prefix and data). With V3 keys, the 2156 checksum is stored in the clear. With V4 keys, the checksum is 2157 encrypted like the algorithm-specific data. This value is used to 2158 check that the passphrase was correct. However, this checksum is 2159 deprecated; an implementation SHOULD NOT use it, but should rather 2160 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2161 this is that there are some attacks that involve undetectably 2162 modifying the secret key. 2164 5.6. Compressed Data Packet (Tag 8) 2166 The Compressed Data packet contains compressed data. Typically, this 2167 packet is found as the contents of an encrypted packet, or following 2168 a Signature or One-Pass Signature packet, and contains a literal data 2169 packet. 2171 The body of this packet consists of: 2173 * One octet that gives the algorithm used to compress the packet. 2175 * Compressed data, which makes up the remainder of the packet. 2177 A Compressed Data Packet's body contains an block that compresses 2178 some set of packets. See Section 11 for details on how messages are 2179 formed. 2181 ZIP-compressed packets are compressed with raw [RFC1951] DEFLATE 2182 blocks. Note that PGP V2.6 uses 13 bits of compression. If an 2183 implementation uses more bits of compression, PGP V2.6 cannot 2184 decompress it. 2186 ZLIB-compressed packets are compressed with [RFC1950] ZLIB-style 2187 blocks. 2189 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2190 algorithm. 2192 5.7. Symmetrically Encrypted Data Packet (Tag 9) 2194 The Symmetrically Encrypted Data packet contains data encrypted with 2195 a symmetric-key algorithm. When it has been decrypted, it contains 2196 other packets (usually a literal data packet or compressed data 2197 packet, but in theory other Symmetrically Encrypted Data packets or 2198 sequences of packets that form whole OpenPGP messages). 2200 The body of this packet consists of: 2202 * Encrypted data, the output of the selected symmetric-key cipher 2203 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2205 The symmetric cipher used may be specified in a Public-Key or 2206 Symmetric-Key Encrypted Session Key packet that precedes the 2207 Symmetrically Encrypted Data packet. In that case, the cipher 2208 algorithm octet is prefixed to the session key before it is 2209 encrypted. If no packets of these types precede the encrypted data, 2210 the IDEA algorithm is used with the session key calculated as the MD5 2211 hash of the passphrase, though this use is deprecated. 2213 The data is encrypted in CFB mode, with a CFB shift size equal to the 2214 cipher's block size. The Initial Vector (IV) is specified as all 2215 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2216 equal to the block size of the cipher plus two to the data before it 2217 is encrypted. The first block-size octets (for example, 8 octets for 2218 a 64-bit block length) are random, and the following two octets are 2219 copies of the last two octets of the IV. For example, in an 8-octet 2220 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2221 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2222 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2223 in both these examples, we consider the first octet to be numbered 1. 2225 After encrypting the first block-size-plus-two octets, the CFB state 2226 is resynchronized. The last block-size octets of ciphertext are 2227 passed through the cipher and the block boundary is reset. 2229 The repetition of 16 bits in the random data prefixed to the message 2230 allows the receiver to immediately check whether the session key is 2231 incorrect. See Section 14 for hints on the proper use of this "quick 2232 check". 2234 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) 2236 An experimental version of PGP used this packet as the Literal 2237 packet, but no released version of PGP generated Literal packets with 2238 this tag. With PGP 5.x, this packet has been reassigned and is 2239 reserved for use as the Marker packet. 2241 The body of this packet consists of: 2243 * The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2245 Such a packet MUST be ignored when received. It may be placed at the 2246 beginning of a message that uses features not available in PGP 2.6.x 2247 in order to cause that version to report that newer software is 2248 necessary to process the message. 2250 5.9. Literal Data Packet (Tag 11) 2252 A Literal Data packet contains the body of a message; data that is 2253 not to be further interpreted. 2255 The body of this packet consists of: 2257 * A one-octet field that describes how the data is formatted. 2259 If it is a "b" (0x62), then the Literal packet contains binary 2260 data. If it is a "t" (0x74), then it contains text data, and thus 2261 may need line ends converted to local form, or other text-mode 2262 changes. The tag "u" (0x75) means the same as "t", but also 2263 indicates that implementation believes that the literal data 2264 contains UTF-8 text. 2266 Early versions of PGP also defined a value of "l" as a 'local' 2267 mode for machine-local conversions. [RFC1991] incorrectly stated 2268 this local mode flag as "1" (ASCII numeral one). Both of these 2269 local modes are deprecated. 2271 * File name as a string (one-octet length, followed by a file name). 2272 This may be a zero-length string. Commonly, if the source of the 2273 encrypted data is a file, this will be the name of the encrypted 2274 file. An implementation MAY consider the file name in the Literal 2275 packet to be a more authoritative name than the actual file name. 2277 If the special name "_CONSOLE" is used, the message is considered 2278 to be "for your eyes only". This advises that the message data is 2279 unusually sensitive, and the receiving program should process it 2280 more carefully, perhaps avoiding storing the received data to 2281 disk, for example. 2283 * A four-octet number that indicates a date associated with the 2284 literal data. Commonly, the date might be the modification date 2285 of a file, or the time the packet was created, or a zero that 2286 indicates no specific time. 2288 * The remainder of the packet is literal data. 2290 Text data is stored with text endings (i.e., network- 2291 normal line endings). These should be converted to native line 2292 endings by the receiving software. 2294 5.10. Trust Packet (Tag 12) 2296 The Trust packet is used only within keyrings and is not normally 2297 exported. Trust packets contain data that record the user's 2298 specifications of which key holders are trustworthy introducers, 2299 along with other information that implementing software uses for 2300 trust information. The format of Trust packets is defined by a given 2301 implementation. 2303 Trust packets SHOULD NOT be emitted to output streams that are 2304 transferred to other users, and they SHOULD be ignored on any input 2305 other than local keyring files. 2307 5.11. User ID Packet (Tag 13) 2309 A User ID packet consists of UTF-8 text that is intended to represent 2310 the name and email address of the key holder. By convention, it 2311 includes an [RFC2822] mail name-addr, but there are no restrictions 2312 on its content. The packet length in the header specifies the length 2313 of the User ID. 2315 5.12. User Attribute Packet (Tag 17) 2317 The User Attribute packet is a variation of the User ID packet. It 2318 is capable of storing more types of data than the User ID packet, 2319 which is limited to text. Like the User ID packet, a User Attribute 2320 packet may be certified by the key owner ("self-signed") or any other 2321 key owner who cares to certify it. Except as noted, a User Attribute 2322 packet may be used anywhere that a User ID packet may be used. 2324 While User Attribute packets are not a required part of the OpenPGP 2325 standard, implementations SHOULD provide at least enough 2326 compatibility to properly handle a certification signature on the 2327 User Attribute packet. A simple way to do this is by treating the 2328 User Attribute packet as a User ID packet with opaque contents, but 2329 an implementation may use any method desired. 2331 The User Attribute packet is made up of one or more attribute 2332 subpackets. Each subpacket consists of a subpacket header and a 2333 body. The header consists of: 2335 * the subpacket length (1, 2, or 5 octets) 2337 * the subpacket type (1 octet) 2338 and is followed by the subpacket specific data. 2340 The only currently defined subpacket type is 1, signifying an image. 2341 An implementation SHOULD ignore any subpacket of a type that it does 2342 not recognize. Subpacket types 100 through 110 are reserved for 2343 private or experimental use. 2345 5.12.1. The Image Attribute Subpacket 2347 The Image Attribute subpacket is used to encode an image, presumably 2348 (but not required to be) that of the key owner. 2350 The Image Attribute subpacket begins with an image header. The first 2351 two octets of the image header contain the length of the image 2352 header. Note that unlike other multi-octet numerical values in this 2353 document, due to a historical accident this value is encoded as a 2354 little-endian number. The image header length is followed by a 2355 single octet for the image header version. The only currently 2356 defined version of the image header is 1, which is a 16-octet image 2357 header. The first three octets of a version 1 image header are thus 2358 0x10, 0x00, 0x01. 2360 The fourth octet of a version 1 image header designates the encoding 2361 format of the image. The only currently defined encoding format is 2362 the value 1 to indicate JPEG. Image format types 100 through 110 are 2363 reserved for private or experimental use. The rest of the version 1 2364 image header is made up of 12 reserved octets, all of which MUST be 2365 set to 0. 2367 The rest of the image subpacket contains the image itself. As the 2368 only currently defined image type is JPEG, the image is encoded in 2369 the JPEG File Interchange Format (JFIF), a standard file format for 2370 JPEG images [JFIF]. 2372 An implementation MAY try to determine the type of an image by 2373 examination of the image data if it is unable to handle a particular 2374 version of the image header or if a specified encoding format value 2375 is not recognized. 2377 5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2379 The Symmetrically Encrypted Integrity Protected Data packet is a 2380 variant of the Symmetrically Encrypted Data packet. It is a new 2381 feature created for OpenPGP that addresses the problem of detecting a 2382 modification to encrypted data. It is used in combination with a 2383 Modification Detection Code packet. 2385 There is a corresponding feature in the features Signature subpacket 2386 that denotes that an implementation can properly use this packet 2387 type. An implementation MUST support decrypting these packets and 2388 SHOULD prefer generating them to the older Symmetrically Encrypted 2389 Data packet when possible. Since this data packet protects against 2390 modification attacks, this standard encourages its proliferation. 2391 While blanket adoption of this data packet would create 2392 interoperability problems, rapid adoption is nevertheless important. 2393 An implementation SHOULD specifically denote support for this packet, 2394 but it MAY infer it from other mechanisms. 2396 For example, an implementation might infer from the use of a cipher 2397 such as Advanced Encryption Standard (AES) or Twofish that a user 2398 supports this feature. It might place in the unhashed portion of 2399 another user's key signature a Features subpacket. It might also 2400 present a user with an opportunity to regenerate their own self- 2401 signature with a Features subpacket. 2403 This packet contains data encrypted with a symmetric-key algorithm 2404 and protected against modification by the SHA-1 hash algorithm. When 2405 it has been decrypted, it will typically contain other packets (often 2406 a Literal Data packet or Compressed Data packet). The last decrypted 2407 packet in this packet's payload MUST be a Modification Detection Code 2408 packet. 2410 The body of this packet consists of: 2412 * A one-octet version number. The only currently defined value is 2413 1. 2415 * Encrypted data, the output of the selected symmetric-key cipher 2416 operating in Cipher Feedback mode with shift amount equal to the 2417 block size of the cipher (CFB-n where n is the block size). 2419 The symmetric cipher used MUST be specified in a Public-Key or 2420 Symmetric-Key Encrypted Session Key packet that precedes the 2421 Symmetrically Encrypted Data packet. In either case, the cipher 2422 algorithm octet is prefixed to the session key before it is 2423 encrypted. 2425 The data is encrypted in CFB mode, with a CFB shift size equal to the 2426 cipher's block size. The Initial Vector (IV) is specified as all 2427 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2428 the data before it is encrypted. The length of the octet string 2429 equals the block size of the cipher in octets, plus two. The first 2430 octets in the group, of length equal to the block size of the cipher, 2431 are random; the last two octets are each copies of their 2nd 2432 preceding octet. For example, with a cipher whose block size is 128 2433 bits or 16 octets, the prefix data will contain 16 random octets, 2434 then two more octets, which are copies of the 15th and 16th octets, 2435 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2436 special CFB resynchronization is done after encrypting this prefix 2437 data. See Section 13.9 for more details. 2439 The repetition of 16 bits in the random data prefixed to the message 2440 allows the receiver to immediately check whether the session key is 2441 incorrect. 2443 The plaintext of the data to be encrypted is passed through the SHA-1 2444 hash function, and the result of the hash is appended to the 2445 plaintext in a Modification Detection Code packet. The input to the 2446 hash function includes the prefix data described above; it includes 2447 all of the plaintext, and then also includes two octets of values 2448 0xD3, 0x14. These represent the encoding of a Modification Detection 2449 Code packet tag and length field of 20 octets. 2451 The resulting hash value is stored in a Modification Detection Code 2452 (MDC) packet, which MUST use the two octet encoding just given to 2453 represent its tag and length field. The body of the MDC packet is 2454 the 20-octet output of the SHA-1 hash. 2456 The Modification Detection Code packet is appended to the plaintext 2457 and encrypted along with the plaintext using the same CFB context. 2459 During decryption, the plaintext data should be hashed with SHA-1, 2460 including the prefix data as well as the packet tag and length field 2461 of the Modification Detection Code packet. The body of the MDC 2462 packet, upon decryption, is compared with the result of the SHA-1 2463 hash. 2465 Any failure of the MDC indicates that the message has been modified 2466 and MUST be treated as a security problem. Failures include a 2467 difference in the hash values, but also the absence of an MDC packet, 2468 or an MDC packet in any position other than the end of the plaintext. 2469 Any failure SHOULD be reported to the user. 2471 Note: future designs of new versions of this packet should consider 2472 rollback attacks since it will be possible for an attacker to change 2473 the version back to 1. 2475 NON-NORMATIVE EXPLANATION 2477 The MDC system, as packets 18 and 19 are called, were created to 2478 provide an integrity mechanism that is less strong than a 2479 signature, yet stronger than bare CFB encryption. 2481 It is a limitation of CFB encryption that damage to the ciphertext 2482 will corrupt the affected cipher blocks and the block following. 2483 Additionally, if data is removed from the end of a CFB-encrypted 2484 block, that removal is undetectable. (Note also that CBC mode has 2485 a similar limitation, but data removed from the front of the block 2486 is undetectable.) 2488 The obvious way to protect or authenticate an encrypted block is 2489 to digitally sign it. However, many people do not wish to 2490 habitually sign data, for a large number of reasons beyond the 2491 scope of this document. Suffice it to say that many people 2492 consider properties such as deniability to be as valuable as 2493 integrity. 2495 OpenPGP addresses this desire to have more security than raw 2496 encryption and yet preserve deniability with the MDC system. An 2497 MDC is intentionally not a MAC. Its name was not selected by 2498 accident. It is analogous to a checksum. 2500 Despite the fact that it is a relatively modest system, it has 2501 proved itself in the real world. It is an effective defense to 2502 several attacks that have surfaced since it has been created. It 2503 has met its modest goals admirably. 2505 Consequently, because it is a modest security system, it has 2506 modest requirements on the hash function(s) it employs. It does 2507 not rely on a hash function being collision-free, it relies on a 2508 hash function being one-way. If a forger, Frank, wishes to send 2509 Alice a (digitally) unsigned message that says, "I've always 2510 secretly loved you, signed Bob", it is far easier for him to 2511 construct a new message than it is to modify anything intercepted 2512 from Bob. (Note also that if Bob wishes to communicate secretly 2513 with Alice, but without authentication or identification and with 2514 a threat model that includes forgers, he has a problem that 2515 transcends mere cryptography.) 2517 Note also that unlike nearly every other OpenPGP subsystem, there 2518 are no parameters in the MDC system. It hard-defines SHA-1 as its 2519 hash function. This is not an accident. It is an intentional 2520 choice to avoid downgrade and cross-grade attacks while making a 2521 simple, fast system. (A downgrade attack would be an attack that 2522 replaced SHA-256 with SHA-1, for example. A cross-grade attack 2523 would replace SHA-1 with another 160-bit hash, such as RIPE- 2524 MD/160, for example.) 2526 However, given the present state of hash function cryptanalysis 2527 and cryptography, it may be desirable to upgrade the MDC system to 2528 a new hash function. See Section 13.11 for guidance. 2530 5.14. Modification Detection Code Packet (Tag 19) 2532 The Modification Detection Code packet contains a SHA-1 hash of 2533 plaintext data, which is used to detect message modification. It is 2534 only used with a Symmetrically Encrypted Integrity Protected Data 2535 packet. The Modification Detection Code packet MUST be the last 2536 packet in the plaintext data that is encrypted in the Symmetrically 2537 Encrypted Integrity Protected Data packet, and MUST appear in no 2538 other place. 2540 A Modification Detection Code packet MUST have a length of 20 octets. 2542 The body of this packet consists of: 2544 * A 20-octet SHA-1 hash of the preceding plaintext data of the 2545 Symmetrically Encrypted Integrity Protected Data packet, including 2546 prefix data, the tag octet, and length octet of the Modification 2547 Detection Code packet. 2549 Note that the Modification Detection Code packet MUST always use a 2550 new format encoding of the packet tag, and a one-octet encoding of 2551 the packet length. The reason for this is that the hashing rules for 2552 modification detection include a one-octet tag and one-octet length 2553 in the data hash. While this is a bit restrictive, it reduces 2554 complexity. 2556 6. Radix-64 Conversions 2558 As stated in the introduction, OpenPGP's underlying native 2559 representation for objects is a stream of arbitrary octets, and some 2560 systems desire these objects to be immune to damage caused by 2561 character set translation, data conversions, etc. 2563 In principle, any printable encoding scheme that met the requirements 2564 of the unsafe channel would suffice, since it would not change the 2565 underlying binary bit streams of the native OpenPGP data structures. 2566 The OpenPGP standard specifies one such printable encoding scheme to 2567 ensure interoperability. 2569 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2570 encoding of the binary data and a checksum. The base64 encoding is 2571 identical to the MIME base64 content-transfer-encoding [RFC2045]. 2573 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 2574 four characters of radix-64 encoding by the same MIME base64 2575 transformation, preceded by an equal sign (=). The CRC is computed 2576 by using the generator 0x864CFB and an initialization of 0xB704CE. 2577 The accumulation is done on the data before it is converted to radix- 2578 64, rather than on the converted data. A sample implementation of 2579 this algorithm is in the next section. 2581 The checksum with its leading equal sign MAY appear on the first line 2582 after the base64 encoded data. 2584 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2585 base64. The nonzero initialization can detect more errors than a 2586 zero initialization. 2588 6.1. An Implementation of the CRC-24 in "C" 2590 #define CRC24_INIT 0xB704CEL 2591 #define CRC24_POLY 0x1864CFBL 2593 typedef long crc24; 2594 crc24 crc_octets(unsigned char *octets, size_t len) 2595 { 2596 crc24 crc = CRC24_INIT; 2597 int i; 2598 while (len--) { 2599 crc ^= (*octets++) << 16; 2600 for (i = 0; i < 8; i++) { 2601 crc <<= 1; 2602 if (crc & 0x1000000) 2603 crc ^= CRC24_POLY; 2604 } 2605 } 2606 return crc & 0xFFFFFFL; 2607 } 2609 6.2. Forming ASCII Armor 2611 When OpenPGP encodes data into ASCII Armor, it puts specific headers 2612 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 2613 later. An OpenPGP implementation MAY use ASCII armor to protect raw 2614 binary data. OpenPGP informs the user what kind of data is encoded 2615 in the ASCII armor through the use of the headers. 2617 Concatenating the following data creates ASCII Armor: 2619 * An Armor Header Line, appropriate for the type of data 2620 * Armor Headers 2622 * A blank (zero-length, or containing only whitespace) line 2624 * The ASCII-Armored data 2626 * An Armor Checksum 2628 * The Armor Tail, which depends on the Armor Header Line 2630 An Armor Header Line consists of the appropriate header line text 2631 surrounded by five (5) dashes ("-", 0x2D) on either side of the 2632 header line text. The header line text is chosen based upon the type 2633 of data that is being encoded in Armor, and how it is being encoded. 2634 Header line texts include the following strings: 2636 BEGIN PGP MESSAGE 2637 Used for signed, encrypted, or compressed files. 2639 BEGIN PGP PUBLIC KEY BLOCK 2640 Used for armoring public keys. 2642 BEGIN PGP PRIVATE KEY BLOCK 2643 Used for armoring private keys. 2645 BEGIN PGP MESSAGE, PART X/Y 2646 Used for multi-part messages, where the armor is split amongst Y 2647 parts, and this is the Xth part out of Y. 2649 BEGIN PGP MESSAGE, PART X 2650 Used for multi-part messages, where this is the Xth part of an 2651 unspecified number of parts. Requires the MESSAGE-ID Armor Header 2652 to be used. 2654 BEGIN PGP SIGNATURE 2655 Used for detached signatures, OpenPGP/MIME signatures, and 2656 cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE 2657 for detached signatures. 2659 Note that all these Armor Header Lines are to consist of a complete 2660 line. That is to say, there is always a line ending preceding the 2661 starting five dashes, and following the ending five dashes. The 2662 header lines, therefore, MUST start at the beginning of a line, and 2663 MUST NOT have text other than whitespace following them on the same 2664 line. These line endings are considered a part of the Armor Header 2665 Line for the purposes of determining the content they delimit. This 2666 is particularly important when computing a cleartext signature (see 2667 below). 2669 The Armor Headers are pairs of strings that can give the user or the 2670 receiving OpenPGP implementation some information about how to decode 2671 or use the message. The Armor Headers are a part of the armor, not a 2672 part of the message, and hence are not protected by any signatures 2673 applied to the message. 2675 The format of an Armor Header is that of a key-value pair. A colon 2676 (":" 0x38) and a single space (0x20) separate the key and value. 2677 OpenPGP should consider improperly formatted Armor Headers to be 2678 corruption of the ASCII Armor. Unknown keys should be reported to 2679 the user, but OpenPGP should continue to process the message. 2681 Note that some transport methods are sensitive to line length. While 2682 there is a limit of 76 characters for the Radix-64 data 2683 (Section 6.3), there is no limit to the length of Armor Headers. 2684 Care should be taken that the Armor Headers are short enough to 2685 survive transport. One way to do this is to repeat an Armor Header 2686 key multiple times with different values for each so that no one line 2687 is overly long. 2689 Currently defined Armor Header Keys are as follows: 2691 * "Version", which states the OpenPGP implementation and version 2692 used to encode the message. 2694 * "Comment", a user-defined comment. OpenPGP defines all text to be 2695 in UTF-8. A comment may be any UTF-8 string. However, the whole 2696 point of armoring is to provide seven-bit-clean data. 2697 Consequently, if a comment has characters that are outside the US- 2698 ASCII range of UTF, they may very well not survive transport. 2700 * "MessageID", a 32-character string of printable characters. The 2701 string must be the same for all parts of a multi-part message that 2702 uses the "PART X" Armor Header. MessageID strings should be 2703 unique enough that the recipient of the mail can associate all the 2704 parts of a message with each other. A good checksum or 2705 cryptographic hash function is sufficient. 2707 The MessageID SHOULD NOT appear unless it is in a multi-part 2708 message. If it appears at all, it MUST be computed from the 2709 finished (encrypted, signed, etc.) message in a deterministic 2710 fashion, rather than contain a purely random value. This is to 2711 allow the legitimate recipient to determine that the MessageID 2712 cannot serve as a covert means of leaking cryptographic key 2713 information. 2715 * "Hash", a comma-separated list of hash algorithms used in this 2716 message. This is used only in cleartext signed messages. 2718 * "Charset", a description of the character set that the plaintext 2719 is in. Please note that OpenPGP defines text to be in UTF-8. An 2720 implementation will get best results by translating into and out 2721 of UTF-8. However, there are many instances where this is easier 2722 said than done. Also, there are communities of users who have no 2723 need for UTF-8 because they are all happy with a character set 2724 like ISO Latin-5 or a Japanese character set. In such instances, 2725 an implementation MAY override the UTF-8 default by using this 2726 header key. An implementation MAY implement this key and any 2727 translations it cares to; an implementation MAY ignore it and 2728 assume all text is UTF-8. 2730 The Armor Tail Line is composed in the same manner as the Armor 2731 Header Line, except the string "BEGIN" is replaced by the string 2732 "END". 2734 6.3. Encoding Binary in Radix-64 2736 The encoding process represents 24-bit groups of input bits as output 2737 strings of 4 encoded characters. Proceeding from left to right, a 2738 24-bit input group is formed by concatenating three 8-bit input 2739 groups. These 24 bits are then treated as four concatenated 6-bit 2740 groups, each of which is translated into a single digit in the 2741 Radix-64 alphabet. When encoding a bit stream with the Radix-64 2742 encoding, the bit stream must be presumed to be ordered with the most 2743 significant bit first. That is, the first bit in the stream will be 2744 the high-order bit in the first 8-bit octet, and the eighth bit will 2745 be the low-order bit in the first 8-bit octet, and so on. 2747 ┌──first octet──┬─second octet──┬──third octet──┐ 2748 │7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│ 2749 ├───────────┬───┴───────┬───────┴───┬───────────┤ 2750 │5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│ 2751 └──1.index──┴──2.index──┴──3.index──┴──4.index──┘ 2753 Each 6-bit group is used as an index into an array of 64 printable 2754 characters from the table below. The character referenced by the 2755 index is placed in the output string. 2757 +=====+========++=====+=========++=====+==========++=====+==========+ 2758 |Value|Encoding||Value|Encoding ||Value| Encoding ||Value| Encoding | 2759 +=====+========++=====+=========++=====+==========++=====+==========+ 2760 | 0|A || 17|R || 34| i || 51| z | 2761 +-----+--------++-----+---------++-----+----------++-----+----------+ 2762 | 1|B || 18|S || 35| j || 52| 0 | 2763 +-----+--------++-----+---------++-----+----------++-----+----------+ 2764 | 2|C || 19|T || 36| k || 53| 1 | 2765 +-----+--------++-----+---------++-----+----------++-----+----------+ 2766 | 3|D || 20|U || 37| l || 54| 2 | 2767 +-----+--------++-----+---------++-----+----------++-----+----------+ 2768 | 4|E || 21|V || 38| m || 55| 3 | 2769 +-----+--------++-----+---------++-----+----------++-----+----------+ 2770 | 5|F || 22|W || 39| n || 56| 4 | 2771 +-----+--------++-----+---------++-----+----------++-----+----------+ 2772 | 6|G || 23|X || 40| o || 57| 5 | 2773 +-----+--------++-----+---------++-----+----------++-----+----------+ 2774 | 7|H || 24|Y || 41| p || 58| 6 | 2775 +-----+--------++-----+---------++-----+----------++-----+----------+ 2776 | 8|I || 25|Z || 42| q || 59| 7 | 2777 +-----+--------++-----+---------++-----+----------++-----+----------+ 2778 | 9|J || 26|a || 43| r || 60| 8 | 2779 +-----+--------++-----+---------++-----+----------++-----+----------+ 2780 | 10|K || 27|b || 44| s || 61| 9 | 2781 +-----+--------++-----+---------++-----+----------++-----+----------+ 2782 | 11|L || 28|c || 45| t || 62| + | 2783 +-----+--------++-----+---------++-----+----------++-----+----------+ 2784 | 12|M || 29|d || 46| u || 63| / | 2785 +-----+--------++-----+---------++-----+----------++-----+----------+ 2786 | 13|N || 30|e || 47| v || | | 2787 +-----+--------++-----+---------++-----+----------++-----+----------+ 2788 | 14|O || 31|f || 48| w ||(pad)| = | 2789 +-----+--------++-----+---------++-----+----------++-----+----------+ 2790 | 15|P || 32|g || 49| x || | | 2791 +-----+--------++-----+---------++-----+----------++-----+----------+ 2792 | 16|Q || 33|h || 50| y || | | 2793 +-----+--------++-----+---------++-----+----------++-----+----------+ 2795 Table 12: Encoding for Radix-64 2797 The encoded output stream must be represented in lines of no more 2798 than 76 characters each. 2800 Special processing is performed if fewer than 24 bits are available 2801 at the end of the data being encoded. There are three possibilities: 2803 1. The last data group has 24 bits (3 octets). No special 2804 processing is needed. 2806 2. The last data group has 16 bits (2 octets). The first two 6-bit 2807 groups are processed as above. The third (incomplete) data group 2808 has two zero-value bits added to it, and is processed as above. 2809 A pad character (=) is added to the output. 2811 3. The last data group has 8 bits (1 octet). The first 6-bit group 2812 is processed as above. The second (incomplete) data group has 2813 four zero-value bits added to it, and is processed as above. Two 2814 pad characters (=) are added to the output. 2816 6.4. Decoding Radix-64 2818 In Radix-64 data, characters other than those in the table, line 2819 breaks, and other white space probably indicate a transmission error, 2820 about which a warning message or even a message rejection might be 2821 appropriate under some circumstances. Decoding software must ignore 2822 all white space. 2824 Because it is used only for padding at the end of the data, the 2825 occurrence of any "=" characters may be taken as evidence that the 2826 end of the data has been reached (without truncation in transit). No 2827 such assurance is possible, however, when the number of octets 2828 transmitted was a multiple of three and no "=" characters are 2829 present. 2831 6.5. Examples of Radix-64 2832 Input data: 0x14FB9C03D97E 2833 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 2834 8-bit: 00010100 11111011 10011100 | 00000011 11011001 11111110 2835 6-bit: 000101 001111 101110 011100 | 000000 111101 100111 111110 2836 Decimal: 5 15 46 28 0 61 37 62 2837 Output: F P u c A 9 l + 2838 Input data: 0x14FB9C03D9 2839 Hex: 1 4 F B 9 C | 0 3 D 9 2840 8-bit: 00010100 11111011 10011100 | 00000011 11011001 2841 pad with 00 2842 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 2843 Decimal: 5 15 46 28 0 61 36 2844 pad with = 2845 Output: F P u c A 9 k = 2846 Input data: 0x14FB9C03 2847 Hex: 1 4 F B 9 C | 0 3 2848 8-bit: 00010100 11111011 10011100 | 00000011 2849 pad with 0000 2850 6-bit: 000101 001111 101110 011100 | 000000 110000 2851 Decimal: 5 15 46 28 0 48 2852 pad with = = 2853 Output: F P u c A w = = 2855 6.6. Example of an ASCII Armored Message 2857 -----BEGIN PGP MESSAGE----- 2858 Version: OpenPrivacy 0.99 2860 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 2861 vBSFjNSiVHsuAA== 2862 =njUN 2863 -----END PGP MESSAGE----- 2865 Note that this example has extra indenting; an actual armored message 2866 would have no leading whitespace. 2868 7. Cleartext Signature Framework 2870 It is desirable to be able to sign a textual octet stream without 2871 ASCII armoring the stream itself, so the signed text is still 2872 readable without special software. In order to bind a signature to 2873 such a cleartext, this framework is used. (Note that this framework 2874 is not intended to be reversible. [RFC3156] defines another way to 2875 sign cleartext messages for environments that support MIME.) 2877 The cleartext signed message consists of: 2879 * The cleartext header "-----BEGIN PGP SIGNED MESSAGE-----" on a 2880 single line, 2882 * One or more "Hash" Armor Headers, 2884 * Exactly one empty line not included into the message digest, 2886 * The dash-escaped cleartext that is included into the message 2887 digest, 2889 * The ASCII armored signature(s) including the "-----BEGIN PGP 2890 SIGNATURE-----" Armor Header and Armor Tail Lines. 2892 If the "Hash" Armor Header is given, the specified message digest 2893 algorithm(s) are used for the signature. If there are no such 2894 headers, MD5 is used. If MD5 is the only hash used, then an 2895 implementation MAY omit this header for improved V2.x compatibility. 2896 If more than one message digest is used in the signature, the "Hash" 2897 armor header contains a comma-delimited list of used message digests. 2899 Current message digest names are described below with the algorithm 2900 IDs. 2902 An implementation SHOULD add a line break after the cleartext, but 2903 MAY omit it if the cleartext ends with a line break. This is for 2904 visual clarity. 2906 7.1. Dash-Escaped Text 2908 The cleartext content of the message must also be dash-escaped. 2910 Dash-escaped cleartext is the ordinary cleartext where every line 2911 starting with a dash "-" (0x2D) is prefixed by the sequence dash "-" 2912 (0x2D) and space ` ` (0x20). This prevents the parser from 2913 recognizing armor headers of the cleartext itself. An implementation 2914 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 2915 followed by a space, and MUST dash-escape any line commencing in a 2916 dash. The message digest is computed using the cleartext itself, not 2917 the dash-escaped form. 2919 As with binary signatures on text documents, a cleartext signature is 2920 calculated on the text using canonical line endings. The 2921 line ending (i.e., the ) before the "-----BEGIN PGP 2922 SIGNATURE-----" line that terminates the signed text is not 2923 considered part of the signed text. 2925 When reversing dash-escaping, an implementation MUST strip the string 2926 "-" if it occurs at the beginning of a line, and SHOULD warn on "-" 2927 and any character other than a space at the beginning of a line. 2929 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 2930 the end of any line is removed when the cleartext signature is 2931 generated. 2933 8. Regular Expressions 2935 A regular expression is zero or more branches, separated by "|". It 2936 matches anything that matches one of the branches. 2938 A branch is zero or more pieces, concatenated. It matches a match 2939 for the first, followed by a match for the second, etc. 2941 A piece is an atom possibly followed by "*", "+", or "?". An atom 2942 followed by "*" matches a sequence of 0 or more matches of the atom. 2943 An atom followed by "+" matches a sequence of 1 or more matches of 2944 the atom. An atom followed by "?" matches a match of the atom, or 2945 the null string. 2947 An atom is a regular expression in parentheses (matching a match for 2948 the regular expression), a range (see below), "." (matching any 2949 single character), "^" (matching the null string at the beginning of 2950 the input string), "$" (matching the null string at the end of the 2951 input string), a "\" followed by a single character (matching that 2952 character), or a single character with no other significance 2953 (matching that character). 2955 A range is a sequence of characters enclosed in "[]". It normally 2956 matches any single character from the sequence. If the sequence 2957 begins with "^", it matches any single character not from the rest of 2958 the sequence. If two characters in the sequence are separated by 2959 "-", this is shorthand for the full list of ASCII characters between 2960 them (e.g., "[0-9]" matches any decimal digit). To include a literal 2961 "]" in the sequence, make it the first character (following a 2962 possible "^"). To include a literal "-", make it the first or last 2963 character. 2965 9. Constants 2967 This section describes the constants used in OpenPGP. 2969 Note that these tables are not exhaustive lists; an implementation 2970 MAY implement an algorithm not on these lists, so long as the 2971 algorithm numbers are chosen from the private or experimental 2972 algorithm range. 2974 See Section 13 for more discussion of the algorithms. 2976 9.1. Public-Key Algorithms 2978 +========+===================================================+ 2979 | ID | Algorithm | 2980 +========+===================================================+ 2981 | 1 | RSA (Encrypt or Sign) [HAC] | 2982 +--------+---------------------------------------------------+ 2983 | 2 | RSA Encrypt-Only [HAC] | 2984 +--------+---------------------------------------------------+ 2985 | 3 | RSA Sign-Only [HAC] | 2986 +--------+---------------------------------------------------+ 2987 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 2988 +--------+---------------------------------------------------+ 2989 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 2990 +--------+---------------------------------------------------+ 2991 | 18 | Reserved for Elliptic Curve | 2992 +--------+---------------------------------------------------+ 2993 | 19 | Reserved for ECDSA | 2994 +--------+---------------------------------------------------+ 2995 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 2996 +--------+---------------------------------------------------+ 2997 | 21 | Reserved for Diffie-Hellman (X9.42, as defined | 2998 | | for IETF-S/MIME) | 2999 +--------+---------------------------------------------------+ 3000 | 100 to | Private/Experimental algorithm | 3001 | 110 | | 3002 +--------+---------------------------------------------------+ 3004 Table 13: Public-key algorithm registry 3006 Implementations MUST implement DSA for signatures, and Elgamal for 3007 encryption. Implementations SHOULD implement RSA keys (1). RSA 3008 Encrypt-Only (2) and RSA Sign-Only are deprecated and SHOULD NOT be 3009 generated, but may be interpreted. See Section 13.5. See 3010 Section 13.8 for notes on Elliptic Curve (18), ECDSA (19), Elgamal 3011 Encrypt or Sign (20), and X9.42 (21). Implementations MAY implement 3012 any other algorithm. 3014 9.2. Symmetric-Key Algorithms 3016 +========+=======================================+ 3017 | ID | Algorithm | 3018 +========+=======================================+ 3019 | 0 | Plaintext or unencrypted data | 3020 +--------+---------------------------------------+ 3021 | 1 | IDEA [IDEA] | 3022 +--------+---------------------------------------+ 3023 | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] | 3024 | | - 168 bit key derived from 192) | 3025 +--------+---------------------------------------+ 3026 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3027 +--------+---------------------------------------+ 3028 | 4 | Blowfish (128 bit key, 16 rounds) | 3029 | | [BLOWFISH] | 3030 +--------+---------------------------------------+ 3031 | 5 | Reserved | 3032 +--------+---------------------------------------+ 3033 | 6 | Reserved | 3034 +--------+---------------------------------------+ 3035 | 7 | AES with 128-bit key [AES] | 3036 +--------+---------------------------------------+ 3037 | 8 | AES with 192-bit key | 3038 +--------+---------------------------------------+ 3039 | 9 | AES with 256-bit key | 3040 +--------+---------------------------------------+ 3041 | 10 | Twofish with 256-bit key [TWOFISH] | 3042 +--------+---------------------------------------+ 3043 | 100 to | Private/Experimental algorithm | 3044 | 110 | | 3045 +--------+---------------------------------------+ 3047 Table 14: Symmetric-key algorithm registry 3049 Implementations MUST implement TripleDES. Implementations SHOULD 3050 implement AES-128 and CAST5. Implementations that interoperate with 3051 PGP 2.6 or earlier need to support IDEA, as that is the only 3052 symmetric cipher those versions use. Implementations MAY implement 3053 any other algorithm. 3055 9.3. Compression Algorithms 3057 +============+================================+ 3058 | ID | Algorithm | 3059 +============+================================+ 3060 | 0 | Uncompressed | 3061 +------------+--------------------------------+ 3062 | 1 | ZIP [RFC1951] | 3063 +------------+--------------------------------+ 3064 | 2 | ZLIB [RFC1950] | 3065 +------------+--------------------------------+ 3066 | 3 | BZip2 [BZ2] | 3067 +------------+--------------------------------+ 3068 | 100 to 110 | Private/Experimental algorithm | 3069 +------------+--------------------------------+ 3070 Table 15: Compression algorithm registry 3072 Implementations MUST implement uncompressed data. Implementations 3073 SHOULD implement ZIP. Implementations MAY implement any other 3074 algorithm. 3076 9.4. Hash Algorithms 3078 +============+================================+=============+ 3079 | ID | Algorithm | Text Name | 3080 +============+================================+=============+ 3081 | 1 | MD5 [HAC] | "MD5" | 3082 +------------+--------------------------------+-------------+ 3083 | 2 | SHA-1 [FIPS180] | "SHA1" | 3084 +------------+--------------------------------+-------------+ 3085 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3086 +------------+--------------------------------+-------------+ 3087 | 4 | Reserved | | 3088 +------------+--------------------------------+-------------+ 3089 | 5 | Reserved | | 3090 +------------+--------------------------------+-------------+ 3091 | 6 | Reserved | | 3092 +------------+--------------------------------+-------------+ 3093 | 7 | Reserved | | 3094 +------------+--------------------------------+-------------+ 3095 | 8 | SHA256 [FIPS180] | "SHA256" | 3096 +------------+--------------------------------+-------------+ 3097 | 9 | SHA384 [FIPS180] | "SHA384" | 3098 +------------+--------------------------------+-------------+ 3099 | 10 | SHA512 [FIPS180] | "SHA512" | 3100 +------------+--------------------------------+-------------+ 3101 | 11 | SHA224 [FIPS180] | "SHA224" | 3102 +------------+--------------------------------+-------------+ 3103 | 100 to 110 | Private/Experimental algorithm | | 3104 +------------+--------------------------------+-------------+ 3106 Table 16: Hash algorithm registry 3108 Implementations MUST implement SHA-1. Implementations MAY implement 3109 other algorithms. MD5 is deprecated. 3111 10. IANA Considerations 3113 OpenPGP is highly parameterized, and consequently there are a number 3114 of considerations for allocating parameters for extensions. This 3115 section describes how IANA should look at extensions to the protocol 3116 as described in this document. 3118 10.1. New String-to-Key Specifier Types 3120 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3121 a string into a key. This specification creates a registry of S2K 3122 specifier types. The registry includes the S2K type, the name of the 3123 S2K, and a reference to the defining specification. The initial 3124 values for this registry can be found in Section 3.7.1. Adding a new 3125 S2K specifier MUST be done through the IETF CONSENSUS method, as 3126 described in [RFC2434]. 3128 10.2. New Packets 3130 Major new features of OpenPGP are defined through new packet types. 3131 This specification creates a registry of packet types. The registry 3132 includes the packet type, the name of the packet, and a reference to 3133 the defining specification. The initial values for this registry can 3134 be found in Section 4.3. Adding a new packet type MUST be done 3135 through the IETF CONSENSUS method, as described in [RFC2434]. 3137 10.2.1. User Attribute Types 3139 The User Attribute packet permits an extensible mechanism for other 3140 types of certificate identification. This specification creates a 3141 registry of User Attribute types. The registry includes the User 3142 Attribute type, the name of the User Attribute, and a reference to 3143 the defining specification. The initial values for this registry can 3144 be found in Section 5.12. Adding a new User Attribute type MUST be 3145 done through the IETF CONSENSUS method, as described in [RFC2434]. 3147 10.2.1.1. Image Format Subpacket Types 3149 Within User Attribute packets, there is an extensible mechanism for 3150 other types of image-based user attributes. This specification 3151 creates a registry of Image Attribute subpacket types. The registry 3152 includes the Image Attribute subpacket type, the name of the Image 3153 Attribute subpacket, and a reference to the defining specification. 3154 The initial values for this registry can be found in Section 5.12.1. 3155 Adding a new Image Attribute subpacket type MUST be done through the 3156 IETF CONSENSUS method, as described in [RFC2434]. 3158 10.2.2. New Signature Subpackets 3160 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3161 to be added to them for a variety of purposes in the Signature 3162 subpackets as discussed in Section 5.2.3.1. This specification 3163 creates a registry of Signature subpacket types. The registry 3164 includes the Signature subpacket type, the name of the subpacket, and 3165 a reference to the defining specification. The initial values for 3166 this registry can be found in Section 5.2.3.1. Adding a new 3167 Signature subpacket MUST be done through the IETF CONSENSUS method, 3168 as described in [RFC2434]. 3170 10.2.2.1. Signature Notation Data Subpackets 3172 OpenPGP signatures further contain a mechanism for extensions in 3173 signatures. These are the Notation Data subpackets, which contain a 3174 key/value pair. Notations contain a user space that is completely 3175 unmanaged and an IETF space. 3177 This specification creates a registry of Signature Notation Data 3178 types. The registry includes the Signature Notation Data type, the 3179 name of the Signature Notation Data, its allowed values, and a 3180 reference to the defining specification. The initial values for this 3181 registry can be found in Section 5.2.3.16. Adding a new Signature 3182 Notation Data subpacket MUST be done through the EXPERT REVIEW 3183 method, as described in [RFC2434]. 3185 10.2.2.2. Key Server Preference Extensions 3187 OpenPGP signatures contain a mechanism for preferences to be 3188 specified about key servers. This specification creates a registry 3189 of key server preferences. The registry includes the key server 3190 preference, the name of the preference, and a reference to the 3191 defining specification. The initial values for this registry can be 3192 found in Section 5.2.3.17. Adding a new key server preference MUST 3193 be done through the IETF CONSENSUS method, as described in [RFC2434]. 3195 10.2.2.3. Key Flags Extensions 3197 OpenPGP signatures contain a mechanism for flags to be specified 3198 about key usage. This specification creates a registry of key usage 3199 flags. The registry includes the key flags value, the name of the 3200 flag, and a reference to the defining specification. The initial 3201 values for this registry can be found in Section 5.2.3.21. Adding a 3202 new key usage flag MUST be done through the IETF CONSENSUS method, as 3203 described in [RFC2434]. 3205 10.2.2.4. Reason for Revocation Extensions 3207 OpenPGP signatures contain a mechanism for flags to be specified 3208 about why a key was revoked. This specification creates a registry 3209 of "Reason for Revocation" flags. The registry includes the "Reason 3210 for Revocation" flags value, the name of the flag, and a reference to 3211 the defining specification. The initial values for this registry can 3212 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3213 through the IETF CONSENSUS method, as described in [RFC2434]. 3215 10.2.2.5. Implementation Features 3217 OpenPGP signatures contain a mechanism for flags to be specified 3218 stating which optional features an implementation supports. This 3219 specification creates a registry of feature-implementation flags. 3220 The registry includes the feature-implementation flags value, the 3221 name of the flag, and a reference to the defining specification. The 3222 initial values for this registry can be found in Section 5.2.3.24. 3223 Adding a new feature-implementation flag MUST be done through the 3224 IETF CONSENSUS method, as described in [RFC2434]. 3226 Also see Section 13.12 for more information about when feature flags 3227 are needed. 3229 10.2.3. New Packet Versions 3231 The core OpenPGP packets all have version numbers, and can be revised 3232 by introducing a new version of an existing packet. This 3233 specification creates a registry of packet types. The registry 3234 includes the packet type, the number of the version, and a reference 3235 to the defining specification. The initial values for this registry 3236 can be found in Section 5. Adding a new packet version MUST be done 3237 through the IETF CONSENSUS method, as described in [RFC2434]. 3239 10.3. New Algorithms 3241 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3242 new algorithm is usually simple. For example, adding in a new 3243 symmetric cipher usually would not need anything more than allocating 3244 a constant for that cipher. If that cipher had other than a 64-bit 3245 or 128-bit block size, there might need to be additional 3246 documentation describing how OpenPGP-CFB mode would be adjusted. 3247 Similarly, when DSA was expanded from a maximum of 1024-bit public 3248 keys to 3072-bit public keys, the revision of FIPS 186 contained 3249 enough information itself to allow implementation. Changes to this 3250 document were made mainly for emphasis. 3252 10.3.1. Public-Key Algorithms 3254 OpenPGP specifies a number of public-key algorithms. This 3255 specification creates a registry of public-key algorithm identifiers. 3256 The registry includes the algorithm name, its key sizes and 3257 parameters, and a reference to the defining specification. The 3258 initial values for this registry can be found in Section 9.1. Adding 3259 a new public-key algorithm MUST be done through the IETF CONSENSUS 3260 method, as described in [RFC2434]. 3262 10.3.2. Symmetric-Key Algorithms 3264 OpenPGP specifies a number of symmetric-key algorithms. This 3265 specification creates a registry of symmetric-key algorithm 3266 identifiers. The registry includes the algorithm name, its key sizes 3267 and block size, and a reference to the defining specification. The 3268 initial values for this registry can be found in Section 9.2. Adding 3269 a new symmetric-key algorithm MUST be done through the IETF CONSENSUS 3270 method, as described in [RFC2434]. 3272 10.3.3. Hash Algorithms 3274 OpenPGP specifies a number of hash algorithms. This specification 3275 creates a registry of hash algorithm identifiers. The registry 3276 includes the algorithm name, a text representation of that name, its 3277 block size, an OID hash prefix, and a reference to the defining 3278 specification. The initial values for this registry can be found in 3279 Section 9.4 for the algorithm identifiers and text names, and 3280 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3281 new hash algorithm MUST be done through the IETF CONSENSUS method, as 3282 described in [RFC2434]. 3284 10.3.4. Compression Algorithms 3286 OpenPGP specifies a number of compression algorithms. This 3287 specification creates a registry of compression algorithm 3288 identifiers. The registry includes the algorithm name and a 3289 reference to the defining specification. The initial values for this 3290 registry can be found in Section 9.3. Adding a new compression key 3291 algorithm MUST be done through the IETF CONSENSUS method, as 3292 described in [RFC2434]. 3294 11. Packet Composition 3296 OpenPGP packets are assembled into sequences in order to create 3297 messages and to transfer keys. Not all possible packet sequences are 3298 meaningful and correct. This section describes the rules for how 3299 packets should be placed into sequences. 3301 11.1. Transferable Public Keys 3303 OpenPGP users may transfer public keys. The essential elements of a 3304 transferable public key are as follows: 3306 * One Public-Key packet 3308 * Zero or more revocation signatures 3309 * One or more User ID packets 3311 * After each User ID packet, zero or more Signature packets 3312 (certifications) 3314 * Zero or more User Attribute packets 3316 * After each User Attribute packet, zero or more Signature packets 3317 (certifications) 3319 * Zero or more Subkey packets 3321 * After each Subkey packet, one Signature packet, plus optionally a 3322 revocation 3324 The Public-Key packet occurs first. Each of the following User ID 3325 packets provides the identity of the owner of this public key. If 3326 there are multiple User ID packets, this corresponds to multiple 3327 means of identifying the same unique individual user; for example, a 3328 user may have more than one email address, and construct a User ID 3329 for each one. 3331 Immediately following each User ID packet, there are zero or more 3332 Signature packets. Each Signature packet is calculated on the 3333 immediately preceding User ID packet and the initial Public-Key 3334 packet. The signature serves to certify the corresponding public key 3335 and User ID. In effect, the signer is testifying to his or her 3336 belief that this public key belongs to the user identified by this 3337 User ID. 3339 Within the same section as the User ID packets, there are zero or 3340 more User Attribute packets. Like the User ID packets, a User 3341 Attribute packet is followed by zero or more Signature packets 3342 calculated on the immediately preceding User Attribute packet and the 3343 initial Public-Key packet. 3345 User Attribute packets and User ID packets may be freely intermixed 3346 in this section, so long as the signatures that follow them are 3347 maintained on the proper User Attribute or User ID packet. 3349 After the User ID packet or Attribute packet, there may be zero or 3350 more Subkey packets. In general, subkeys are provided in cases where 3351 the top-level public key is a signature-only key. However, any V4 3352 key may have subkeys, and the subkeys may be encryption-only keys, 3353 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3354 subkeys. 3356 Each Subkey packet MUST be followed by one Signature packet, which 3357 should be a subkey binding signature issued by the top-level key. 3358 For subkeys that can issue signatures, the subkey binding signature 3359 MUST contain an Embedded Signature subpacket with a primary key 3360 binding signature (0x19) issued by the subkey on the top-level key. 3362 Subkey and Key packets may each be followed by a revocation Signature 3363 packet to indicate that the key is revoked. Revocation signatures 3364 are only accepted if they are issued by the key itself, or by a key 3365 that is authorized to issue revocations via a Revocation Key 3366 subpacket in a self-signature by the top-level key. 3368 Transferable public-key packet sequences may be concatenated to allow 3369 transferring multiple public keys in one operation. 3371 11.2. Transferable Secret Keys 3373 OpenPGP users may transfer secret keys. The format of a transferable 3374 secret key is the same as a transferable public key except that 3375 secret-key and secret-subkey packets are used instead of the public 3376 key and public-subkey packets. Implementations SHOULD include self- 3377 signatures on any user IDs and subkeys, as this allows for a complete 3378 public key to be automatically extracted from the transferable secret 3379 key. Implementations MAY choose to omit the self-signatures, 3380 especially if a transferable public key accompanies the transferable 3381 secret key. 3383 11.3. OpenPGP Messages 3385 An OpenPGP message is a packet or sequence of packets that 3386 corresponds to the following grammatical rules (comma represents 3387 sequential composition, and vertical bar separates alternatives): 3389 OpenPGP Message :- Encrypted Message | Signed Message | Compressed 3390 Message | Literal Message. 3392 Compressed Message :- Compressed Data Packet. 3394 Literal Message :- Literal Data Packet. 3396 ESK :- Public-Key Encrypted Session Key Packet | Symmetric-Key 3397 Encrypted Session Key Packet. 3399 ESK Sequence :- ESK | ESK Sequence, ESK. 3401 Encrypted Data :- Symmetrically Encrypted Data Packet | 3402 Symmetrically Encrypted Integrity Protected Data Packet 3404 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3406 One-Pass Signed Message :- One-Pass Signature Packet, OpenPGP 3407 Message, Corresponding Signature Packet. 3409 Signed Message :- Signature Packet, OpenPGP Message | One-Pass 3410 Signed Message. 3412 In addition, decrypting a Symmetrically Encrypted Data packet or a 3413 Symmetrically Encrypted Integrity Protected Data packet as well as 3414 decompressing a Compressed Data packet must yield a valid OpenPGP 3415 Message. 3417 11.4. Detached Signatures 3419 Some OpenPGP applications use so-called "detached signatures". For 3420 example, a program bundle may contain a file, and with it a second 3421 file that is a detached signature of the first file. These detached 3422 signatures are simply a Signature packet stored separately from the 3423 data for which they are a signature. 3425 12. Enhanced Key Formats 3427 12.1. Key Structures 3429 The format of an OpenPGP V3 key is as follows. Entries in square 3430 brackets are optional and ellipses indicate repetition. 3432 RSA Public Key 3433 [Revocation Self Signature] 3434 User ID [Signature ...] 3435 [User ID [Signature ...] ...] 3437 Each signature certifies the RSA public key and the preceding User 3438 ID. The RSA public key can have many User IDs and each User ID can 3439 have many signatures. V3 keys are deprecated. Implementations MUST 3440 NOT generate new V3 keys, but MAY continue to use existing ones. 3442 The format of an OpenPGP V4 key that uses multiple public keys is 3443 similar except that the other keys are added to the end as "subkeys" 3444 of the primary key. 3446 Primary-Key 3447 [Revocation Self Signature] 3448 [Direct Key Signature...] 3449 User ID [Signature ...] 3450 [User ID [Signature ...] ...] 3451 [User Attribute [Signature ...] ...] 3452 [[Subkey [Binding-Signature-Revocation] 3453 Primary-Key-Binding-Signature] ...] 3455 A subkey always has a single signature after it that is issued using 3456 the primary key to tie the two keys together. This binding signature 3457 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3458 issue signatures MUST have a V4 binding signature due to the REQUIRED 3459 embedded primary key binding signature. 3461 In the above diagram, if the binding signature of a subkey has been 3462 revoked, the revoked key may be removed, leaving only one key. 3464 In a V4 key, the primary key MUST be a key capable of certification. 3465 The subkeys may be keys of any other type. There may be other 3466 constructions of V4 keys, too. For example, there may be a single- 3467 key RSA key in V4 format, a DSA primary key with an RSA encryption 3468 key, or RSA primary key with an Elgamal subkey, etc. 3470 It is also possible to have a signature-only subkey. This permits a 3471 primary key that collects certifications (key signatures), but is 3472 used only for certifying subkeys that are used for encryption and 3473 signatures. 3475 12.2. Key IDs and Fingerprints 3477 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3478 the public modulus of the RSA key. 3480 The fingerprint of a V3 key is formed by hashing the body (but not 3481 the two-octet length) of the MPIs that form the key material (public 3482 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3483 and MD5 are deprecated. 3485 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3486 followed by the two-octet packet length, followed by the entire 3487 Public-Key packet starting with the version field. The Key ID is the 3488 low-order 64 bits of the fingerprint. Here are the fields of the 3489 hash material, with the example of a DSA key: 3491 a.1) 0x99 (1 octet) 3493 a.2) high-order length octet of (b)-(e) (1 octet) 3494 a.3) low-order length octet of (b)-(e) (1 octet) 3496 b) version number = 4 (1 octet); 3498 c) timestamp of key creation (4 octets); 3500 d) algorithm (1 octet): 17 = DSA (example); 3502 e) Algorithm-specific fields. 3504 Algorithm-Specific Fields for DSA keys (example): 3506 e.1) MPI of DSA prime p; 3508 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 3510 e.3) MPI of DSA group generator g; 3512 e.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 3514 Note that it is possible for there to be collisions of Key IDs -- two 3515 different keys with the same Key ID. Note that there is a much 3516 smaller, but still non-zero, probability that two different keys have 3517 the same fingerprint. 3519 Also note that if V3 and V4 format keys share the same RSA key 3520 material, they will have different Key IDs as well as different 3521 fingerprints. 3523 Finally, the Key ID and fingerprint of a subkey are calculated in the 3524 same way as for a primary key, including the 0x99 as the first octet 3525 (even though this is not a valid packet ID for a public subkey). 3527 13. Notes on Algorithms 3529 13.1. PKCS#1 Encoding in OpenPGP 3531 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 3532 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 3533 has changed in the past. To avoid potential confusion and 3534 interoperability problems, we are including local copies in this 3535 document, adapted from those in PKCS#1 v2.1 [RFC3447]. [RFC3447] 3536 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 3537 Nonetheless, we believe that there is value in having a self- 3538 contained document that avoids problems in the future with needed 3539 changes in the conventions. 3541 13.1.1. EME-PKCS1-v1_5-ENCODE 3543 Input: 3545 k = the length in octets of the key modulus 3547 M = message to be encoded, an octet string of length mLen, where 3548 mLen <= k - 11 3550 Output: 3552 EM = encoded message, an octet string of length k 3554 Error: "message too long" 3556 1. Length checking: If mLen > k - 11, output "message too long" and 3557 stop. 3559 2. Generate an octet string PS of length k - mLen - 3 consisting of 3560 pseudo-randomly generated nonzero octets. The length of PS will 3561 be at least eight octets. 3563 3. Concatenate PS, the message M, and other padding to form an 3564 encoded message EM of length k octets as 3566 EM = 0x00 || 0x02 || PS || 0x00 || M. 3568 4. Output EM. 3570 13.1.2. EME-PKCS1-v1_5-DECODE 3572 Input: 3574 EM = encoded message, an octet string 3576 Output: 3578 M = message, an octet string 3580 Error: "decryption error" 3582 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 3583 into an octet string PS consisting of nonzero octets and a message M 3584 as follows 3586 EM = 0x00 || 0x02 || PS || 0x00 || M. 3588 If the first octet of EM does not have hexadecimal value 0x00, if the 3589 second octet of EM does not have hexadecimal value 0x02, if there is 3590 no octet with hexadecimal value 0x00 to separate PS from M, or if the 3591 length of PS is less than 8 octets, output "decryption error" and 3592 stop. See also the security note in Section 14 regarding differences 3593 in reporting between a decryption error and a padding error. 3595 13.1.3. EMSA-PKCS1-v1_5 3597 This encoding method is deterministic and only has an encoding 3598 operation. 3600 Option: 3602 Hash - a hash function in which hLen denotes the length in octets of 3603 the hash function output 3605 Input: 3607 M = message to be encoded 3609 mL = intended length in octets of the encoded message, at least tLen 3610 + 11, where tLen is the octet length of the DER encoding T of a 3611 certain value computed during the encoding operation 3613 Output: 3615 EM = encoded message, an octet string of length emLen 3617 Errors: "message too long"; "intended encoded message length too 3618 short" 3620 Steps: 3622 1. Apply the hash function to the message M to produce a hash value 3623 H: 3625 H = Hash(M). 3627 If the hash function outputs "message too long," output "message 3628 too long" and stop. 3630 2. Using the list in Section 5.2.2, produce an ASN.1 DER value for 3631 the hash function used. Let T be the full hash prefix from 3632 Section 5.2.2, and let tLen be the length in octets of T. 3634 3. If emLen < tLen + 11, output "intended encoded message length too 3635 short" and stop. 3637 4. Generate an octet string PS consisting of emLen - tLen - 3 octets 3638 with hexadecimal value 0xFF. The length of PS will be at least 8 3639 octets. 3641 5. Concatenate PS, the hash prefix T, and other padding to form the 3642 encoded message EM as 3644 EM = 0x00 || 0x01 || PS || 0x00 || T. 3646 6. Output EM. 3648 13.2. Symmetric Algorithm Preferences 3650 The symmetric algorithm preference is an ordered list of algorithms 3651 that the keyholder accepts. Since it is found on a self-signature, 3652 it is possible that a keyholder may have multiple, different 3653 preferences. For example, Alice may have TripleDES only specified 3654 for "alice@work.com" but CAST5, Blowfish, and TripleDES specified for 3655 "alice@home.org". Note that it is also possible for preferences to 3656 be in a subkey's binding signature. 3658 Since TripleDES is the MUST-implement algorithm, if it is not 3659 explicitly in the list, it is tacitly at the end. However, it is 3660 good form to place it there explicitly. Note also that if an 3661 implementation does not implement the preference, then it is 3662 implicitly a TripleDES-only implementation. 3664 An implementation MUST NOT use a symmetric algorithm that is not in 3665 the recipient's preference list. When encrypting to more than one 3666 recipient, the implementation finds a suitable algorithm by taking 3667 the intersection of the preferences of the recipients. Note that the 3668 MUST-implement algorithm, TripleDES, ensures that the intersection is 3669 not null. The implementation may use any mechanism to pick an 3670 algorithm in the intersection. 3672 If an implementation can decrypt a message that a keyholder doesn't 3673 have in their preferences, the implementation SHOULD decrypt the 3674 message anyway, but MUST warn the keyholder that the protocol has 3675 been violated. For example, suppose that Alice, above, has software 3676 that implements all algorithms in this specification. Nonetheless, 3677 she prefers subsets for work or home. If she is sent a message 3678 encrypted with IDEA, which is not in her preferences, the software 3679 warns her that someone sent her an IDEA-encrypted message, but it 3680 would ideally decrypt it anyway. 3682 13.3. Other Algorithm Preferences 3684 Other algorithm preferences work similarly to the symmetric algorithm 3685 preference, in that they specify which algorithms the keyholder 3686 accepts. There are two interesting cases that other comments need to 3687 be made about, though, the compression preferences and the hash 3688 preferences. 3690 13.3.1. Compression Preferences 3692 Compression has been an integral part of PGP since its first days. 3693 OpenPGP and all previous versions of PGP have offered compression. 3694 In this specification, the default is for messages to be compressed, 3695 although an implementation is not required to do so. Consequently, 3696 the compression preference gives a way for a keyholder to request 3697 that messages not be compressed, presumably because they are using a 3698 minimal implementation that does not include compression. 3699 Additionally, this gives a keyholder a way to state that it can 3700 support alternate algorithms. 3702 Like the algorithm preferences, an implementation MUST NOT use an 3703 algorithm that is not in the preference vector. If the preferences 3704 are not present, then they are assumed to be [ZIP(1), 3705 Uncompressed(0)]. 3707 Additionally, an implementation MUST implement this preference to the 3708 degree of recognizing when to send an uncompressed message. A robust 3709 implementation would satisfy this requirement by looking at the 3710 recipient's preference and acting accordingly. A minimal 3711 implementation can satisfy this requirement by never generating a 3712 compressed message, since all implementations can handle messages 3713 that have not been compressed. 3715 13.3.2. Hash Algorithm Preferences 3717 Typically, the choice of a hash algorithm is something the signer 3718 does, rather than the verifier, because a signer rarely knows who is 3719 going to be verifying the signature. This preference, though, allows 3720 a protocol based upon digital signatures ease in negotiation. 3722 Thus, if Alice is authenticating herself to Bob with a signature, it 3723 makes sense for her to use a hash algorithm that Bob's software uses. 3724 This preference allows Bob to state in his key which algorithms Alice 3725 may use. 3727 Since SHA1 is the MUST-implement hash algorithm, if it is not 3728 explicitly in the list, it is tacitly at the end. However, it is 3729 good form to place it there explicitly. 3731 13.4. Plaintext 3733 Algorithm 0, "plaintext", may only be used to denote secret keys that 3734 are stored in the clear. Implementations MUST NOT use plaintext in 3735 Symmetrically Encrypted Data packets; they must use Literal Data 3736 packets to encode unencrypted or literal data. 3738 13.5. RSA 3740 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 3741 keys. These types are deprecated. The "key flags" subpacket in a 3742 signature is a much better way to express the same idea, and 3743 generalizes it to all algorithms. An implementation SHOULD NOT 3744 create such a key, but MAY interpret it. 3746 An implementation SHOULD NOT implement RSA keys of size less than 3747 1024 bits. 3749 13.6. DSA 3751 An implementation SHOULD NOT implement DSA keys of size less than 3752 1024 bits. It MUST NOT implement a DSA key with a q size of less 3753 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 3754 q size MUST be a multiple of 8 bits. The Digital Signature Standard 3755 (DSS) [FIPS186] specifies that DSA be used in one of the following 3756 ways: 3758 * 1024-bit key, 160-bit q, SHA-1, SHA-224, SHA-256, SHA-384, or 3759 SHA-512 hash 3761 * 2048-bit key, 224-bit q, SHA-224, SHA-256, SHA-384, or SHA-512 3762 hash 3764 * 2048-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash 3766 * 3072-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash 3768 The above key and q size pairs were chosen to best balance the 3769 strength of the key with the strength of the hash. Implementations 3770 SHOULD use one of the above key and q size pairs when generating DSA 3771 keys. If DSS compliance is desired, one of the specified SHA hashes 3772 must be used as well. [FIPS186] is the ultimate authority on DSS, 3773 and should be consulted for all questions of DSS compliance. 3775 Note that earlier versions of this standard only allowed a 160-bit q 3776 with no truncation allowed, so earlier implementations may not be 3777 able to handle signatures with a different q size or a truncated 3778 hash. 3780 13.7. Elgamal 3782 An implementation SHOULD NOT implement Elgamal keys of size less than 3783 1024 bits. 3785 13.8. Reserved Algorithm Numbers 3787 A number of algorithm IDs have been reserved for algorithms that 3788 would be useful to use in an OpenPGP implementation, yet there are 3789 issues that prevent an implementer from actually implementing the 3790 algorithm. These are marked in Section 9.1 as "reserved for". 3792 The reserved public-key algorithms, Elliptic Curve (18), ECDSA (19), 3793 and X9.42 (21), do not have the necessary parameters, parameter 3794 order, or semantics defined. 3796 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 3797 with a public-key identifier of 20. These are no longer permitted. 3798 An implementation MUST NOT generate such keys. An implementation 3799 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 3801 13.9. OpenPGP CFB Mode 3803 OpenPGP does symmetric encryption using a variant of Cipher Feedback 3804 mode (CFB mode). This section describes the procedure it uses in 3805 detail. This mode is what is used for Symmetrically Encrypted Data 3806 Packets; the mechanism used for encrypting secret-key material is 3807 similar, and is described in the sections above. 3809 In the description below, the value BS is the block size in octets of 3810 the cipher. Most ciphers have a block size of 8 octets. The AES and 3811 Twofish have a block size of 16 octets. Also note that the 3812 description below assumes that the IV and CFB arrays start with an 3813 index of 1 (unlike the C language, which assumes arrays start with a 3814 zero index). 3816 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 3817 prefixes the plaintext with BS+2 octets of random data, such that 3818 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 3819 resynchronization after encrypting those BS+2 octets. 3821 Thus, for an algorithm that has a block size of 8 octets (64 bits), 3822 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 3823 octets 9 and 10. For an algorithm with a block size of 16 octets 3824 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 3825 octets 15 and 16. Those extra two octets are an easy check for a 3826 correct key. 3828 Step by step, here is the procedure: 3830 1. The feedback register (FR) is set to the IV, which is all zeros. 3832 2. FR is encrypted to produce FRE (FR Encrypted). This is the 3833 encryption of an all-zero value. 3835 3. FRE is xored with the first BS octets of random data prefixed to 3836 the plaintext to produce C[1] through C[BS], the first BS octets 3837 of ciphertext. 3839 4. FR is loaded with C[1] through C[BS]. 3841 5. FR is encrypted to produce FRE, the encryption of the first BS 3842 octets of ciphertext. 3844 6. The left two octets of FRE get xored with the next two octets of 3845 data that were prefixed to the plaintext. This produces C[BS+1] 3846 and C[BS+2], the next two octets of ciphertext. 3848 7. (The resynchronization step) FR is loaded with C[3] through 3849 C[BS+2]. 3851 8. FR is encrypted to produce FRE. 3853 9. FRE is xored with the first BS octets of the given plaintext, 3854 now that we have finished encrypting the BS+2 octets of prefixed 3855 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 3856 octets of ciphertext. 3858 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 3859 for an 8-octet block). 3861 11. FR is encrypted to produce FRE. 3863 12. FRE is xored with the next BS octets of plaintext, to produce 3864 the next BS octets of ciphertext. These are loaded into FR, and 3865 the process is repeated until the plaintext is used up. 3867 13.10. Private or Experimental Parameters 3869 S2K specifiers, Signature subpacket types, user attribute types, 3870 image format types, and algorithms described in Section 9 all reserve 3871 the range 100 to 110 for private and experimental use. Packet types 3872 reserve the range 60 to 63 for private and experimental use. These 3873 are intentionally managed with the PRIVATE USE method, as described 3874 in [RFC2434]. 3876 However, implementations need to be careful with these and promote 3877 them to full IANA-managed parameters when they grow beyond the 3878 original, limited system. 3880 13.11. Extension of the MDC System 3882 As described in the non-normative explanation in Section 5.13, the 3883 MDC system is uniquely unparameterized in OpenPGP. This was an 3884 intentional decision to avoid cross-grade attacks. If the MDC system 3885 is extended to a stronger hash function, care must be taken to avoid 3886 downgrade and cross-grade attacks. 3888 One simple way to do this is to create new packets for a new MDC. 3889 For example, instead of the MDC system using packets 18 and 19, a new 3890 MDC could use 20 and 21. This has obvious drawbacks (it uses two 3891 packet numbers for each new hash function in a space that is limited 3892 to a maximum of 60). 3894 Another simple way to extend the MDC system is to create new versions 3895 of packet 18, and reflect this in packet 19. For example, suppose 3896 that V2 of packet 18 implicitly used SHA-256. This would require 3897 packet 19 to have a length of 32 octets. The change in the version 3898 in packet 18 and the size of packet 19 prevent a downgrade attack. 3900 There are two drawbacks to this latter approach. The first is that 3901 using the version number of a packet to carry algorithm information 3902 is not tidy from a protocol-design standpoint. It is possible that 3903 there might be several versions of the MDC system in common use, but 3904 this untidiness would reflect untidiness in cryptographic consensus 3905 about hash function security. The second is that different versions 3906 of packet 19 would have to have unique sizes. If there were two 3907 versions each with 256-bit hashes, they could not both have 32-octet 3908 packet 19s without admitting the chance of a cross-grade attack. 3910 Yet another, complex approach to extend the MDC system would be a 3911 hybrid of the two above -- create a new pair of MDC packets that are 3912 fully parameterized, and yet protected from downgrade and cross- 3913 grade. 3915 Any change to the MDC system MUST be done through the IETF CONSENSUS 3916 method, as described in [RFC2434]. 3918 13.12. Meta-Considerations for Expansion 3920 If OpenPGP is extended in a way that is not backwards-compatible, 3921 meaning that old implementations will not gracefully handle their 3922 absence of a new feature, the extension proposal can be declared in 3923 the key holder's self-signature as part of the Features signature 3924 subpacket. 3926 We cannot state definitively what extensions will not be upwards- 3927 compatible, but typically new algorithms are upwards-compatible, 3928 whereas new packets are not. 3930 If an extension proposal does not update the Features system, it 3931 SHOULD include an explanation of why this is unnecessary. If the 3932 proposal contains neither an extension to the Features system nor an 3933 explanation of why such an extension is unnecessary, the proposal 3934 SHOULD be rejected. 3936 14. Security Considerations 3938 * As with any technology involving cryptography, you should check 3939 the current literature to determine if any algorithms used here 3940 have been found to be vulnerable to attack. 3942 * This specification uses Public-Key Cryptography technologies. It 3943 is assumed that the private key portion of a public-private key 3944 pair is controlled and secured by the proper party or parties. 3946 * Certain operations in this specification involve the use of random 3947 numbers. An appropriate entropy source should be used to generate 3948 these numbers (see [RFC4086]). 3950 * The MD5 hash algorithm has been found to have weaknesses, with 3951 collisions found in a number of cases. MD5 is deprecated for use 3952 in OpenPGP. Implementations MUST NOT generate new signatures 3953 using MD5 as a hash function. They MAY continue to consider old 3954 signatures that used MD5 as valid. 3956 * SHA-224 and SHA-384 require the same work as SHA-256 and SHA-512, 3957 respectively. In general, there are few reasons to use them 3958 outside of DSS compatibility. You need a situation where one 3959 needs more security than smaller hashes, but does not want to have 3960 the full 256-bit or 512-bit data length. 3962 * Many security protocol designers think that it is a bad idea to 3963 use a single key for both privacy (encryption) and integrity 3964 (signatures). In fact, this was one of the motivating forces 3965 behind the V4 key format with separate signature and encryption 3966 keys. If you as an implementer promote dual-use keys, you should 3967 at least be aware of this controversy. 3969 * The DSA algorithm will work with any hash, but is sensitive to the 3970 quality of the hash algorithm. Verifiers should be aware that 3971 even if the signer used a strong hash, an attacker could have 3972 modified the signature to use a weak one. Only signatures using 3973 acceptably strong hash algorithms should be accepted as valid. 3975 * As OpenPGP combines many different asymmetric, symmetric, and hash 3976 algorithms, each with different measures of strength, care should 3977 be taken that the weakest element of an OpenPGP message is still 3978 sufficiently strong for the purpose at hand. While consensus 3979 about the strength of a given algorithm may evolve, NIST Special 3980 Publication 800-57 [SP800-57] recommends the following list of 3981 equivalent strengths: 3983 +=====================+===========+====================+ 3984 | Asymmetric key size | Hash size | Symmetric key size | 3985 +=====================+===========+====================+ 3986 | 1024 | 160 | 80 | 3987 +---------------------+-----------+--------------------+ 3988 | 2048 | 224 | 112 | 3989 +---------------------+-----------+--------------------+ 3990 | 3072 | 256 | 128 | 3991 +---------------------+-----------+--------------------+ 3992 | 7680 | 384 | 192 | 3993 +---------------------+-----------+--------------------+ 3994 | 15360 | 512 | 256 | 3995 +---------------------+-----------+--------------------+ 3997 Table 17: Key length equivalences 3999 * There is a somewhat-related potential security problem in 4000 signatures. If an attacker can find a message that hashes to the 4001 same hash with a different algorithm, a bogus signature structure 4002 can be constructed that evaluates correctly. 4004 For example, suppose Alice DSA signs message M using hash 4005 algorithm H. Suppose that Mallet finds a message M' that has the 4006 same hash value as M with H'. Mallet can then construct a 4007 signature block that verifies as Alice's signature of M' with H'. 4008 However, this would also constitute a weakness in either H or H' 4009 or both. Should this ever occur, a revision will have to be made 4010 to this document to revise the allowed hash algorithms. 4012 * If you are building an authentication system, the recipient may 4013 specify a preferred signing algorithm. However, the signer would 4014 be foolish to use a weak algorithm simply because the recipient 4015 requests it. 4017 * Some of the encryption algorithms mentioned in this document have 4018 been analyzed less than others. For example, although CAST5 is 4019 presently considered strong, it has been analyzed less than 4020 TripleDES. Other algorithms may have other controversies 4021 surrounding them. 4023 * In late summer 2002, Jallad, Katz, and Schneier published an 4024 interesting attack on the OpenPGP protocol and some of its 4025 implementations [JKS02]. In this attack, the attacker modifies a 4026 message and sends it to a user who then returns the erroneously 4027 decrypted message to the attacker. The attacker is thus using the 4028 user as a random oracle, and can often decrypt the message. 4030 Compressing data can ameliorate this attack. The incorrectly 4031 decrypted data nearly always decompresses in ways that defeat the 4032 attack. However, this is not a rigorous fix, and leaves open some 4033 small vulnerabilities. For example, if an implementation does not 4034 compress a message before encryption (perhaps because it knows it 4035 was already compressed), then that message is vulnerable. Because 4036 of this happenstance -- that modification attacks can be thwarted 4037 by decompression errors -- an implementation SHOULD treat a 4038 decompression error as a security problem, not merely a data 4039 problem. 4041 This attack can be defeated by the use of Modification Detection, 4042 provided that the implementation does not let the user naively 4043 return the data to the attacker. An implementation MUST treat an 4044 MDC failure as a security problem, not merely a data problem. 4046 In either case, the implementation MAY allow the user access to 4047 the erroneous data, but MUST warn the user as to potential 4048 security problems should that data be returned to the sender. 4050 While this attack is somewhat obscure, requiring a special set of 4051 circumstances to create it, it is nonetheless quite serious as it 4052 permits someone to trick a user to decrypt a message. 4053 Consequently, it is important that: 4055 1. Implementers treat MDC errors and decompression failures as 4056 security problems. 4058 2. Implementers implement Modification Detection with all due 4059 speed and encourage its spread. 4061 3. Users migrate to implementations that support Modification 4062 Detection with all due speed. 4064 * PKCS#1 has been found to be vulnerable to attacks in which a 4065 system that reports errors in padding differently from errors in 4066 decryption becomes a random oracle that can leak the private key 4067 in mere millions of queries. Implementations must be aware of 4068 this attack and prevent it from happening. The simplest solution 4069 is to report a single error code for all variants of decryption 4070 errors so as not to leak information to an attacker. 4072 * Some technologies mentioned here may be subject to government 4073 control in some countries. 4075 * In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4076 released a paper describing a way that the "quick check" in 4077 OpenPGP CFB mode can be used with a random oracle to decrypt two 4078 octets of every cipher block [MZ05]. They recommend as prevention 4079 not using the quick check at all. 4081 Many implementers have taken this advice to heart for any data 4082 that is symmetrically encrypted and for which the session key is 4083 public-key encrypted. In this case, the quick check is not needed 4084 as the public-key encryption of the session key should guarantee 4085 that it is the right session key. In other cases, the 4086 implementation should use the quick check with care. 4088 On the one hand, there is a danger to using it if there is a 4089 random oracle that can leak information to an attacker. In 4090 plainer language, there is a danger to using the quick check if 4091 timing information about the check can be exposed to an attacker, 4092 particularly via an automated service that allows rapidly repeated 4093 queries. 4095 On the other hand, it is inconvenient to the user to be informed 4096 that they typed in the wrong passphrase only after a petabyte of 4097 data is decrypted. There are many cases in cryptographic 4098 engineering where the implementer must use care and wisdom, and 4099 this is one. 4101 15. Implementation Nits 4103 This section is a collection of comments to help an implementer, 4104 particularly with an eye to backward compatibility. Previous 4105 implementations of PGP are not OpenPGP compliant. Often the 4106 differences are small, but small differences are frequently more 4107 vexing than large differences. Thus, this is a non-comprehensive 4108 list of potential problems and gotchas for a developer who is trying 4109 to be backward-compatible. 4111 * The IDEA algorithm is patented, and yet it is required for PGP 2.x 4112 interoperability. It is also the de-facto preferred algorithm for 4113 a V3 key with a V3 self-signature (or no self-signature). 4115 * When exporting a private key, PGP 2.x generates the header "BEGIN 4116 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 4117 All previous versions ignore the implied data type, and look 4118 directly at the packet data type. 4120 * PGP 2.0 through 2.5 generated V2 Public-Key packets. These are 4121 identical to the deprecated V3 keys except for the version number. 4122 An implementation MUST NOT generate them and may accept or reject 4123 them as it sees fit. Some older PGP versions generated V2 PKESK 4124 packets (Tag 1) as well. An implementation may accept or reject 4125 V2 PKESK packets as it sees fit, and MUST NOT generate them. 4127 * PGP 2.6.x will not accept key-material packets with versions 4128 greater than 3. 4130 * There are many ways possible for two keys to have the same key 4131 material, but different fingerprints (and thus Key IDs). Perhaps 4132 the most interesting is an RSA key that has been "upgraded" to V4 4133 format, but since a V4 fingerprint is constructed by hashing the 4134 key creation time along with other things, two V4 keys created at 4135 different times, yet with the same key material will have 4136 different fingerprints. 4138 * If an implementation is using zlib to interoperate with PGP 2.x, 4139 then the "windowBits" parameter should be set to -13. 4141 * The 0x19 back signatures were not required for signing subkeys 4142 until relatively recently. Consequently, there may be keys in the 4143 wild that do not have these back signatures. Implementing 4144 software may handle these keys as it sees fit. 4146 * OpenPGP does not put limits on the size of public keys. However, 4147 larger keys are not necessarily better keys. Larger keys take 4148 more computation time to use, and this can quickly become 4149 impractical. Different OpenPGP implementations may also use 4150 different upper bounds for public key sizes, and so care should be 4151 taken when choosing sizes to maintain interoperability. As of 4152 2007 most implementations have an upper bound of 4096 bits. 4154 * ASCII armor is an optional feature of OpenPGP. The OpenPGP 4155 working group strives for a minimal set of mandatory-to-implement 4156 features, and since there could be useful implementations that 4157 only use binary object formats, this is not a "MUST" feature for 4158 an implementation. For example, an implementation that is using 4159 OpenPGP as a mechanism for file signatures may find ASCII armor 4160 unnecessary. OpenPGP permits an implementation to declare what 4161 features it does and does not support, but ASCII armor is not one 4162 of these. Since most implementations allow binary and armored 4163 objects to be used indiscriminately, an implementation that does 4164 not implement ASCII armor may find itself with compatibility 4165 issues with general-purpose implementations. Moreover, 4166 implementations of OpenPGP-MIME [RFC3156] already have a 4167 requirement for ASCII armor so those implementations will 4168 necessarily have support. 4170 16. References 4172 16.1. Normative References 4174 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 4175 November 2001, 4176 . 4179 [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 4180 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 4181 Cambridge Security Workshop Proceedings Springer-Verlag, 4182 1994, pp191-204, December 1993, 4183 . 4185 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, 4186 . 4188 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 4189 Scheme Based on Discrete Logarithms", IEEE Transactions on 4190 Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 4191 1985. 4193 [FIPS180] National Institute of Standards and Technology, U.S. 4194 Department of Commerce, "Secure Hash Standard (SHS), FIPS 4195 180-4", August 2015, 4196 . 4198 [FIPS186] National Institute of Standards and Technology, U.S. 4199 Department of Commerce, "Digital Signature Standard (DSS), 4200 FIPS 186-4", July 2013, 4201 . 4203 [HAC] Menezes, A.J., Oorschot, P.v., and S. Vanstone, "Handbook 4204 of Applied Cryptography", 1996. 4206 [IDEA] Lai, X., "On the design and security of block ciphers", 4207 ETH Series in Information Processing, J.L. Massey 4208 (editor) Vol. 1, Hartung-Gorre Verlag Konstanz, Technische 4209 Hochschule (Zurich), 1992. 4211 [ISO10646] International Organization for Standardization, 4212 "Information Technology - Universal Multiple-octet coded 4213 Character Set (UCS) - Part 1: Architecture and Basic 4214 Multilingual Plane", ISO Standard 10646-1, May 1993. 4216 [JFIF] CA, E.H.M., "JPEG File Interchange Format (Version 4217 1.02).", September 1996. 4219 [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format 4220 Specification version 3.3", RFC 1950, 4221 DOI 10.17487/RFC1950, May 1996, 4222 . 4224 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 4225 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 4226 . 4228 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4229 Extensions (MIME) Part One: Format of Internet Message 4230 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 4231 . 4233 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4234 Requirement Levels", BCP 14, RFC 2119, 4235 DOI 10.17487/RFC2119, March 1997, 4236 . 4238 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 4239 DOI 10.17487/RFC2144, May 1997, 4240 . 4242 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an 4243 IANA Considerations Section in RFCs", RFC 2434, 4244 DOI 10.17487/RFC2434, October 1998, 4245 . 4247 [RFC2822] Resnick, P., Ed., "Internet Message Format", RFC 2822, 4248 DOI 10.17487/RFC2822, April 2001, 4249 . 4251 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 4252 "MIME Security with OpenPGP", RFC 3156, 4253 DOI 10.17487/RFC3156, August 2001, 4254 . 4256 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4257 Standards (PKCS) #1: RSA Cryptography Specifications 4258 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 4259 2003, . 4261 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 4262 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 4263 2003, . 4265 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 4266 "Randomness Requirements for Security", BCP 106, RFC 4086, 4267 DOI 10.17487/RFC4086, June 2005, 4268 . 4270 [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: 4271 protocols, algorithms, and source code in C", 1996. 4273 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 4274 C., and N. Ferguson, "The Twofish Encryption Algorithm", 4275 1999. 4277 16.2. Informative References 4279 [BLEICHENBACHER] 4280 Bleichenbacher, D., "Generating ElGamal Signatures Without 4281 Knowing the Secret Key", Lecture Notes in Computer 4282 Science Volume 1070, pp. 10-18, 1996. 4284 [JKS02] Jallad, K., Katz, J., and B. Schneier, "Implementation of 4285 Chosen-Ciphertext Attacks against PGP and GnuPG", 2002, 4286 . 4288 [MAURER] Maurer, U., "Modelling a Public-Key Infrastructure", Proc. 4289 1996 European Symposium on Research in Computer Security 4290 (ESORICS' 96), Lecture Notes in Computer Science, 4291 Springer-Verlag, vol. 1146, pp. 325-350 , September 1996. 4293 [MZ05] Mister, S. and R. Zuccherato, "An Attack on CFB Mode 4294 Encryption As Used By OpenPGP", IACR ePrint Archive Report 4295 2005/033, 8 February 2005, 4296 . 4298 [REGEX] Friedl, J., "Mastering Regular Expressions", 4299 ISBN 0-596-00289-0, August 2002. 4301 [RFC1423] Balenson, D., "Privacy Enhancement for Internet Electronic 4302 Mail: Part III: Algorithms, Modes, and Identifiers", 4303 RFC 1423, DOI 10.17487/RFC1423, February 1993, 4304 . 4306 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 4307 Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, August 4308 1996, . 4310 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 4311 "OpenPGP Message Format", RFC 2440, DOI 10.17487/RFC2440, 4312 November 1998, . 4314 [SP800-57] NIST, "Recommendation on Key Management", NIST Special 4315 Publication 800-57, March 2007, 4316 . 4319 Appendix A. Acknowledgements 4321 This memo also draws on much previous work from a number of other 4322 authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc 4323 Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, 4324 Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, 4325 Mark Weaver, and Philip R. Zimmermann. 4327 Authors' Addresses 4329 Werner Koch (editor) 4330 GnuPG e.V. 4331 Rochusstr. 44 4332 40479 Duesseldorf 4333 Germany 4335 Email: wk@gnupg.org 4336 URI: https://gnupg.org/verein 4338 Paul Wouters (editor) 4340 Email: pwouters@redhat.com