idnits 2.17.1 draft-ietf-openpgp-rfc4880bis-10.txt: 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: ---------------------------------------------------------------------------- == The page length should not exceed 58 lines per page, but there was 1 longer page, the longest (page 1) being 6167 lines Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 4 instances of too long lines in the document, the longest one being 4 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 5893 has weird spacing: '...0 dc ae dc 5b...' -- The document date (31 August 2020) is 1327 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 398 -- Looks like a reference, but probably isn't: '1' on line 4971 -- Looks like a reference, but probably isn't: '2' on line 398 -- Looks like a reference, but probably isn't: '3' on line 4980 == Missing Reference: 'Optional' is mentioned on line 2471, but not defined == Missing Reference: 'TBD1' is mentioned on line 2868, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 4306, but not defined == Missing Reference: 'SP800-56A' is mentioned on line 4618, but not defined == Missing Reference: 'BS' is mentioned on line 4971, but not defined == Unused Reference: 'RFC1423' is defined on line 5680, 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. 'EAX' -- 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. 'FIPS202' -- 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' -- Possible downref: Non-RFC (?) normative reference: ref. 'PKCS5' ** 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 2822 (Obsoleted by RFC 5322) ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Downref: Normative reference to an Informational RFC: RFC 3713 ** Downref: Normative reference to an Informational RFC: RFC 5639 ** Downref: Normative reference to an Informational RFC: RFC 7253 ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8032 -- Possible downref: Non-RFC (?) normative reference: ref. 'SCHNEIER' -- Possible downref: Non-RFC (?) normative reference: ref. 'SuiteB' -- 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: 12 errors (**), 0 flaws (~~), 9 warnings (==), 24 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group W. Koch 3 Internet-Draft GnuPG e.V. 4 Obsoletes4880, 5581, 6637 (if approved) B. Carlson 5 Intended status: Standards Track R.H. Tse 6 Expires: 4 March 2021 Ribose 7 D.A. Atkins 8 D.K. Gillmor 9 31 August 2020 11 OpenPGP Message Format 12 draft-ietf-openpgp-rfc4880bis-10 14 Abstract 16 { Work in progress to update the OpenPGP specification from RFC4880 } 18 This document specifies the message formats used in OpenPGP. OpenPGP 19 provides encryption with public-key or symmetric cryptographic 20 algorithms, digital signatures, compression and key management. 22 This document is maintained in order to publish all necessary 23 information needed to develop interoperable applications based on the 24 OpenPGP format. It is not a step-by-step cookbook for writing an 25 application. It describes only the format and methods needed to 26 read, check, generate, and write conforming packets crossing any 27 network. It does not deal with storage and implementation questions. 28 It does, however, discuss implementation issues necessary to avoid 29 security flaws. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at https://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on 4 March 2021. 48 Copyright Notice 50 Copyright (c) 2020 IETF Trust and the persons identified as the 51 document authors. All rights reserved. 53 This document is subject to BCP 78 and the IETF Trust's Legal 54 Provisions Relating to IETF Documents (http://trustee.ietf.org/ 55 license-info) in effect on the date of publication of this document. 56 Please review these documents carefully, as they describe your rights 57 and restrictions with respect to this document. Code Components 58 extracted from this document must include Simplified BSD License text 59 as described in Section 4.e of the Trust Legal Provisions and are 60 provided without warranty as described in the Simplified BSD License. 62 Table of Contents 64 1. Introduction 65 1.1. Terms 66 2. General functions 67 2.1. Confidentiality via Encryption 68 2.2. Authentication via Digital Signature 69 2.3. Compression 70 2.4. Conversion to Radix-64 71 2.5. Signature-Only Applications 72 3. Data Element Formats 73 3.1. Scalar Numbers 74 3.2. Multiprecision Integers 75 3.3. Key IDs 76 3.4. Text 77 3.5. Time Fields 78 3.6. Keyrings 79 3.7. String-to-Key (S2K) Specifiers 80 3.7.1. String-to-Key (S2K) Specifier Types 81 3.7.2. String-to-Key Usage 82 4. Packet Syntax 83 4.1. Overview 84 4.2. Packet Headers 85 4.2.1. Old Format Packet Lengths 86 4.2.2. New Format Packet Lengths 87 4.2.3. Packet Length Examples 88 4.3. Packet Tags 89 5. Packet Types 90 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 91 5.2. Signature Packet (Tag 2) 92 5.2.1. Signature Types 93 5.2.2. Version 3 Signature Packet Format 94 5.2.3. Version 4 and 5 Signature Packet Formats 95 5.2.4. Computing Signatures 96 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 97 5.4. One-Pass Signature Packets (Tag 4) 98 5.5. Key Material Packet 99 5.5.1. Key Packet Variants 100 5.5.2. Public-Key Packet Formats 101 5.5.3. Secret-Key Packet Formats 102 5.6. Algorithm-specific Parts of Keys 103 5.6.1. Algorithm-Specific Part for RSA Keys 104 5.6.2. Algorithm-Specific Part for DSA Keys 105 5.6.3. Algorithm-Specific Part for Elgamal Keys 106 5.6.4. Algorithm-Specific Part for ECDSA Keys 107 5.6.5. Algorithm-Specific Part for EdDSA Keys 108 5.6.6. Algorithm-Specific Part for ECDH Keys 109 5.7. Compressed Data Packet (Tag 8) 110 5.8. Symmetrically Encrypted Data Packet (Tag 9) 111 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) 112 5.10. Literal Data Packet (Tag 11) 113 5.11. Trust Packet (Tag 12) 114 5.12. User ID Packet (Tag 13) 115 5.13. User Attribute Packet (Tag 17) 116 5.13.1. The Image Attribute Subpacket 117 5.13.2. User ID Attribute Subpacket 118 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 119 18) 120 5.15. Modification Detection Code Packet (Tag 19) 121 5.16. AEAD Encrypted Data Packet (Tag 20) 122 5.16.1. EAX Mode 123 5.16.2. OCB Mode 124 6. Radix-64 Conversions 125 6.1. An Implementation of the CRC-24 in "C" 126 6.2. Forming ASCII Armor 127 6.3. Encoding Binary in Radix-64 128 6.4. Decoding Radix-64 129 6.5. Examples of Radix-64 130 6.6. Example of an ASCII Armored Message 131 7. Cleartext Signature Framework 132 7.1. Dash-Escaped Text 133 8. Regular Expressions 134 9. Constants 135 9.1. Public-Key Algorithms 136 9.2. ECC Curve OID 137 9.3. Symmetric-Key Algorithms 138 9.4. Compression Algorithms 139 9.5. Hash Algorithms 140 9.6. AEAD Algorithms 141 10. IANA Considerations 142 10.1. New String-to-Key Specifier Types 143 10.2. New Packets 144 10.2.1. User Attribute Types 145 10.2.2. Image Format Subpacket Types 146 10.2.3. New Signature Subpackets 147 10.2.4. New Packet Versions 148 10.3. New Algorithms 149 10.3.1. Public-Key Algorithms 150 10.3.2. Symmetric-Key Algorithms 151 10.3.3. Hash Algorithms 152 10.3.4. Compression Algorithms 153 11. Packet Composition 154 11.1. Transferable Public Keys 155 11.2. Transferable Secret Keys 156 11.3. OpenPGP Messages 157 11.4. Detached Signatures 158 12. Enhanced Key Formats 159 12.1. Key Structures 160 12.2. Key IDs and Fingerprints 161 13. Elliptic Curve Cryptography 162 13.1. Supported ECC Curves 163 13.2. ECDSA and ECDH Conversion Primitives 164 13.3. EdDSA Point Format 165 13.4. Key Derivation Function 166 13.5. EC DH Algorithm (ECDH) 167 14. Notes on Algorithms 168 14.1. PKCS#1 Encoding in OpenPGP 169 14.1.1. EME-PKCS1-v1_5-ENCODE 170 14.1.2. EME-PKCS1-v1_5-DECODE 171 14.1.3. EMSA-PKCS1-v1_5 172 14.2. Symmetric Algorithm Preferences 173 14.3. Other Algorithm Preferences 174 14.3.1. Compression Preferences 175 14.3.2. Hash Algorithm Preferences 176 14.4. Plaintext 177 14.5. RSA 178 14.6. DSA 179 14.7. Elgamal 180 14.8. EdDSA 181 14.9. Reserved Algorithm Numbers 182 14.10. OpenPGP CFB Mode 183 14.11. Private or Experimental Parameters 184 14.12. Meta-Considerations for Expansion 185 15. Security Considerations 186 16. Compatibility Profiles 187 16.1. OpenPGP ECC Profile 188 16.2. Suite-B Profile 189 16.2.1. Security Strength at 192 Bits 190 16.2.2. Security Strength at 128 Bits 191 17. Implementation Nits 192 18. References 193 18.1. Normative References 194 18.2. Informative References 195 Appendix A. Test vectors 196 A.1. Sample EdDSA key 197 A.2. Sample EdDSA signature 198 A.3. Sample AEAD-EAX encryption and decryption 199 A.3.1. Sample Parameters 200 A.3.2. Sample symmetric-key encrypted session key 201 packet (v5) 202 A.3.3. Starting AEAD-EAX decryption of CEK 203 A.3.4. Sample AEAD encrypted data packet 204 A.3.5. Decryption of data 205 A.3.6. Complete AEAD-EAX encrypted packet sequence 206 A.4. Sample AEAD-OCB encryption and decryption 207 A.4.1. Sample Parameters 208 A.4.2. Sample symmetric-key encrypted session key 209 packet (v5) 210 A.4.3. Starting AEAD-OCB decryption of CEK 211 A.4.4. Sample AEAD encrypted data packet 212 A.4.5. Decryption of data 213 A.4.6. Complete AEAD-OCB encrypted packet sequence 214 Appendix B. ECC Point compression flag bytes 215 Appendix C. Changes since RFC-4880 216 Appendix D. The principal authors of RFC-4880 217 Authors' Addresses 219 1. Introduction 221 { This is work in progress to update OpenPGP. Editorial notes are 222 enclosed in curly braces. } 224 This document provides information on the message-exchange packet 225 formats used by OpenPGP to provide encryption, decryption, signing, 226 and key management functions. It is a revision of RFC 4880, "OpenPGP 227 Message Format", which is a revision of RFC 2440, which itself 228 replaces RFC 1991, "PGP Message Exchange Formats" [RFC1991] [RFC2440] 229 [RFC4880]. 231 This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia 232 cipher) and RFC 6637 (ECC for OpenPGP). 234 1.1. Terms 236 * OpenPGP - This is a term for security software that uses PGP 5 as 237 a basis, formalized in this document. 239 * PGP - Pretty Good Privacy. PGP is a family of software systems 240 developed by Philip R. Zimmermann from which OpenPGP is based. 242 * PGP 2 - This version of PGP has many variants; where necessary a 243 more detailed version number is used here. PGP 2 uses only RSA, 244 MD5, and IDEA for its cryptographic transforms. An informational 245 RFC, RFC 1991, was written describing this version of PGP. 247 * PGP 5 - This version of PGP is formerly known as "PGP 3" in the 248 community. It has new formats and corrects a number of problems 249 in the PGP 2 design. It is referred to here as PGP 5 because that 250 software was the first release of the "PGP 3" code base. 252 * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 253 implementation that avoids all encumbered algorithms. 254 Consequently, early versions of GnuPG did not include RSA public 255 keys. 257 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 258 Corporation and are used with permission. The term "OpenPGP" refers 259 to the protocol described in this and related documents. 261 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 262 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 263 document are to be interpreted as described in [RFC2119]. 265 The key words "PRIVATE USE", "EXPERT REVIEW", "SPECIFICATION 266 REQUIRED", "RFC REQUIRED", and "IETF REVIEW" that appear in this 267 document when used to describe namespace allocation are to be 268 interpreted as described in [RFC8126]. 270 2. General functions 272 OpenPGP provides data integrity services for messages and data files 273 by using these core technologies: 275 * digital signatures 277 * encryption 279 * compression 281 * Radix-64 conversion 283 In addition, OpenPGP provides key management and certificate 284 services, but many of these are beyond the scope of this document. 286 2.1. Confidentiality via Encryption 288 OpenPGP combines symmetric-key encryption and public-key encryption 289 to provide confidentiality. When made confidential, first the object 290 is encrypted using a symmetric encryption algorithm. Each symmetric 291 key is used only once, for a single object. A new "session key" is 292 generated as a random number for each object (sometimes referred to 293 as a session). Since it is used only once, the session key is bound 294 to the message and transmitted with it. To protect the key, it is 295 encrypted with the receiver's public key. The sequence is as 296 follows: 298 1. The sender creates a message. 300 2. The sending OpenPGP generates a random number to be used as a 301 session key for this message only. 303 3. The session key is encrypted using each recipient's public key. 304 These "encrypted session keys" start the message. 306 4. The sending OpenPGP encrypts the message using the session key, 307 which forms the remainder of the message. Note that the message 308 is also usually compressed. 310 5. The receiving OpenPGP decrypts the session key using the 311 recipient's private key. 313 6. The receiving OpenPGP decrypts the message using the session key. 314 If the message was compressed, it will be decompressed. 316 With symmetric-key encryption, an object may be encrypted with a 317 symmetric key derived from a passphrase (or other shared secret), or 318 a two-stage mechanism similar to the public-key method described 319 above in which a session key is itself encrypted with a symmetric 320 algorithm keyed from a shared secret. 322 Both digital signature and confidentiality services may be applied to 323 the same message. First, a signature is generated for the message 324 and attached to the message. Then the message plus signature is 325 encrypted using a symmetric session key. Finally, the session key is 326 encrypted using public-key encryption and prefixed to the encrypted 327 block. 329 2.2. Authentication via Digital Signature 331 The digital signature uses a hash code or message digest algorithm, 332 and a public-key signature algorithm. The sequence is as follows: 334 1. The sender creates a message. 336 2. The sending software generates a hash code of the message. 338 3. The sending software generates a signature from the hash code 339 using the sender's private key. 341 4. The binary signature is attached to the message. 343 5. The receiving software keeps a copy of the message signature. 345 6. The receiving software generates a new hash code for the received 346 message and verifies it using the message's signature. If the 347 verification is successful, the message is accepted as authentic. 349 2.3. Compression 351 OpenPGP implementations SHOULD compress the message after applying 352 the signature but before encryption. 354 If an implementation does not implement compression, its authors 355 should be aware that most OpenPGP messages in the world are 356 compressed. Thus, it may even be wise for a space-constrained 357 implementation to implement decompression, but not compression. 359 Furthermore, compression has the added side effect that some types of 360 attacks can be thwarted by the fact that slightly altered, compressed 361 data rarely uncompresses without severe errors. This is hardly 362 rigorous, but it is operationally useful. These attacks can be 363 rigorously prevented by implementing and using Modification Detection 364 Codes as described in sections following. 366 2.4. Conversion to Radix-64 368 OpenPGP's underlying native representation for encrypted messages, 369 signature certificates, and keys is a stream of arbitrary octets. 370 Some systems only permit the use of blocks consisting of seven-bit, 371 printable text. For transporting OpenPGP's native raw binary octets 372 through channels that are not safe to raw binary data, a printable 373 encoding of these binary octets is needed. OpenPGP provides the 374 service of converting the raw 8-bit binary octet stream to a stream 375 of printable ASCII characters, called Radix-64 encoding or ASCII 376 Armor. 378 Implementations SHOULD provide Radix-64 conversions. 380 2.5. Signature-Only Applications 382 OpenPGP is designed for applications that use both encryption and 383 signatures, but there are a number of problems that are solved by a 384 signature-only implementation. Although this specification requires 385 both encryption and signatures, it is reasonable for there to be 386 subset implementations that are non-conformant only in that they omit 387 encryption. 389 3. Data Element Formats 391 This section describes the data elements used by OpenPGP. 393 3.1. Scalar Numbers 395 Scalar numbers are unsigned and are always stored in big-endian 396 format. Using n[k] to refer to the kth octet being interpreted, the 397 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 398 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 399 n[3]). 401 3.2. Multiprecision Integers 403 Multiprecision integers (also called MPIs) are unsigned integers used 404 to hold large integers such as the ones used in cryptographic 405 calculations. 407 An MPI consists of two pieces: a two-octet scalar that is the length 408 of the MPI in bits followed by a string of octets that contain the 409 actual integer. 411 These octets form a big-endian number; a big-endian number can be 412 made into an MPI by prefixing it with the appropriate length. 414 Examples: 416 (all numbers are in hexadecimal) 418 The string of octets [00 01 01] forms an MPI with the value 1. The 419 string [00 09 01 FF] forms an MPI with the value of 511. 421 Additional rules: 423 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 425 The length field of an MPI describes the length starting from its 426 most significant non-zero bit. Thus, the MPI [00 02 01] is not 427 formed correctly. It should be [00 01 01]. 429 Unused bits of an MPI MUST be zero. 431 Also note that when an MPI is encrypted, the length refers to the 432 plaintext MPI. It may be ill-formed in its ciphertext. 434 3.3. Key IDs 436 A Key ID is an eight-octet scalar that identifies a key. 437 Implementations SHOULD NOT assume that Key IDs are unique. The 438 section "Enhanced Key Formats" below describes how Key IDs are 439 formed. 441 3.4. Text 443 Unless otherwise specified, the character set for text is the UTF-8 444 [RFC3629] encoding of Unicode [ISO10646]. 446 3.5. Time Fields 448 A time field is an unsigned four-octet number containing the number 449 of seconds elapsed since midnight, 1 January 1970 UTC. 451 3.6. Keyrings 453 A keyring is a collection of one or more keys in a file or database. 454 Traditionally, a keyring is simply a sequential list of keys, but may 455 be any suitable database. It is beyond the scope of this standard to 456 discuss the details of keyrings or other databases. 458 3.7. String-to-Key (S2K) Specifiers 460 String-to-key (S2K) specifiers are used to convert passphrase strings 461 into symmetric-key encryption/decryption keys. They are used in two 462 places, currently: to encrypt the secret part of private keys in the 463 private keyring, and to convert passphrases to encryption keys for 464 symmetrically encrypted messages. 466 3.7.1. String-to-Key (S2K) Specifier Types 468 There are three types of S2K specifiers currently supported, and some 469 reserved values: 471 +------------+--------------------------+ 472 | ID | S2K Type | 473 +============+==========================+ 474 | 0 | Simple S2K | 475 +------------+--------------------------+ 476 | 1 | Salted S2K | 477 +------------+--------------------------+ 478 | 2 | Reserved value | 479 +------------+--------------------------+ 480 | 3 | Iterated and Salted S2K | 481 +------------+--------------------------+ 482 | 100 to 110 | Private/Experimental S2K | 483 +------------+--------------------------+ 485 Table 1 487 These are described in the following Sections. 489 3.7.1.1. Simple S2K 491 This directly hashes the string to produce the key data. See below 492 for how this hashing is done. 494 Octet 0: 0x00 495 Octet 1: hash algorithm 497 Simple S2K hashes the passphrase to produce the session key. The 498 manner in which this is done depends on the size of the session key 499 (which will depend on the cipher used) and the size of the hash 500 algorithm's output. If the hash size is greater than the session key 501 size, the high-order (leftmost) octets of the hash are used as the 502 key. 504 If the hash size is less than the key size, multiple instances of the 505 hash context are created -- enough to produce the required key data. 506 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 507 is to say, the first instance has no preloading, the second gets 508 preloaded with 1 octet of zero, the third is preloaded with two 509 octets of zeros, and so forth). 511 As the data is hashed, it is given independently to each hash 512 context. Since the contexts have been initialized differently, they 513 will each produce different hash output. Once the passphrase is 514 hashed, the output data from the multiple hashes is concatenated, 515 first hash leftmost, to produce the key data, with any excess octets 516 on the right discarded. 518 3.7.1.2. Salted S2K 520 This includes a "salt" value in the S2K specifier -- some arbitrary 521 data -- that gets hashed along with the passphrase string, to help 522 prevent dictionary attacks. 524 Octet 0: 0x01 525 Octet 1: hash algorithm 526 Octets 2-9: 8-octet salt value 528 Salted S2K is exactly like Simple S2K, except that the input to the 529 hash function(s) consists of the 8 octets of salt from the S2K 530 specifier, followed by the passphrase. 532 3.7.1.3. Iterated and Salted S2K 534 This includes both a salt and an octet count. The salt is combined 535 with the passphrase and the resulting value is hashed repeatedly. 536 This further increases the amount of work an attacker must do to try 537 dictionary attacks. 539 Octet 0: 0x03 540 Octet 1: hash algorithm 541 Octets 2-9: 8-octet salt value 542 Octet 10: count, a one-octet, coded value 544 The count is coded into a one-octet number using the following 545 formula: 547 #define EXPBIAS 6 548 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 550 The above formula is in C, where "Int32" is a type for a 32-bit 551 integer, and the variable "c" is the coded count, Octet 10. 553 Iterated-Salted S2K hashes the passphrase and salt data multiple 554 times. The total number of octets to be hashed is specified in the 555 encoded count in the S2K specifier. Note that the resulting count 556 value is an octet count of how many octets will be hashed, not an 557 iteration count. 559 Initially, one or more hash contexts are set up as with the other S2K 560 algorithms, depending on how many octets of key data are needed. 561 Then the salt, followed by the passphrase data, is repeatedly hashed 562 until the number of octets specified by the octet count has been 563 hashed. The one exception is that if the octet count is less than 564 the size of the salt plus passphrase, the full salt plus passphrase 565 will be hashed even though that is greater than the octet count. 566 After the hashing is done, the data is unloaded from the hash 567 context(s) as with the other S2K algorithms. 569 3.7.2. String-to-Key Usage 571 Implementations SHOULD use salted or iterated-and-salted S2K 572 specifiers, as simple S2K specifiers are more vulnerable to 573 dictionary attacks. 575 3.7.2.1. Secret-Key Encryption 577 An S2K specifier can be stored in the secret keyring to specify how 578 to convert the passphrase to a key that unlocks the secret data. 579 Older versions of PGP just stored a cipher algorithm octet preceding 580 the secret data or a zero to indicate that the secret data was 581 unencrypted. The MD5 hash function was always used to convert the 582 passphrase to a key for the specified cipher algorithm. 584 For compatibility, when an S2K specifier is used, the special value 585 253, 254, or 255 is stored in the position where the hash algorithm 586 octet would have been in the old data structure. This is then 587 followed immediately by a one-octet algorithm identifier, and then by 588 the S2K specifier as encoded above. 590 Therefore, preceding the secret data there will be one of these 591 possibilities: 593 0: secret data is unencrypted (no passphrase) 594 255, 254, or 253: followed by algorithm octet and S2K specifier 595 Cipher alg: use Simple S2K algorithm using MD5 hash 597 This last possibility, the cipher algorithm number with an implicit 598 use of MD5 and IDEA, is provided for backward compatibility; it MAY 599 be understood, but SHOULD NOT be generated, and is deprecated. 601 These are followed by an Initial Vector of the same length as the 602 block size of the cipher for the decryption of the secret values, if 603 they are encrypted, and then the secret-key values themselves. 605 3.7.2.2. Symmetric-Key Message Encryption 607 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 608 at the front of a message. This is used to allow S2K specifiers to 609 be used for the passphrase conversion or to create messages with a 610 mix of symmetric-key ESKs and public-key ESKs. This allows a message 611 to be decrypted either with a passphrase or a public-key pair. 613 PGP 2 always used IDEA with Simple string-to-key conversion when 614 encrypting a message with a symmetric algorithm. This is deprecated, 615 but MAY be used for backward-compatibility. 617 4. Packet Syntax 619 This section describes the packets used by OpenPGP. 621 4.1. Overview 623 An OpenPGP message is constructed from a number of records that are 624 traditionally called packets. A packet is a chunk of data that has a 625 tag specifying its meaning. An OpenPGP message, keyring, 626 certificate, and so forth consists of a number of packets. Some of 627 those packets may contain other OpenPGP packets (for example, a 628 compressed data packet, when uncompressed, contains OpenPGP packets). 630 Each packet consists of a packet header, followed by the packet body. 631 The packet header is of variable length. 633 4.2. Packet Headers 635 The first octet of the packet header is called the "Packet Tag". It 636 determines the format of the header and denotes the packet contents. 637 The remainder of the packet header is the length of the packet. 639 Note that the most significant bit is the leftmost bit, called bit 7. 640 A mask for this bit is 0x80 in hexadecimal. 642 +---------------+ 643 PTag |7 6 5 4 3 2 1 0| 644 +---------------+ 645 Bit 7 -- Always one 646 Bit 6 -- New packet format if set 648 PGP 2.6.x only uses old format packets. Thus, software that 649 interoperates with those versions of PGP must only use old format 650 packets. If interoperability is not an issue, the new packet format 651 is RECOMMENDED. Note that old format packets have four bits of 652 packet tags, and new format packets have six; some features cannot be 653 used and still be backward-compatible. 655 Also note that packets with a tag greater than or equal to 16 MUST 656 use new format packets. The old format packets can only express tags 657 less than or equal to 15. 659 Old format packets contain: 661 Bits 5-2 -- packet tag 662 Bits 1-0 -- length-type 664 New format packets contain: 666 Bits 5-0 -- packet tag 668 4.2.1. Old Format Packet Lengths 670 The meaning of the length-type in old format packets is: 672 0 The packet has a one-octet length. The header is 2 octets long. 674 1 The packet has a two-octet length. The header is 3 octets long. 676 2 The packet has a four-octet length. The header is 5 octets long. 678 3 The packet is of indeterminate length. The header is 1 octet 679 long, and the implementation must determine how long the packet 680 is. If the packet is in a file, this means that the packet 681 extends until the end of the file. In general, an implementation 682 SHOULD NOT use indeterminate-length packets except where the end 683 of the data will be clear from the context, and even then it is 684 better to use a definite length, or a new format header. The new 685 format headers described below have a mechanism for precisely 686 encoding data of indeterminate length. 688 4.2.2. New Format Packet Lengths 690 New format packets have four possible ways of encoding length: 692 1. A one-octet Body Length header encodes packet lengths of up to 693 191 octets. 695 2. A two-octet Body Length header encodes packet lengths of 192 to 696 8383 octets. 698 3. A five-octet Body Length header encodes packet lengths of up to 699 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 700 encodes a four-octet scalar number.) 702 4. When the length of the packet body is not known in advance by the 703 issuer, Partial Body Length headers encode a packet of 704 indeterminate length, effectively making it a stream. 706 4.2.2.1. One-Octet Lengths 708 A one-octet Body Length header encodes a length of 0 to 191 octets. 709 This type of length header is recognized because the one octet value 710 is less than 192. The body length is equal to: 712 bodyLen = 1st_octet; 714 4.2.2.2. Two-Octet Lengths 716 A two-octet Body Length header encodes a length of 192 to 8383 717 octets. It is recognized because its first octet is in the range 192 718 to 223. The body length is equal to: 720 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 722 4.2.2.3. Five-Octet Lengths 724 A five-octet Body Length header consists of a single octet holding 725 the value 255, followed by a four-octet scalar. The body length is 726 equal to: 728 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 729 (4th_octet << 8) | 5th_octet 731 This basic set of one, two, and five-octet lengths is also used 732 internally to some packets. 734 4.2.2.4. Partial Body Lengths 736 A Partial Body Length header is one octet long and encodes the length 737 of only part of the data packet. This length is a power of 2, from 1 738 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 739 octet value that is greater than or equal to 224, and less than 255. 740 The Partial Body Length is equal to: 742 partialBodyLen = 1 << (1st_octet & 0x1F); 744 Each Partial Body Length header is followed by a portion of the 745 packet body data. The Partial Body Length header specifies this 746 portion's length. Another length header (one octet, two-octet, five- 747 octet, or partial) follows that portion. The last length header in 748 the packet MUST NOT be a Partial Body Length header. Partial Body 749 Length headers may only be used for the non-final parts of the 750 packet. 752 Note also that the last Body Length header can be a zero-length 753 header. 755 An implementation MAY use Partial Body Lengths for data packets, be 756 they literal, compressed, or encrypted. The first partial length 757 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 758 used for any other packet types. 760 4.2.3. Packet Length Examples 762 These examples show ways that new format packets might encode the 763 packet lengths. 765 A packet with length 100 may have its length encoded in one octet: 766 0x64. This is followed by 100 octets of data. 768 A packet with length 1723 may have its length encoded in two octets: 769 0xC5, 0xFB. This header is followed by the 1723 octets of data. 771 A packet with length 100000 may have its length encoded in five 772 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 774 It might also be encoded in the following octet stream: 0xEF, first 775 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 776 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 777 octets of data. This is just one possible encoding, and many 778 variations are possible on the size of the Partial Body Length 779 headers, as long as a regular Body Length header encodes the last 780 portion of the data. 782 Please note that in all of these explanations, the total length of 783 the packet is the length of the header(s) plus the length of the 784 body. 786 4.3. Packet Tags 788 The packet tag denotes what type of packet the body holds. Note that 789 old format headers can only have tags less than 16, whereas new 790 format headers can have tags as great as 63. The defined tags (in 791 decimal) are as follows: 793 +----------+----------------------------------------------------+ 794 | Tag | Packet Type | 795 +==========+====================================================+ 796 | 0 | Reserved - a packet tag MUST NOT have this value | 797 +----------+----------------------------------------------------+ 798 | 1 | Public-Key Encrypted Session Key Packet | 799 +----------+----------------------------------------------------+ 800 | 2 | Signature Packet | 801 +----------+----------------------------------------------------+ 802 | 3 | Symmetric-Key Encrypted Session Key Packet | 803 +----------+----------------------------------------------------+ 804 | 4 | One-Pass Signature Packet | 805 +----------+----------------------------------------------------+ 806 | 5 | Secret-Key Packet | 807 +----------+----------------------------------------------------+ 808 | 6 | Public-Key Packet | 809 +----------+----------------------------------------------------+ 810 | 7 | Secret-Subkey Packet | 811 +----------+----------------------------------------------------+ 812 | 8 | Compressed Data Packet | 813 +----------+----------------------------------------------------+ 814 | 9 | Symmetrically Encrypted Data Packet | 815 +----------+----------------------------------------------------+ 816 | 10 | Marker Packet | 817 +----------+----------------------------------------------------+ 818 | 11 | Literal Data Packet | 819 +----------+----------------------------------------------------+ 820 | 12 | Trust Packet | 821 +----------+----------------------------------------------------+ 822 | 13 | User ID Packet | 823 +----------+----------------------------------------------------+ 824 | 14 | Public-Subkey Packet | 825 +----------+----------------------------------------------------+ 826 | 17 | User Attribute Packet | 827 +----------+----------------------------------------------------+ 828 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 829 +----------+----------------------------------------------------+ 830 | 19 | Modification Detection Code Packet | 831 +----------+----------------------------------------------------+ 832 | 20 | AEAD Encrypted Data Packet | 833 +----------+----------------------------------------------------+ 834 | 60 to 63 | Private or Experimental Values | 835 +----------+----------------------------------------------------+ 837 Table 2 839 5. Packet Types 841 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 843 A Public-Key Encrypted Session Key packet holds the session key used 844 to encrypt a message. Zero or more Public-Key Encrypted Session Key 845 packets and/or Symmetric-Key Encrypted Session Key packets may 846 precede a Symmetrically Encrypted Data Packet, which holds an 847 encrypted message. The message is encrypted with the session key, 848 and the session key is itself encrypted and stored in the Encrypted 849 Session Key packet(s). The Symmetrically Encrypted Data Packet is 850 preceded by one Public-Key Encrypted Session Key packet for each 851 OpenPGP key to which the message is encrypted. The recipient of the 852 message finds a session key that is encrypted to their public key, 853 decrypts the session key, and then uses the session key to decrypt 854 the message. 856 The body of this packet consists of: 858 * A one-octet number giving the version number of the packet type. 859 The currently defined value for packet version is 3. 861 * An eight-octet number that gives the Key ID of the public key to 862 which the session key is encrypted. If the session key is 863 encrypted to a subkey, then the Key ID of this subkey is used here 864 instead of the Key ID of the primary key. 866 * A one-octet number giving the public-key algorithm used. 868 * A string of octets that is the encrypted session key. This string 869 takes up the remainder of the packet, and its contents are 870 dependent on the public-key algorithm used. 872 Algorithm Specific Fields for RSA encryption: 874 - Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 876 Algorithm Specific Fields for Elgamal encryption: 878 - MPI of Elgamal (Diffie-Hellman) value g**k mod p. 880 - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 882 Algorithm-Specific Fields for ECDH encryption: 884 - MPI of an EC point representing an ephemeral public key. 886 - a one-octet size, followed by a symmetric key encoded using the 887 method described in Section 13.5. 889 The value "m" in the above formulas is derived from the session key 890 as follows. First, the session key is prefixed with a one-octet 891 algorithm identifier that specifies the symmetric encryption 892 algorithm used to encrypt the following Symmetrically Encrypted Data 893 Packet. Then a two-octet checksum is appended, which is equal to the 894 sum of the preceding session key octets, not including the algorithm 895 identifier, modulo 65536. This value is then encoded as described in 896 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 897 form the "m" value used in the formulas above. See Section 14.1 of 898 this document for notes on OpenPGP's use of PKCS#1. 900 Note that when an implementation forms several PKESKs with one 901 session key, forming a message that can be decrypted by several keys, 902 the implementation MUST make a new PKCS#1 encoding for each key. 904 An implementation MAY accept or use a Key ID of zero as a "wild card" 905 or "speculative" Key ID. In this case, the receiving implementation 906 would try all available private keys, checking for a valid decrypted 907 session key. This format helps reduce traffic analysis of messages. 909 5.2. Signature Packet (Tag 2) 911 A Signature packet describes a binding between some public key and 912 some data. The most common signatures are a signature of a file or a 913 block of text, and a signature that is a certification of a User ID. 915 Three versions of Signature packets are defined. Version 3 provides 916 basic signature information, while versions 4 and 5 provide an 917 expandable format with subpackets that can specify more information 918 about the signature. PGP 2.6.x only accepts version 3 signatures. 920 Implementations MUST generate version 5 signatures when using a 921 version 5 key. Implementations SHOULD generate V4 signatures with 922 version 4 keys. Implementations MUST NOT create version 3 923 signatures; they MAY accept version 3 signatures. 925 5.2.1. Signature Types 927 There are a number of possible meanings for a signature, which are 928 indicated in a signature type octet in any given signature. Please 929 note that the vagueness of these meanings is not a flaw, but a 930 feature of the system. Because OpenPGP places final authority for 931 validity upon the receiver of a signature, it may be that one 932 signer's casual act might be more rigorous than some other 933 authority's positive act. See Section 5.2.4, "Computing Signatures", 934 for detailed information on how to compute and verify signatures of 935 each type. 937 These meanings are as follows: 939 0x00 Signature of a binary document. This means the signer owns it, 940 created it, or certifies that it has not been modified. 942 0x01 Signature of a canonical text document. This means the signer 943 owns it, created it, or certifies that it has not been 944 modified. The signature is calculated over the text data with 945 its line endings converted to . 947 0x02 Standalone signature. This signature is a signature of only 948 its own subpacket contents. It is calculated identically to a 949 signature over a zero-length binary document. Note that it 950 doesn't make sense to have a V3 standalone signature. 952 0x10 Generic certification of a User ID and Public-Key packet. The 953 issuer of this certification does not make any particular 954 assertion as to how well the certifier has checked that the 955 owner of the key is in fact the person described by the User 956 ID. 958 0x11 Persona certification of a User ID and Public-Key packet. The 959 issuer of this certification has not done any verification of 960 the claim that the owner of this key is the User ID specified. 962 0x12 Casual certification of a User ID and Public-Key packet. The 963 issuer of this certification has done some casual verification 964 of the claim of identity. 966 0x13 Positive certification of a User ID and Public-Key packet. The 967 issuer of this certification has done substantial verification 968 of the claim of identity. Most OpenPGP implementations make 969 their "key signatures" as 0x10 certifications. Some 970 implementations can issue 0x11-0x13 certifications, but few 971 differentiate between the types. 973 0x16 Attested Key Signature. This signature is issued by the 974 primary key over itself and its User ID (or User Attribute). 975 It MUST contain an "Attested Certifications" subpacket and a 976 "Signature Creation Time" subpacket. This type of key 977 signature does not replace or override any standard 978 certification (0x10-0x13). Only the most recent Attestation 979 Key Signature is valid for any given pair. If 980 more than one Certification Attestation Key Signature is 981 present with the same Signature Creation Time, the set of 982 attestations should be treated as the union of all "Attested 983 Certifications" subpackets from all such signatures with the 984 same timestamp. 986 0x18 Subkey Binding Signature. This signature is a statement by the 987 top-level signing key that indicates that it owns the subkey. 988 This signature is calculated directly on the primary key and 989 subkey, and not on any User ID or other packets. A signature 990 that binds a signing subkey MUST have an Embedded Signature 991 subpacket in this binding signature that contains a 0x19 992 signature made by the signing subkey on the primary key and 993 subkey. 995 0x19 Primary Key Binding Signature. This signature is a statement 996 by a signing subkey, indicating that it is owned by the primary 997 key and subkey. This signature is calculated the same way as a 998 0x18 signature: directly on the primary key and subkey, and not 999 on any User ID or other packets. 1001 0x1F Signature directly on a key. This signature is calculated 1002 directly on a key. It binds the information in the Signature 1003 subpackets to the key, and is appropriate to be used for 1004 subpackets that provide information about the key, such as the 1005 Revocation Key subpacket. It is also appropriate for 1006 statements that non-self certifiers want to make about the key 1007 itself, rather than the binding between a key and a name. 1009 0x20 Key revocation signature. The signature is calculated directly 1010 on the key being revoked. A revoked key is not to be used. 1011 Only revocation signatures by the key being revoked, or by an 1012 authorized revocation key, should be considered valid 1013 revocation signatures. 1015 0x28 Subkey revocation signature. The signature is calculated 1016 directly on the subkey being revoked. A revoked subkey is not 1017 to be used. Only revocation signatures by the top-level 1018 signature key that is bound to this subkey, or by an authorized 1019 revocation key, should be considered valid revocation 1020 signatures. 1022 0x30 Certification revocation signature. This signature revokes an 1023 earlier User ID certification signature (signature class 0x10 1024 through 0x13) or direct-key signature (0x1F). It should be 1025 issued by the same key that issued the revoked signature or an 1026 authorized revocation key. The signature is computed over the 1027 same data as the certificate that it revokes, and should have a 1028 later creation date than that certificate. 1030 0x40 Timestamp signature. This signature is only meaningful for the 1031 timestamp contained in it. 1033 0x50 Third-Party Confirmation signature. This signature is a 1034 signature over some other OpenPGP Signature packet(s). It is 1035 analogous to a notary seal on the signed data. A third-party 1036 signature SHOULD include Signature Target subpacket(s) to give 1037 easy identification. Note that we really do mean SHOULD. 1038 There are plausible uses for this (such as a blind party that 1039 only sees the signature, not the key or source document) that 1040 cannot include a target subpacket. 1042 5.2.2. Version 3 Signature Packet Format 1044 The body of a version 3 Signature Packet contains: 1046 * One-octet version number (3). 1048 * One-octet length of following hashed material. MUST be 5. 1050 * One-octet signature type. 1052 * Four-octet creation time. 1054 * Eight-octet Key ID of signer. 1056 * One-octet public-key algorithm. 1058 * One-octet hash algorithm. 1060 * Two-octet field holding left 16 bits of signed hash value. 1062 * One or more multiprecision integers comprising the signature. 1063 This portion is algorithm specific, as described below. 1065 The concatenation of the data to be signed, the signature type, 1066 and creation time from the Signature packet (5 additional octets) 1067 is hashed. The resulting hash value is used in the signature 1068 algorithm. The high 16 bits (first two octets) of the hash are 1069 included in the Signature packet to provide a way to reject 1070 invalid signatures without performing a signature verification. 1072 Algorithm-Specific Fields for RSA signatures: 1074 - Multiprecision integer (MPI) of RSA signature value m**d mod n. 1076 Algorithm-Specific Fields for DSA and ECDSA signatures: 1078 - MPI of DSA or ECDSA value r. 1080 - MPI of DSA or ECDSA value s. 1082 The signature calculation is based on a hash of the signed data, as 1083 described above. The details of the calculation are different for 1084 DSA signatures than for RSA signatures. 1086 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1087 type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This 1088 requires inserting the hash value as an octet string into an ASN.1 1089 structure. The object identifier for the type of hash being used is 1090 included in the structure. The hexadecimal representations for the 1091 currently defined hash algorithms are as follows: 1093 - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 1095 - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 1097 - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A 1099 - SHA2-224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04 1101 - SHA2-256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 1103 - SHA2-384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 1105 - SHA2-512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 1107 The ASN.1 Object Identifiers (OIDs) are as follows: 1109 - MD5: 1.2.840.113549.2.5 1111 - RIPEMD-160: 1.3.36.3.2.1 1113 - SHA-1: 1.3.14.3.2.26 1115 - SHA2-224: 2.16.840.1.101.3.4.2.4 1117 - SHA2-256: 2.16.840.1.101.3.4.2.1 1119 - SHA2-384: 2.16.840.1.101.3.4.2.2 1121 - SHA2-512: 2.16.840.1.101.3.4.2.3 1123 The full hash prefixes for these are as follows: 1125 - MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 1126 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 1127 0x04, 0x10 1129 - RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 1130 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 1132 - SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, 1133 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 1135 - SHA2-224: 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1136 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 1137 0x00, 0x04, 0x1C 1139 - SHA2-256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1140 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 1141 0x00, 0x04, 0x20 1143 - SHA2-384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1144 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 1145 0x00, 0x04, 0x30 1147 - SHA2-512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1148 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 1149 0x00, 0x04, 0x40 1151 DSA signatures MUST use hashes that are equal in size to the number 1152 of bits of q, the group generated by the DSA key's generator value. 1154 If the output size of the chosen hash is larger than the number of 1155 bits of q, the hash result is truncated to fit by taking the number 1156 of leftmost bits equal to the number of bits of q. This (possibly 1157 truncated) hash function result is treated as a number and used 1158 directly in the DSA signature algorithm. 1160 5.2.3. Version 4 and 5 Signature Packet Formats 1162 The body of a V4 or V5 Signature packet contains: 1164 * One-octet version number. This is 4 for V4 signatures and 5 for 1165 V5 signatures. 1167 * One-octet signature type. 1169 * One-octet public-key algorithm. 1171 * One-octet hash algorithm. 1173 * Two-octet scalar octet count for following hashed subpacket data. 1174 Note that this is the length in octets of all of the hashed 1175 subpackets; a pointer incremented by this number will skip over 1176 the hashed subpackets. 1178 * Hashed subpacket data set (zero or more subpackets). 1180 * Two-octet scalar octet count for the following unhashed subpacket 1181 data. Note that this is the length in octets of all of the 1182 unhashed subpackets; a pointer incremented by this number will 1183 skip over the unhashed subpackets. 1185 * Unhashed subpacket data set (zero or more subpackets). 1187 * Two-octet field holding the left 16 bits of the signed hash value. 1189 * One or more multiprecision integers comprising the signature. 1190 This portion is algorithm specific: 1192 Algorithm-Specific Fields for RSA signatures: 1194 - Multiprecision integer (MPI) of RSA signature value m**d mod n. 1196 Algorithm-Specific Fields for DSA or ECDSA signatures: 1198 - MPI of DSA or ECDSA value r. 1200 - MPI of DSA or ECDSA value s. 1202 Algorithm-Specific Fields for EdDSA signatures: 1204 - MPI of an EC point r. 1206 - EdDSA value s, in MPI, in the little endian representation. 1208 The format of R and S for use with EdDSA is described in [RFC8032]. 1209 A version 3 signature MUST NOT be created and MUST NOT be used with 1210 EdDSA. 1212 The concatenation of the data being signed and the signature data 1213 from the version number through the hashed subpacket data (inclusive) 1214 is hashed. The resulting hash value is what is signed. The high 16 1215 bits (first two octets) of the hash are included in the Signature 1216 packet to provide a way to reject invalid signatures without 1217 performing a signature verification. 1219 There are two fields consisting of Signature subpackets. The first 1220 field is hashed with the rest of the signature data, while the second 1221 is unhashed. The second set of subpackets is not cryptographically 1222 protected by the signature and should include only advisory 1223 information. 1225 The difference between a V4 and V5 signature is that the latter 1226 includes additional meta data. 1228 The algorithms for converting the hash function result to a signature 1229 are described in a section below. 1231 5.2.3.1. Signature Subpacket Specification 1233 A subpacket data set consists of zero or more Signature subpackets. 1234 In Signature packets, the subpacket data set is preceded by a two- 1235 octet scalar count of the length in octets of all the subpackets. A 1236 pointer incremented by this number will skip over the subpacket data 1237 set. 1239 Each subpacket consists of a subpacket header and a body. The header 1240 consists of: 1242 * the subpacket length (1, 2, or 5 octets), 1244 * the subpacket type (1 octet), 1246 and is followed by the subpacket-specific data. 1248 The length includes the type octet but not this length. Its format 1249 is similar to the "new" format packet header lengths, but cannot have 1250 Partial Body Lengths. That is: 1252 if the 1st octet < 192, then 1253 lengthOfLength = 1 1254 subpacketLen = 1st_octet 1256 if the 1st octet >= 192 and < 255, then 1257 lengthOfLength = 2 1258 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1260 if the 1st octet = 255, then 1261 lengthOfLength = 5 1262 subpacket length = [four-octet scalar starting at 2nd_octet] 1264 The value of the subpacket type octet may be: 1266 +------------+----------------------------------------+ 1267 | Type | Description | 1268 +============+========================================+ 1269 | 0 | Reserved | 1270 +------------+----------------------------------------+ 1271 | 1 | Reserved | 1272 +------------+----------------------------------------+ 1273 | 2 | Signature Creation Time | 1274 +------------+----------------------------------------+ 1275 | 3 | Signature Expiration Time | 1276 +------------+----------------------------------------+ 1277 | 4 | Exportable Certification | 1278 +------------+----------------------------------------+ 1279 | 5 | Trust Signature | 1280 +------------+----------------------------------------+ 1281 | 6 | Regular Expression | 1282 +------------+----------------------------------------+ 1283 | 7 | Revocable | 1284 +------------+----------------------------------------+ 1285 | 8 | Reserved | 1286 +------------+----------------------------------------+ 1287 | 9 | Key Expiration Time | 1288 +------------+----------------------------------------+ 1289 | 10 | Placeholder for backward compatibility | 1290 +------------+----------------------------------------+ 1291 | 11 | Preferred Symmetric Algorithms | 1292 +------------+----------------------------------------+ 1293 | 12 | Revocation Key | 1294 +------------+----------------------------------------+ 1295 | 13 to 15 | Reserved | 1296 +------------+----------------------------------------+ 1297 | 16 | Issuer | 1298 +------------+----------------------------------------+ 1299 | 17 to 19 | Reserved | 1300 +------------+----------------------------------------+ 1301 | 20 | Notation Data | 1302 +------------+----------------------------------------+ 1303 | 21 | Preferred Hash Algorithms | 1304 +------------+----------------------------------------+ 1305 | 22 | Preferred Compression Algorithms | 1306 +------------+----------------------------------------+ 1307 | 23 | Key Server Preferences | 1308 +------------+----------------------------------------+ 1309 | 24 | Preferred Key Server | 1310 +------------+----------------------------------------+ 1311 | 25 | Primary User ID | 1312 +------------+----------------------------------------+ 1313 | 26 | Policy URI | 1314 +------------+----------------------------------------+ 1315 | 27 | Key Flags | 1316 +------------+----------------------------------------+ 1317 | 28 | Signer's User ID | 1318 +------------+----------------------------------------+ 1319 | 29 | Reason for Revocation | 1320 +------------+----------------------------------------+ 1321 | 30 | Features | 1322 +------------+----------------------------------------+ 1323 | 31 | Signature Target | 1324 +------------+----------------------------------------+ 1325 | 32 | Embedded Signature | 1326 +------------+----------------------------------------+ 1327 | 33 | Issuer Fingerprint | 1328 +------------+----------------------------------------+ 1329 | 34 | Preferred AEAD Algorithms | 1330 +------------+----------------------------------------+ 1331 | 35 | Intended Recipient Fingerprint | 1332 +------------+----------------------------------------+ 1333 | 37 | Attested Certifications | 1334 +------------+----------------------------------------+ 1335 | 38 | Key Block | 1336 +------------+----------------------------------------+ 1337 | 100 to 110 | Private or experimental | 1338 +------------+----------------------------------------+ 1340 Table 3 1342 An implementation SHOULD ignore any subpacket of a type that it does 1343 not recognize. 1345 Bit 7 of the subpacket type is the "critical" bit. If set, it 1346 denotes that the subpacket is one that is critical for the evaluator 1347 of the signature to recognize. If a subpacket is encountered that is 1348 marked critical but is unknown to the evaluating software, the 1349 evaluator SHOULD consider the signature to be in error. 1351 An evaluator may "recognize" a subpacket, but not implement it. The 1352 purpose of the critical bit is to allow the signer to tell an 1353 evaluator that it would prefer a new, unknown feature to generate an 1354 error than be ignored. 1356 Implementations SHOULD implement the four preferred algorithm 1357 subpackets (11, 21, 22, and 34), as well as the "Reason for 1358 Revocation" subpacket. Note, however, that if an implementation 1359 chooses not to implement some of the preferences, it is required to 1360 behave in a polite manner to respect the wishes of those users who do 1361 implement these preferences. 1363 5.2.3.2. Signature Subpacket Types 1365 A number of subpackets are currently defined. Some subpackets apply 1366 to the signature itself and some are attributes of the key. 1367 Subpackets that are found on a self-signature are placed on a 1368 certification made by the key itself. Note that a key may have more 1369 than one User ID, and thus may have more than one self-signature, and 1370 differing subpackets. 1372 A subpacket may be found either in the hashed or unhashed subpacket 1373 sections of a signature. If a subpacket is not hashed, then the 1374 information in it cannot be considered definitive because it is not 1375 part of the signature proper. 1377 5.2.3.3. Notes on Self-Signatures 1379 A self-signature is a binding signature made by the key to which the 1380 signature refers. There are three types of self-signatures, the 1381 certification signatures (types 0x10-0x13), the direct-key signature 1382 (type 0x1F), and the subkey binding signature (type 0x18). For 1383 certification self-signatures, each User ID may have a self- 1384 signature, and thus different subpackets in those self-signatures. 1385 For subkey binding signatures, each subkey in fact has a self- 1386 signature. Subpackets that appear in a certification self-signature 1387 apply to the user name, and subpackets that appear in the subkey 1388 self-signature apply to the subkey. Lastly, subpackets on the 1389 direct-key signature apply to the entire key. 1391 Implementing software should interpret a self-signature's preference 1392 subpackets as narrowly as possible. For example, suppose a key has 1393 two user names, Alice and Bob. Suppose that Alice prefers the 1394 symmetric algorithm AES-256, and Bob prefers Camellia-256 or AES-128. 1395 If the software locates this key via Alice's name, then the preferred 1396 algorithm is AES-256; if software locates the key via Bob's name, 1397 then the preferred algorithm is Camellia-256. If the key is located 1398 by Key ID, the algorithm of the primary User ID of the key provides 1399 the preferred symmetric algorithm. 1401 Revoking a self-signature or allowing it to expire has a semantic 1402 meaning that varies with the signature type. Revoking the self- 1403 signature on a User ID effectively retires that user name. The self- 1404 signature is a statement, "My name X is tied to my signing key K" and 1405 is corroborated by other users' certifications. If another user 1406 revokes their certification, they are effectively saying that they no 1407 longer believe that name and that key are tied together. Similarly, 1408 if the users themselves revoke their self-signature, then the users 1409 no longer go by that name, no longer have that email address, etc. 1410 Revoking a binding signature effectively retires that subkey. 1411 Revoking a direct-key signature cancels that signature. Please see 1412 the "Reason for Revocation" subpacket (Section 5.2.3.24) for more 1413 relevant detail. 1415 Since a self-signature contains important information about the key's 1416 use, an implementation SHOULD allow the user to rewrite the self- 1417 signature, and important information in it, such as preferences and 1418 key expiration. 1420 It is good practice to verify that a self-signature imported into an 1421 implementation doesn't advertise features that the implementation 1422 doesn't support, rewriting the signature as appropriate. 1424 An implementation that encounters multiple self-signatures on the 1425 same object may resolve the ambiguity in any way it sees fit, but it 1426 is RECOMMENDED that priority be given to the most recent self- 1427 signature. 1429 5.2.3.4. Signature Creation Time 1431 (4-octet time field) 1433 The time the signature was made. 1435 MUST be present in the hashed area. 1437 5.2.3.5. Issuer 1439 (8-octet Key ID) 1441 The OpenPGP Key ID of the key issuing the signature. If the version 1442 of that key is greater than 4, this subpacket MUST NOT be included in 1443 the signature. 1445 5.2.3.6. Key Expiration Time 1447 (4-octet time field) 1449 The validity period of the key. This is the number of seconds after 1450 the key creation time that the key expires. If this is not present 1451 or has a value of zero, the key never expires. This is found only on 1452 a self-signature. 1454 5.2.3.7. Preferred Symmetric Algorithms 1456 (array of one-octet values) 1458 Symmetric algorithm numbers that indicate which algorithms the key 1459 holder prefers to use. The subpacket body is an ordered list of 1460 octets with the most preferred listed first. It is assumed that only 1461 algorithms listed are supported by the recipient's software. 1462 Algorithm numbers are in Section 9. This is only found on a self- 1463 signature. 1465 5.2.3.8. Preferred AEAD Algorithms 1467 (array of one-octet values) 1469 AEAD algorithm numbers that indicate which AEAD algorithms the key 1470 holder prefers to use. The subpacket body is an ordered list of 1471 octets with the most preferred listed first. It is assumed that only 1472 algorithms listed are supported by the recipient's software. 1473 Algorithm numbers are in Section 9.6. This is only found on a self- 1474 signature. Note that support for the AEAD Encrypted Data packet in 1475 the general is indicated by a Feature Flag. 1477 5.2.3.9. Preferred Hash Algorithms 1479 (array of one-octet values) 1481 Message digest algorithm numbers that indicate which algorithms the 1482 key holder prefers to receive. Like the preferred symmetric 1483 algorithms, the list is ordered. Algorithm numbers are in 1484 Section 9.5. This is only found on a self-signature. 1486 5.2.3.10. Preferred Compression Algorithms 1488 (array of one-octet values) 1490 Compression algorithm numbers that indicate which algorithms the key 1491 holder prefers to use. Like the preferred symmetric algorithms, the 1492 list is ordered. Algorithm numbers are in Section 9.4. If this 1493 subpacket is not included, ZIP is preferred. A zero denotes that 1494 uncompressed data is preferred; the key holder's software might have 1495 no compression software in that implementation. This is only found 1496 on a self-signature. 1498 5.2.3.11. Signature Expiration Time 1500 (4-octet time field) 1502 The validity period of the signature. This is the number of seconds 1503 after the signature creation time that the signature expires. If 1504 this is not present or has a value of zero, it never expires. 1506 5.2.3.12. Exportable Certification 1508 (1 octet of exportability, 0 for not, 1 for exportable) 1510 This subpacket denotes whether a certification signature is 1511 "exportable", to be used by other users than the signature's issuer. 1512 The packet body contains a Boolean flag indicating whether the 1513 signature is exportable. If this packet is not present, the 1514 certification is exportable; it is equivalent to a flag containing a 1515 1. 1517 Non-exportable, or "local", certifications are signatures made by a 1518 user to mark a key as valid within that user's implementation only. 1520 Thus, when an implementation prepares a user's copy of a key for 1521 transport to another user (this is the process of "exporting" the 1522 key), any local certification signatures are deleted from the key. 1524 The receiver of a transported key "imports" it, and likewise trims 1525 any local certifications. In normal operation, there won't be any, 1526 assuming the import is performed on an exported key. However, there 1527 are instances where this can reasonably happen. For example, if an 1528 implementation allows keys to be imported from a key database in 1529 addition to an exported key, then this situation can arise. 1531 Some implementations do not represent the interest of a single user 1532 (for example, a key server). Such implementations always trim local 1533 certifications from any key they handle. 1535 5.2.3.13. Revocable 1537 (1 octet of revocability, 0 for not, 1 for revocable) 1539 Signature's revocability status. The packet body contains a Boolean 1540 flag indicating whether the signature is revocable. Signatures that 1541 are not revocable have any later revocation signatures ignored. They 1542 represent a commitment by the signer that he cannot revoke his 1543 signature for the life of his key. If this packet is not present, 1544 the signature is revocable. 1546 5.2.3.14. Trust Signature 1548 (1 octet "level" (depth), 1 octet of trust amount) 1550 Signer asserts that the key is not only valid but also trustworthy at 1551 the specified level. Level 0 has the same meaning as an ordinary 1552 validity signature. Level 1 means that the signed key is asserted to 1553 be a valid trusted introducer, with the 2nd octet of the body 1554 specifying the degree of trust. Level 2 means that the signed key is 1555 asserted to be trusted to issue level 1 trust signatures, i.e., that 1556 it is a "meta introducer". Generally, a level n trust signature 1557 asserts that a key is trusted to issue level n-1 trust signatures. 1558 The trust amount is in a range from 0-255, interpreted such that 1559 values less than 120 indicate partial trust and values of 120 or 1560 greater indicate complete trust. Implementations SHOULD emit values 1561 of 60 for partial trust and 120 for complete trust. 1563 5.2.3.15. Regular Expression 1565 (null-terminated regular expression) 1567 Used in conjunction with trust Signature packets (of level > 0) to 1568 limit the scope of trust that is extended. Only signatures by the 1569 target key on User IDs that match the regular expression in the body 1570 of this packet have trust extended by the trust Signature subpacket. 1571 The regular expression uses the same syntax as the Henry Spencer's 1572 "almost public domain" regular expression [REGEX] package. A 1573 description of the syntax is found in Section 8 below. 1575 5.2.3.16. Revocation Key 1577 (1 octet of class, 1 octet of public-key algorithm ID, 20 or 32 1578 octets of fingerprint) 1580 V4 keys use the full 20 octet fingerprint; V5 keys use the full 32 1581 octet fingerprint 1583 Authorizes the specified key to issue revocation signatures for this 1584 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1585 then this means that the revocation information is sensitive. Other 1586 bits are for future expansion to other kinds of authorizations. This 1587 is only found on a direct-key self-signature (type 0x1f). The use on 1588 other types of self-signatures is unspecified. 1590 If the "sensitive" flag is set, the keyholder feels this subpacket 1591 contains private trust information that describes a real-world 1592 sensitive relationship. If this flag is set, implementations SHOULD 1593 NOT export this signature to other users except in cases where the 1594 data needs to be available: when the signature is being sent to the 1595 designated revoker, or when it is accompanied by a revocation 1596 signature from that revoker. Note that it may be appropriate to 1597 isolate this subpacket within a separate signature so that it is not 1598 combined with other subpackets that need to be exported. 1600 5.2.3.17. Notation Data 1602 (4 octets of flags, 2 octets of name length (M), 1603 2 octets of value length (N), 1604 M octets of name data, 1605 N octets of value data) 1607 This subpacket describes a "notation" on the signature that the 1608 issuer wishes to make. The notation has a name and a value, each of 1609 which are strings of octets. There may be more than one notation in 1610 a signature. Notations can be used for any extension the issuer of 1611 the signature cares to make. The "flags" field holds four octets of 1612 flags. 1614 All undefined flags MUST be zero. Defined flags are as follows: 1616 First octet: 0x80 = human-readable. This note value is text. 1617 Other octets: none. 1619 Notation names are arbitrary strings encoded in UTF-8. They reside 1620 in two namespaces: The IETF namespace and the user namespace. 1622 The IETF namespace is registered with IANA. These names MUST NOT 1623 contain the "@" character (0x40). This is a tag for the user 1624 namespace. 1626 Names in the user namespace consist of a UTF-8 string tag followed by 1627 "@" followed by a DNS domain name. Note that the tag MUST NOT 1628 contain an "@" character. For example, the "sample" tag used by 1629 Example Corporation could be "sample@example.com". 1631 Names in a user space are owned and controlled by the owners of that 1632 domain. Obviously, it's bad form to create a new name in a DNS space 1633 that you don't own. 1635 Since the user namespace is in the form of an email address, 1636 implementers MAY wish to arrange for that address to reach a person 1637 who can be consulted about the use of the named tag. Note that due 1638 to UTF-8 encoding, not all valid user space name tags are valid email 1639 addresses. 1641 If there is a critical notation, the criticality applies to that 1642 specific notation and not to notations in general. 1644 The following subsections define a set of standard notations. 1646 5.2.3.17.1. The 'charset' Notation 1648 The "charset" notation is a description of the character set used to 1649 encode the signed plaintext. The default value is "UTF-8". If used, 1650 the value MUST be encoded as human readable and MUST be present in 1651 the hashed subpacket section of the signature. This notation is 1652 useful for cleartext signatures in cases where it is not possible to 1653 encode the text in UTF-8. By having the used character set a part of 1654 the signed data, attacks exploiting different representation of code 1655 points will be mitigated. 1657 5.2.3.17.2. The 'manu' Notation 1659 The "manu" notation is a string that declares the device 1660 manufacturer's name. The certifier key is asserting this string 1661 (which may or may not be related to the User ID of the certifier's 1662 key). 1664 5.2.3.17.3. The 'make' Notation 1666 This notation defines the product make. It is a free form string. 1668 5.2.3.17.4. The 'model' Notation 1670 This notation defines the product model name/number. It is a free 1671 form string. 1673 5.2.3.17.5. The 'prodid' Notation 1675 This notation contains the product identifier. It is a free form 1676 string. 1678 5.2.3.17.6. The 'pvers' Notation 1680 This notation defines the product version number (which could be a 1681 release number, year, or some other identifier to differentiate 1682 different versions of the same make/model). It is a free form 1683 string. 1685 5.2.3.17.7. The 'lot' Notation 1687 This notation defines the product lot number (which is an indicator 1688 of the batch of product). It is a free form string. 1690 5.2.3.17.8. The 'qty' Notation 1692 This notation defines the quantity of items in this package. It is a 1693 decimal integer representation with no punctuation, e.g. "10", 1694 "1000", "10000", etc. 1696 5.2.3.17.9. The 'loc' and 'dest' Notations 1698 The "loc" and 'dest' notations declare a GeoLocation as defined by 1699 RFC 5870 [RFC5870] but without the leading "geo:" header. For 1700 example, if you had a GeoLocation URI of "geo:13.4125,103.8667" you 1701 would encode that in these notations as "13.4125,103.8667". 1703 The 'loc' notation is meant to encode the geo location where the 1704 signature was made. The 'dest' notation is meant to encode the geo 1705 location where the device is "destined" (i.e., a "destination" for 1706 the device). 1708 5.2.3.17.10. The 'hash' Notation 1710 A 'hash' notation is a means to include external data in the contents 1711 of a signature without including the data itself. This is done by 1712 hashing the external data separately and then including the data's 1713 name and hash in the signature via this notation. This is useful, 1714 for example, to have an external "manifest," "image," or other data 1715 that might not be vital to the signature itself but still needs to be 1716 protected and authenticated without requiring a second signature. 1718 The 'hash' notation has the following structure: * A single byte 1719 specifying the length of the name of the hashed data * A UTF-8 string 1720 of the name of the hashed data * A single byte specifying the hash 1721 algorithm (see section 9.4) * The binary hash output of the hashed 1722 data using the specified algorithm. (The length of this data is 1723 implicit based on the algorithm specified). 1725 Due to its nature a 'hash' notation is not human readable and MUST 1726 NOT be marked as such when used. 1728 5.2.3.18. Key Server Preferences 1730 (N octets of flags) 1732 This is a list of one-bit flags that indicate preferences that the 1733 key holder has about how the key is handled on a key server. All 1734 undefined flags MUST be zero. 1736 First octet: 0x80 = No-modify 1738 The key holder requests that this key only be modified or updated 1739 by the key holder or an administrator of the key server. 1741 If No-modify is set on the most recent self-sig over a User ID, 1742 then a keyserver should only redistribute those third-party 1743 certifications over that User ID that have been attested to in the 1744 most recent Attestation Key Signature packet (see "Attested 1745 Certifications" below). 1747 This is found only on a self-signature. 1749 5.2.3.19. Preferred Key Server 1751 (String) 1753 This is a URI of a key server that the key holder prefers be used for 1754 updates. Note that keys with multiple User IDs can have a preferred 1755 key server for each User ID. Note also that since this is a URI, the 1756 key server can actually be a copy of the key retrieved by ftp, http, 1757 finger, etc. 1759 5.2.3.20. Primary User ID 1761 (1 octet, Boolean) 1763 This is a flag in a User ID's self-signature that states whether this 1764 User ID is the main User ID for this key. It is reasonable for an 1765 implementation to resolve ambiguities in preferences, etc. by 1766 referring to the primary User ID. If this flag is absent, its value 1767 is zero. If more than one User ID in a key is marked as primary, the 1768 implementation may resolve the ambiguity in any way it sees fit, but 1769 it is RECOMMENDED that priority be given to the User ID with the most 1770 recent self-signature. 1772 When appearing on a self-signature on a User ID packet, this 1773 subpacket applies only to User ID packets. When appearing on a self- 1774 signature on a User Attribute packet, this subpacket applies only to 1775 User Attribute packets. That is to say, there are two different and 1776 independent "primaries" -- one for User IDs, and one for User 1777 Attributes. 1779 5.2.3.21. Policy URI 1781 (String) 1783 This subpacket contains a URI of a document that describes the policy 1784 under which the signature was issued. 1786 5.2.3.22. Key Flags 1788 (N octets of flags) 1790 This subpacket contains a list of binary flags that hold information 1791 about a key. It is a string of octets, and an implementation MUST 1792 NOT assume a fixed size. This is so it can grow over time. If a 1793 list is shorter than an implementation expects, the unstated flags 1794 are considered to be zero. The defined flags are as follows: 1796 First octet: 1798 0x01 - This key may be used to certify other keys. 1800 0x02 - This key may be used to sign data. 1802 0x04 - This key may be used to encrypt communications. 1804 0x08 - This key may be used to encrypt storage. 1806 0x10 - The private component of this key may have been split by a 1807 secret-sharing mechanism. 1809 0x20 - This key may be used for authentication. 1811 0x80 - The private component of this key may be in the possession 1812 of more than one person. 1814 Second octet: 1816 0x04 - This key may be used as an additional decryption subkey (ADSK). 1818 0x08 - This key may be used for timestamping. 1820 Usage notes: 1822 The flags in this packet may appear in self-signatures or in 1823 certification signatures. They mean different things depending on 1824 who is making the statement -- for example, a certification signature 1825 that has the "sign data" flag is stating that the certification is 1826 for that use. On the other hand, the "communications encryption" 1827 flag in a self-signature is stating a preference that a given key be 1828 used for communications. Note however, that it is a thorny issue to 1829 determine what is "communications" and what is "storage". This 1830 decision is left wholly up to the implementation; the authors of this 1831 document do not claim any special wisdom on the issue and realize 1832 that accepted opinion may change. 1834 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1835 self-signature only; they are meaningless on a certification 1836 signature. They SHOULD be placed only on a direct-key signature 1837 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1838 key the flag applies to. 1840 The ADSK flag helps to figure out an encryption subkey. 1842 5.2.3.23. Signer's User ID 1844 (String) 1846 This subpacket allows a keyholder to state which User ID is 1847 responsible for the signing. Many keyholders use a single key for 1848 different purposes, such as business communications as well as 1849 personal communications. This subpacket allows such a keyholder to 1850 state which of their roles is making a signature. 1852 This subpacket is not appropriate to use to refer to a User Attribute 1853 packet. 1855 5.2.3.24. Reason for Revocation 1857 (1 octet of revocation code, N octets of reason string) 1859 This subpacket is used only in key revocation and certification 1860 revocation signatures. It describes the reason why the key or 1861 certificate was revoked. 1863 The first octet contains a machine-readable code that denotes the 1864 reason for the revocation: 1866 +---------+----------------------------------+ 1867 | Code | Reason | 1868 +=========+==================================+ 1869 | 0 | No reason specified (key | 1870 | | revocations or cert revocations) | 1871 +---------+----------------------------------+ 1872 | 1 | Key is superseded (key | 1873 | | revocations) | 1874 +---------+----------------------------------+ 1875 | 2 | Key material has been | 1876 | | compromised (key revocations) | 1877 +---------+----------------------------------+ 1878 | 3 | Key is retired and no longer | 1879 | | used (key revocations) | 1880 +---------+----------------------------------+ 1881 | 32 | User ID information is no longer | 1882 | | valid (cert revocations) | 1883 +---------+----------------------------------+ 1884 | 100-110 | Private Use | 1885 +---------+----------------------------------+ 1887 Table 4 1889 Following the revocation code is a string of octets that gives 1890 information about the Reason for Revocation in human-readable form 1891 (UTF-8). The string may be null, that is, of zero length. The 1892 length of the subpacket is the length of the reason string plus one. 1893 An implementation SHOULD implement this subpacket, include it in all 1894 revocation signatures, and interpret revocations appropriately. 1895 There are important semantic differences between the reasons, and 1896 there are thus important reasons for revoking signatures. 1898 If a key has been revoked because of a compromise, all signatures 1899 created by that key are suspect. However, if it was merely 1900 superseded or retired, old signatures are still valid. If the 1901 revoked signature is the self-signature for certifying a User ID, a 1902 revocation denotes that that user name is no longer in use. Such a 1903 revocation SHOULD include a 0x20 code. 1905 Note that any signature may be revoked, including a certification on 1906 some other person's key. There are many good reasons for revoking a 1907 certification signature, such as the case where the keyholder leaves 1908 the employ of a business with an email address. A revoked 1909 certification is no longer a part of validity calculations. 1911 5.2.3.25. Features 1913 (N octets of flags) 1915 The Features subpacket denotes which advanced OpenPGP features a 1916 user's implementation supports. This is so that as features are 1917 added to OpenPGP that cannot be backwards-compatible, a user can 1918 state that they can use that feature. The flags are single bits that 1919 indicate that a given feature is supported. 1921 This subpacket is similar to a preferences subpacket, and only 1922 appears in a self-signature. 1924 An implementation SHOULD NOT use a feature listed when sending to a 1925 user who does not state that they can use it. 1927 Defined features are as follows: 1929 First octet: 1931 0x01 - Modification Detection (packets 18 and 19) 1933 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5 1934 Symmetric-Key Encrypted Session Key Packets (packet 3) 1936 0x04 - Version 5 Public-Key Packet format and corresponding new 1937 fingerprint format 1939 If an implementation implements any of the defined features, it 1940 SHOULD implement the Features subpacket, too. 1942 An implementation may freely infer features from other suitable 1943 implementation-dependent mechanisms. 1945 5.2.3.26. Signature Target 1947 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1949 This subpacket identifies a specific target signature to which a 1950 signature refers. For revocation signatures, this subpacket provides 1951 explicit designation of which signature is being revoked. For a 1952 third-party or timestamp signature, this designates what signature is 1953 signed. All arguments are an identifier of that target signature. 1955 The N octets of hash data MUST be the size of the hash of the 1956 signature. For example, a target signature with a SHA-1 hash MUST 1957 have 20 octets of hash data. 1959 5.2.3.27. Embedded Signature 1961 (1 signature packet body) 1963 This subpacket contains a complete Signature packet body as specified 1964 in Section 5.2 above. It is useful when one signature needs to refer 1965 to, or be incorporated in, another signature. 1967 5.2.3.28. Issuer Fingerprint 1969 (1 octet key version number, N octets of fingerprint) 1971 The OpenPGP Key fingerprint of the key issuing the signature. This 1972 subpacket SHOULD be included in all signatures. If the version of 1973 the issuing key is 4 and an Issuer subpacket is also included in the 1974 signature, the key ID of the Issuer subpacket MUST match the low 64 1975 bits of the fingerprint. 1977 Note that the length N of the fingerprint for a version 4 key is 20 1978 octets; for a version 5 key N is 32. 1980 5.2.3.29. Intended Recipient Fingerprint 1982 (1 octet key version number, N octets of fingerprint) 1984 The OpenPGP Key fingerprint of the intended recipient primary key. 1985 If one or more subpackets of this type are included in a signature, 1986 it SHOULD be considered valid only in an encrypted context, where the 1987 key it was encrypted to is one of the indicated primary keys, or one 1988 of their subkeys. This can be used to prevent forwarding a signature 1989 outside of its intended, encrypted context. 1991 Note that the length N of the fingerprint for a version 4 key is 20 1992 octets; for a version 5 key N is 32. 1994 5.2.3.30. Attested Certifications 1996 (N octets of certification digests) 1998 This subpacket MUST only appear as a hashed subpacket of an 1999 Attestation Key Signature. It has no meaning in any other signature 2000 type. It is used by the primary key to attest to a set of third- 2001 party certifications over the associated User ID or User Attribute. 2002 This enables the holder of an OpenPGP primary key to mark specific 2003 third-party certifications as re-distributable with the rest of the 2004 Transferable Public Key (see the "No-modify" flag in "Key Server 2005 Preferences", above). Implementations MUST include exactly one 2006 Attested Certification subpacket in any generated Attestation Key 2007 Signature. 2009 The contents of the subpacket consists of a series of digests using 2010 the same hash algorithm used by the signature itself. Each digest is 2011 made over one third-party signature (any Certification, i.e., 2012 signature type 0x10-0x13) that covers the same Primary Key and User 2013 ID (or User Attribute). For example, an Attestation Key Signature 2014 made by key X over User ID U using hash algorithm SHA256 might 2015 contain an Attested Certifications subpacket of 192 octets (6*32 2016 octets) covering six third-party certification Signatures over . 2017 They SHOULD be ordered by binary hash value from low to high (e.g., a 2018 hash with hexadecimal value 037a... precedes a hash with value 2019 0392..., etc). The length of this subpacket MUST be an integer 2020 multiple of the length of the hash algorithm used for the enclosing 2021 Attestation Key Signature. 2023 The listed digests MUST be calculated over the third-party 2024 certification's Signature packet as described in the "Computing 2025 Signatures" section, but without a trailer: the hash data starts with 2026 the octet 0x88, followed by the four-octet length of the Signature, 2027 and then the body of the Signature packet. (Note that this is an 2028 old-style packet header for a Signature packet with the length-of- 2029 length field set to zero.) The unhashed subpacket data of the 2030 Signature packet being hashed is not included in the hash, and the 2031 unhashed subpacket data length value is set to zero. 2033 If an implementation encounters more than one such subpacket in an 2034 Attestation Key Signature, it MUST treat it as a single Attested 2035 Certifications subpacket containing the union of all hashes. 2037 The Attested Certifications subpacket in the most recent Attestation 2038 Key Signature over a given User ID supersedes all Attested 2039 Certifications subpackets from any previous Attestation Key 2040 Signature. However, note that if more than one Attestation Key 2041 Signatures has the same (most recent) Signature Creation Time 2042 subpacket, implementations MUST consider the union of the 2043 attestations of all Attestation Key Signatures (this allows the 2044 keyholder to attest to more third-party certifications than could fit 2045 in a single Attestation Key Signature). 2047 If a keyholder Alice has already attested to third-party 2048 certifications from Bob and Carol and she wants to add an attestation 2049 to a certification from David, she should issue a new Attestation Key 2050 Signature (with a more recent Signature Creation timestamp) that 2051 contains an Attested Certifications subpacket covering all three 2052 third-party certifications. 2054 If she later decides that she does not want Carol's certification to 2055 be redistributed with her certificate, she can issue a new 2056 Attestation Key Signature (again, with a more recent Signature 2057 Creation timestamp) that contains an Attested Certifications 2058 subpacket covering only the certifications from Bob and David. 2060 Note that Certification Revocation Signatures are not relevant for 2061 Attestation Key Signatures. To rescind all attestations, the primary 2062 key holder needs only to publish a more recent Attestation Key 2063 Signature with an empty Attested Certifications subpacket. 2065 5.2.3.31. Key Block 2067 (1 octet with value 0, N octets of key data) 2069 This subpacket MAY be used to convey key data along with a signature 2070 of class 0x00, 0x01, or 0x02. It MUST contain the key used to create 2071 the signature; either as the primary key or as a subkey. The key 2072 SHOULD contain a primary or subkey capable of encryption and the 2073 entire key must be a valid OpenPGP key including at least one User ID 2074 packet and the corresponding self-signatures. 2076 Implementations MUST ignore this subpacket if the first octet does 2077 not have a value of zero or if the key data does not represent a 2078 valid transferable public key. 2080 5.2.4. Computing Signatures 2082 All signatures are formed by producing a hash over the signature 2083 data, and then using the resulting hash in the signature algorithm. 2085 For binary document signatures (type 0x00), the document data is 2086 hashed directly. For text document signatures (type 0x01), the 2087 document is canonicalized by converting line endings to , and 2088 the resulting data is hashed. 2090 When a V4 signature is made over a key, the hash data starts with the 2091 octet 0x99, followed by a two-octet length of the key, and then body 2092 of the key packet; when a V5 signature is made over a key, the hash 2093 data starts with the octet 0x9a, followed by a four-octet length of 2094 the key, and then body of the key packet. A subkey binding signature 2095 (type 0x18) or primary key binding signature (type 0x19) then hashes 2096 the subkey using the same format as the main key (also using 0x99 or 2097 0x9a as the first octet). Primary key revocation signatures (type 2098 0x20) hash only the key being revoked. Subkey revocation signature 2099 (type 0x28) hash first the primary key and then the subkey being 2100 revoked. 2102 A certification signature (type 0x10 through 0x13) hashes the User ID 2103 being bound to the key into the hash context after the above data. A 2104 V3 certification hashes the contents of the User ID or attribute 2105 packet packet, without any header. A V4 or V5 certification hashes 2106 the constant 0xB4 for User ID certifications or the constant 0xD1 for 2107 User Attribute certifications, followed by a four-octet number giving 2108 the length of the User ID or User Attribute data, and then the User 2109 ID or User Attribute data. 2111 An Attestation Key Signature (0x16) hashes the same data body that a 2112 standard certification signature does: primary key, followed by User 2113 ID or User Attribute. 2115 When a signature is made over a Signature packet (type 0x50, "Third- 2116 Party Confirmation signature"), the hash data starts with the octet 2117 0x88, followed by the four-octet length of the signature, and then 2118 the body of the Signature packet. (Note that this is an old-style 2119 packet header for a Signature packet with the length-of-length field 2120 set to zero.) The unhashed subpacket data of the Signature packet 2121 being hashed is not included in the hash, and the unhashed subpacket 2122 data length value is set to zero. 2124 Once the data body is hashed, then a trailer is hashed. This trailer 2125 depends on the version of the signature. 2127 * A V3 signature hashes five octets of the packet body, starting 2128 from the signature type field. This data is the signature type, 2129 followed by the four-octet signature time. 2131 * A V4 signature hashes the packet body starting from its first 2132 field, the version number, through the end of the hashed subpacket 2133 data and a final extra trailer. Thus, the hashed fields are: 2135 - the signature version (0x04), 2137 - the signature type, 2139 - the public-key algorithm, 2141 - the hash algorithm, 2143 - the hashed subpacket length, 2145 - the hashed subpacket body, 2147 - the two octets 0x04 and 0xFF, 2149 - a four-octet big-endian number that is the length of the hashed 2150 data from the Signature packet stopping right before the 0x04, 2151 0xff octets. 2153 The four-octet big-endian number is considered to be an 2154 unsigned integer modulo 2^32. 2156 * A V5 signature hashes the packet body starting from its first 2157 field, the version number, through the end of the hashed subpacket 2158 data and a final extra trailer. Thus, the hashed fields are: 2160 - the signature version (0x05), 2162 - the signature type, 2164 - the public-key algorithm, 2166 - the hash algorithm, 2168 - the hashed subpacket length, 2170 - the hashed subpacket body, 2172 - Only for document signatures (type 0x00 or 0x01) the following 2173 three data items are hashed here: 2175 o the one-octet content format, 2177 o the file name as a string (one octet length, followed by the 2178 file name), 2180 o a four-octet number that indicates a date, 2182 - the two octets 0x05 and 0xFF, 2184 - a eight-octet big-endian number that is the length of the 2185 hashed data from the Signature packet stopping right before the 2186 0x05, 0xff octets. 2188 The three data items hashed for document signatures need to 2189 mirror the values of the Literal Data packet. For detached and 2190 cleartext signatures 6 zero bytes are hashed instead. 2192 After all this has been hashed in a single hash context, the 2193 resulting hash field is used in the signature algorithm and placed at 2194 the end of the Signature packet. 2196 5.2.4.1. Subpacket Hints 2198 It is certainly possible for a signature to contain conflicting 2199 information in subpackets. For example, a signature may contain 2200 multiple copies of a preference or multiple expiration times. In 2201 most cases, an implementation SHOULD use the last subpacket in the 2202 signature, but MAY use any conflict resolution scheme that makes more 2203 sense. Please note that we are intentionally leaving conflict 2204 resolution to the implementer; most conflicts are simply syntax 2205 errors, and the wishy-washy language here allows a receiver to be 2206 generous in what they accept, while putting pressure on a creator to 2207 be stingy in what they generate. 2209 Some apparent conflicts may actually make sense -- for example, 2210 suppose a keyholder has a V3 key and a V4 key that share the same RSA 2211 key material. Either of these keys can verify a signature created by 2212 the other, and it may be reasonable for a signature to contain an 2213 issuer subpacket for each key, as a way of explicitly tying those 2214 keys to the signature. 2216 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 2218 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 2219 key encryption of a session key used to encrypt a message. Zero or 2220 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 2221 Encrypted Session Key packets may precede a Symmetrically Encrypted 2222 Data packet that holds an encrypted message. The message is 2223 encrypted with a session key, and the session key is itself encrypted 2224 and stored in the Encrypted Session Key packet or the Symmetric-Key 2225 Encrypted Session Key packet. 2227 If the Symmetrically Encrypted Data packet is preceded by one or more 2228 Symmetric-Key Encrypted Session Key packets, each specifies a 2229 passphrase that may be used to decrypt the message. This allows a 2230 message to be encrypted to a number of public keys, and also to one 2231 or more passphrases. This packet type is new and is not generated by 2232 PGP 2 or PGP version 5.0. 2234 A version 4 Symmetric-Key Encrypted Session Key packet consists of: 2236 * A one-octet version number with value 4. 2238 * A one-octet number describing the symmetric algorithm used. 2240 * A string-to-key (S2K) specifier, length as defined above. 2242 * Optionally, the encrypted session key itself, which is decrypted 2243 with the string-to-key object. 2245 If the encrypted session key is not present (which can be detected on 2246 the basis of packet length and S2K specifier size), then the S2K 2247 algorithm applied to the passphrase produces the session key for 2248 decrypting the message, using the symmetric cipher algorithm from the 2249 Symmetric-Key Encrypted Session Key packet. 2251 If the encrypted session key is present, the result of applying the 2252 S2K algorithm to the passphrase is used to decrypt just that 2253 encrypted session key field, using CFB mode with an IV of all zeros. 2254 The decryption result consists of a one-octet algorithm identifier 2255 that specifies the symmetric-key encryption algorithm used to encrypt 2256 the following Symmetrically Encrypted Data packet, followed by the 2257 session key octets themselves. 2259 Note: because an all-zero IV is used for this decryption, the S2K 2260 specifier MUST use a salt value, either a Salted S2K or an Iterated- 2261 Salted S2K. The salt value will ensure that the decryption key is 2262 not repeated even if the passphrase is reused. 2264 A version 5 Symmetric-Key Encrypted Session Key packet consists of: 2266 * A one-octet version number with value 5. 2268 * A one-octet cipher algorithm. 2270 * A one-octet AEAD algorithm. 2272 * A string-to-key (S2K) specifier, length as defined above. 2274 * A starting initialization vector of size specified by the AEAD 2275 algorithm. 2277 * The encrypted session key itself, which is decrypted with the 2278 string-to-key object using the given cipher and AEAD mode. 2280 * An authentication tag for the AEAD mode. 2282 The encrypted session key is encrypted using one of the AEAD 2283 algorithms specified for the AEAD Encrypted Packet. Note that no 2284 chunks are used and that there is only one authentication tag. The 2285 Packet Tag in new format encoding (bits 7 and 6 set, bits 5-0 carry 2286 the packet tag), the packet version number, the cipher algorithm 2287 octet, and the AEAD algorithm octet are given as additional data. 2288 For example, the additional data used with EAX and AES-128 consists 2289 of the octets 0xC3, 0x05, 0x07, and 0x01. 2291 5.4. One-Pass Signature Packets (Tag 4) 2293 The One-Pass Signature packet precedes the signed data and contains 2294 enough information to allow the receiver to begin calculating any 2295 hashes needed to verify the signature. It allows the Signature 2296 packet to be placed at the end of the message, so that the signer can 2297 compute the entire signed message in one pass. 2299 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 2301 The body of this packet consists of: 2303 * A one-octet version number. The current version is 3. 2305 * A one-octet signature type. Signature types are described in 2306 Section 5.2.1. 2308 * A one-octet number describing the hash algorithm used. 2310 * A one-octet number describing the public-key algorithm used. 2312 * An eight-octet number holding the Key ID of the signing key. 2314 * A one-octet number holding a flag showing whether the signature is 2315 nested. A zero value indicates that the next packet is another 2316 One-Pass Signature packet that describes another signature to be 2317 applied to the same message data. 2319 Note that if a message contains more than one one-pass signature, 2320 then the Signature packets bracket the message; that is, the first 2321 Signature packet after the message corresponds to the last one-pass 2322 packet and the final Signature packet corresponds to the first one- 2323 pass packet. 2325 5.5. Key Material Packet 2327 A key material packet contains all the information about a public or 2328 private key. There are four variants of this packet type, and two 2329 major versions. Consequently, this section is complex. 2331 5.5.1. Key Packet Variants 2333 5.5.1.1. Public-Key Packet (Tag 6) 2335 A Public-Key packet starts a series of packets that forms an OpenPGP 2336 key (sometimes called an OpenPGP certificate). 2338 5.5.1.2. Public-Subkey Packet (Tag 14) 2340 A Public-Subkey packet (tag 14) has exactly the same format as a 2341 Public-Key packet, but denotes a subkey. One or more subkeys may be 2342 associated with a top-level key. By convention, the top-level key 2343 provides signature services, and the subkeys provide encryption 2344 services. 2346 Note: in PGP version 2.6, tag 14 was intended to indicate a comment 2347 packet. This tag was selected for reuse because no previous version 2348 of PGP ever emitted comment packets but they did properly ignore 2349 them. Public-Subkey packets are ignored by PGP version 2.6 and do 2350 not cause it to fail, providing a limited degree of backward 2351 compatibility. 2353 5.5.1.3. Secret-Key Packet (Tag 5) 2355 A Secret-Key packet contains all the information that is found in a 2356 Public-Key packet, including the public-key material, but also 2357 includes the secret-key material after all the public-key fields. 2359 5.5.1.4. Secret-Subkey Packet (Tag 7) 2361 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2362 packet and has exactly the same format. 2364 5.5.2. Public-Key Packet Formats 2366 There are three versions of key-material packets. Version 3 packets 2367 were first generated by PGP version 2.6. Version 4 keys first 2368 appeared in PGP 5 and are the preferred key version for OpenPGP. 2370 OpenPGP implementations MUST create keys with version 4 format. V3 2371 keys are deprecated; an implementation MUST NOT generate a V3 key, 2372 but MAY accept it. 2374 A version 3 public key or public-subkey packet contains: 2376 * A one-octet version number (3). 2378 * A four-octet number denoting the time that the key was created. 2380 * A two-octet number denoting the time in days that this key is 2381 valid. If this number is zero, then it does not expire. 2383 * A one-octet number denoting the public-key algorithm of this key. 2385 * A series of multiprecision integers comprising the key material: 2387 - a multiprecision integer (MPI) of RSA public modulus n; 2389 - an MPI of RSA public encryption exponent e. 2391 V3 keys are deprecated. They contain three weaknesses. First, it is 2392 relatively easy to construct a V3 key that has the same Key ID as any 2393 other key because the Key ID is simply the low 64 bits of the public 2394 modulus. Secondly, because the fingerprint of a V3 key hashes the 2395 key material, but not its length, there is an increased opportunity 2396 for fingerprint collisions. Third, there are weaknesses in the MD5 2397 hash algorithm that make developers prefer other algorithms. See 2398 below for a fuller discussion of Key IDs and fingerprints. 2400 V2 keys are identical to the deprecated V3 keys except for the 2401 version number. An implementation MUST NOT generate them and MAY 2402 accept or reject them as it sees fit. 2404 The version 4 format is similar to the version 3 format except for 2405 the absence of a validity period. This has been moved to the 2406 Signature packet. In addition, fingerprints of version 4 keys are 2407 calculated differently from version 3 keys, as described in the 2408 section "Enhanced Key Formats". 2410 A version 4 packet contains: 2412 * A one-octet version number (4). 2414 * A four-octet number denoting the time that the key was created. 2416 * A one-octet number denoting the public-key algorithm of this key. 2418 * A series of values comprising the key material. This is 2419 algorithm-specific and described in Section 5.6. 2421 The version 5 format is similar to the version 4 format except for 2422 the addition of a count for the key material. This count helps 2423 parsing secret key packets (which are an extension of the public key 2424 packet format) in the case of an unknown algoritm. In addition, 2425 fingerprints of version 5 keys are calculated differently from 2426 version 4 keys, as described in the section "Enhanced Key Formats". 2428 A version 5 packet contains: 2430 * A one-octet version number (5). 2432 * A four-octet number denoting the time that the key was created. 2434 * A one-octet number denoting the public-key algorithm of this key. 2436 * A four-octet scalar octet count for the following public key 2437 material. 2439 * A series of values comprising the public key material. This is 2440 algorithm-specific and described in Section 5.6. 2442 5.5.3. Secret-Key Packet Formats 2444 The Secret-Key and Secret-Subkey packets contain all the data of the 2445 Public-Key and Public-Subkey packets, with additional algorithm- 2446 specific secret-key data appended, usually in encrypted form. 2448 The packet contains: 2450 * A Public-Key or Public-Subkey packet, as described above. 2452 * One octet indicating string-to-key usage conventions. Zero 2453 indicates that the secret-key data is not encrypted. 255 or 254 2454 indicates that a string-to-key specifier is being given. Any 2455 other value is a symmetric-key encryption algorithm identifier. A 2456 version 5 packet MUST NOT use the value 255. 2458 * Only for a version 5 packet, a one-octet scalar octet count of the 2459 next 4 optional fields. 2461 * [Optional] If string-to-key usage octet was 255, 254, or 253, a 2462 one-octet symmetric encryption algorithm. 2464 * [Optional] If string-to-key usage octet was 253, a one-octet AEAD 2465 algorithm. 2467 * [Optional] If string-to-key usage octet was 255, 254, or 253, a 2468 string-to-key specifier. The length of the string-to-key 2469 specifier is implied by its type, as described above. 2471 * [Optional] If secret data is encrypted (string-to-key usage octet 2472 not zero), an Initial Vector (IV) of the same length as the 2473 cipher's block size. If string-to-key usage octet was 253 the IV 2474 is used as the nonce for the AEAD algorithm. If the AEAD 2475 algorithm requires a shorter nonce, the high-order bits of the IV 2476 are used and the remaining bits MUST be zero. 2478 * Only for a version 5 packet, a four-octet scalar octet count for 2479 the following secret key material. This includes the encrypted 2480 SHA-1 hash or AEAD tag if the string-to-key usage octet is 254 or 2481 253. 2483 * Plain or encrypted series of values comprising the secret key 2484 material. This is algorithm-specific and described in section 2485 Section 5.6. Note that if the string-to-key usage octet is 254, a 2486 20-octet SHA-1 hash of the plaintext of the algorithm-specific 2487 portion is appended to plaintext and encrypted with it. If the 2488 string-to-key usage octet is 253, then an AEAD authentication tag 2489 is part of that data. 2491 * If the string-to-key usage octet is zero or 255, then a two-octet 2492 checksum of the plaintext of the algorithm-specific portion (sum 2493 of all octets, mod 65536). 2495 Note that the version 5 packet format adds two count values to help 2496 parsing packets with unknown S2K or public key algorithms. 2498 Secret MPI values can be encrypted using a passphrase. If a string- 2499 to-key specifier is given, that describes the algorithm for 2500 converting the passphrase to a key, else a simple MD5 hash of the 2501 passphrase is used. Implementations MUST use a string-to-key 2502 specifier; the simple hash is for backward compatibility and is 2503 deprecated, though implementations MAY continue to use existing 2504 private keys in the old format. The cipher for encrypting the MPIs 2505 is specified in the Secret-Key packet. 2507 Encryption/decryption of the secret data is done in CFB mode using 2508 the key created from the passphrase and the Initial Vector from the 2509 packet. A different mode is used with V3 keys (which are only RSA) 2510 than with other key formats. With V3 keys, the MPI bit count prefix 2511 (i.e., the first two octets) is not encrypted. Only the MPI non- 2512 prefix data is encrypted. Furthermore, the CFB state is 2513 resynchronized at the beginning of each new MPI value, so that the 2514 CFB block boundary is aligned with the start of the MPI data. 2516 With V4 and V5 keys, a simpler method is used. All secret MPI values 2517 are encrypted, including the MPI bitcount prefix. 2519 If the string-to-key usage octet is 253, the encrypted MPI values are 2520 encrypted as one combined plaintext using one of the AEAD algorithms 2521 specified for the AEAD Encrypted Packet. Note that no chunks are 2522 used and that there is only one authentication tag. The Packet Tag 2523 in new format encoding (bits 7 and 6 set, bits 5-0 carry the packet 2524 tag), the packet version number, the cipher algorithm octet, and the 2525 AEAD algorithm octet are given as additional data. For example, the 2526 additional data used with EAX and AES-128 in a Secret-Key Packet of 2527 version 4 consists of the octets 0xC5, 0x04, 0x07, and 0x01; in a 2528 Secret-Subkey Packet the first octet would be 0xC7. 2530 The two-octet checksum that follows the algorithm-specific portion is 2531 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2532 specific octets (including MPI prefix and data). With V3 keys, the 2533 checksum is stored in the clear. With V4 keys, the checksum is 2534 encrypted like the algorithm-specific data. This value is used to 2535 check that the passphrase was correct. However, this checksum is 2536 deprecated; an implementation SHOULD NOT use it, but should rather 2537 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2538 this is that there are some attacks that involve undetectably 2539 modifying the secret key. If the string-to-key usage octet is 253 no 2540 checksum or SHA-1 hash is used but the authentication tag of the AEAD 2541 algorithm follows. 2543 5.6. Algorithm-specific Parts of Keys 2545 The public and secret key format specifies algorithm-specific parts 2546 of a key. The following sections describe them in detail. 2548 5.6.1. Algorithm-Specific Part for RSA Keys 2550 The public key is this series of multiprecision integers: 2552 * MPI of RSA public modulus n; 2554 * MPI of RSA public encryption exponent e. 2556 The secret key is this series of multiprecision integers: 2558 * MPI of RSA secret exponent d; 2560 * MPI of RSA secret prime value p; 2562 * MPI of RSA secret prime value q (p < q); 2564 * MPI of u, the multiplicative inverse of p, mod q. 2566 5.6.2. Algorithm-Specific Part for DSA Keys 2568 The public key is this series of multiprecision integers: 2570 * MPI of DSA prime p; 2572 * MPI of DSA group order q (q is a prime divisor of p-1); 2574 * MPI of DSA group generator g; 2576 * MPI of DSA public-key value y (= g**x mod p where x is secret). 2578 The secret key is this single multiprecision integer: 2580 * MPI of DSA secret exponent x. 2582 5.6.3. Algorithm-Specific Part for Elgamal Keys 2584 The public key is this series of multiprecision integers: 2586 * MPI of Elgamal prime p; 2588 * MPI of Elgamal group generator g; 2590 * MPI of Elgamal public key value y (= g**x mod p where x is 2591 secret). 2593 The secret key is this single multiprecision integer: 2595 * MPI of Elgamal secret exponent x. 2597 5.6.4. Algorithm-Specific Part for ECDSA Keys 2599 The public key is this series of values: 2601 * a variable-length field containing a curve OID, formatted as 2602 follows: 2604 - a one-octet size of the following field; values 0 and 0xFF are 2605 reserved for future extensions, 2607 - the octets representing a curve OID, defined in Section 9.2; 2609 * a MPI of an EC point representing a public key. 2611 The secret key is this single multiprecision integer: 2613 * MPI of an integer representing the secret key, which is a scalar 2614 of the public EC point. 2616 5.6.5. Algorithm-Specific Part for EdDSA Keys 2618 The public key is this series of values: 2620 * a variable-length field containing a curve OID, formatted as 2621 follows: 2623 - a one-octet size of the following field; values 0 and 0xFF are 2624 reserved for future extensions, 2626 - the octets representing a curve OID, defined in Section 9.2; 2628 * a MPI of an EC point representing a public key Q as described 2629 under EdDSA Point Format below. 2631 The secret key is this single multiprecision integer: 2633 * MPI of an integer representing the secret key, which is a scalar 2634 of the public EC point. 2636 5.6.6. Algorithm-Specific Part for ECDH Keys 2638 The public key is this series of values: 2640 * a variable-length field containing a curve OID, formatted as 2641 follows: 2643 - a one-octet size of the following field; values 0 and 0xFF are 2644 reserved for future extensions, 2646 - the octets representing a curve OID, defined in Section 9.2; 2648 * a MPI of an EC point representing a public key; 2650 * a variable-length field containing KDF parameters, formatted as 2651 follows: 2653 - a one-octet size of the following fields; values 0 and 0xff are 2654 reserved for future extensions; 2656 - a one-octet value 1, reserved for future extensions; 2658 - a one-octet hash function ID used with a KDF; 2660 - a one-octet algorithm ID for the symmetric algorithm used to 2661 wrap the symmetric key used for the message encryption; see 2662 Section 13.5 for details. 2664 Observe that an ECDH public key is composed of the same sequence of 2665 fields that define an ECDSA key, plus the KDF parameters field. 2667 The secret key is this single multiprecision integer: 2669 * MPI of an integer representing the secret key, which is a scalar 2670 of the public EC point. 2672 5.7. Compressed Data Packet (Tag 8) 2674 The Compressed Data packet contains compressed data. Typically, this 2675 packet is found as the contents of an encrypted packet, or following 2676 a Signature or One-Pass Signature packet, and contains a literal data 2677 packet. 2679 The body of this packet consists of: 2681 * One octet that gives the algorithm used to compress the packet. 2683 * Compressed data, which makes up the remainder of the packet. 2685 A Compressed Data Packet's body contains an block that compresses 2686 some set of packets. See section "Packet Composition" for details on 2687 how messages are formed. 2689 ZIP-compressed packets are compressed with raw RFC 1951 [RFC1951] 2690 DEFLATE blocks. Note that PGP V2.6 uses 13 bits of compression. If 2691 an implementation uses more bits of compression, PGP V2.6 cannot 2692 decompress it. 2694 ZLIB-compressed packets are compressed with RFC 1950 [RFC1950] ZLIB- 2695 style blocks. 2697 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2698 algorithm. 2700 5.8. Symmetrically Encrypted Data Packet (Tag 9) 2702 The Symmetrically Encrypted Data packet contains data encrypted with 2703 a symmetric-key algorithm. When it has been decrypted, it contains 2704 other packets (usually a literal data packet or compressed data 2705 packet, but in theory other Symmetrically Encrypted Data packets or 2706 sequences of packets that form whole OpenPGP messages). 2708 This packet is obsolete. An implementation MUST NOT create this 2709 packet. An implementation MAY process such a packet but it MUST 2710 return a clear diagnostic that a non-integrity protected packet has 2711 been processed. The implementation SHOULD also return an error in 2712 this case and stop processing. 2714 The body of this packet consists of: 2716 * Encrypted data, the output of the selected symmetric-key cipher 2717 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2719 The symmetric cipher used may be specified in a Public-Key or 2720 Symmetric-Key Encrypted Session Key packet that precedes the 2721 Symmetrically Encrypted Data packet. In that case, the cipher 2722 algorithm octet is prefixed to the session key before it is 2723 encrypted. If no packets of these types precede the encrypted data, 2724 the IDEA algorithm is used with the session key calculated as the MD5 2725 hash of the passphrase, though this use is deprecated. 2727 The data is encrypted in CFB mode, with a CFB shift size equal to the 2728 cipher's block size. The Initial Vector (IV) is specified as all 2729 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2730 equal to the block size of the cipher plus two to the data before it 2731 is encrypted. The first block-size octets (for example, 8 octets for 2732 a 64-bit block length) are random, and the following two octets are 2733 copies of the last two octets of the IV. For example, in an 8-octet 2734 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2735 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2736 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2737 in both these examples, we consider the first octet to be numbered 1. 2739 After encrypting the first block-size-plus-two octets, the CFB state 2740 is resynchronized. The last block-size octets of ciphertext are 2741 passed through the cipher and the block boundary is reset. 2743 The repetition of 16 bits in the random data prefixed to the message 2744 allows the receiver to immediately check whether the session key is 2745 incorrect. See the "Security Considerations" section for hints on 2746 the proper use of this "quick check". 2748 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) 2750 An experimental version of PGP used this packet as the Literal 2751 packet, but no released version of PGP generated Literal packets with 2752 this tag. With PGP 5, this packet has been reassigned and is 2753 reserved for use as the Marker packet. 2755 The body of this packet consists of: 2757 * The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2759 Such a packet MUST be ignored when received. It may be placed at the 2760 beginning of a message that uses features not available in PGP 2761 version 2.6 in order to cause that version to report that newer 2762 software is necessary to process the message. 2764 5.10. Literal Data Packet (Tag 11) 2766 A Literal Data packet contains the body of a message; data that is 2767 not to be further interpreted. 2769 The body of this packet consists of: 2771 * A one-octet field that describes how the data is formatted. 2773 If it is a 'b' (0x62), then the Literal packet contains binary 2774 data. If it is a 't' (0x74), then it contains text data, and thus 2775 may need line ends converted to local form, or other text-mode 2776 changes. The tag 'u' (0x75) means the same as 't', but also 2777 indicates that implementation believes that the literal data 2778 contains UTF-8 text. If it is a 'm' (0x6d), then it contains a 2779 MIME message body part [RFC2045]. 2781 Early versions of PGP also defined a value of 'l' as a 'local' 2782 mode for machine-local conversions. RFC 1991 [RFC1991] 2783 incorrectly stated this local mode flag as '1' (ASCII numeral 2784 one). Both of these local modes are deprecated. 2786 * File name as a string (one-octet length, followed by a file name). 2787 This may be a zero-length string. Commonly, if the source of the 2788 encrypted data is a file, this will be the name of the encrypted 2789 file. An implementation MAY consider the file name in the Literal 2790 packet to be a more authoritative name than the actual file name. 2792 If the special name "_CONSOLE" is used, the message is considered 2793 to be "for your eyes only". This advises that the message data is 2794 unusually sensitive, and the receiving program should process it 2795 more carefully, perhaps avoiding storing the received data to 2796 disk, for example. 2798 * A four-octet number that indicates a date associated with the 2799 literal data. Commonly, the date might be the modification date 2800 of a file, or the time the packet was created, or a zero that 2801 indicates no specific time. 2803 * The remainder of the packet is literal data. 2805 Text data is stored with text endings (i.e., network- 2806 normal line endings). These should be converted to native line 2807 endings by the receiving software. 2809 Note that V3 and V4 signatures do not include the formatting octet, 2810 the file name, and the date field of the literal packet in a 2811 signature hash and thus are not protected against tampering in a 2812 signed document. In contrast V5 signatures include them. 2814 5.11. Trust Packet (Tag 12) 2816 The Trust packet is used only within keyrings and is not normally 2817 exported. Trust packets contain data that record the user's 2818 specifications of which key holders are trustworthy introducers, 2819 along with other information that implementing software uses for 2820 trust information. The format of Trust packets is defined by a given 2821 implementation. 2823 Trust packets SHOULD NOT be emitted to output streams that are 2824 transferred to other users, and they SHOULD be ignored on any input 2825 other than local keyring files. 2827 5.12. User ID Packet (Tag 13) 2829 A User ID packet consists of UTF-8 text that is intended to represent 2830 the name and email address of the key holder. By convention, it 2831 includes an RFC 2822 [RFC2822] mail name-addr, but there are no 2832 restrictions on its content. The packet length in the header 2833 specifies the length of the User ID. 2835 5.13. User Attribute Packet (Tag 17) 2837 The User Attribute packet is a variation of the User ID packet. It 2838 is capable of storing more types of data than the User ID packet, 2839 which is limited to text. Like the User ID packet, a User Attribute 2840 packet may be certified by the key owner ("self-signed") or any other 2841 key owner who cares to certify it. Except as noted, a User Attribute 2842 packet may be used anywhere that a User ID packet may be used. 2844 While User Attribute packets are not a required part of the OpenPGP 2845 standard, implementations SHOULD provide at least enough 2846 compatibility to properly handle a certification signature on the 2847 User Attribute packet. A simple way to do this is by treating the 2848 User Attribute packet as a User ID packet with opaque contents, but 2849 an implementation may use any method desired. 2851 The User Attribute packet is made up of one or more attribute 2852 subpackets. Each subpacket consists of a subpacket header and a 2853 body. The header consists of: 2855 * the subpacket length (1, 2, or 5 octets) 2857 * the subpacket type (1 octet) 2859 and is followed by the subpacket specific data. 2861 The following table lists the currently known subpackets: 2863 +---------+-----------------------------+ 2864 | Type | Attribute Subpacket | 2865 +=========+=============================+ 2866 | 1 | Image Attribute Subpacket | 2867 +---------+-----------------------------+ 2868 | [TBD1] | User ID Attribute Subpacket | 2869 +---------+-----------------------------+ 2870 | 100-110 | Private/Experimental Use | 2871 +---------+-----------------------------+ 2873 Table 5 2875 An implementation SHOULD ignore any subpacket of a type that it does 2876 not recognize. 2878 5.13.1. The Image Attribute Subpacket 2880 The Image Attribute subpacket is used to encode an image, presumably 2881 (but not required to be) that of the key owner. 2883 The Image Attribute subpacket begins with an image header. The first 2884 two octets of the image header contain the length of the image 2885 header. Note that unlike other multi-octet numerical values in this 2886 document, due to a historical accident this value is encoded as a 2887 little-endian number. The image header length is followed by a 2888 single octet for the image header version. The only currently 2889 defined version of the image header is 1, which is a 16-octet image 2890 header. The first three octets of a version 1 image header are thus 2891 0x10, 0x00, 0x01. 2893 The fourth octet of a version 1 image header designates the encoding 2894 format of the image. The only currently defined encoding format is 2895 the value 1 to indicate JPEG. Image format types 100 through 110 are 2896 reserved for private or experimental use. The rest of the version 1 2897 image header is made up of 12 reserved octets, all of which MUST be 2898 set to 0. 2900 The rest of the image subpacket contains the image itself. As the 2901 only currently defined image type is JPEG, the image is encoded in 2902 the JPEG File Interchange Format (JFIF), a standard file format for 2903 JPEG images [JFIF]. 2905 An implementation MAY try to determine the type of an image by 2906 examination of the image data if it is unable to handle a particular 2907 version of the image header or if a specified encoding format value 2908 is not recognized. 2910 5.13.2. User ID Attribute Subpacket 2912 A User ID Attribute subpacket has type [IANA -- assignment TBD1]. 2914 A User ID Attribute subpacket, just like a User ID packet, consists 2915 of UTF-8 text that is intended to represent the name and email 2916 address of the key holder. By convention, it includes an RFC 2822 2917 [RFC2822] mail name-addr, but there are no restrictions on its 2918 content. For devices using OpenPGP for device certificates, it may 2919 just be the device identifier. The packet length in the header 2920 specifies the length of the User ID. 2922 Because User Attribute subpackets can be used anywhere a User ID 2923 packet can be used, implementations MAY choose to trust a signed User 2924 Attribute subpacket that includes a User ID Attribute subpacket. 2926 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2928 The Symmetrically Encrypted Integrity Protected Data packet is a 2929 variant of the Symmetrically Encrypted Data packet. It is a new 2930 feature created for OpenPGP that addresses the problem of detecting a 2931 modification to encrypted data. It is used in combination with a 2932 Modification Detection Code packet. 2934 There is a corresponding feature in the features Signature subpacket 2935 that denotes that an implementation can properly use this packet 2936 type. An implementation MUST support decrypting these packets and 2937 SHOULD prefer generating them to the older Symmetrically Encrypted 2938 Data packet when possible. Since this data packet protects against 2939 modification attacks, this standard encourages its proliferation. 2940 While blanket adoption of this data packet would create 2941 interoperability problems, rapid adoption is nevertheless important. 2942 An implementation SHOULD specifically denote support for this packet, 2943 but it MAY infer it from other mechanisms. 2945 For example, an implementation might infer from the use of a cipher 2946 such as Advanced Encryption Standard (AES) or Twofish that a user 2947 supports this feature. It might place in the unhashed portion of 2948 another user's key signature a Features subpacket. It might also 2949 present a user with an opportunity to regenerate their own self- 2950 signature with a Features subpacket. 2952 This packet contains data encrypted with a symmetric-key algorithm 2953 and protected against modification by the SHA-1 hash algorithm. When 2954 it has been decrypted, it will typically contain other packets (often 2955 a Literal Data packet or Compressed Data packet). The last decrypted 2956 packet in this packet's payload MUST be a Modification Detection Code 2957 packet. 2959 The body of this packet consists of: 2961 * A one-octet version number. The only defined value is 1. There 2962 won't be any future versions of this packet because the MDC system 2963 has been superseded by the AEAD Encrypted Data packet. 2965 * Encrypted data, the output of the selected symmetric-key cipher 2966 operating in Cipher Feedback mode with shift amount equal to the 2967 block size of the cipher (CFB-n where n is the block size). 2969 The symmetric cipher used MUST be specified in a Public-Key or 2970 Symmetric-Key Encrypted Session Key packet that precedes the 2971 Symmetrically Encrypted Data packet. In either case, the cipher 2972 algorithm octet is prefixed to the session key before it is 2973 encrypted. 2975 The data is encrypted in CFB mode, with a CFB shift size equal to the 2976 cipher's block size. The Initial Vector (IV) is specified as all 2977 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2978 the data before it is encrypted. The length of the octet string 2979 equals the block size of the cipher in octets, plus two. The first 2980 octets in the group, of length equal to the block size of the cipher, 2981 are random; the last two octets are each copies of their 2nd 2982 preceding octet. For example, with a cipher whose block size is 128 2983 bits or 16 octets, the prefix data will contain 16 random octets, 2984 then two more octets, which are copies of the 15th and 16th octets, 2985 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2986 special CFB resynchronization is done after encrypting this prefix 2987 data. See "OpenPGP CFB Mode" below for more details. 2989 The repetition of 16 bits in the random data prefixed to the message 2990 allows the receiver to immediately check whether the session key is 2991 incorrect. 2993 The plaintext of the data to be encrypted is passed through the SHA-1 2994 hash function, and the result of the hash is appended to the 2995 plaintext in a Modification Detection Code packet. The input to the 2996 hash function includes the prefix data described above; it includes 2997 all of the plaintext, and then also includes two octets of values 2998 0xD3, 0x14. These represent the encoding of a Modification Detection 2999 Code packet tag and length field of 20 octets. 3001 The resulting hash value is stored in a Modification Detection Code 3002 (MDC) packet, which MUST use the two octet encoding just given to 3003 represent its tag and length field. The body of the MDC packet is 3004 the 20-octet output of the SHA-1 hash. 3006 The Modification Detection Code packet is appended to the plaintext 3007 and encrypted along with the plaintext using the same CFB context. 3009 During decryption, the plaintext data should be hashed with SHA-1, 3010 including the prefix data as well as the packet tag and length field 3011 of the Modification Detection Code packet. The body of the MDC 3012 packet, upon decryption, is compared with the result of the SHA-1 3013 hash. 3015 Any failure of the MDC indicates that the message has been modified 3016 and MUST be treated as a security problem. Failures include a 3017 difference in the hash values, but also the absence of an MDC packet, 3018 or an MDC packet in any position other than the end of the plaintext. 3019 Any failure SHOULD be reported to the user. 3021 NON-NORMATIVE EXPLANATION 3023 The MDC system, as packets 18 and 19 are called, were created to 3024 provide an integrity mechanism that is less strong than a 3025 signature, yet stronger than bare CFB encryption. 3027 It is a limitation of CFB encryption that damage to the 3028 ciphertext will corrupt the affected cipher blocks and the block 3029 following. Additionally, if data is removed from the end of a 3030 CFB-encrypted block, that removal is undetectable. (Note also 3031 that CBC mode has a similar limitation, but data removed from 3032 the front of the block is undetectable.) 3034 The obvious way to protect or authenticate an encrypted block is 3035 to digitally sign it. However, many people do not wish to 3036 habitually sign data, for a large number of reasons beyond the 3037 scope of this document. Suffice it to say that many people 3038 consider properties such as deniability to be as valuable as 3039 integrity. 3041 OpenPGP addresses this desire to have more security than raw 3042 encryption and yet preserve deniability with the MDC system. An 3043 MDC is intentionally not a MAC. Its name was not selected by 3044 accident. It is analogous to a checksum. 3046 Despite the fact that it is a relatively modest system, it has 3047 proved itself in the real world. It is an effective defense to 3048 several attacks that have surfaced since it has been created. 3049 It has met its modest goals admirably. 3051 Consequently, because it is a modest security system, it has 3052 modest requirements on the hash function(s) it employs. It does 3053 not rely on a hash function being collision-free, it relies on a 3054 hash function being one-way. If a forger, Frank, wishes to send 3055 Alice a (digitally) unsigned message that says, "I've always 3056 secretly loved you, signed Bob", it is far easier for him to 3057 construct a new message than it is to modify anything 3058 intercepted from Bob. (Note also that if Bob wishes to 3059 communicate secretly with Alice, but without authentication or 3060 identification and with a threat model that includes forgers, he 3061 has a problem that transcends mere cryptography.) 3063 Note also that unlike nearly every other OpenPGP subsystem, 3064 there are no parameters in the MDC system. It hard-defines 3065 SHA-1 as its hash function. This is not an accident. It is an 3066 intentional choice to avoid downgrade and cross-grade attacks 3067 while making a simple, fast system. (A downgrade attack would 3068 be an attack that replaced SHA2-256 with SHA-1, for example. A 3069 cross-grade attack would replace SHA-1 with another 160-bit 3070 hash, such as RIPE-MD/160, for example.) 3072 However, no update will be needed because the MDC will be 3073 replaced by the AEAD encryption described in this document. 3075 5.15. Modification Detection Code Packet (Tag 19) 3077 The Modification Detection Code packet contains a SHA-1 hash of 3078 plaintext data, which is used to detect message modification. It is 3079 only used with a Symmetrically Encrypted Integrity Protected Data 3080 packet. The Modification Detection Code packet MUST be the last 3081 packet in the plaintext data that is encrypted in the Symmetrically 3082 Encrypted Integrity Protected Data packet, and MUST appear in no 3083 other place. 3085 A Modification Detection Code packet MUST have a length of 20 octets. 3087 The body of this packet consists of: 3089 * A 20-octet SHA-1 hash of the preceding plaintext data of the 3090 Symmetrically Encrypted Integrity Protected Data packet, including 3091 prefix data, the tag octet, and length octet of the Modification 3092 Detection Code packet. 3094 Note that the Modification Detection Code packet MUST always use a 3095 new format encoding of the packet tag, and a one-octet encoding of 3096 the packet length. The reason for this is that the hashing rules for 3097 modification detection include a one-octet tag and one-octet length 3098 in the data hash. While this is a bit restrictive, it reduces 3099 complexity. 3101 5.16. AEAD Encrypted Data Packet (Tag 20) 3103 This packet contains data encrypted with an authenticated encryption 3104 and additional data (AEAD) construction. When it has been decrypted, 3105 it will typically contain other packets (often a Literal Data packet 3106 or Compressed Data packet). 3108 The body of this packet consists of: 3110 * A one-octet version number. The only currently defined value is 3111 1. 3113 * A one-octet cipher algorithm. 3115 * A one-octet AEAD algorithm. 3117 * A one-octet chunk size. 3119 * A starting initialization vector of size specified by the AEAD 3120 algorithm. 3122 * Encrypted data, the output of the selected symmetric-key cipher 3123 operating in the given AEAD mode. 3125 * A final, summary authentication tag for the AEAD mode. 3127 An AEAD encrypted data packet consists of one or more chunks of data. 3128 The plaintext of each chunk is of a size specified using the chunk 3129 size octet using the method specified below. 3131 The encrypted data consists of the encryption of each chunk of 3132 plaintext, followed immediately by the relevant authentication tag. 3133 If the last chunk of plaintext is smaller than the chunk size, the 3134 ciphertext for that data may be shorter; it is nevertheless followed 3135 by a full authentication tag. 3137 For each chunk, the AEAD construction is given the Packet Tag in new 3138 format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag), 3139 version number, cipher algorithm octet, AEAD algorithm octet, chunk 3140 size octet, and an eight-octet, big-endian chunk index as additional 3141 data. The index of the first chunk is zero. For example, the 3142 additional data of the first chunk using EAX and AES-128 with a chunk 3143 size of 64 kiByte consists of the octets 0xD4, 0x01, 0x07, 0x01, 3144 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, and 0x00. 3146 After the final chunk, the AEAD algorithm is used to produce a final 3147 authentication tag encrypting the empty string. This AEAD instance 3148 is given the additional data specified above, plus an eight-octet, 3149 big-endian value specifying the total number of plaintext octets 3150 encrypted. This allows detection of a truncated ciphertext. Please 3151 note that the big-endian number representing the chunk index in the 3152 additional data is increased accordingly, although it's not really a 3153 chunk. 3155 The chunk size octet specifies the size of chunks using the following 3156 formula (in C), where c is the chunk size octet: 3158 chunk_size = ((uint64_t)1 << (c + 6)) 3160 An implementation MUST support chunk size octets with values from 0 3161 to 56. Chunk size octets with other values are reserved for future 3162 extensions. Implementations SHOULD NOT create data with a chunk size 3163 octet value larger than 21 (128 MiB chunks) to facilitate buffering 3164 of not yet authenticated plaintext. 3166 A new random initialization vector MUST be used for each message. 3167 Failure to do so for each message will lead to a catastrophic failure 3168 depending on the used AEAD mode. 3170 5.16.1. EAX Mode 3172 The EAX algorithm can only use block ciphers with 16-octet blocks. 3173 The starting initialization vector and authentication tag are both 16 3174 octets long. 3176 The starting initialization vector for this mode MUST be unique and 3177 unpredictable. 3179 The nonce for EAX mode is computed by treating the starting 3180 initialization vector as a 16-octet, big-endian value and exclusive- 3181 oring the low eight octets of it with the chunk index. 3183 The security of EAX requires that the nonce is never reused, hence 3184 the requirement that the starting initialization vector be unique. 3186 5.16.2. OCB Mode 3188 The OCB Authenticated-Encryption Algorithm used in this document is 3189 defined in [RFC7253]. 3191 OCB usage requires specification of the following parameters: 3193 * a blockcipher that operate on 128-bit (16-octet) blocks 3195 * an authentication tag length of 16 octets 3197 * a nonce of 15 octets long (which is the longest nonce allowed 3198 specified by [RFC7253]) 3200 * an initialization vector of at least 15 octets long 3202 In the case that the initialization vector is longer than 15 octets 3203 (such as in Section 5.5.1.3, only the 15 leftmost octets are used in 3204 calculations; the remaining octets MUST be considered as zero. 3206 The nonce for OCB mode is computed by the exclusive-oring of the 3207 initialization vector as a 15-octet, big endian value, against the 3208 chunk index. 3210 Security of OCB mode depends on the non-repeated nature of nonces 3211 used for the same key on distinct plaintext [RFC7253]. Therefore the 3212 initialization vector per message MUST be distinct, and OCB mode 3213 SHOULD only be used in environments when there is certainty to 3214 fulfilling this requirement. 3216 6. Radix-64 Conversions 3218 As stated in the introduction, OpenPGP's underlying native 3219 representation for objects is a stream of arbitrary octets, and some 3220 systems desire these objects to be immune to damage caused by 3221 character set translation, data conversions, etc. 3223 In principle, any printable encoding scheme that met the requirements 3224 of the unsafe channel would suffice, since it would not change the 3225 underlying binary bit streams of the native OpenPGP data structures. 3226 The OpenPGP standard specifies one such printable encoding scheme to 3227 ensure interoperability. 3229 OpenPGP's Radix-64 encoding is composed of two parts: a base64 3230 encoding of the binary data and a checksum. The base64 encoding is 3231 identical to the MIME base64 content-transfer-encoding [RFC2045]. 3233 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 3234 four characters of radix-64 encoding by the same MIME base64 3235 transformation, preceded by an equal sign (=). The CRC is computed 3236 by using the generator 0x864CFB and an initialization of 0xB704CE. 3237 The accumulation is done on the data before it is converted to radix- 3238 64, rather than on the converted data. A sample implementation of 3239 this algorithm is in the next section. 3241 The checksum with its leading equal sign MAY appear on the first line 3242 after the base64 encoded data. 3244 Rationale for CRC-24: The size of 24 bits fits evenly into printable 3245 base64. The nonzero initialization can detect more errors than a 3246 zero initialization. 3248 6.1. An Implementation of the CRC-24 in "C" 3250 3251 #define CRC24_INIT 0xB704CEL 3252 #define CRC24_POLY 0x864CFBL 3254 typedef long crc24; 3255 crc24 crc_octets(unsigned char *octets, size_t len) 3256 { 3257 crc24 crc = CRC24_INIT; 3258 int i; 3259 while (len--) { 3260 crc ^= (*octets++) << 16; 3261 for (i = 0; i < 8; i++) { 3262 crc <<= 1; 3263 if (crc & 0x1000000) 3264 crc ^= CRC24_POLY; 3265 } 3266 } 3267 return crc & 0xFFFFFFL; 3268 } 3269 3271 6.2. Forming ASCII Armor 3273 When OpenPGP encodes data into ASCII Armor, it puts specific headers 3274 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 3275 later. An OpenPGP implementation MAY use ASCII armor to protect raw 3276 binary data. OpenPGP informs the user what kind of data is encoded 3277 in the ASCII armor through the use of the headers. 3279 Concatenating the following data creates ASCII Armor: 3281 * An Armor Header Line, appropriate for the type of data 3283 * Armor Headers 3285 * A blank line 3287 * The ASCII-Armored data 3289 * An Armor Checksum 3291 * The Armor Tail, which depends on the Armor Header Line 3293 An Armor Header Line consists of the appropriate header line text 3294 surrounded by five (5) dashes ('-', 0x2D) on either side of the 3295 header line text. The header line text is chosen based upon the type 3296 of data that is being encoded in Armor, and how it is being encoded. 3297 Header line texts include the following strings: 3299 BEGIN PGP MESSAGE Used for signed, encrypted, or compressed files. 3301 BEGIN PGP PUBLIC KEY BLOCK Used for armoring public keys. 3303 BEGIN PGP PRIVATE KEY BLOCK Used for armoring private keys. 3305 BEGIN PGP MESSAGE, PART X/Y Used for multi-part messages, where the 3306 armor is split amongst Y parts, and this is the Xth part out of Y. 3308 BEGIN PGP MESSAGE, PART X Used for multi-part messages, where this 3309 is the Xth part of an unspecified number of parts. Requires the 3310 MESSAGE-ID Armor Header to be used. 3312 BEGIN PGP SIGNATURE Used for detached signatures, OpenPGP/MIME 3313 signatures, and cleartext signatures. Note that PGP 2 uses BEGIN 3314 PGP MESSAGE for detached signatures. 3316 Note that all these Armor Header Lines are to consist of a complete 3317 line. That is to say, there is always a line ending preceding the 3318 starting five dashes, and following the ending five dashes. The 3319 header lines, therefore, MUST start at the beginning of a line, and 3320 MUST NOT have text other than whitespace -- space (0x20), tab (0x09) 3321 or carriage return (0x0d) -- following them on the same line. These 3322 line endings are considered a part of the Armor Header Line for the 3323 purposes of determining the content they delimit. This is 3324 particularly important when computing a cleartext signature (see 3325 below). 3327 The Armor Headers are pairs of strings that can give the user or the 3328 receiving OpenPGP implementation some information about how to decode 3329 or use the message. The Armor Headers are a part of the armor, not a 3330 part of the message, and hence are not protected by any signatures 3331 applied to the message. 3333 The format of an Armor Header is that of a key-value pair. A colon 3334 (':' 0x38) and a single space (0x20) separate the key and value. 3335 OpenPGP should consider improperly formatted Armor Headers to be 3336 corruption of the ASCII Armor. Unknown keys should be reported to 3337 the user, but OpenPGP should continue to process the message. 3339 Note that some transport methods are sensitive to line length. While 3340 there is a limit of 76 characters for the Radix-64 data 3341 (Section 6.3), there is no limit to the length of Armor Headers. 3342 Care should be taken that the Armor Headers are short enough to 3343 survive transport. One way to do this is to repeat an Armor Header 3344 Key multiple times with different values for each so that no one line 3345 is overly long. 3347 Currently defined Armor Header Keys are as follows: 3349 * "Version", which states the OpenPGP implementation and version 3350 used to encode the message. 3352 * "Comment", a user-defined comment. OpenPGP defines all text to be 3353 in UTF-8. A comment may be any UTF-8 string. However, the whole 3354 point of armoring is to provide seven-bit-clean data. 3355 Consequently, if a comment has characters that are outside the US- 3356 ASCII range of UTF, they may very well not survive transport. 3358 * "Hash", a comma-separated list of hash algorithms used in this 3359 message. This is used only in cleartext signed messages. 3361 * "MessageID", a 32-character string of printable characters. The 3362 string must be the same for all parts of a multi-part message that 3363 uses the "PART X" Armor Header. MessageID strings should be 3364 unique enough that the recipient of the mail can associate all the 3365 parts of a message with each other. A good checksum or 3366 cryptographic hash function is sufficient. 3368 The MessageID SHOULD NOT appear unless it is in a multi-part 3369 message. If it appears at all, it MUST be computed from the 3370 finished (encrypted, signed, etc.) message in a deterministic 3371 fashion, rather than contain a purely random value. This is to 3372 allow the legitimate recipient to determine that the MessageID 3373 cannot serve as a covert means of leaking cryptographic key 3374 information. 3376 * "Charset", a description of the character set that the plaintext 3377 is in. Please note that OpenPGP defines text to be in UTF-8. An 3378 implementation will get best results by translating into and out 3379 of UTF-8. However, there are many instances where this is easier 3380 said than done. Also, there are communities of users who have no 3381 need for UTF-8 because they are all happy with a character set 3382 like ISO Latin-5 or a Japanese character set. In such instances, 3383 an implementation MAY override the UTF-8 default by using this 3384 header key. An implementation MAY implement this key and any 3385 translations it cares to; an implementation MAY ignore it and 3386 assume all text is UTF-8. 3388 The blank line can either be zero-length or contain only whitespace, 3389 that is spaces (0x20), tabs (0x09) or carriage returns (0x0d). 3391 The Armor Tail Line is composed in the same manner as the Armor 3392 Header Line, except the string "BEGIN" is replaced by the string 3393 "END". 3395 6.3. Encoding Binary in Radix-64 3397 The encoding process represents 24-bit groups of input bits as output 3398 strings of 4 encoded characters. Proceeding from left to right, a 3399 24-bit input group is formed by concatenating three 8-bit input 3400 groups. These 24 bits are then treated as four concatenated 6-bit 3401 groups, each of which is translated into a single digit in the 3402 Radix-64 alphabet. When encoding a bit stream with the Radix-64 3403 encoding, the bit stream must be presumed to be ordered with the most 3404 significant bit first. That is, the first bit in the stream will be 3405 the high-order bit in the first 8-bit octet, and the eighth bit will 3406 be the low-order bit in the first 8-bit octet, and so on. 3408 +--first octet--+-second octet--+--third octet--+ 3409 |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| 3410 +-----------+---+-------+-------+---+-----------+ 3411 |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| 3412 +--1.index--+--2.index--+--3.index--+--4.index--+ 3414 Each 6-bit group is used as an index into an array of 64 printable 3415 characters from the table below. The character referenced by the 3416 index is placed in the output string. 3418 Value Encoding Value Encoding Value Encoding Value Encoding 3419 0 A 17 R 34 i 51 z 3420 1 B 18 S 35 j 52 0 3421 2 C 19 T 36 k 53 1 3422 3 D 20 U 37 l 54 2 3423 4 E 21 V 38 m 55 3 3424 5 F 22 W 39 n 56 4 3425 6 G 23 X 40 o 57 5 3426 7 H 24 Y 41 p 58 6 3427 8 I 25 Z 42 q 59 7 3428 9 J 26 a 43 r 60 8 3429 10 K 27 b 44 s 61 9 3430 11 L 28 c 45 t 62 + 3431 12 M 29 d 46 u 63 / 3432 13 N 30 e 47 v 3433 14 O 31 f 48 w (pad) = 3434 15 P 32 g 49 x 3435 16 Q 33 h 50 y 3437 The encoded output stream must be represented in lines of no more 3438 than 76 characters each. 3440 Special processing is performed if fewer than 24 bits are available 3441 at the end of the data being encoded. There are three possibilities: 3443 1. The last data group has 24 bits (3 octets). No special 3444 processing is needed. 3446 2. The last data group has 16 bits (2 octets). The first two 3447 6-bit groups are processed as above. The third (incomplete) 3448 data group has two zero-value bits added to it, and is 3449 processed as above. A pad character (=) is added to the 3450 output. 3452 3. The last data group has 8 bits (1 octet). The first 6-bit 3453 group is processed as above. The second (incomplete) data 3454 group has four zero-value bits added to it, and is processed 3455 as above. Two pad characters (=) are added to the output. 3457 6.4. Decoding Radix-64 3459 In Radix-64 data, characters other than those in the table, line 3460 breaks, and other white space probably indicate a transmission error, 3461 about which a warning message or even a message rejection might be 3462 appropriate under some circumstances. Decoding software must ignore 3463 all white space. 3465 Because it is used only for padding at the end of the data, the 3466 occurrence of any "=" characters may be taken as evidence that the 3467 end of the data has been reached (without truncation in transit). No 3468 such assurance is possible, however, when the number of octets 3469 transmitted was a multiple of three and no "=" characters are 3470 present. 3472 6.5. Examples of Radix-64 3474 Input data: 0x14FB9C03D97E 3475 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 3476 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 3477 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 3478 Decimal: 5 15 46 28 0 61 37 62 3479 Output: F P u c A 9 l + 3480 Input data: 0x14FB9C03D9 3481 Hex: 1 4 F B 9 C | 0 3 D 9 3482 8-bit: 00010100 11111011 10011100 | 00000011 11011001 3483 pad with 00 3484 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 3485 Decimal: 5 15 46 28 0 61 36 3486 pad with = 3487 Output: F P u c A 9 k = 3488 Input data: 0x14FB9C03 3489 Hex: 1 4 F B 9 C | 0 3 3490 8-bit: 00010100 11111011 10011100 | 00000011 3491 pad with 0000 3492 6-bit: 000101 001111 101110 011100 | 000000 110000 3493 Decimal: 5 15 46 28 0 48 3494 pad with = = 3495 Output: F P u c A w = = 3497 6.6. Example of an ASCII Armored Message 3499 -----BEGIN PGP MESSAGE----- 3500 Version: OpenPrivacy 0.99 3502 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3503 vBSFjNSiVHsuAA== 3504 =njUN 3505 -----END PGP MESSAGE----- 3507 Note that this example has extra indenting; an actual armored message 3508 would have no leading whitespace. 3510 7. Cleartext Signature Framework 3512 It is desirable to be able to sign a textual octet stream without 3513 ASCII armoring the stream itself, so the signed text is still 3514 readable without special software. In order to bind a signature to 3515 such a cleartext, this framework is used, which follows the same 3516 basic format and restrictions as the ASCII armoring described above 3517 in "Forming ASCII Armor" (Section 6.2). (Note that this framework is 3518 not intended to be reversible. RFC 3156 [RFC3156] defines another 3519 way to sign cleartext messages for environments that support MIME.) 3521 The cleartext signed message consists of: 3523 * The cleartext header "-----BEGIN PGP SIGNED MESSAGE-----" on a 3524 single line, 3526 * One or more "Hash" Armor Headers, 3528 * Exactly one blank line not included into the message digest, 3530 * The dash-escaped cleartext that is included into the message 3531 digest, 3533 * The ASCII armored signature(s) including the "-----BEGIN PGP 3534 SIGNATURE-----" Armor Header and Armor Tail Lines. 3536 If the "Hash" Armor Header is given, the specified message digest 3537 algorithm(s) are used for the signature. If there are no such 3538 headers, MD5 is used. If MD5 is the only hash used, then an 3539 implementation MAY omit this header for improved V2.x compatibility. 3540 If more than one message digest is used in the signature, the "Hash" 3541 armor header contains a comma-delimited list of used message digests. 3543 Current message digest names are described below with the algorithm 3544 IDs. 3546 An implementation SHOULD add a line break after the cleartext, but 3547 MAY omit it if the cleartext ends with a line break. This is for 3548 visual clarity. 3550 7.1. Dash-Escaped Text 3552 The cleartext content of the message must also be dash-escaped. 3554 Dash-escaped cleartext is the ordinary cleartext where every line 3555 starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' 3556 (0x2D) and space ' ' (0x20). This prevents the parser from 3557 recognizing armor headers of the cleartext itself. An implementation 3558 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3559 followed by a space, and MUST dash-escape any line commencing in a 3560 dash. The message digest is computed using the cleartext itself, not 3561 the dash-escaped form. 3563 As with binary signatures on text documents, a cleartext signature is 3564 calculated on the text using canonical line endings. The 3565 line ending (i.e., the ) before the "-----BEGIN PGP 3566 SIGNATURE-----" line that terminates the signed text is not 3567 considered part of the signed text. 3569 When reversing dash-escaping, an implementation MUST strip the string 3570 "- " if it occurs at the beginning of a line, and SHOULD warn on "-" 3571 and any character other than a space at the beginning of a line. 3573 Also, any trailing whitespace -- spaces (0x20), tabs (0x09) or 3574 carriage returns (0x0d) -- at the end of any line is removed when the 3575 cleartext signature is generated and verified. 3577 8. Regular Expressions 3579 A regular expression is zero or more branches, separated by '|'. It 3580 matches anything that matches one of the branches. 3582 A branch is zero or more pieces, concatenated. It matches a match 3583 for the first, followed by a match for the second, etc. 3585 A piece is an atom possibly followed by '_', '+', or '?'. An atom 3586 followed by '_' matches a sequence of 0 or more matches of the atom. 3587 An atom followed by '+' matches a sequence of 1 or more matches of 3588 the atom. An atom followed by '?' matches a match of the atom, or 3589 the null string. 3591 An atom is a regular expression in parentheses (matching a match for 3592 the regular expression), a range (see below), '.' (matching any 3593 single character), '^' (matching the null string at the beginning of 3594 the input string), '$' (matching the null string at the end of the 3595 input string), a '\' followed by a single character (matching that 3596 character), or a single character with no other significance 3597 (matching that character). 3599 A range is a sequence of characters enclosed in "[]". It normally 3600 matches any single character from the sequence. If the sequence 3601 begins with '^', it matches any single character not from the rest of 3602 the sequence. If two characters in the sequence are separated by 3603 '-', this is shorthand for the full list of ASCII characters between 3604 them (e.g., "[0-9]" matches any decimal digit). To include a literal 3605 ']' in the sequence, make it the first character (following a 3606 possible '^'). To include a literal '-', make it the first or last 3607 character. 3609 9. Constants 3611 This section describes the constants used in OpenPGP. 3613 Note that these tables are not exhaustive lists; an implementation 3614 MAY implement an algorithm not on these lists, so long as the 3615 algorithm numbers are chosen from the private or experimental 3616 algorithm range. 3618 See the section "Notes on Algorithms" below for more discussion of 3619 the algorithms. 3621 9.1. Public-Key Algorithms 3623 +---------+---------------------------------------------------+ 3624 | ID | Algorithm | 3625 +=========+===================================================+ 3626 | 1 | RSA (Encrypt or Sign) [HAC] | 3627 +---------+---------------------------------------------------+ 3628 | 2 | RSA Encrypt-Only [HAC] | 3629 +---------+---------------------------------------------------+ 3630 | 3 | RSA Sign-Only [HAC] | 3631 +---------+---------------------------------------------------+ 3632 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3633 +---------+---------------------------------------------------+ 3634 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3635 +---------+---------------------------------------------------+ 3636 | 18 | ECDH public key algorithm | 3637 +---------+---------------------------------------------------+ 3638 | 19 | ECDSA public key algorithm [FIPS186] | 3639 +---------+---------------------------------------------------+ 3640 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3641 +---------+---------------------------------------------------+ 3642 | 21 | Reserved for Diffie-Hellman (X9.42, as defined | 3643 | | for IETF-S/MIME) | 3644 +---------+---------------------------------------------------+ 3645 | 22 | EdDSA [RFC8032] | 3646 +---------+---------------------------------------------------+ 3647 | 23 | Reserved for AEDH | 3648 +---------+---------------------------------------------------+ 3649 | 24 | Reserved for AEDSA | 3650 +---------+---------------------------------------------------+ 3651 | 100-110 | Private/Experimental algorithm | 3652 +---------+---------------------------------------------------+ 3654 Table 6 3656 Implementations MUST implement RSA (1) and ECDSA (19) for signatures, 3657 and RSA (1) and ECDH (18) for encryption. Implementations SHOULD 3658 implement EdDSA (22) keys. 3660 RSA Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD 3661 NOT be generated, but may be interpreted. See Section 14.5. See 3662 Section 14.9 for notes on Elgamal Encrypt or Sign (20), and X9.42 3663 (21). Implementations MAY implement any other algorithm. 3665 Note that implementations conforming to previous versions of this 3666 standard (RFC-4880) have DSA (17) and Elgamal (16) as its only MUST- 3667 implement algorithm. 3669 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3670 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this 3671 document. 3673 9.2. ECC Curve OID 3675 The parameter curve OID is an array of octets that define a named 3676 curve. The table below specifies the exact sequence of bytes for 3677 each named curve referenced in this document: 3679 +------------------------+-----+-----------------+-----------------+ 3680 | ASN.1 Object | OID | Curve OID bytes | Curve name | 3681 | Identifier | len | in hexadecimal | | 3682 | | | representation | | 3683 +========================+=====+=================+=================+ 3684 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | 3685 | | | 03 01 07 | | 3686 +------------------------+-----+-----------------+-----------------+ 3687 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | 3688 +------------------------+-----+-----------------+-----------------+ 3689 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | 3690 +------------------------+-----+-----------------+-----------------+ 3691 | 1.3.36.3.3.2.8.1.1.7 | 9 | 2B 24 03 03 02 | brainpoolP256r1 | 3692 | | | 08 01 01 07 | | 3693 +------------------------+-----+-----------------+-----------------+ 3694 | 1.3.36.3.3.2.8.1.1.13 | 9 | 2B 24 03 03 02 | brainpoolP512r1 | 3695 | | | 08 01 01 0D | | 3696 +------------------------+-----+-----------------+-----------------+ 3697 | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 | Ed25519 | 3698 | | | DA 47 0F 01 | | 3699 +------------------------+-----+-----------------+-----------------+ 3700 | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | 3701 | | | 97 55 01 05 01 | | 3702 +------------------------+-----+-----------------+-----------------+ 3704 Table 7 3706 The sequence of octets in the third column is the result of applying 3707 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3708 with subsequent truncation. The truncation removes the two fields of 3709 encoded Object Identifier. The first omitted field is one octet 3710 representing the Object Identifier tag, and the second omitted field 3711 is the length of the Object Identifier body. For example, the 3712 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3713 86 48 CE 3D 03 01 07", from which the first entry in the table above 3714 is constructed by omitting the first two octets. Only the truncated 3715 sequence of octets is the valid representation of a curve OID. 3717 9.3. Symmetric-Key Algorithms 3719 +---------+--------------------------------------+ 3720 | ID | Algorithm | 3721 +=========+======================================+ 3722 | 0 | Plaintext or unencrypted data | 3723 +---------+--------------------------------------+ 3724 | 1 | IDEA [IDEA] | 3725 +---------+--------------------------------------+ 3726 | 2 | TripleDES (DES-EDE, [SCHNEIER] [HAC] | 3727 | | - 168 bit key derived from 192) | 3728 +---------+--------------------------------------+ 3729 | 3 | CAST5 (128 bit key, as per | 3730 | | [RFC2144]) | 3731 +---------+--------------------------------------+ 3732 | 4 | Blowfish (128 bit key, 16 rounds) | 3733 | | [BLOWFISH] | 3734 +---------+--------------------------------------+ 3735 | 5 | Reserved | 3736 +---------+--------------------------------------+ 3737 | 6 | Reserved | 3738 +---------+--------------------------------------+ 3739 | 7 | AES with 128-bit key [AES] | 3740 +---------+--------------------------------------+ 3741 | 8 | AES with 192-bit key | 3742 +---------+--------------------------------------+ 3743 | 9 | AES with 256-bit key | 3744 +---------+--------------------------------------+ 3745 | 10 | Twofish with 256-bit key [TWOFISH] | 3746 +---------+--------------------------------------+ 3747 | 11 | Camellia with 128-bit key [RFC3713] | 3748 +---------+--------------------------------------+ 3749 | 12 | Camellia with 192-bit key | 3750 +---------+--------------------------------------+ 3751 | 13 | Camellia with 256-bit key | 3752 +---------+--------------------------------------+ 3753 | 100-110 | Private/Experimental algorithm | 3754 +---------+--------------------------------------+ 3756 Table 8 3758 Implementations MUST implement AES-128. Implementations SHOULD 3759 implement AES-256. Implementations that interoperate with RFC-4880 3760 implementations need to support TripleDES and CAST5. Implementations 3761 that interoperate with PGP 2.6 or earlier need to support IDEA, as 3762 that is the only symmetric cipher those versions use. 3763 Implementations MAY implement any other algorithm. 3765 9.4. Compression Algorithms 3767 +---------+--------------------------------+ 3768 | ID | Algorithm | 3769 +=========+================================+ 3770 | 0 | Uncompressed | 3771 +---------+--------------------------------+ 3772 | 1 | ZIP [RFC1951] | 3773 +---------+--------------------------------+ 3774 | 2 | ZLIB [RFC1950] | 3775 +---------+--------------------------------+ 3776 | 3 | BZip2 [BZ2] | 3777 +---------+--------------------------------+ 3778 | 100-110 | Private/Experimental algorithm | 3779 +---------+--------------------------------+ 3781 Table 9 3783 Implementations MUST implement uncompressed data. Implementations 3784 SHOULD implement ZLIB. For interoperability reasons implementations 3785 SHOULD be able to decompress using ZIP. Implementations MAY 3786 implement any other algorithm. 3788 9.5. Hash Algorithms 3790 +---------+--------------------------------+-------------+ 3791 | ID | Algorithm | Text Name | 3792 +=========+================================+=============+ 3793 | 1 | MD5 [HAC] | "MD5" | 3794 +---------+--------------------------------+-------------+ 3795 | 2 | SHA-1 [FIPS180] | "SHA1" | 3796 +---------+--------------------------------+-------------+ 3797 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3798 +---------+--------------------------------+-------------+ 3799 | 4 | Reserved | | 3800 +---------+--------------------------------+-------------+ 3801 | 5 | Reserved | | 3802 +---------+--------------------------------+-------------+ 3803 | 6 | Reserved | | 3804 +---------+--------------------------------+-------------+ 3805 | 7 | Reserved | | 3806 +---------+--------------------------------+-------------+ 3807 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3808 +---------+--------------------------------+-------------+ 3809 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3810 +---------+--------------------------------+-------------+ 3811 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3812 +---------+--------------------------------+-------------+ 3813 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3814 +---------+--------------------------------+-------------+ 3815 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3816 +---------+--------------------------------+-------------+ 3817 | 13 | Reserved | | 3818 +---------+--------------------------------+-------------+ 3819 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3820 +---------+--------------------------------+-------------+ 3821 | 100-110 | Private/Experimental algorithm | | 3822 +---------+--------------------------------+-------------+ 3824 Table 10 3826 Implementations MUST implement SHA2-256. Implementations MAY 3827 implement other algorithms. Implementations SHOULD NOT create 3828 messages which require the use of SHA-1 with the exception of 3829 computing version 4 key fingerprints and for purposes of the MDC 3830 packet. Implementations SHOULD NOT use MD5 or RIPE-MD/160. 3832 9.6. AEAD Algorithms 3834 +---------+--------------------------------+ 3835 | ID | Algorithm | 3836 +=========+================================+ 3837 | 1 | EAX [EAX] | 3838 +---------+--------------------------------+ 3839 | 2 | OCB [RFC7253] | 3840 +---------+--------------------------------+ 3841 | 100-110 | Private/Experimental algorithm | 3842 +---------+--------------------------------+ 3844 Table 11 3846 Implementations MUST implement EAX. Implementations MAY implement 3847 OCB and other algorithms. 3849 10. IANA Considerations 3851 OpenPGP is highly parameterized, and consequently there are a number 3852 of considerations for allocating parameters for extensions. This 3853 section describes how IANA should look at extensions to the protocol 3854 as described in this document. 3856 { FIXME: Also add forward references, like "The list of S2K specifier 3857 types is maintained by IANA as described in Section 10." } 3859 10.1. New String-to-Key Specifier Types 3861 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3862 a string into a key. This specification creates a registry of S2K 3863 specifier types. The registry includes the S2K type, the name of the 3864 S2K, and a reference to the defining specification. The initial 3865 values for this registry can be found in Section 3.7.1. Adding a new 3866 S2K specifier MUST be done through the SPECIFICATION REQUIRED method, 3867 as described in [RFC8126]. 3869 10.2. New Packets 3871 Major new features of OpenPGP are defined through new packet types. 3872 This specification creates a registry of packet types. The registry 3873 includes the packet type, the name of the packet, and a reference to 3874 the defining specification. The initial values for this registry can 3875 be found in Section 4.3. Adding a new packet type MUST be done 3876 through the RFC REQUIRED method, as described in [RFC8126]. 3878 10.2.1. User Attribute Types 3880 The User Attribute packet permits an extensible mechanism for other 3881 types of certificate identification. This specification creates a 3882 registry of User Attribute types. The registry includes the User 3883 Attribute type, the name of the User Attribute, and a reference to 3884 the defining specification. The initial values for this registry can 3885 be found in Section 5.13. Adding a new User Attribute type MUST be 3886 done through the SPECIFICATION REQUIRED method, as described in 3887 [RFC8126]. 3889 This document requests that IANA register the User ID Attribute Type 3890 found in Section 5.13.2: 3892 +-------+-----------+---------------+ 3893 | Value | Attribute | Reference | 3894 +=======+===========+===============+ 3895 | 1 | Image | This Document | 3896 +-------+-----------+---------------+ 3897 | TBD1 | User ID | This Document | 3898 +-------+-----------+---------------+ 3900 Table 12 3902 10.2.2. Image Format Subpacket Types 3904 Within User Attribute packets, there is an extensible mechanism for 3905 other types of image-based User Attributes. This specification 3906 creates a registry of Image Attribute subpacket types. The registry 3907 includes the Image Attribute subpacket type, the name of the Image 3908 Attribute subpacket, and a reference to the defining specification. 3909 The initial values for this registry can be found in Section 5.13.1. 3910 Adding a new Image Attribute subpacket type MUST be done through the 3911 SPECIFICATION REQUIRED method, as described in [RFC8126]. 3913 10.2.3. New Signature Subpackets 3915 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3916 to be added to them for a variety of purposes in the Signature 3917 subpackets as discussed in Section 5.2.3.1. This specification 3918 creates a registry of Signature subpacket types. The registry 3919 includes the Signature subpacket type, the name of the subpacket, and 3920 a reference to the defining specification. The initial values for 3921 this registry can be found in Section 5.2.3.1. Adding a new 3922 Signature subpacket MUST be done through the SPECIFICATION REQUIRED 3923 method, as described in [RFC8126]. 3925 10.2.3.1. Signature Notation Data Subpackets 3927 OpenPGP signatures further contain a mechanism for extensions in 3928 signatures. These are the Notation Data subpackets, which contain a 3929 key/value pair. Notations contain a user space that is completely 3930 unmanaged and an IETF space. 3932 This specification creates a registry of Signature Notation Data 3933 types. The registry includes the Signature Notation Data type, the 3934 name of the Signature Notation Data, its allowed values, and a 3935 reference to the defining specification. The initial values for this 3936 registry can be found in Section 5.2.3.17. Adding a new Signature 3937 Notation Data subpacket MUST be done through the SPECIFICATION 3938 REQUIRED method, as described in [RFC8126]. 3940 This document requests IANA register the following Signature Notation 3941 Data types: 3943 +----------------+---------+--------------------+----------------+ 3944 | Allowed Values | Name | Type | Reference | 3945 +================+=========+====================+================+ 3946 | A String | charset | Character Set | This Doc Secti | 3947 | | | | on 5.2.3.17.1 | 3948 +----------------+---------+--------------------+----------------+ 3949 | Any String | manu | Manufacturer Name | This Doc Secti | 3950 | | | | on 5.2.3.17.2 | 3951 +----------------+---------+--------------------+----------------+ 3952 | Any String | make | Product Make | This Doc Secti | 3953 | | | | on 5.2.3.17.3 | 3954 +----------------+---------+--------------------+----------------+ 3955 | Any String | model | Product Model | This Doc Secti | 3956 | | | | on 5.2.3.17.4 | 3957 +----------------+---------+--------------------+----------------+ 3958 | Any String | prodid | Product ID | This Doc Secti | 3959 | | | | on 5.2.3.17.5 | 3960 +----------------+---------+--------------------+----------------+ 3961 | Any String | pvers | Product Version | This Doc Secti | 3962 | | | | on 5.2.3.17.6 | 3963 +----------------+---------+--------------------+----------------+ 3964 | Any String | lot | Product Lot Number | This Doc Secti | 3965 | | | | on 5.2.3.17.7 | 3966 +----------------+---------+--------------------+----------------+ 3967 | Decimal | qty | Package Quantity | This Doc Secti | 3968 | Integer String | | | on 5.2.3.17.8 | 3969 +----------------+---------+--------------------+----------------+ 3970 | A geo: URI | loc | Current | This Doc Secti | 3971 | without the | | Geolocation | on 5.2.3.17.9 | 3972 | "geo:" | | Latitude/Longitude | | 3973 +----------------+---------+--------------------+----------------+ 3974 | A geo: URI | dest | Destination | This Doc Secti | 3975 | without the | | Geolocation | on 5.2.3.17.9 | 3976 | "geo:" | | Latitude/Longitude | | 3977 +----------------+---------+--------------------+----------------+ 3978 | Hash Notation | hash | The Hash of | This Doc Secti | 3979 | data | | external data | on 5.2.3.17.10 | 3980 +----------------+---------+--------------------+----------------+ 3982 Table 13 3984 10.2.3.2. Signature Notation Data Subpacket Notation Flags 3986 This specification creates a new registry of Signature Notation Data 3987 Subpacket Notation Flags. The registry includes the columns "Flag", 3988 "Description", "Security Recommended", "Interoperability 3989 Recommended", and "Reference". The initial values for this registry 3990 can be found in Section 5.2.3.17. Adding a new item MUST be done 3991 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 3993 10.2.3.3. Key Server Preference Extensions 3995 OpenPGP signatures contain a mechanism for preferences to be 3996 specified about key servers. This specification creates a registry 3997 of key server preferences. The registry includes the key server 3998 preference, the name of the preference, and a reference to the 3999 defining specification. The initial values for this registry can be 4000 found in Section 5.2.3.18. Adding a new key server preference MUST 4001 be done through the SPECIFICATION REQUIRED method, as described in 4002 [RFC8126]. 4004 10.2.3.4. Key Flags Extensions 4006 OpenPGP signatures contain a mechanism for flags to be specified 4007 about key usage. This specification creates a registry of key usage 4008 flags. The registry includes the key flags value, the name of the 4009 flag, and a reference to the defining specification. The initial 4010 values for this registry can be found in Section 5.2.3.22. Adding a 4011 new key usage flag MUST be done through the SPECIFICATION REQUIRED 4012 method, as described in [RFC8126]. 4014 10.2.3.5. Reason for Revocation Extensions 4016 OpenPGP signatures contain a mechanism for flags to be specified 4017 about why a key was revoked. This specification creates a registry 4018 of "Reason for Revocation" flags. The registry includes the "Reason 4019 for Revocation" flags value, the name of the flag, and a reference to 4020 the defining specification. The initial values for this registry can 4021 be found in Section 5.2.3.24. Adding a new feature flag MUST be done 4022 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 4024 10.2.3.6. Implementation Features 4026 OpenPGP signatures contain a mechanism for flags to be specified 4027 stating which optional features an implementation supports. This 4028 specification creates a registry of feature-implementation flags. 4029 The registry includes the feature-implementation flags value, the 4030 name of the flag, and a reference to the defining specification. The 4031 initial values for this registry can be found in Section 5.2.3.25. 4032 Adding a new feature-implementation flag MUST be done through the 4033 SPECIFICATION REQUIRED method, as described in [RFC8126]. 4035 Also see Section 14.12 for more information about when feature flags 4036 are needed. 4038 10.2.4. New Packet Versions 4040 The core OpenPGP packets all have version numbers, and can be revised 4041 by introducing a new version of an existing packet. This 4042 specification creates a registry of packet types. The registry 4043 includes the packet type, the number of the version, and a reference 4044 to the defining specification. The initial values for this registry 4045 can be found in Section 5. Adding a new packet version MUST be done 4046 through the RFC REQUIRED method, as described in [RFC8126]. 4048 10.3. New Algorithms 4050 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 4051 new algorithm is usually simple. For example, adding in a new 4052 symmetric cipher usually would not need anything more than allocating 4053 a constant for that cipher. If that cipher had other than a 64-bit 4054 or 128-bit block size, there might need to be additional 4055 documentation describing how OpenPGP-CFB mode would be adjusted. 4056 Similarly, when DSA was expanded from a maximum of 1024-bit public 4057 keys to 3072-bit public keys, the revision of FIPS 186 contained 4058 enough information itself to allow implementation. Changes to this 4059 document were made mainly for emphasis. 4061 10.3.1. Public-Key Algorithms 4063 OpenPGP specifies a number of public-key algorithms. This 4064 specification creates a registry of public-key algorithm identifiers. 4065 The registry includes the algorithm name, its key sizes and 4066 parameters, and a reference to the defining specification. The 4067 initial values for this registry can be found in Section 9.1. Adding 4068 a new public-key algorithm MUST be done through the SPECIFICATION 4069 REQUIRED method, as described in [RFC8126]. 4071 This document requests IANA register the following new public-key 4072 algorithm: 4074 +----+----------------------------+------------------------+ 4075 | ID | Algorithm | Reference | 4076 +====+============================+========================+ 4077 | 22 | EdDSA public key algorithm | This doc, Section 14.8 | 4078 +----+----------------------------+------------------------+ 4079 | 23 | Reserved for AEDH | This doc | 4080 +----+----------------------------+------------------------+ 4081 | 24 | Reserved for AEDSA | This doc | 4082 +----+----------------------------+------------------------+ 4084 Table 14 4086 [Notes to RFC-Editor: Please remove the table above on publication. 4087 It is desirable not to reuse old or reserved algorithms because some 4088 existing tools might print a wrong description. A higher number is 4089 also an indication for a newer algorithm. As of now 22 is the next 4090 free number.] 4092 10.3.2. Symmetric-Key Algorithms 4094 OpenPGP specifies a number of symmetric-key algorithms. This 4095 specification creates a registry of symmetric-key algorithm 4096 identifiers. The registry includes the algorithm name, its key sizes 4097 and block size, and a reference to the defining specification. The 4098 initial values for this registry can be found in Section 9.3. Adding 4099 a new symmetric-key algorithm MUST be done through the SPECIFICATION 4100 REQUIRED method, as described in [RFC8126]. 4102 10.3.3. Hash Algorithms 4104 OpenPGP specifies a number of hash algorithms. This specification 4105 creates a registry of hash algorithm identifiers. The registry 4106 includes the algorithm name, a text representation of that name, its 4107 block size, an OID hash prefix, and a reference to the defining 4108 specification. The initial values for this registry can be found in 4109 Section 9.5 for the algorithm identifiers and text names, and 4110 Section 9.2 for the OIDs and expanded signature prefixes. Adding a 4111 new hash algorithm MUST be done through the SPECIFICATION REQUIRED 4112 method, as described in [RFC8126]. 4114 This document requests IANA register the following hash algorithms: 4116 +----+-----------+-----------+ 4117 | ID | Algorithm | Reference | 4118 +====+===========+===========+ 4119 | 12 | SHA3-256 | This doc | 4120 +----+-----------+-----------+ 4121 | 13 | Reserved | | 4122 +----+-----------+-----------+ 4123 | 14 | SHA3-512 | This doc | 4124 +----+-----------+-----------+ 4126 Table 15 4128 [Notes to RFC-Editor: Please remove the table above on publication. 4129 It is desirable not to reuse old or reserved algorithms because some 4130 existing tools might print a wrong description. The ID 13 has been 4131 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 4132 counterparts.] 4134 10.3.4. Compression Algorithms 4136 OpenPGP specifies a number of compression algorithms. This 4137 specification creates a registry of compression algorithm 4138 identifiers. The registry includes the algorithm name and a 4139 reference to the defining specification. The initial values for this 4140 registry can be found in Section 9.4. Adding a new compression key 4141 algorithm MUST be done through the SPECIFICATION REQUIRED method, as 4142 described in [RFC8126]. 4144 11. Packet Composition 4146 OpenPGP packets are assembled into sequences in order to create 4147 messages and to transfer keys. Not all possible packet sequences are 4148 meaningful and correct. This section describes the rules for how 4149 packets should be placed into sequences. 4151 11.1. Transferable Public Keys 4153 OpenPGP users may transfer public keys. The essential elements of a 4154 transferable public key are as follows: 4156 * One Public-Key packet 4158 * Zero or more revocation signatures 4160 * Zero or more User ID packets 4162 * After each User ID packet, zero or more Signature packets 4163 (certifications and attestation key signatures) 4165 * Zero or more User Attribute packets 4167 * After each User Attribute packet, zero or more Signature packets 4168 (certifications and attestation key signatures) 4170 * Zero or more Subkey packets 4172 * After each Subkey packet, one Signature packet, plus optionally a 4173 revocation 4175 The Public-Key packet occurs first. Each of the following User ID 4176 packets provides the identity of the owner of this public key. If 4177 there are multiple User ID packets, this corresponds to multiple 4178 means of identifying the same unique individual user; for example, a 4179 user may have more than one email address, and construct a User ID 4180 for each one. A transferable public key SHOULD include at least one 4181 User ID packet unless storage requirements prohibit this. 4183 Immediately following each User ID packet, there are zero or more 4184 Signature packets. Each Signature packet is calculated on the 4185 immediately preceding User ID packet and the initial Public-Key 4186 packet. The signature serves to certify the corresponding public key 4187 and User ID. In effect, the signer is testifying to his or her 4188 belief that this public key belongs to the user identified by this 4189 User ID. Intermixed with these certifications may be Attestation Key 4190 Signature packets issued by the primary key over the same User ID and 4191 Public Key packet. The most recent of these is used to attest to 4192 third-party certifications over the associated User ID. 4194 Within the same section as the User ID packets, there are zero or 4195 more User Attribute packets. Like the User ID packets, a User 4196 Attribute packet is followed by zero or more Signature packets 4197 calculated on the immediately preceding User Attribute packet and the 4198 initial Public-Key packet. 4200 User Attribute packets and User ID packets may be freely intermixed 4201 in this section, so long as the signatures that follow them are 4202 maintained on the proper User Attribute or User ID packet. 4204 After the User ID packet or Attribute packet, there may be zero or 4205 more Subkey packets. In general, subkeys are provided in cases where 4206 the top-level public key is a signature-only key. However, any V4 or 4207 V5 key may have subkeys, and the subkeys may be encryption-only keys, 4208 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 4209 subkeys. 4211 Each Subkey packet MUST be followed by one Signature packet, which 4212 should be a subkey binding signature issued by the top-level key. 4213 For subkeys that can issue signatures, the subkey binding signature 4214 MUST contain an Embedded Signature subpacket with a primary key 4215 binding signature (0x19) issued by the subkey on the top-level key. 4217 Subkey and Key packets may each be followed by a revocation Signature 4218 packet to indicate that the key is revoked. Revocation signatures 4219 are only accepted if they are issued by the key itself, or by a key 4220 that is authorized to issue revocations via a Revocation Key 4221 subpacket in a self-signature by the top-level key. 4223 Transferable public-key packet sequences may be concatenated to allow 4224 transferring multiple public keys in one operation. 4226 11.2. Transferable Secret Keys 4228 OpenPGP users may transfer secret keys. The format of a transferable 4229 secret key is the same as a transferable public key except that 4230 secret-key and secret-subkey packets are used instead of the public 4231 key and public-subkey packets. Implementations SHOULD include self- 4232 signatures on any User IDs and subkeys, as this allows for a complete 4233 public key to be automatically extracted from the transferable secret 4234 key. Implementations MAY choose to omit the self-signatures, 4235 especially if a transferable public key accompanies the transferable 4236 secret key. 4238 11.3. OpenPGP Messages 4240 An OpenPGP message is a packet or sequence of packets that 4241 corresponds to the following grammatical rules (comma represents 4242 sequential composition, and vertical bar separates alternatives): 4244 OpenPGP Message :- Encrypted Message | Signed Message | 4245 Compressed Message | Literal Message. 4247 Compressed Message :- Compressed Data Packet. 4249 Literal Message :- Literal Data Packet. 4251 ESK :- Public-Key Encrypted Session Key Packet | 4252 Symmetric-Key Encrypted Session Key Packet. 4254 ESK Sequence :- ESK | ESK Sequence, ESK. 4256 Encrypted Data :- Symmetrically Encrypted Data Packet | 4257 Symmetrically Encrypted Integrity Protected Data Packet 4259 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 4261 One-Pass Signed Message :- One-Pass Signature Packet, 4262 OpenPGP Message, Corresponding Signature Packet. 4264 Signed Message :- Signature Packet, OpenPGP Message | 4265 One-Pass Signed Message. 4267 In addition, decrypting a Symmetrically Encrypted Data packet or a 4268 Symmetrically Encrypted Integrity Protected Data packet as well as 4269 decompressing a Compressed Data packet must yield a valid OpenPGP 4270 Message. 4272 11.4. Detached Signatures 4274 Some OpenPGP applications use so-called "detached signatures". For 4275 example, a program bundle may contain a file, and with it a second 4276 file that is a detached signature of the first file. These detached 4277 signatures are simply a Signature packet stored separately from the 4278 data for which they are a signature. 4280 12. Enhanced Key Formats 4282 12.1. Key Structures 4284 The format of an OpenPGP V3 key is as follows. Entries in square 4285 brackets are optional and ellipses indicate repetition. 4287 RSA Public Key 4288 [Revocation Self Signature] 4289 User ID [Signature ...] 4290 [User ID [Signature ...] ...] 4292 Each signature certifies the RSA public key and the preceding User 4293 ID. The RSA public key can have many User IDs and each User ID can 4294 have many signatures. V3 keys are deprecated. Implementations MUST 4295 NOT generate new V3 keys, but MAY continue to use existing ones. 4297 The format of an OpenPGP V4 key that uses multiple public keys is 4298 similar except that the other keys are added to the end as "subkeys" 4299 of the primary key. 4301 Primary-Key 4302 [Revocation Self Signature] 4303 [Direct Key Signature...] 4304 [User ID [Signature ...] ...] 4305 [User Attribute [Signature ...] ...] 4306 [[Subkey [Binding-Signature-Revocation] 4307 Primary-Key-Binding-Signature] ...] 4309 A subkey always has a single signature after it that is issued using 4310 the primary key to tie the two keys together. This binding signature 4311 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 4312 issue signatures MUST have a V4 binding signature due to the REQUIRED 4313 embedded primary key binding signature. 4315 In the above diagram, if the binding signature of a subkey has been 4316 revoked, the revoked key may be removed, leaving only one key. 4318 In a V4 key, the primary key SHOULD be a key capable of 4319 certification. There are cases, such as device certificates, where 4320 the primary key may not be capable of certification. A primary key 4321 capable of making signatures SHOULD be accompanied by either a 4322 certification signature (on a User ID or User Attribute) or a 4323 signature directly on the key. 4325 Implementations SHOULD accept encryption-only primary keys without a 4326 signature. It also SHOULD allow importing any key accompanied either 4327 by a certification signature or a signature on itself. It MAY accept 4328 signature-capable primary keys without an accompanying signature. 4330 The subkeys may be keys of any other type. There may be other 4331 constructions of V4 keys, too. For example, there may be a single- 4332 key RSA key in V4 format, a DSA primary key with an RSA encryption 4333 key, or RSA primary key with an Elgamal subkey, etc. 4335 It is also possible to have a signature-only subkey. This permits a 4336 primary key that collects certifications (key signatures), but is 4337 used only for certifying subkeys that are used for encryption and 4338 signatures. 4340 12.2. Key IDs and Fingerprints 4342 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 4343 the public modulus of the RSA key. 4345 The fingerprint of a V3 key is formed by hashing the body (but not 4346 the two-octet length) of the MPIs that form the key material (public 4347 modulus n, followed by exponent e) with MD5. Note that both V3 keys 4348 and MD5 are deprecated. 4350 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 4351 followed by the two-octet packet length, followed by the entire 4352 Public-Key packet starting with the version field. The Key ID is the 4353 low-order 64 bits of the fingerprint. Here are the fields of the 4354 hash material, with the example of a DSA key: 4356 a.1) 0x99 (1 octet) 4358 a.2) two-octet scalar octet count of (b)-(e) 4360 b) version number = 4 (1 octet); 4362 c) timestamp of key creation (4 octets); 4364 d) algorithm (1 octet): 17 = DSA (example); 4366 e) Algorithm-specific fields. 4368 Algorithm-Specific Fields for DSA keys (example): 4370 e.1) MPI of DSA prime p; 4372 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 4374 e.3) MPI of DSA group generator g; 4376 e.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 4378 A V5 fingerprint is the 256-bit SHA2-256 hash of the octet 0x9A, 4379 followed by the four-octet packet length, followed by the entire 4380 Public-Key packet starting with the version field. The Key ID is the 4381 high-order 64 bits of the fingerprint. Here are the fields of the 4382 hash material, with the example of a DSA key: 4384 a.1) 0x9A (1 octet) 4386 a.2) four-octet scalar octet count of (b)-(f) 4388 b) version number = 5 (1 octet); 4390 c) timestamp of key creation (4 octets); 4392 d) algorithm (1 octet): 17 = DSA (example); 4394 e) four-octet scalar octet count for the following key material; 4396 f) algorithm-specific fields. 4398 Algorithm-Specific Fields for DSA keys (example): 4400 f.1) MPI of DSA prime p; 4402 f.2) MPI of DSA group order q (q is a prime divisor of p-1); 4404 f.3) MPI of DSA group generator g; 4406 f.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 4408 Note that it is possible for there to be collisions of Key IDs -- two 4409 different keys with the same Key ID. Note that there is a much 4410 smaller, but still non-zero, probability that two different keys have 4411 the same fingerprint. 4413 Also note that if V3, V4, and V5 format keys share the same RSA key 4414 material, they will have different Key IDs as well as different 4415 fingerprints. 4417 Finally, the Key ID and fingerprint of a subkey are calculated in the 4418 same way as for a primary key, including the 0x99 (V3 and V4 key) or 4419 0x9A (V5 key) as the first octet (even though this is not a valid 4420 packet ID for a public subkey). 4422 13. Elliptic Curve Cryptography 4424 This section descripes algorithms and parameters used with Elliptic 4425 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 4426 found in [KOBLITZ]. 4428 13.1. Supported ECC Curves 4430 This document references five named prime field curves, defined in 4431 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521"; and 4432 defined in [RFC5639] as "brainpoolP256r1", and "brainpoolP512r1". 4433 Further curve "Curve25519", defined in [RFC7748] is referenced for 4434 use with Ed25519 (EdDSA signing) and X25519 (encryption). 4436 The named curves are referenced as a sequence of bytes in this 4437 document, called throughout, curve OID. Section 9.2 describes in 4438 detail how this sequence of bytes is formed. 4440 13.2. ECDSA and ECDH Conversion Primitives 4442 This document defines the uncompressed point format for ECDSA and 4443 ECDH and a custom compression format for certain curves. The point 4444 is encoded in the Multiprecision Integer (MPI) format. 4446 For an uncompressed point the content of the MPI is: 4448 B = 04 || x || y 4450 where x and y are coordinates of the point P = (x, y), each encoded 4451 in the big-endian format and zero-padded to the adjusted underlying 4452 field size. The adjusted underlying field size is the underlying 4453 field size that is rounded up to the nearest 8-bit boundary. This 4454 encoding is compatible with the definition given in [SEC1]. 4456 For a custom compressed point the content of the MPI is: 4458 B = 40 || x 4460 where x is the x coordinate of the point P encoded to the rules 4461 defined for the specified curve. This format is used for ECDH keys 4462 based on curves expressed in Montgomery form. 4464 Therefore, the exact size of the MPI payload is 515 bits for "Curve 4465 P-256", 771 for "Curve P-384", 1059 for "Curve P-521", and 263 for 4466 Curve25519. 4468 Even though the zero point, also called the point at infinity, may 4469 occur as a result of arithmetic operations on points of an elliptic 4470 curve, it SHALL NOT appear in data structures defined in this 4471 document. 4473 If other conversion methods are defined in the future, a compliant 4474 application MUST NOT use a new format when in doubt that any 4475 recipient can support it. Consider, for example, that while both the 4476 public key and the per-recipient ECDH data structure, respectively 4477 defined in Section 5.6.6 and Section 5.1, contain an encoded point 4478 field, the format changes to the field in Section 5.1 only affect a 4479 given recipient of a given message. 4481 13.3. EdDSA Point Format 4483 The EdDSA algorithm defines a specific point compression format. To 4484 indicate the use of this compression format and to make sure that the 4485 key can be represented in the Multiprecision Integer (MPI) format the 4486 octet string specifying the point is prefixed with the octet 0x40. 4487 This encoding is an extension of the encoding given in [SEC1] which 4488 uses 0x04 to indicate an uncompressed point. 4490 For example, the length of a public key for the curve Ed25519 is 263 4491 bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the 4492 native value of the public key. 4494 13.4. Key Derivation Function 4496 A key derivation function (KDF) is necessary to implement the EC 4497 encryption. The Concatenation Key Derivation Function (Approved 4498 Alternative 1) [SP800-56A] with the KDF hash function that is 4499 SHA2-256 [FIPS180] or stronger is REQUIRED. See Section 16 for the 4500 details regarding the choice of the hash function. 4502 For convenience, the synopsis of the encoding method is given below 4503 with significant simplifications attributable to the restricted 4504 choice of hash functions in this document. However, [SP800-56A] is 4505 the normative source of the definition. 4507 // Implements KDF( X, oBits, Param ); 4508 // Input: point X = (x,y) 4509 // oBits - the desired size of output 4510 // hBits - the size of output of hash function Hash 4511 // Param - octets representing the parameters 4512 // Assumes that oBits <= hBits 4513 // Convert the point X to the octet string: 4514 // ZB' = 04 || x || y 4515 // and extract the x portion from ZB' 4516 ZB = x; 4517 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 4518 return oBits leftmost bits of MB. 4520 Note that ZB in the KDF description above is the compact 4521 representation of X, defined in Section 4.2 of [RFC6090]. 4523 13.5. EC DH Algorithm (ECDH) 4525 The method is a combination of an ECC Diffie-Hellman method to 4526 establish a shared secret, a key derivation method to process the 4527 shared secret into a derived key, and a key wrapping method that uses 4528 the derived key to protect a session key used to encrypt a message. 4530 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 4531 be implemented with the following restrictions: the ECC CDH primitive 4532 employed by this method is modified to always assume the cofactor as 4533 1, the KDF specified in Section 13.4 is used, and the KDF parameters 4534 specified below are used. 4536 The KDF parameters are encoded as a concatenation of the following 5 4537 variable-length and fixed-length fields, compatible with the 4538 definition of the OtherInfo bitstring [SP800-56A]: 4540 * a variable-length field containing a curve OID, formatted as 4541 follows: 4543 - a one-octet size of the following field 4545 - the octets representing a curve OID, defined in Section 9.2 4547 * a one-octet public key algorithm ID defined in Section 9.1 4549 * a variable-length field containing KDF parameters, identical to 4550 the corresponding field in the ECDH public key, formatted as 4551 follows: 4553 - a one-octet size of the following fields; values 0 and 0xff are 4554 reserved for future extensions 4556 - a one-octet value 01, reserved for future extensions 4558 - a one-octet hash function ID used with the KDF 4560 - a one-octet algorithm ID for the symmetric algorithm used to 4561 wrap the symmetric key for message encryption; see Section 13.5 4562 for details 4564 * 20 octets representing the UTF-8 encoding of the string "Anonymous 4565 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 73 4566 20 53 65 6E 64 65 72 20 20 20 20 4568 * 20 octets representing a recipient encryption subkey or a master 4569 key fingerprint, identifying the key material that is needed for 4570 the decryption. For version 5 keys the 20 leftmost octets of the 4571 fingerprint are used. 4573 The size of the KDF parameters sequence, defined above, is either 54 4574 for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 4575 for Curve25519. 4577 The key wrapping method is described in [RFC3394]. KDF produces a 4578 symmetric key that is used as a key-encryption key (KEK) as specified 4579 in [RFC3394]. Refer to Section 15 for the details regarding the 4580 choice of the KEK algorithm, which SHOULD be one of three AES 4581 algorithms. Key wrapping and unwrapping is performed with the 4582 default initial value of [RFC3394]. 4584 The input to the key wrapping method is the value "m" derived from 4585 the session key, as described in Section 5.1, "Public-Key Encrypted 4586 Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step 4587 is omitted. The result is padded using the method described in 4588 [PKCS5] to the 8-byte granularity. For example, the following 4589 AES-256 session key, in which 32 octets are denoted from k0 to k31, 4590 is composed to form the following 40 octet sequence: 4592 09 k0 k1 ... k31 c0 c1 05 05 05 05 05 4594 The octets c0 and c1 above denote the checksum. This encoding allows 4595 the sender to obfuscate the size of the symmetric encryption key used 4596 to encrypt the data. For example, assuming that an AES algorithm is 4597 used for the session key, the sender MAY use 21, 13, and 5 bytes of 4598 padding for AES-128, AES-192, and AES-256, respectively, to provide 4599 the same number of octets, 40 total, as an input to the key wrapping 4600 method. 4602 The output of the method consists of two fields. The first field is 4603 the MPI containing the ephemeral key used to establish the shared 4604 secret. The second field is composed of the following two fields: 4606 * a one-octet encoding the size in octets of the result of the key 4607 wrapping method; the value 255 is reserved for future extensions; 4609 * up to 254 octets representing the result of the key wrapping 4610 method, applied to the 8-byte padded session key, as described 4611 above. 4613 Note that for session key sizes 128, 192, and 256 bits, the size of 4614 the result of the key wrapping method is, respectively, 32, 40, and 4615 48 octets, unless the size obfuscation is used. 4617 For convenience, the synopsis of the encoding method is given below; 4618 however, this section, [SP800-56A], and [RFC3394] are the normative 4619 sources of the definition. 4621 Obtain the authenticated recipient public key R 4622 Generate an ephemeral key pair {v, V=vG} 4623 Compute the shared point S = vR; 4624 m = symm_alg_ID || session key || checksum || pkcs5_padding; 4625 curve_OID_len = (byte)len(curve_OID); 4626 Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 4627 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 4628 Sender " || recipient_fingerprint; 4629 Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 4630 Compute Z = KDF( S, Z_len, Param ); 4631 Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4632 VB = convert point V to the octet string 4633 Output (MPI(VB) || len(C) || C). 4635 The decryption is the inverse of the method given. Note that the 4636 recipient obtains the shared secret by calculating 4638 S = rV = rvG, where (r,R) is the recipient's key pair. 4640 Consistent with Section 5.16, "AEAD Encrypted Data Packet (Tag 20)" 4641 and Section 5.14, "Sym. Encrypted Integrity Protected Data Packet 4642 (Tag 18)", AEAD encryption or a Modification Detection Code (MDC) 4643 MUST be used anytime the symmetric key is protected by ECDH. 4645 14. Notes on Algorithms 4647 14.1. PKCS#1 Encoding in OpenPGP 4649 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4650 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4651 has changed in the past. To avoid potential confusion and 4652 interoperability problems, we are including local copies in this 4653 document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447 4654 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4655 Nonetheless, we believe that there is value in having a self- 4656 contained document that avoids problems in the future with needed 4657 changes in the conventions. 4659 14.1.1. EME-PKCS1-v1_5-ENCODE 4661 Input: 4663 k = the length in octets of the key modulus. 4665 M = message to be encoded, an octet string of length mLen, 4666 where mLen <= k - 11. 4668 Output: 4670 EM = encoded message, an octet string of length k. 4672 Error: "message too long". 4674 1. Length checking: If mLen > k - 11, output "message too long" 4675 and stop. 4677 2. Generate an octet string PS of length k - mLen - 3 consisting 4678 of pseudo-randomly generated nonzero octets. The length of PS 4679 will be at least eight octets. 4681 3. Concatenate PS, the message M, and other padding to form an 4682 encoded message EM of length k octets as 4684 EM = 0x00 || 0x02 || PS || 0x00 || M. 4686 4. Output EM. 4688 14.1.2. EME-PKCS1-v1_5-DECODE 4690 Input: 4692 EM = encoded message, an octet string 4694 Output: 4696 M = message, an octet string, 4698 Error: "decryption error", 4700 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4701 into an octet string PS consisting of nonzero octets and a message M 4702 as follows 4704 EM = 0x00 || 0x02 || PS || 0x00 || M. 4706 If the first octet of EM does not have hexadecimal value 0x00, if the 4707 second octet of EM does not have hexadecimal value 0x02, if there is 4708 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4709 length of PS is less than 8 octets, output "decryption error" and 4710 stop. See also the security note in Section 15 regarding differences 4711 in reporting between a decryption error and a padding error. 4713 14.1.3. EMSA-PKCS1-v1_5 4715 This encoding method is deterministic and only has an encoding 4716 operation. 4718 Option: 4720 Hash - a hash function in which hLen denotes the length in octets 4721 of the hash function output. 4723 Input: 4725 M = message to be encoded. 4727 emLen = intended length in octets of the encoded message, at least 4728 tLen + 11, where tLen is the octet length of the DER encoding 4729 T of a certain value computed during the encoding operation. 4731 Output: 4733 EM = encoded message, an octet string of length emLen. 4735 Errors: "message too long"; 4736 "intended encoded message length too short". 4738 Steps: 4740 1. Apply the hash function to the message M to produce a hash 4741 value H: 4743 H = Hash(M). 4745 If the hash function outputs "message too long," output 4746 "message too long" and stop. 4748 2. Using the list in Section {FIXREF} 5.2.2, "Version 2 Signature Packet 4749 Format", produce an ASN.1 DER value for the hash function 4750 used. Let T be the full hash prefix from the list, and let 4751 tLen be the length in octets of T. 4753 3. If emLen < tLen + 11, output "intended encoded message length 4754 too short" and stop. 4756 4. Generate an octet string PS consisting of emLen - tLen - 3 4757 octets with hexadecimal value 0xFF. The length of PS will be 4758 at least 8 octets. 4760 5. Concatenate PS, the hash prefix T, and other padding to form 4761 the encoded message EM as 4763 EM = 0x00 || 0x01 || PS || 0x00 || T. 4765 6. Output EM. 4767 14.2. Symmetric Algorithm Preferences 4769 The symmetric algorithm preference is an ordered list of algorithms 4770 that the keyholder accepts. Since it is found on a self-signature, 4771 it is possible that a keyholder may have multiple, different 4772 preferences. For example, Alice may have AES-128 only specified for 4773 "alice@work.com" but Camellia-256, Twofish, and AES-128 specified for 4774 "alice@home.org". Note that it is also possible for preferences to 4775 be in a subkey's binding signature. 4777 Since AES-128 is the MUST-implement algorithm, if it is not 4778 explicitly in the list, it is tacitly at the end. However, it is 4779 good form to place it there explicitly. Note also that if an 4780 implementation does not implement the preference, then it is 4781 implicitly an AES-128-only implementation. Note further that 4782 implementations conforming to previous versions of this standard 4783 (RFC-4880) have TripleDES as its only MUST-implement algorithm. 4785 An implementation MUST NOT use a symmetric algorithm that is not in 4786 the recipient's preference list. When encrypting to more than one 4787 recipient, the implementation finds a suitable algorithm by taking 4788 the intersection of the preferences of the recipients. Note that the 4789 MUST-implement algorithm, AES-128, ensures that the intersection is 4790 not null. The implementation may use any mechanism to pick an 4791 algorithm in the intersection. 4793 If an implementation can decrypt a message that a keyholder doesn't 4794 have in their preferences, the implementation SHOULD decrypt the 4795 message anyway, but MUST warn the keyholder that the protocol has 4796 been violated. For example, suppose that Alice, above, has software 4797 that implements all algorithms in this specification. Nonetheless, 4798 she prefers subsets for work or home. If she is sent a message 4799 encrypted with IDEA, which is not in her preferences, the software 4800 warns her that someone sent her an IDEA-encrypted message, but it 4801 would ideally decrypt it anyway. 4803 14.3. Other Algorithm Preferences 4805 Other algorithm preferences work similarly to the symmetric algorithm 4806 preference, in that they specify which algorithms the keyholder 4807 accepts. There are two interesting cases that other comments need to 4808 be made about, though, the compression preferences and the hash 4809 preferences. 4811 14.3.1. Compression Preferences 4813 Compression has been an integral part of PGP since its first days. 4814 OpenPGP and all previous versions of PGP have offered compression. 4815 In this specification, the default is for messages to be compressed, 4816 although an implementation is not required to do so. Consequently, 4817 the compression preference gives a way for a keyholder to request 4818 that messages not be compressed, presumably because they are using a 4819 minimal implementation that does not include compression. 4820 Additionally, this gives a keyholder a way to state that it can 4821 support alternate algorithms. 4823 Like the algorithm preferences, an implementation MUST NOT use an 4824 algorithm that is not in the preference vector. If the preferences 4825 are not present, then they are assumed to be [ZIP(1), 4826 Uncompressed(0)]. 4828 Additionally, an implementation MUST implement this preference to the 4829 degree of recognizing when to send an uncompressed message. A robust 4830 implementation would satisfy this requirement by looking at the 4831 recipient's preference and acting accordingly. A minimal 4832 implementation can satisfy this requirement by never generating a 4833 compressed message, since all implementations can handle messages 4834 that have not been compressed. 4836 14.3.2. Hash Algorithm Preferences 4838 Typically, the choice of a hash algorithm is something the signer 4839 does, rather than the verifier, because a signer rarely knows who is 4840 going to be verifying the signature. This preference, though, allows 4841 a protocol based upon digital signatures ease in negotiation. 4843 Thus, if Alice is authenticating herself to Bob with a signature, it 4844 makes sense for her to use a hash algorithm that Bob's software uses. 4845 This preference allows Bob to state in his key which algorithms Alice 4846 may use. 4848 Since SHA2-256 is the MUST-implement hash algorithm, if it is not 4849 explicitly in the list, it is tacitly at the end. However, it is 4850 good form to place it there explicitly. 4852 14.4. Plaintext 4854 Algorithm 0, "plaintext", may only be used to denote secret keys that 4855 are stored in the clear. Implementations MUST NOT use plaintext in 4856 Symmetrically Encrypted Data packets; they must use Literal Data 4857 packets to encode unencrypted or literal data. 4859 14.5. RSA 4861 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4862 keys. These types are deprecated. The "key flags" subpacket in a 4863 signature is a much better way to express the same idea, and 4864 generalizes it to all algorithms. An implementation SHOULD NOT 4865 create such a key, but MAY interpret it. 4867 An implementation SHOULD NOT implement RSA keys of size less than 4868 1024 bits. 4870 14.6. DSA 4872 An implementation SHOULD NOT implement DSA keys of size less than 4873 1024 bits. It MUST NOT implement a DSA key with a q size of less 4874 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4875 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4876 (DSS) [FIPS186] specifies that DSA be used in one of the following 4877 ways: 4879 * 1024-bit key, 160-bit q, SHA-1, SHA2-224, SHA2-256, SHA2-384, or 4880 SHA2-512 hash 4882 * 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 4883 hash 4885 * 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4887 * 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4889 The above key and q size pairs were chosen to best balance the 4890 strength of the key with the strength of the hash. Implementations 4891 SHOULD use one of the above key and q size pairs when generating DSA 4892 keys. If DSS compliance is desired, one of the specified SHA hashes 4893 must be used as well. [FIPS186] is the ultimate authority on DSS, 4894 and should be consulted for all questions of DSS compliance. 4896 Note that earlier versions of this standard only allowed a 160-bit q 4897 with no truncation allowed, so earlier implementations may not be 4898 able to handle signatures with a different q size or a truncated 4899 hash. 4901 14.7. Elgamal 4903 An implementation SHOULD NOT implement Elgamal keys of size less than 4904 1024 bits. 4906 14.8. EdDSA 4908 Although the EdDSA algorithm allows arbitrary data as input, its use 4909 with OpenPGP requires that a digest of the message is used as input 4910 (pre-hashed). See section Section 5.2.4, "Computing Signatures" for 4911 details. Truncation of the resulting digest is never applied; the 4912 resulting digest value is used verbatim as input to the EdDSA 4913 algorithm. 4915 14.9. Reserved Algorithm Numbers 4917 A number of algorithm IDs have been reserved for algorithms that 4918 would be useful to use in an OpenPGP implementation, yet there are 4919 issues that prevent an implementer from actually implementing the 4920 algorithm. These are marked in Section 9.1, "Public-Key Algorithms", 4921 as "reserved for". 4923 The reserved public-key algorithm X9.42 (21) does not have the 4924 necessary parameters, parameter order, or semantics defined. The 4925 same is currently true for reserved public-key algorithms AEDH (23) 4926 and AEDSA (24). 4928 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4929 with a public-key identifier of 20. These are no longer permitted. 4930 An implementation MUST NOT generate such keys. An implementation 4931 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4933 14.10. OpenPGP CFB Mode 4935 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4936 mode (CFB mode). This section describes the procedure it uses in 4937 detail. This mode is what is used for Symmetrically Encrypted Data 4938 Packets; the mechanism used for encrypting secret-key material is 4939 similar, and is described in the sections above. 4941 In the description below, the value BS is the block size in octets of 4942 the cipher. Most ciphers have a block size of 8 octets. The AES and 4943 Twofish have a block size of 16 octets. Also note that the 4944 description below assumes that the IV and CFB arrays start with an 4945 index of 1 (unlike the C language, which assumes arrays start with a 4946 zero index). 4948 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4949 prefixes the plaintext with BS+2 octets of random data, such that 4950 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4951 resynchronization after encrypting those BS+2 octets. 4953 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4954 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4955 octets 9 and 10. For an algorithm with a block size of 16 octets 4956 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4957 octets 15 and 16. Those extra two octets are an easy check for a 4958 correct key. 4960 Step by step, here is the procedure: 4962 1. The feedback register (FR) is set to the IV, which is all zeros. 4964 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4965 encryption of an all-zero value. 4967 3. FRE is xored with the first BS octets of random data prefixed to 4968 the plaintext to produce C[1] through C[BS], the first BS octets 4969 of ciphertext. 4971 4. FR is loaded with C[1] through C[BS]. 4973 5. FR is encrypted to produce FRE, the encryption of the first BS 4974 octets of ciphertext. 4976 6. The left two octets of FRE get xored with the next two octets of 4977 data that were prefixed to the plaintext. This produces C[BS+1] 4978 and C[BS+2], the next two octets of ciphertext. 4980 7. (The resynchronization step) FR is loaded with C[3] through 4981 C[BS+2]. 4983 8. FRE is xored with the first BS octets of the given plaintext, 4984 now that we have finished encrypting the BS+2 octets of prefixed 4985 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4986 octets of ciphertext. 4988 9. FR is encrypted to produce FRE. 4990 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4991 for an 8-octet block). 4993 11. FR is encrypted to produce FRE. 4995 12. FRE is xored with the next BS octets of plaintext, to produce 4996 the next BS octets of ciphertext. These are loaded into FR, and 4997 the process is repeated until the plaintext is used up. 4999 14.11. Private or Experimental Parameters 5001 S2K specifiers, Signature subpacket types, User Attribute types, 5002 image format types, and algorithms described in Section 9 all reserve 5003 the range 100 to 110 for private and experimental use. Packet types 5004 reserve the range 60 to 63 for private and experimental use. These 5005 are intentionally managed with the PRIVATE USE method, as described 5006 in [RFC8126]. 5008 However, implementations need to be careful with these and promote 5009 them to full IANA-managed parameters when they grow beyond the 5010 original, limited system. 5012 14.12. Meta-Considerations for Expansion 5014 If OpenPGP is extended in a way that is not backwards-compatible, 5015 meaning that old implementations will not gracefully handle their 5016 absence of a new feature, the extension proposal can be declared in 5017 the key holder's self-signature as part of the Features signature 5018 subpacket. 5020 We cannot state definitively what extensions will not be upwards- 5021 compatible, but typically new algorithms are upwards-compatible, 5022 whereas new packets are not. 5024 If an extension proposal does not update the Features system, it 5025 SHOULD include an explanation of why this is unnecessary. If the 5026 proposal contains neither an extension to the Features system nor an 5027 explanation of why such an extension is unnecessary, the proposal 5028 SHOULD be rejected. 5030 15. Security Considerations 5032 * As with any technology involving cryptography, you should check 5033 the current literature to determine if any algorithms used here 5034 have been found to be vulnerable to attack. 5036 * This specification uses Public-Key Cryptography technologies. It 5037 is assumed that the private key portion of a public-private key 5038 pair is controlled and secured by the proper party or parties. 5040 * Certain operations in this specification involve the use of random 5041 numbers. An appropriate entropy source should be used to generate 5042 these numbers (see [RFC4086]). 5044 * The MD5 hash algorithm has been found to have weaknesses, with 5045 collisions found in a number of cases. MD5 is deprecated for use 5046 in OpenPGP. Implementations MUST NOT generate new signatures 5047 using MD5 as a hash function. They MAY continue to consider old 5048 signatures that used MD5 as valid. 5050 * SHA2-224 and SHA2-384 require the same work as SHA2-256 and 5051 SHA2-512, respectively. In general, there are few reasons to use 5052 them outside of DSS compatibility. You need a situation where one 5053 needs more security than smaller hashes, but does not want to have 5054 the full 256-bit or 512-bit data length. 5056 * Many security protocol designers think that it is a bad idea to 5057 use a single key for both privacy (encryption) and integrity 5058 (signatures). In fact, this was one of the motivating forces 5059 behind the V4 key format with separate signature and encryption 5060 keys. If you as an implementer promote dual-use keys, you should 5061 at least be aware of this controversy. 5063 * The DSA algorithm will work with any hash, but is sensitive to the 5064 quality of the hash algorithm. Verifiers should be aware that 5065 even if the signer used a strong hash, an attacker could have 5066 modified the signature to use a weak one. Only signatures using 5067 acceptably strong hash algorithms should be accepted as valid. 5069 * As OpenPGP combines many different asymmetric, symmetric, and hash 5070 algorithms, each with different measures of strength, care should 5071 be taken that the weakest element of an OpenPGP message is still 5072 sufficiently strong for the purpose at hand. While consensus 5073 about the strength of a given algorithm may evolve, NIST Special 5074 Publication 800-57 [SP800-57] recommends the following list of 5075 equivalent strengths: 5077 +---------------------+-----------+--------------------+ 5078 | Asymmetric key size | Hash size | Symmetric key size | 5079 +=====================+===========+====================+ 5080 | 1024 | 160 | 80 | 5081 +---------------------+-----------+--------------------+ 5082 | 2048 | 224 | 112 | 5083 +---------------------+-----------+--------------------+ 5084 | 3072 | 256 | 128 | 5085 +---------------------+-----------+--------------------+ 5086 | 7680 | 384 | 192 | 5087 +---------------------+-----------+--------------------+ 5088 | 15360 | 512 | 256 | 5089 +---------------------+-----------+--------------------+ 5091 Table 16 5093 * There is a somewhat-related potential security problem in 5094 signatures. If an attacker can find a message that hashes to the 5095 same hash with a different algorithm, a bogus signature structure 5096 can be constructed that evaluates correctly. 5098 For example, suppose Alice DSA signs message M using hash 5099 algorithm H. Suppose that Mallet finds a message M' that has the 5100 same hash value as M with H'. Mallet can then construct a 5101 signature block that verifies as Alice's signature of M' with H'. 5102 However, this would also constitute a weakness in either H or H' 5103 or both. Should this ever occur, a revision will have to be made 5104 to this document to revise the allowed hash algorithms. 5106 * If you are building an authentication system, the recipient may 5107 specify a preferred signing algorithm. However, the signer would 5108 be foolish to use a weak algorithm simply because the recipient 5109 requests it. 5111 * Some of the encryption algorithms mentioned in this document have 5112 been analyzed less than others. For example, although CAST5 is 5113 presently considered strong, it has been analyzed less than 5114 TripleDES. Other algorithms may have other controversies 5115 surrounding them. 5117 * In late summer 2002, Jallad, Katz, and Schneier published an 5118 interesting attack on the OpenPGP protocol and some of its 5119 implementations [JKS02]. In this attack, the attacker modifies a 5120 message and sends it to a user who then returns the erroneously 5121 decrypted message to the attacker. The attacker is thus using the 5122 user as a random oracle, and can often decrypt the message. 5124 Compressing data can ameliorate this attack. The incorrectly 5125 decrypted data nearly always decompresses in ways that defeat the 5126 attack. However, this is not a rigorous fix, and leaves open some 5127 small vulnerabilities. For example, if an implementation does not 5128 compress a message before encryption (perhaps because it knows it 5129 was already compressed), then that message is vulnerable. Because 5130 of this happenstance -- that modification attacks can be thwarted 5131 by decompression errors -- an implementation SHOULD treat a 5132 decompression error as a security problem, not merely a data 5133 problem. 5135 This attack can be defeated by the use of modification detection, 5136 provided that the implementation does not let the user naively 5137 return the data to the attacker. The modification detection is 5138 prefereabble implemented by using the AEAD Encrypted Data Packet 5139 and only if the recipients don't supports this by use of the 5140 Symmmetric Encrypted and Integrity Protected Data Packet. An 5141 implementation MUST treat an authentication or MDC failure as a 5142 security problem, not merely a data problem. 5144 In either case, the implementation SHOULD NOT allow the user 5145 access to the erroneous data, and MUST warn the user as to 5146 potential security problems should that data be returned to the 5147 sender. 5149 While this attack is somewhat obscure, requiring a special set of 5150 circumstances to create it, it is nonetheless quite serious as it 5151 permits someone to trick a user to decrypt a message. 5152 Consequently, it is important that: 5154 1. Implementers treat authentication errors, MDC errors, 5155 decompression failures or no use of MDC or AEAD as security 5156 problems. 5158 2. Implementers implement AEAD with all due speed and encourage 5159 its spread. 5161 3. Users migrate to implementations that support AEAD encryption 5162 with all due speed. 5164 * PKCS#1 has been found to be vulnerable to attacks in which a 5165 system that reports errors in padding differently from errors in 5166 decryption becomes a random oracle that can leak the private key 5167 in mere millions of queries. Implementations must be aware of 5168 this attack and prevent it from happening. The simplest solution 5169 is to report a single error code for all variants of decryption 5170 errors so as not to leak information to an attacker. 5172 * Some technologies mentioned here may be subject to government 5173 control in some countries. 5175 * In winter 2005, Serge Mister and Robert Zuccherato from Entrust 5176 released a paper describing a way that the "quick check" in 5177 OpenPGP CFB mode can be used with a random oracle to decrypt two 5178 octets of every cipher block [MZ05]. They recommend as prevention 5179 not using the quick check at all. 5181 Many implementers have taken this advice to heart for any data 5182 that is symmetrically encrypted and for which the session key is 5183 public-key encrypted. In this case, the quick check is not needed 5184 as the public-key encryption of the session key should guarantee 5185 that it is the right session key. In other cases, the 5186 implementation should use the quick check with care. 5188 On the one hand, there is a danger to using it if there is a 5189 random oracle that can leak information to an attacker. In 5190 plainer language, there is a danger to using the quick check if 5191 timing information about the check can be exposed to an attacker, 5192 particularly via an automated service that allows rapidly repeated 5193 queries. 5195 On the other hand, it is inconvenient to the user to be informed 5196 that they typed in the wrong passphrase only after a petabyte of 5197 data is decrypted. There are many cases in cryptographic 5198 engineering where the implementer must use care and wisdom, and 5199 this is one. 5201 * Refer to [FIPS186], B.4.1, for the method to generate a uniformly 5202 distributed ECC private key. 5204 * The curves proposed in this document correspond to the symmetric 5205 key sizes 128 bits, 192 bits, and 256 bits, as described in the 5206 table below. This allows a compliant application to offer 5207 balanced public key security, which is compatible with the 5208 symmetric key strength for each AES algorithm defined here. 5210 The following table defines the hash and the symmetric encryption 5211 algorithm that SHOULD be used with a given curve for ECDSA or 5212 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 5213 be used for a given ECC curve. However, note that the increase in 5214 the strength of the hash algorithm or the symmetric key algorithm 5215 may not increase the overall security offered by the given ECC 5216 key. 5218 +------------+-----+--------------+---------------------+-----------+ 5219 | Curve name | ECC | RSA | Hash size strength, | Symmetric | 5220 | | | strength | informative | key size | 5221 +============+=====+==============+=====================+===========+ 5222 | NIST P-256 | 256 | 3072 | 256 | 128 | 5223 +------------+-----+--------------+---------------------+-----------+ 5224 | NIST P-384 | 384 | 7680 | 384 | 192 | 5225 +------------+-----+--------------+---------------------+-----------+ 5226 | NIST P-521 | 521 | 15360 | 512 | 256 | 5227 +------------+-----+--------------+---------------------+-----------+ 5229 Table 17 5231 * Requirement levels indicated elsewhere in this document lead to 5232 the following combinations of algorithms in the OpenPGP profile: 5233 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 5234 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 5235 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 5236 combinations. 5238 Consistent with the table above, the following table defines the 5239 KDF hash algorithm and the AES KEK encryption algorithm that 5240 SHOULD be used with a given curve for ECDH. A stronger KDF hash 5241 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 5243 +------------+-----------------+----------------------+ 5244 | Curve name | Recommended KDF | Recommended KEK | 5245 | | hash algorithm | encryption algorithm | 5246 +============+=================+======================+ 5247 | NIST P-256 | SHA2-256 | AES-128 | 5248 +------------+-----------------+----------------------+ 5249 | NIST P-384 | SHA2-384 | AES-192 | 5250 +------------+-----------------+----------------------+ 5251 | NIST P-521 | SHA2-512 | AES-256 | 5252 +------------+-----------------+----------------------+ 5254 Table 18 5256 * This document explicitly discourages the use of algorithms other 5257 than AES as a KEK algorithm because backward compatibility of the 5258 ECDH format is not a concern. The KEK algorithm is only used 5259 within the scope of a Public-Key Encrypted Session Key Packet, 5260 which represents an ECDH key recipient of a message. Compare this 5261 with the algorithm used for the session key of the message, which 5262 MAY be different from a KEK algorithm. 5264 Compliant applications SHOULD implement, advertise through key 5265 preferences, and use the strongest algorithms specified in this 5266 document. 5268 Note that the symmetric algorithm preference list may make it 5269 impossible to use the balanced strength of symmetric key 5270 algorithms for a corresponding public key. For example, the 5271 presence of the symmetric key algorithm IDs and their order in the 5272 key preference list affects the algorithm choices available to the 5273 encoding side, which in turn may make the adherence to the table 5274 above infeasible. Therefore, compliance with this specification 5275 is a concern throughout the life of the key, starting immediately 5276 after the key generation when the key preferences are first added 5277 to a key. It is generally advisable to position a symmetric 5278 algorithm ID of strength matching the public key at the head of 5279 the key preference list. 5281 Encryption to multiple recipients often results in an unordered 5282 intersection subset. For example, if the first recipient's set is 5283 {A, B} and the second's is {B, A}, the intersection is an 5284 unordered set of two algorithms, A and B. In this case, a 5285 compliant application SHOULD choose the stronger encryption 5286 algorithm. 5288 Resource constraints, such as limited computational power, is a 5289 likely reason why an application might prefer to use the weakest 5290 algorithm. On the other side of the spectrum are applications 5291 that can implement every algorithm defined in this document. Most 5292 applications are expected to fall into either of two categories. 5293 A compliant application in the second, or strongest, category 5294 SHOULD prefer AES-256 to AES-192. 5296 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 5297 method. 5299 MDC MUST be used when a symmetric encryption key is protected by 5300 ECDH. None of the ECC methods described in this document are 5301 allowed with deprecated V3 keys. A compliant application MUST 5302 only use iterated and salted S2K to protect private keys, as 5303 defined in Section 3.7.1.3, "Iterated and Salted S2K". 5305 Side channel attacks are a concern when a compliant application's 5306 use of the OpenPGP format can be modeled by a decryption or 5307 signing oracle model, for example, when an application is a 5308 network service performing decryption to unauthenticated remote 5309 users. ECC scalar multiplication operations used in ECDSA and 5310 ECDH are vulnerable to side channel attacks. Countermeasures can 5311 often be taken at the higher protocol level, such as limiting the 5312 number of allowed failures or time-blinding of the operations 5313 associated with each network interface. Mitigations at the scalar 5314 multiplication level seek to eliminate any measurable distinction 5315 between the ECC point addition and doubling operations. 5317 * Although technically possible, the EdDSA algorithm MUST NOT be 5318 used with a digest algorithms weaker than SHA2-256. 5320 OpenPGP was designed with security in mind, with many smart, 5321 intelligent people spending a lot of time thinking about the 5322 ramifications of their decisions. Removing the requirement for self- 5323 certifying User ID (and User Attribute) packets on a key means that 5324 someone could surreptitiously add an unwanted ID to a key and sign 5325 it. If enough "trusted" people sign that surreptitious identity then 5326 other people might believe it. The attack could wind up sending 5327 encrypted mail destined for alice to some other target, bob, because 5328 someone added "alice" to bob's key without bob's consent. 5330 In the case of device certificates the device itself does not have 5331 any consent. It is given an identity by the device manufacturer and 5332 the manufacturer can insert that ID on the device certificate, 5333 signing it with the manufacturer's key. If another people wants to 5334 label the device by another name, they can do so. There is no harm 5335 in multiple IDs, because the verification is all done based on who 5336 has signed those IDs. 5338 When a key can self-sign, it is still suggested to self-certify IDs, 5339 even if it no longer required by this modification to OpenPGP. This 5340 at least signals to recipients of keys that yes, the owner of this 5341 key asserts that this identity belongs to herself. Note, however, 5342 that mallet could still assert that he is 'alice' and could even 5343 self-certify that. So the attack is not truly different. Moreover, 5344 in the case of device certificates, it's more the manufacturer than 5345 the device that wants to assert an identity (even if the device could 5346 self-certify). 5348 There is no signaling whether a key is using this looser-requirement 5349 key format. An attacker could therefore just remove the self- 5350 signature off a published key. However one would hope that wide 5351 publication would result in another copy still having that signature 5352 and it being returned quickly. However, the lack of signaling also 5353 means that a user with an application following RFC 4880 directly 5354 would see a key following this specification as "broken" and may not 5355 accept it. 5357 On a different note, including the "geo" notation could leak 5358 information about where a signer is located. However it is just an 5359 assertion (albeit a signed assertion) so there is no verifiable truth 5360 to the location information released. Similarly, all the rest of the 5361 signature notations are pure assertions, so they should be taken with 5362 the trustworthiness of the signer. 5364 Combining the User ID with the User Attribute means that an ID and 5365 image would not be separable. For a person this is probably not 5366 good, but for a device it's unlikely the image will change so it 5367 makes sense to combine the ID and image into a single signed packet 5368 with a single signature. 5370 16. Compatibility Profiles 5372 16.1. OpenPGP ECC Profile 5374 A compliant application MUST implement NIST curve P-256, SHOULD 5375 implement NIST curve P-521, SHOULD implemend Ed25519, SHOULD 5376 implement Curve25519, MAY implement NIST curve P-384, MAY implement 5377 brainpoolP256r1, and MAY implement brainpoolP512r1, as defined in 5378 Section 9.2. A compliant application MUST implement SHA2-256 and 5379 SHOULD implement SHA2-384 and SHA2-512. A compliant application MUST 5380 implement AES-128 and SHOULD implement AES-256. 5382 A compliant application SHOULD follow Section 15 regarding the choice 5383 of the following algorithms for each curve: 5385 * the KDF hash algorithm, 5387 * the KEK algorithm, 5389 * the message digest algorithm and the hash algorithm used in the 5390 key certifications, 5392 * the symmetric algorithm used for message encryption. 5394 It is recommended that the chosen symmetric algorithm for message 5395 encryption be no less secure than the KEK algorithm. 5397 16.2. Suite-B Profile 5399 A subset of algorithms allowed by this document can be used to 5400 achieve [SuiteB] compatibility. The references to [SuiteB] in this 5401 document are informative. This document is primarily concerned with 5402 format specification, leaving additional security restrictions 5403 unspecified, such as matching the assigned security level of 5404 information to authorized recipients or interoperability concerns 5405 arising from fewer allowed algorithms in [SuiteB] than allowed by 5406 this document. 5408 16.2.1. Security Strength at 192 Bits 5410 To achieve the security strength of 192 bits, [SuiteB] requires NIST 5411 curve P-384, AES-256, and SHA2-384. The symmetric algorithm 5412 restriction means that the algorithm of KEK used for key wrapping in 5413 Section 13.5 and an OpenPGP session key used for message encryption 5414 must be AES-256. The hash algorithm restriction means that the hash 5415 algorithms of KDF and the OpenPGP message digest calculation must be 5416 SHA2-384. 5418 16.2.2. Security Strength at 128 Bits 5420 The set of algorithms in Section 16.2.1 is extended to allow NIST 5421 curve P-256, AES-128, and SHA2-256. 5423 17. Implementation Nits 5425 This section is a collection of comments to help an implementer, 5426 particularly with an eye to backward compatibility. Previous 5427 implementations of PGP are not OpenPGP compliant. Often the 5428 differences are small, but small differences are frequently more 5429 vexing than large differences. Thus, this is a non-comprehensive 5430 list of potential problems and gotchas for a developer who is trying 5431 to be backward-compatible. 5433 * The IDEA algorithm is patented, and yet it is required for PGP 2 5434 interoperability. It is also the de-facto preferred algorithm for 5435 a V3 key with a V3 self-signature (or no self- signature). 5437 * When exporting a private key, PGP 2 generates the header "BEGIN 5438 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 5439 All previous versions ignore the implied data type, and look 5440 directly at the packet data type. 5442 * PGP versions 2.0 through 2.5 generated V2 Public-Key packets. 5443 These are identical to the deprecated V3 keys except for the 5444 version number. An implementation MUST NOT generate them and may 5445 accept or reject them as it sees fit. Some older PGP versions 5446 generated V2 PKESK packets (Tag 1) as well. An implementation may 5447 accept or reject V2 PKESK packets as it sees fit, and MUST NOT 5448 generate them. 5450 * PGP version 2.6 will not accept key-material packets with versions 5451 greater than 3. 5453 * There are many ways possible for two keys to have the same key 5454 material, but different fingerprints (and thus Key IDs). Perhaps 5455 the most interesting is an RSA key that has been "upgraded" to V4 5456 format, but since a V4 fingerprint is constructed by hashing the 5457 key creation time along with other things, two V4 keys created at 5458 different times, yet with the same key material will have 5459 different fingerprints. 5461 * If an implementation is using zlib to interoperate with PGP 2, 5462 then the "windowBits" parameter should be set to -13. 5464 * The 0x19 back signatures were not required for signing subkeys 5465 until relatively recently. Consequently, there may be keys in the 5466 wild that do not have these back signatures. Implementing 5467 software may handle these keys as it sees fit. 5469 * OpenPGP does not put limits on the size of public keys. However, 5470 larger keys are not necessarily better keys. Larger keys take 5471 more computation time to use, and this can quickly become 5472 impractical. Different OpenPGP implementations may also use 5473 different upper bounds for public key sizes, and so care should be 5474 taken when choosing sizes to maintain interoperability. As of 5475 2007 most implementations have an upper bound of 4096 bits. 5477 * ASCII armor is an optional feature of OpenPGP. The OpenPGP 5478 working group strives for a minimal set of mandatory-to-implement 5479 features, and since there could be useful implementations that 5480 only use binary object formats, this is not a "MUST" feature for 5481 an implementation. For example, an implementation that is using 5482 OpenPGP as a mechanism for file signatures may find ASCII armor 5483 unnecessary. OpenPGP permits an implementation to declare what 5484 features it does and does not support, but ASCII armor is not one 5485 of these. Since most implementations allow binary and armored 5486 objects to be used indiscriminately, an implementation that does 5487 not implement ASCII armor may find itself with compatibility 5488 issues with general-purpose implementations. Moreover, 5489 implementations of OpenPGP-MIME [RFC3156] already have a 5490 requirement for ASCII armor so those implementations will 5491 necessarily have support. 5493 * The OCB mode is patented and a debate is still underway on whether 5494 it can be included in RFC4880bis or needs to be moved to a 5495 separate document. For the sole purpose of experimenting with the 5496 Preferred AEAD Algorithms signature subpacket it is has been 5497 included in this I-D. 5499 18. References 5501 18.1. Normative References 5503 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 5504 November 2001, 5505 . 5508 [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 5509 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 5510 Cambridge Security Workshop Proceedings Springer-Verlag, 5511 1994, pp191-204, December 1993, 5512 . 5514 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, 5515 . 5517 [EAX] Bellare, M., Rogaway, P., and D. Wagner, "A Conventional 5518 Authenticated-Encryption Mode", April 2003. 5520 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 5521 Scheme Based on Discrete Logarithms", IEEE Transactions on 5522 Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 5523 1985. 5525 [FIPS180] National Institute of Standards and Technology, U.S. 5526 Department of Commerce, "Secure Hash Standard (SHS), FIPS 5527 180-4", August 2015, 5528 . 5530 [FIPS186] National Institute of Standards and Technology, U.S. 5531 Department of Commerce, "Digital Signature Standard (DSS), 5532 FIPS 186-4", July 2013, 5533 . 5535 [FIPS202] National Institute of Standards and Technology, U.S. 5536 Department of Commerce, "SHA-3 Standard: Permutation-Based 5537 Hash and Extendable-Output Functions, FIPS 202", August 5538 2015, . 5540 [HAC] Menezes, A.J., Oorschot, P.v., and S. Vanstone, "Handbook 5541 of Applied Cryptography", 1996. 5543 [IDEA] Lai, X., "On the design and security of block ciphers", 5544 ETH Series in Information Processing, J.L. Massey 5545 (editor) Vol. 1, Hartung-Gorre Verlag Konstanz, Technische 5546 Hochschule (Zurich), 1992. 5548 [ISO10646] International Organization for Standardization, 5549 "Information Technology - Universal Multiple-octet coded 5550 Character Set (UCS) - Part 1: Architecture and Basic 5551 Multilingual Plane", ISO Standard 10646-1, May 1993. 5553 [JFIF] CA, E.H.M., "JPEG File Interchange Format (Version 5554 1.02).", September 1996. 5556 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 5557 Cryptography Standard", 25 March 1999. 5559 [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format 5560 Specification version 3.3", RFC 1950, 5561 DOI 10.17487/RFC1950, May 1996, 5562 . 5564 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 5565 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 5566 . 5568 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5569 Extensions (MIME) Part One: Format of Internet Message 5570 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 5571 . 5573 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5574 Requirement Levels", BCP 14, RFC 2119, 5575 DOI 10.17487/RFC2119, March 1997, 5576 . 5578 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 5579 DOI 10.17487/RFC2144, May 1997, 5580 . 5582 [RFC2822] Resnick, P., Ed., "Internet Message Format", RFC 2822, 5583 DOI 10.17487/RFC2822, April 2001, 5584 . 5586 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 5587 "MIME Security with OpenPGP", RFC 3156, 5588 DOI 10.17487/RFC3156, August 2001, 5589 . 5591 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 5592 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 5593 September 2002, . 5595 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 5596 Standards (PKCS) #1: RSA Cryptography Specifications 5597 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 5598 2003, . 5600 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5601 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 5602 2003, . 5604 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 5605 the Camellia Encryption Algorithm", RFC 3713, 5606 DOI 10.17487/RFC3713, April 2004, 5607 . 5609 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 5610 "Randomness Requirements for Security", BCP 106, RFC 4086, 5611 DOI 10.17487/RFC4086, June 2005, 5612 . 5614 [RFC5639] Lochter, M. and J. Merkle, "Elliptic Curve Cryptography 5615 (ECC) Brainpool Standard Curves and Curve Generation", 5616 RFC 5639, DOI 10.17487/RFC5639, March 2010, 5617 . 5619 [RFC5870] Mayrhofer, A. and C. Spanring, "A Uniform Resource 5620 Identifier for Geographic Locations ('geo' URI)", 5621 RFC 5870, DOI 10.17487/RFC5870, June 2010, 5622 . 5624 [RFC7253] Krovetz, T. and P. Rogaway, "The OCB Authenticated- 5625 Encryption Algorithm", RFC 7253, DOI 10.17487/RFC7253, May 5626 2014, . 5628 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 5629 for Security", RFC 7748, DOI 10.17487/RFC7748, January 5630 2016, . 5632 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 5633 Signature Algorithm (EdDSA)", RFC 8032, 5634 DOI 10.17487/RFC8032, January 2017, 5635 . 5637 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 5638 Writing an IANA Considerations Section in RFCs", BCP 26, 5639 RFC 8126, DOI 10.17487/RFC8126, June 2017, 5640 . 5642 [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: 5643 protocols, algorithms, and source code in C", 1996. 5645 [SP800-56A]Barker, E., Johnson, D., and M. Smid, "Recommendation for 5646 Pair-Wise Key Establishment Schemes Using Discrete 5647 Logarithm Cryptography", NIST Special Publication 800-56A 5648 Revision 1, March 2007. 5650 [SuiteB] National Security Agency, "NSA Suite B Cryptography", 11 5651 March 2010, 5652 . 5654 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 5655 C., and N. Ferguson, "The Twofish Encryption Algorithm", 5656 1999. 5658 18.2. Informative References 5660 [BLEICHENBACHER] 5661 Bleichenbacher, D., "Generating ElGamal Signatures Without 5662 Knowing the Secret Key", Lecture Notes in Computer 5663 Science Volume 1070, pp. 10-18, 1996. 5665 [JKS02] Jallad, K., Katz, J., and B. Schneier, "Implementation of 5666 Chosen-Ciphertext Attacks against PGP and GnuPG", 2002, 5667 . 5669 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 5670 Chapter VI. Elliptic Curves", ISBN 0-387-96576-9, 1997. 5672 [MZ05] Mister, S. and R. Zuccherato, "An Attack on CFB Mode 5673 Encryption As Used By OpenPGP", IACR ePrint Archive Report 5674 2005/033, 8 February 2005, 5675 . 5677 [REGEX] Friedl, J., "Mastering Regular Expressions", 5678 ISBN 0-596-00289-0, August 2002. 5680 [RFC1423] Balenson, D., "Privacy Enhancement for Internet Electronic 5681 Mail: Part III: Algorithms, Modes, and Identifiers", 5682 RFC 1423, DOI 10.17487/RFC1423, February 1993, 5683 . 5685 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5686 Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, August 5687 1996, . 5689 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5690 "OpenPGP Message Format", RFC 2440, DOI 10.17487/RFC2440, 5691 November 1998, . 5693 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 5694 Thayer, "OpenPGP Message Format", RFC 4880, 5695 DOI 10.17487/RFC4880, November 2007, 5696 . 5698 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5699 Curve Cryptography Algorithms", RFC 6090, 5700 DOI 10.17487/RFC6090, February 2011, 5701 . 5703 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5704 Elliptic Curve Cryptography", September 2000. 5706 [SP800-57] NIST, "Recommendation on Key Management", NIST Special 5707 Publication 800-57, March 2007, 5708 . 5711 Appendix A. Test vectors 5713 To help implementing this specification a non-normative example for 5714 the EdDSA algorithm is given. 5716 A.1. Sample EdDSA key 5718 The secret key used for this example is: 5720 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 5722 Note that this is the raw secret key used as input to the EdDSA 5723 signing operation. The key was created on 2014-08-19 14:28:27 and 5724 thus the fingerprint of the OpenPGP key is: 5726 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 5728 The algorithm specific input parameters without the MPI length 5729 headers are: 5731 oid: 2b06010401da470f01 5733 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 5735 The entire public key packet is thus: 5737 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 5738 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 5739 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 5740 43 ee 3b 24 06 5742 A.2. Sample EdDSA signature 5744 The signature is created using the sample key over the input data 5745 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 5746 function is: 5748 m: 4f70656e504750040016080006050255f95f9504ff0000000c 5750 Using the SHA2-256 hash algorithm yields the digest: 5752 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 5754 Which is fed into the EdDSA signature function and yields this 5755 signature: 5757 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 5759 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 5761 The entire signature packet is thus: 5763 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 5764 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 5765 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 5766 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 5767 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 5768 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 5770 A.3. Sample AEAD-EAX encryption and decryption 5772 Encryption is performed with the string 'Hello, world!' and password 5773 'password', using AES-128 with AEAD-EAX encryption. 5775 A.3.1. Sample Parameters 5777 S2K: 5779 type 3 5781 Iterations: 5783 524288 (144), SHA-256 5785 Salt: 5787 cd5a9f70fbe0bc65 5789 A.3.2. Sample symmetric-key encrypted session key packet (v5) 5791 Packet header: 5793 c3 3e 5795 Version, algorithms, S2K fields: 5797 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5799 AEAD IV: 5801 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5803 AEAD encrypted CEK: 5805 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 5807 Authentication tag: 5809 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 5811 A.3.3. Starting AEAD-EAX decryption of CEK 5813 The derived key is: 5815 b2 55 69 b9 54 32 45 66 45 27 c4 97 6e 7a 5d 6e 5817 Authenticated Data: 5819 c3 05 07 01 5821 Nonce: 5823 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5825 Decrypted CEK: 5827 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d 5829 A.3.4. Sample AEAD encrypted data packet 5831 Packet header: 5833 d4 4a 5835 Version, AES-128, EAX, Chunk bits (14): 5837 01 07 01 0e 5839 IV: 5841 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5843 AEAD-EAX Encrypted data chunk #0: 5845 5d c1 1a 81 dc 0c b8 a2 f6 f3 d9 00 16 38 4a 56 5846 fc 82 1a e1 1a e8 5848 Chunk #0 authentication tag: 5850 db cb 49 86 26 55 de a8 8d 06 a8 14 86 80 1b 0f 5852 Final (zero-size chunk #1) authentication tag: 5854 f3 87 bd 2e ab 01 3d e1 25 95 86 90 6e ab 24 76 5856 A.3.5. Decryption of data 5858 Starting AEAD-EAX decryption of data, using the CEK. 5860 Chunk #0: 5862 Authenticated data: 5864 d4 01 07 01 0e 00 00 00 00 00 00 00 00 5866 Nonce: 5868 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5870 Decrypted chunk #0. 5872 Literal data packet with the string contents 'Hello, world!\n'. 5874 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 5875 6f 72 6c 64 21 0a 5877 Authenticating final tag: 5879 Authenticated data: 5881 d4 01 07 01 0e 00 00 00 00 00 00 00 01 00 00 00 5882 00 00 00 00 16 5884 Nonce: 5886 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 11 5888 A.3.6. Complete AEAD-EAX encrypted packet sequence 5890 Symmetric-key encrypted session key packet (v5): 5892 c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5893 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5894 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 5895 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 5897 AEAD encrypted data packet: 5899 d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f 5900 ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3 5901 d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86 5902 26 55 de a8 8d 06 a8 14 86 80 1b 0f f3 87 bd 2e 5903 ab 01 3d e1 25 95 86 90 6e ab 24 76 5905 A.4. Sample AEAD-OCB encryption and decryption 5907 Encryption is performed with the string 'Hello, world!' and password 5908 'password', using AES-128 with AEAD-OCB encryption. 5910 A.4.1. Sample Parameters 5912 S2K: 5914 type 3 5916 Iterations: 5918 524288 (144), SHA-256 5920 Salt: 5922 9f0b7da3e5ea6477 5924 A.4.2. Sample symmetric-key encrypted session key packet (v5) 5926 Packet header: 5928 c3 3d 5930 Version, algorithms, S2K fields: 5932 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 5934 AEAD IV: 5936 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 5938 AEAD encrypted CEK: 5940 67 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da 5942 Authentication tag: 5944 c5 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 5946 A.4.3. Starting AEAD-OCB decryption of CEK 5948 The derived key is: 5950 eb 9d a7 8a 9d 5d f8 0e c7 02 05 96 39 9b 65 08 5952 Authenticated Data: 5954 c3 05 07 02 5956 Nonce: 5958 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 5960 Decrypted CEK: 5962 d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 5964 A.4.4. Sample AEAD encrypted data packet 5966 Packet header: 5968 d4 49 5970 Version, AES-128, OCB, Chunk bits (14): 5972 01 07 02 0e 5974 IV: 5976 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 5978 AEAD-OCB Encrypted data chunk #0: 5980 7b 0f 77 01 19 66 11 a1 54 ba 9c 25 74 cd 05 62 5981 84 a8 ef 68 03 5c 5983 Chunk #0 authentication tag: 5985 62 3d 93 cc 70 8a 43 21 1b b6 ea f2 b2 7f 7c 18 5987 Final (zero-size chunk #1) authentication tag: 5989 d5 71 bc d8 3b 20 ad d3 a0 8b 73 af 15 b9 a0 98 5991 A.4.5. Decryption of data 5993 Starting AEAD-OCB decryption of data, using the CEK. 5995 Chunk #0: 5997 Authenticated data: 5999 r4 01 07 02 0e 00 00 00 00 00 00 00 00 6001 Nonce: 6003 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 6005 Decrypted chunk #0. 6007 Literal data packet with the string contents 'Hello, world!\n'. 6009 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 6010 6f 72 6c 64 21 0a 6012 Authenticating final tag: 6014 Authenticated data: 6016 d4 01 07 02 0e 00 00 00 00 00 00 00 01 00 00 00 6017 00 00 00 00 16 6019 Nonce: 6021 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 57 6023 A.4.6. Complete AEAD-OCB encrypted packet sequence 6025 Symmetric-key encrypted session key packet (v5): 6027 c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 6028 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67 6029 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5 6030 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 6032 AEAD encrypted data packet: 6034 d4 49 01 07 02 0e 5e d2 bc 1e 47 0a be 8f 1d 64 6035 4c 7a 6c 8a 56 7b 0f 77 01 19 66 11 a1 54 ba 9c 6036 25 74 cd 05 62 84 a8 ef 68 03 5c 62 3d 93 cc 70 6037 8a 43 21 1b b6 ea f2 b2 7f 7c 18 d5 71 bc d8 3b 6038 20 ad d3 a0 8b 73 af 15 b9 a0 98 6040 Appendix B. ECC Point compression flag bytes 6042 This specification introduces the new flag byte 0x40 to indicate the 6043 point compression format. The value has been chosen so that the high 6044 bit is not cleared and thus to avoid accidental sign extension. Two 6045 other values might also be interesting for other ECC specifications: 6047 Flag Description 6048 ---- ----------- 6049 0x04 Standard flag for uncompressed format 6050 0x40 Native point format of the curve follows 6051 0x41 Only X coordinate follows. 6052 0x42 Only Y coordinate follows. 6054 Appendix C. Changes since RFC-4880 6056 * Applied errata 2270, 2271, 2242, 3298. 6058 * Added Camellia cipher from RFC 5581. 6060 * Incorporated RFC 6637 (ECC for OpenPGP) 6062 * Added draft-atkins-openpgp-device-certificates 6064 * Added draft-koch-eddsa-for-openpgp-04 6066 * Added Issuer Fingerprint signature subpacket. 6068 * Added a v5 key and fingerprint format. 6070 * Added OIDs for brainpool curves and Curve25519. 6072 * Marked SHA2-256 as MUST implement. 6074 * Marked Curve25519 and Ed25519 as SHOULD implement. 6076 * Marked SHA-1 as SHOULD NOT be used to create messages. 6078 * Marked MD5 as SHOULD NOT implement. 6080 * Changed v5 key fingerprint format to full 32 octets. 6082 * Added Literal Data Packet format octet 'm'. 6084 * Added Feature Flag for v5 key support. 6086 * Added AEAD Encrypted Data Packet. 6088 * Removed notes on extending the MDC packet. 6090 * Added v5 Symmetric-Key Encrypted Session Key packet. 6092 * Added AEAD encryption of secret keys. 6094 * Added test vectors for AEAD. 6096 * Added the Additional Encryption Subkey key flag. 6098 * Deprecated the Symmetrically Encrypted Data Packet. 6100 * Suggest limitation of the AEAD chunksize to 128 MiB. 6102 * Specified the V5 signature format. 6104 * Deprectated the creation of V3 signatures. 6106 * Adapted terms from RFC 8126. 6108 * Removed editorial marks and updated cross-references. 6110 * Added the timestamping usage key flag. 6112 * Added Intended Recipient signature subpacket. 6114 * Added Attested Certifications signature subpacket and signature 6115 class. 6117 * Added Key Block signature subpacket. 6119 Appendix D. The principal authors of RFC-4880 6121 Jon Callas 6122 EMail: jon@callas.org 6124 Lutz Donnerhacke 6125 EMail: lutz@iks-jena.de 6127 Hal Finney 6129 David Shaw 6130 EMail: dshaw@jabberwocky.com 6132 Rodney Thayer 6133 EMail: rodney@canola-jones.com 6135 Authors' Addresses 6137 Werner Koch 6138 GnuPG e.V. 6139 Rochusstr. 44 6140 40479 Duesseldorf 6141 Germany 6143 Email: wk@gnupg.org 6144 URI: https://gnupg.org/verein 6146 Email: sandals@crustytoothpaste.net 6148 Hong Kong 6149 Central, Hong Kong 6150 Suite 1111, 1 Pedder Street 6151 Ribose 6152 Ronald Henry Tse 6154 Email: ronald.tse@ribose.com 6155 URI: https://www.ribose.com 6157 Email: derek@ihtfp.com 6159 Email: dkg@fifthhorseman.net