idnits 2.17.1 draft-ietf-openpgp-rfc4880bis-01.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: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) -- The draft header indicates that this document updates RFC4880, but the abstract doesn't seem to directly say this. It does mention RFC4880 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC4880, updated by this document, for RFC5378 checks: 1999-12-21) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (January 2, 2017) is 2671 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 376 -- Looks like a reference, but probably isn't: '1' on line 4208 -- Looks like a reference, but probably isn't: '2' on line 376 -- Looks like a reference, but probably isn't: '3' on line 4217 == Missing Reference: 'REGEX' is mentioned on line 1452, but not defined == Missing Reference: 'Optional' is mentioned on line 2171, but not defined == Missing Reference: 'TBD1' is mentioned on line 2430, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3592, but not defined == Missing Reference: 'BLEICHENBACHER' is mentioned on line 4168, but not defined == Missing Reference: 'BS' is mentioned on line 4208, but not defined == Missing Reference: 'JKS02' is mentioned on line 4387, but not defined == Missing Reference: 'MZ05' is mentioned on line 4440, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. 'BLOWFISH' -- Possible downref: Non-RFC (?) normative reference: ref. 'BZ2' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180-3' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186-3' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' == Outdated reference: A later version (-08) exists of draft-irtf-cfrg-eddsa-02 ** Downref: Normative reference to an Informational draft: draft-irtf-cfrg-eddsa (ref. 'I-D.irtf-cfrg-eddsa') -- 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 2434 (Obsoleted by RFC 5226) ** 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 -- Possible downref: Non-RFC (?) normative reference: ref. 'SCHNEIER' -- Possible downref: Non-RFC (?) normative reference: ref. 'SP800-56A' -- 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: 11 errors (**), 0 flaws (~~), 10 warnings (==), 27 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group W. Koch 3 Internet-Draft 4 Updates: 4880 (if approved) January 2, 2017 5 Intended status: Standards Track 6 Expires: July 6, 2017 8 OpenPGP Message Format 9 draft-ietf-openpgp-rfc4880bis-01 11 Abstract 13 { Work in progress to update the OpenPGP specification from RFC4880 } 15 This document is maintained in order to publish all necessary 16 information needed to develop interoperable applications based on the 17 OpenPGP format. It is not a step-by-step cookbook for writing an 18 application. It describes only the format and methods needed to 19 read, check, generate, and write conforming packets crossing any 20 network. It does not deal with storage and implementation questions. 21 It does, however, discuss implementation issues necessary to avoid 22 security flaws. 24 OpenPGP software uses a combination of strong public-key and 25 symmetric cryptography to provide security services for electronic 26 communications and data storage. These services include 27 confidentiality, key management, authentication, and digital 28 signatures. This document specifies the message formats used in 29 OpenPGP. 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 http://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 July 6, 2017. 48 Copyright Notice 50 Copyright (c) 2017 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 55 (http://trustee.ietf.org/license-info) in effect on the date of 56 publication of this document. Please review these documents 57 carefully, as they describe your rights and restrictions with respect 58 to this document. Code Components extracted from this document must 59 include Simplified BSD License text as described in Section 4.e of 60 the Trust Legal Provisions and are provided without warranty as 61 described in the Simplified BSD License. 63 Table of Contents 65 1. {1} Introduction . . . . . . . . . . . . . . . . . . . . . . 5 66 1.1. {1.1} Terms . . . . . . . . . . . . . . . . . . . . . . . 5 67 2. {2} General functions . . . . . . . . . . . . . . . . . . . . 6 68 2.1. {2.1} Confidentiality via Encryption . . . . . . . . . . 6 69 2.2. {2.2} Authentication via Digital Signature . . . . . . . 7 70 2.3. {2.3} Compression . . . . . . . . . . . . . . . . . . . . 7 71 2.4. {2.4} Conversion to Radix-64 . . . . . . . . . . . . . . 8 72 2.5. {2.5} Signature-Only Applications . . . . . . . . . . . . 8 73 3. {3} Data Element Formats . . . . . . . . . . . . . . . . . . 8 74 3.1. {3.1} Scalar Numbers . . . . . . . . . . . . . . . . . . 8 75 3.2. {3.2} Multiprecision Integers . . . . . . . . . . . . . . 9 76 3.3. {3.3} Key IDs . . . . . . . . . . . . . . . . . . . . . . 9 77 3.4. {3.4} Text . . . . . . . . . . . . . . . . . . . . . . . 9 78 3.5. {3.5} Time Fields . . . . . . . . . . . . . . . . . . . . 10 79 3.6. {3.6} Keyrings . . . . . . . . . . . . . . . . . . . . . 10 80 3.7. {3.7} String-to-Key (S2K) Specifiers . . . . . . . . . . 10 81 3.7.1. {3.7.1} String-to-Key (S2K) Specifier Types . . . . . 10 82 3.7.2. {3.7.2} String-to-Key Usage . . . . . . . . . . . . . 12 83 4. {4} Packet Syntax . . . . . . . . . . . . . . . . . . . . . . 13 84 4.1. {4.1} Overview . . . . . . . . . . . . . . . . . . . . . 13 85 4.2. {4.2} Packet Headers . . . . . . . . . . . . . . . . . . 13 86 4.2.1. {4.2.1} Old Format Packet Lengths . . . . . . . . . . 14 87 4.2.2. {4.2.2} New Format Packet Lengths . . . . . . . . . . 15 88 4.2.3. {4.2.3} Packet Length Examples . . . . . . . . . . . 16 89 4.3. {4.3} Packet Tags . . . . . . . . . . . . . . . . . . . . 17 90 5. {5} Packet Types . . . . . . . . . . . . . . . . . . . . . . 17 91 5.1. {5.1} Public-Key Encrypted Session Key Packets (Tag 1) . 17 92 5.2. {5.2} Signature Packet (Tag 2) . . . . . . . . . . . . . 19 93 5.2.1. {5.2.1} Signature Types . . . . . . . . . . . . . . . 19 94 5.2.2. {5.2.2} Version 3 Signature Packet Format . . . . . . 21 95 5.2.3. {5.2.3} Version 4 Signature Packet Format . . . . . . 24 96 5.2.4. {5.2.4} Computing Signatures . . . . . . . . . . . . 40 97 5.3. {5.3} Symmetric-Key Encrypted Session Key Packets (Tag 3) 41 98 5.4. {5.4} One-Pass Signature Packets (Tag 4) . . . . . . . . 42 99 5.5. {5.5} Key Material Packet . . . . . . . . . . . . . . . . 43 100 5.5.1. {5.5.1} Key Packet Variants . . . . . . . . . . . . . 43 101 5.5.2. {5.5.2} Public-Key Packet Formats . . . . . . . . . . 44 102 5.5.3. {5.5.3} Secret-Key Packet Formats . . . . . . . . . . 47 103 5.6. {5.6} Compressed Data Packet (Tag 8) . . . . . . . . . . 49 104 5.7. {5.7} Symmetrically Encrypted Data Packet (Tag 9) . . . . 49 105 5.8. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) . 50 106 5.9. {5.9} Literal Data Packet (Tag 11) . . . . . . . . . . . 51 107 5.10. {5.10} Trust Packet (Tag 12) . . . . . . . . . . . . . . 52 108 5.11. {5.11} User ID Packet (Tag 13) . . . . . . . . . . . . . 52 109 5.12. {5.12} User Attribute Packet (Tag 17) . . . . . . . . . . 52 110 5.12.1. {5.12.1} The Image Attribute Subpacket . . . . . . . 53 111 5.12.2. User ID Attribute Subpacket . . . . . . . . . . . . 53 112 5.13. {5.13} Sym. Encrypted Integrity Protected Data Packet 113 (Tag 18) . . . . . . . . . . . . . . . . . . . . . . . . 54 114 5.14. {5.14} Modification Detection Code Packet (Tag 19) . . . 57 115 6. {6} Radix-64 Conversions . . . . . . . . . . . . . . . . . . 58 116 6.1. {6.1} An Implementation of the CRC-24 in "C" . . . . . . 58 117 6.2. {6.2} Forming ASCII Armor . . . . . . . . . . . . . . . . 59 118 6.3. {6.3} Encoding Binary in Radix-64 . . . . . . . . . . . . 61 119 6.4. {6.4} Decoding Radix-64 . . . . . . . . . . . . . . . . . 63 120 6.5. {6.5} Examples of Radix-64 . . . . . . . . . . . . . . . 63 121 6.6. {6.6} Example of an ASCII Armored Message . . . . . . . . 64 122 7. {7} Cleartext Signature Framework . . . . . . . . . . . . . . 64 123 7.1. {7.1} Dash-Escaped Text . . . . . . . . . . . . . . . . . 65 124 8. {8} Regular Expressions . . . . . . . . . . . . . . . . . . . 66 125 9. {9} Constants . . . . . . . . . . . . . . . . . . . . . . . . 66 126 9.1. {9.1} Public-Key Algorithms . . . . . . . . . . . . . . . 67 127 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 67 128 9.3. {9.2} Symmetric-Key Algorithms . . . . . . . . . . . . . 68 129 9.4. {9.3} Compression Algorithms . . . . . . . . . . . . . . 69 130 9.5. {9.4} Hash Algorithms . . . . . . . . . . . . . . . . . . 69 131 10. {10} IANA Considerations . . . . . . . . . . . . . . . . . . 70 132 10.1. {10.1} New String-to-Key Specifier Types . . . . . . . . 70 133 10.2. {10.2} New Packets . . . . . . . . . . . . . . . . . . . 70 134 10.2.1. {10.2.1} User Attribute Types . . . . . . . . . . . 70 135 10.2.2. {10.2.1.1} Image Format Subpacket Types . . . . . . 71 136 10.2.3. {10.2.2} New Signature Subpackets . . . . . . . . . 71 137 10.2.4. {10.2.3} New Packet Versions . . . . . . . . . . . . 73 138 10.3. {10.3} New Algorithms . . . . . . . . . . . . . . . . . 73 139 10.3.1. {10.3.1} Public-Key Algorithms . . . . . . . . . . . 74 140 10.3.2. {10.3.2} Symmetric-Key Algorithms . . . . . . . . . 74 141 10.3.3. {10.3.3} Hash Algorithms . . . . . . . . . . . . . . 74 142 10.3.4. {10.3.4} Compression Algorithms . . . . . . . . . . 75 143 11. {11} Packet Composition . . . . . . . . . . . . . . . . . . . 75 144 11.1. {11.1} Transferable Public Keys . . . . . . . . . . . . 75 145 11.2. {11.2} Transferable Secret Keys . . . . . . . . . . . . 76 146 11.3. {11.3} OpenPGP Messages . . . . . . . . . . . . . . . . 77 147 11.4. {11.4} Detached Signatures . . . . . . . . . . . . . . . 77 148 12. {12} Enhanced Key Formats . . . . . . . . . . . . . . . . . . 78 149 12.1. {12.1} Key Structures . . . . . . . . . . . . . . . . . 78 150 12.2. {12.2} Key IDs and Fingerprints . . . . . . . . . . . . 79 151 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 80 152 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 80 153 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 81 154 13.3. EdDSA Point Format . . . . . . . . . . . . . . . . . . . 81 155 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 82 156 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 82 157 14. {13} Notes on Algorithms . . . . . . . . . . . . . . . . . . 85 158 14.1. {13.1} PKCS#1 Encoding in OpenPGP . . . . . . . . . . . 85 159 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . 85 160 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE . . . . . . . . . . . 86 161 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . 87 162 14.2. {13.2} Symmetric Algorithm Preferences . . . . . . . . . 88 163 14.3. {13.3} Other Algorithm Preferences . . . . . . . . . . . 89 164 14.3.1. {13.3.1} Compression Preferences . . . . . . . . . . 89 165 14.3.2. {13.3.2} Hash Algorithm Preferences . . . . . . . . 90 166 14.4. {13.4} Plaintext . . . . . . . . . . . . . . . . . . . . 90 167 14.5. {13.5} RSA . . . . . . . . . . . . . . . . . . . . . . . 90 168 14.6. {13.6} DSA . . . . . . . . . . . . . . . . . . . . . . . 90 169 14.7. {13.7} Elgamal . . . . . . . . . . . . . . . . . . . . . 91 170 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 91 171 14.9. {13.8} Reserved Algorithm Numbers . . . . . . . . . . . 91 172 14.10. {13.9} OpenPGP CFB Mode . . . . . . . . . . . . . . . . 92 173 14.11. {13.10} Private or Experimental Parameters . . . . . . . 93 174 14.12. {13.11} Extension of the MDC System . . . . . . . . . . 93 175 14.13. {13.12} Meta-Considerations for Expansion . . . . . . . 94 176 15. {14} Security Considerations . . . . . . . . . . . . . . . . 94 177 16. Compatibility Profiles . . . . . . . . . . . . . . . . . . . 101 178 16.1. OpenPGP ECC Profile . . . . . . . . . . . . . . . . . . 101 179 16.2. Suite-B Profile . . . . . . . . . . . . . . . . . . . . 102 180 16.3. Security Strength at 192 Bits . . . . . . . . . . . . . 102 181 16.4. Security Strength at 128 Bits . . . . . . . . . . . . . 102 182 17. {15} Implementation Nits . . . . . . . . . . . . . . . . . . 102 183 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 104 184 18.1. Normative References . . . . . . . . . . . . . . . . . . 104 185 18.2. Informative References . . . . . . . . . . . . . . . . . 106 186 Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 107 187 A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 107 188 A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 108 189 Appendix B. ECC Point compression flag bytes . . . . . . . . . . 108 190 Appendix C. Changes since RFC-4880 . . . . . . . . . . . . . . . 109 191 Appendix D. The principal authors of RFC-4880 are as follows: . 109 192 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 109 194 1. {1} Introduction 196 { This is work in progress to update OpenPGP. Editorial notes are 197 enclosed in curly braces. The section numbers from RFC4880 are also 198 indicated in curly braces. } 200 This document provides information on the message-exchange packet 201 formats used by OpenPGP to provide encryption, decryption, signing, 202 and key management functions. It is a revision of RFC 2440, "OpenPGP 203 Message Format", which itself replaces RFC 1991, "PGP Message 204 Exchange Formats" [RFC1991] [RFC2440]. 206 This document obsoletes: RFC 5581 (Camellia cipher) and RFC 6637 (ECC 207 for OpenPGP) 209 1.1. {1.1} Terms 211 o OpenPGP - This is a term for security software that uses PGP 5.x 212 as a basis, formalized in RFC 2440 and this document. 214 o PGP - Pretty Good Privacy. PGP is a family of software systems 215 developed by Philip R. Zimmermann from which OpenPGP is based. 217 o PGP 2.6.x - This version of PGP has many variants, hence the term 218 PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic 219 transforms. An informational RFC, RFC 1991, was written 220 describing this version of PGP. 222 o PGP 5.x - This version of PGP is formerly known as "PGP 3" in the 223 community and also in the predecessor of this document, RFC 1991. 224 It has new formats and corrects a number of problems in the PGP 225 2.6.x design. It is referred to here as PGP 5.x because that 226 software was the first release of the "PGP 3" code base. 228 o GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 229 implementation that avoids all encumbered algorithms. 230 Consequently, early versions of GnuPG did not include RSA public 231 keys. GnuPG may or may not have (depending on version) support 232 for IDEA or other encumbered algorithms. 234 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 235 Corporation and are used with permission. The term "OpenPGP" refers 236 to the protocol described in this and related documents. 238 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 239 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 240 document are to be interpreted as described in [RFC2119]. 242 The key words "PRIVATE USE", "HIERARCHICAL ALLOCATION", "FIRST COME 243 FIRST SERVED", "EXPERT REVIEW", "SPECIFICATION REQUIRED", "IESG 244 APPROVAL", "IETF CONSENSUS", and "STANDARDS ACTION" that appear in 245 this document when used to describe namespace allocation are to be 246 interpreted as described in [RFC2434]. 248 2. {2} General functions 250 OpenPGP provides data integrity services for messages and data files 251 by using these core technologies: 253 o digital signatures 255 o encryption 257 o compression 259 o Radix-64 conversion 261 In addition, OpenPGP provides key management and certificate 262 services, but many of these are beyond the scope of this document. 264 2.1. {2.1} Confidentiality via Encryption 266 OpenPGP combines symmetric-key encryption and public-key encryption 267 to provide confidentiality. When made confidential, first the object 268 is encrypted using a symmetric encryption algorithm. Each symmetric 269 key is used only once, for a single object. A new "session key" is 270 generated as a random number for each object (sometimes referred to 271 as a session). Since it is used only once, the session key is bound 272 to the message and transmitted with it. To protect the key, it is 273 encrypted with the receiver's public key. The sequence is as 274 follows: 276 1. The sender creates a message. 278 2. The sending OpenPGP generates a random number to be used as a 279 session key for this message only. 281 3. The session key is encrypted using each recipient's public key. 282 These "encrypted session keys" start the message. 284 4. The sending OpenPGP encrypts the message using the session key, 285 which forms the remainder of the message. Note that the message 286 is also usually compressed. 288 5. The receiving OpenPGP decrypts the session key using the 289 recipient's private key. 291 6. The receiving OpenPGP decrypts the message using the session key. 292 If the message was compressed, it will be decompressed. 294 With symmetric-key encryption, an object may be encrypted with a 295 symmetric key derived from a passphrase (or other shared secret), or 296 a two-stage mechanism similar to the public-key method described 297 above in which a session key is itself encrypted with a symmetric 298 algorithm keyed from a shared secret. 300 Both digital signature and confidentiality services may be applied to 301 the same message. First, a signature is generated for the message 302 and attached to the message. Then the message plus signature is 303 encrypted using a symmetric session key. Finally, the session key is 304 encrypted using public-key encryption and prefixed to the encrypted 305 block. 307 2.2. {2.2} Authentication via Digital Signature 309 The digital signature uses a hash code or message digest algorithm, 310 and a public-key signature algorithm. The sequence is as follows: 312 1. The sender creates a message. 314 2. The sending software generates a hash code of the message. 316 3. The sending software generates a signature from the hash code 317 using the sender's private key. 319 4. The binary signature is attached to the message. 321 5. The receiving software keeps a copy of the message signature. 323 6. The receiving software generates a new hash code for the received 324 message and verifies it using the message's signature. If the 325 verification is successful, the message is accepted as authentic. 327 2.3. {2.3} Compression 329 OpenPGP implementations SHOULD compress the message after applying 330 the signature but before encryption. 332 If an implementation does not implement compression, its authors 333 should be aware that most OpenPGP messages in the world are 334 compressed. Thus, it may even be wise for a space-constrained 335 implementation to implement decompression, but not compression. 337 Furthermore, compression has the added side effect that some types of 338 attacks can be thwarted by the fact that slightly altered, compressed 339 data rarely uncompresses without severe errors. This is hardly 340 rigorous, but it is operationally useful. These attacks can be 341 rigorously prevented by implementing and using Modification Detection 342 Codes as described in sections following. 344 2.4. {2.4} Conversion to Radix-64 346 OpenPGP's underlying native representation for encrypted messages, 347 signature certificates, and keys is a stream of arbitrary octets. 348 Some systems only permit the use of blocks consisting of seven-bit, 349 printable text. For transporting OpenPGP's native raw binary octets 350 through channels that are not safe to raw binary data, a printable 351 encoding of these binary octets is needed. OpenPGP provides the 352 service of converting the raw 8-bit binary octet stream to a stream 353 of printable ASCII characters, called Radix-64 encoding or ASCII 354 Armor. 356 Implementations SHOULD provide Radix-64 conversions. 358 2.5. {2.5} Signature-Only Applications 360 OpenPGP is designed for applications that use both encryption and 361 signatures, but there are a number of problems that are solved by a 362 signature-only implementation. Although this specification requires 363 both encryption and signatures, it is reasonable for there to be 364 subset implementations that are non-conformant only in that they omit 365 encryption. 367 3. {3} Data Element Formats 369 This section describes the data elements used by OpenPGP. 371 3.1. {3.1} Scalar Numbers 373 Scalar numbers are unsigned and are always stored in big-endian 374 format. Using n[k] to refer to the kth octet being interpreted, the 375 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 376 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 377 n[3]). 379 3.2. {3.2} Multiprecision Integers 381 Multiprecision integers (also called MPIs) are unsigned integers used 382 to hold large integers such as the ones used in cryptographic 383 calculations. 385 An MPI consists of two pieces: a two-octet scalar that is the length 386 of the MPI in bits followed by a string of octets that contain the 387 actual integer. 389 These octets form a big-endian number; a big-endian number can be 390 made into an MPI by prefixing it with the appropriate length. 392 Examples: 394 (all numbers are in hexadecimal) 396 The string of octets [00 01 01] forms an MPI with the value 1. The 397 string [00 09 01 FF] forms an MPI with the value of 511. 399 Additional rules: 401 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 403 The length field of an MPI describes the length starting from its 404 most significant non-zero bit. Thus, the MPI [00 02 01] is not 405 formed correctly. It should be [00 01 01]. 407 Unused bits of an MPI MUST be zero. 409 Also note that when an MPI is encrypted, the length refers to the 410 plaintext MPI. It may be ill-formed in its ciphertext. 412 3.3. {3.3} Key IDs 414 A Key ID is an eight-octet scalar that identifies a key. 415 Implementations SHOULD NOT assume that Key IDs are unique. The 416 section "Enhanced Key Formats" below describes how Key IDs are 417 formed. 419 3.4. {3.4} Text 421 Unless otherwise specified, the character set for text is the UTF-8 422 [RFC3629] encoding of Unicode [ISO10646]. 424 3.5. {3.5} Time Fields 426 A time field is an unsigned four-octet number containing the number 427 of seconds elapsed since midnight, 1 January 1970 UTC. 429 3.6. {3.6} Keyrings 431 A keyring is a collection of one or more keys in a file or database. 432 Traditionally, a keyring is simply a sequential list of keys, but may 433 be any suitable database. It is beyond the scope of this standard to 434 discuss the details of keyrings or other databases. 436 3.7. {3.7} String-to-Key (S2K) Specifiers 438 String-to-key (S2K) specifiers are used to convert passphrase strings 439 into symmetric-key encryption/decryption keys. They are used in two 440 places, currently: to encrypt the secret part of private keys in the 441 private keyring, and to convert passphrases to encryption keys for 442 symmetrically encrypted messages. 444 3.7.1. {3.7.1} String-to-Key (S2K) Specifier Types 446 There are three types of S2K specifiers currently supported, and some 447 reserved values: 449 +-------------+---------------------------+ 450 | ID | S2K Type | 451 +-------------+---------------------------+ 452 | 0 | Simple S2K | 453 | 1 | Salted S2K | 454 | 2 | Reserved value | 455 | 3 | Iterated and Salted S2K | 456 | 100 to 110 | Private/Experimental S2K | 457 +-------------+---------------------------+ 459 These are described in the following Sections. 461 3.7.1.1. {3.7.1.1} Simple S2K 463 This directly hashes the string to produce the key data. See below 464 for how this hashing is done. 466 Octet 0: 0x00 467 Octet 1: hash algorithm 469 Simple S2K hashes the passphrase to produce the session key. The 470 manner in which this is done depends on the size of the session key 471 (which will depend on the cipher used) and the size of the hash 472 algorithm's output. If the hash size is greater than the session key 473 size, the high-order (leftmost) octets of the hash are used as the 474 key. 476 If the hash size is less than the key size, multiple instances of the 477 hash context are created -- enough to produce the required key data. 478 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 479 is to say, the first instance has no preloading, the second gets 480 preloaded with 1 octet of zero, the third is preloaded with two 481 octets of zeros, and so forth). 483 As the data is hashed, it is given independently to each hash 484 context. Since the contexts have been initialized differently, they 485 will each produce different hash output. Once the passphrase is 486 hashed, the output data from the multiple hashes is concatenated, 487 first hash leftmost, to produce the key data, with any excess octets 488 on the right discarded. 490 3.7.1.2. {3.7.1.2} Salted S2K 492 This includes a "salt" value in the S2K specifier -- some arbitrary 493 data -- that gets hashed along with the passphrase string, to help 494 prevent dictionary attacks. 496 Octet 0: 0x01 497 Octet 1: hash algorithm 498 Octets 2-9: 8-octet salt value 500 Salted S2K is exactly like Simple S2K, except that the input to the 501 hash function(s) consists of the 8 octets of salt from the S2K 502 specifier, followed by the passphrase. 504 3.7.1.3. {3.7.1.3} Iterated and Salted S2K 506 This includes both a salt and an octet count. The salt is combined 507 with the passphrase and the resulting value is hashed repeatedly. 508 This further increases the amount of work an attacker must do to try 509 dictionary attacks. 511 Octet 0: 0x03 512 Octet 1: hash algorithm 513 Octets 2-9: 8-octet salt value 514 Octet 10: count, a one-octet, coded value 516 The count is coded into a one-octet number using the following 517 formula: 519 #define EXPBIAS 6 520 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 522 The above formula is in C, where "Int32" is a type for a 32-bit 523 integer, and the variable "c" is the coded count, Octet 10. 525 Iterated-Salted S2K hashes the passphrase and salt data multiple 526 times. The total number of octets to be hashed is specified in the 527 encoded count in the S2K specifier. Note that the resulting count 528 value is an octet count of how many octets will be hashed, not an 529 iteration count. 531 Initially, one or more hash contexts are set up as with the other S2K 532 algorithms, depending on how many octets of key data are needed. 533 Then the salt, followed by the passphrase data, is repeatedly hashed 534 until the number of octets specified by the octet count has been 535 hashed. The one exception is that if the octet count is less than 536 the size of the salt plus passphrase, the full salt plus passphrase 537 will be hashed even though that is greater than the octet count. 538 After the hashing is done, the data is unloaded from the hash 539 context(s) as with the other S2K algorithms. 541 3.7.2. {3.7.2} String-to-Key Usage 543 Implementations SHOULD use salted or iterated-and-salted S2K 544 specifiers, as simple S2K specifiers are more vulnerable to 545 dictionary attacks. 547 3.7.2.1. {3.7.2.1} Secret-Key Encryption 549 An S2K specifier can be stored in the secret keyring to specify how 550 to convert the passphrase to a key that unlocks the secret data. 551 Older versions of PGP just stored a cipher algorithm octet preceding 552 the secret data or a zero to indicate that the secret data was 553 unencrypted. The MD5 hash function was always used to convert the 554 passphrase to a key for the specified cipher algorithm. 556 For compatibility, when an S2K specifier is used, the special value 557 254 or 255 is stored in the position where the hash algorithm octet 558 would have been in the old data structure. This is then followed 559 immediately by a one-octet algorithm identifier, and then by the S2K 560 specifier as encoded above. 562 Therefore, preceding the secret data there will be one of these 563 possibilities: 565 0: secret data is unencrypted (no passphrase) 566 255 or 254: followed by algorithm octet and S2K specifier 567 Cipher alg: use Simple S2K algorithm using MD5 hash 569 This last possibility, the cipher algorithm number with an implicit 570 use of MD5 and IDEA, is provided for backward compatibility; it MAY 571 be understood, but SHOULD NOT be generated, and is deprecated. 573 These are followed by an Initial Vector of the same length as the 574 block size of the cipher for the decryption of the secret values, if 575 they are encrypted, and then the secret-key values themselves. 577 3.7.2.2. {3.7.2.2} Symmetric-Key Message Encryption 579 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 580 at the front of a message. This is used to allow S2K specifiers to 581 be used for the passphrase conversion or to create messages with a 582 mix of symmetric-key ESKs and public-key ESKs. This allows a message 583 to be decrypted either with a passphrase or a public-key pair. 585 PGP 2.X always used IDEA with Simple string-to-key conversion when 586 encrypting a message with a symmetric algorithm. This is deprecated, 587 but MAY be used for backward-compatibility. 589 4. {4} Packet Syntax 591 This section describes the packets used by OpenPGP. 593 4.1. {4.1} Overview 595 An OpenPGP message is constructed from a number of records that are 596 traditionally called packets. A packet is a chunk of data that has a 597 tag specifying its meaning. An OpenPGP message, keyring, 598 certificate, and so forth consists of a number of packets. Some of 599 those packets may contain other OpenPGP packets (for example, a 600 compressed data packet, when uncompressed, contains OpenPGP packets). 602 Each packet consists of a packet header, followed by the packet body. 603 The packet header is of variable length. 605 4.2. {4.2} Packet Headers 607 The first octet of the packet header is called the "Packet Tag". It 608 determines the format of the header and denotes the packet contents. 609 The remainder of the packet header is the length of the packet. 611 Note that the most significant bit is the leftmost bit, called bit 7. 612 A mask for this bit is 0x80 in hexadecimal. 614 +---------------+ 615 PTag |7 6 5 4 3 2 1 0| 616 +---------------+ 617 Bit 7 -- Always one 618 Bit 6 -- New packet format if set 620 PGP 2.6.x only uses old format packets. Thus, software that 621 interoperates with those versions of PGP must only use old format 622 packets. If interoperability is not an issue, the new packet format 623 is RECOMMENDED. Note that old format packets have four bits of 624 packet tags, and new format packets have six; some features cannot be 625 used and still be backward-compatible. 627 Also note that packets with a tag greater than or equal to 16 MUST 628 use new format packets. The old format packets can only express tags 629 less than or equal to 15. 631 Old format packets contain: 633 Bits 5-2 -- packet tag 634 Bits 1-0 -- length-type 636 New format packets contain: 638 Bits 5-0 -- packet tag 640 4.2.1. {4.2.1} Old Format Packet Lengths 642 The meaning of the length-type in old format packets is: 644 0 The packet has a one-octet length. The header is 2 octets long. 646 1 The packet has a two-octet length. The header is 3 octets long. 648 2 The packet has a four-octet length. The header is 5 octets long. 650 3 The packet is of indeterminate length. The header is 1 octet 651 long, and the implementation must determine how long the packet 652 is. If the packet is in a file, this means that the packet 653 extends until the end of the file. In general, an implementation 654 SHOULD NOT use indeterminate-length packets except where the end 655 of the data will be clear from the context, and even then it is 656 better to use a definite length, or a new format header. The new 657 format headers described below have a mechanism for precisely 658 encoding data of indeterminate length. 660 4.2.2. {4.2.2} New Format Packet Lengths 662 New format packets have four possible ways of encoding length: 664 1. A one-octet Body Length header encodes packet lengths of up to 665 191 octets. 667 2. A two-octet Body Length header encodes packet lengths of 192 to 668 8383 octets. 670 3. A five-octet Body Length header encodes packet lengths of up to 671 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 672 encodes a four-octet scalar number.) 674 4. When the length of the packet body is not known in advance by the 675 issuer, Partial Body Length headers encode a packet of 676 indeterminate length, effectively making it a stream. 678 4.2.2.1. {4.2.2.1} One-Octet Lengths 680 A one-octet Body Length header encodes a length of 0 to 191 octets. 681 This type of length header is recognized because the one octet value 682 is less than 192. The body length is equal to: 684 bodyLen = 1st_octet; 686 4.2.2.2. {4.2.2.2} Two-Octet Lengths 688 A two-octet Body Length header encodes a length of 192 to 8383 689 octets. It is recognized because its first octet is in the range 192 690 to 223. The body length is equal to: 692 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 694 4.2.2.3. {4.2.2.3} Five-Octet Lengths 696 A five-octet Body Length header consists of a single octet holding 697 the value 255, followed by a four-octet scalar. The body length is 698 equal to: 700 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 701 (4th_octet << 8) | 5th_octet 703 This basic set of one, two, and five-octet lengths is also used 704 internally to some packets. 706 4.2.2.4. {4.2.2.4} Partial Body Lengths 708 A Partial Body Length header is one octet long and encodes the length 709 of only part of the data packet. This length is a power of 2, from 1 710 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 711 octet value that is greater than or equal to 224, and less than 255. 712 The Partial Body Length is equal to: 714 partialBodyLen = 1 << (1st_octet & 0x1F); 716 Each Partial Body Length header is followed by a portion of the 717 packet body data. The Partial Body Length header specifies this 718 portion's length. Another length header (one octet, two-octet, five- 719 octet, or partial) follows that portion. The last length header in 720 the packet MUST NOT be a Partial Body Length header. Partial Body 721 Length headers may only be used for the non-final parts of the 722 packet. 724 Note also that the last Body Length header can be a zero-length 725 header. 727 An implementation MAY use Partial Body Lengths for data packets, be 728 they literal, compressed, or encrypted. The first partial length 729 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 730 used for any other packet types. 732 4.2.3. {4.2.3} Packet Length Examples 734 These examples show ways that new format packets might encode the 735 packet lengths. 737 A packet with length 100 may have its length encoded in one octet: 738 0x64. This is followed by 100 octets of data. 740 A packet with length 1723 may have its length encoded in two octets: 741 0xC5, 0xFB. This header is followed by the 1723 octets of data. 743 A packet with length 100000 may have its length encoded in five 744 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 746 It might also be encoded in the following octet stream: 0xEF, first 747 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 748 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 749 octets of data. This is just one possible encoding, and many 750 variations are possible on the size of the Partial Body Length 751 headers, as long as a regular Body Length header encodes the last 752 portion of the data. 754 Please note that in all of these explanations, the total length of 755 the packet is the length of the header(s) plus the length of the 756 body. 758 4.3. {4.3} Packet Tags 760 The packet tag denotes what type of packet the body holds. Note that 761 old format headers can only have tags less than 16, whereas new 762 format headers can have tags as great as 63. The defined tags (in 763 decimal) are as follows: 765 +-----------+-----------------------------------------------------+ 766 | Tag | Packet Type | 767 +-----------+-----------------------------------------------------+ 768 | 0 | Reserved - a packet tag MUST NOT have this value | 769 | 1 | Public-Key Encrypted Session Key Packet | 770 | 2 | Signature Packet | 771 | 3 | Symmetric-Key Encrypted Session Key Packet | 772 | 4 | One-Pass Signature Packet | 773 | 5 | Secret-Key Packet | 774 | 6 | Public-Key Packet | 775 | 7 | Secret-Subkey Packet | 776 | 8 | Compressed Data Packet | 777 | 9 | Symmetrically Encrypted Data Packet | 778 | 10 | Marker Packet | 779 | 11 | Literal Data Packet | 780 | 12 | Trust Packet | 781 | 13 | User ID Packet | 782 | 14 | Public-Subkey Packet | 783 | 17 | User Attribute Packet | 784 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 785 | 19 | Modification Detection Code Packet | 786 | 60 to 63 | Private or Experimental Values | 787 +-----------+-----------------------------------------------------+ 789 5. {5} Packet Types 791 5.1. {5.1} Public-Key Encrypted Session Key Packets (Tag 1) 793 A Public-Key Encrypted Session Key packet holds the session key used 794 to encrypt a message. Zero or more Public-Key Encrypted Session Key 795 packets and/or Symmetric-Key Encrypted Session Key packets may 796 precede a Symmetrically Encrypted Data Packet, which holds an 797 encrypted message. The message is encrypted with the session key, 798 and the session key is itself encrypted and stored in the Encrypted 799 Session Key packet(s). The Symmetrically Encrypted Data Packet is 800 preceded by one Public-Key Encrypted Session Key packet for each 801 OpenPGP key to which the message is encrypted. The recipient of the 802 message finds a session key that is encrypted to their public key, 803 decrypts the session key, and then uses the session key to decrypt 804 the message. 806 The body of this packet consists of: 808 o A one-octet number giving the version number of the packet type. 809 The currently defined value for packet version is 3. 811 o An eight-octet number that gives the Key ID of the public key to 812 which the session key is encrypted. If the session key is 813 encrypted to a subkey, then the Key ID of this subkey is used here 814 instead of the Key ID of the primary key. 816 o A one-octet number giving the public-key algorithm used. 818 o A string of octets that is the encrypted session key. This string 819 takes up the remainder of the packet, and its contents are 820 dependent on the public-key algorithm used. 822 Algorithm Specific Fields for RSA encryption: 824 * Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 826 Algorithm Specific Fields for Elgamal encryption: 828 * MPI of Elgamal (Diffie-Hellman) value g**k mod p. 830 * MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 832 Algorithm-Specific Fields for ECDH encryption: 834 * MPI of an EC point representing an ephemeral public key. 836 * a one-octet size, followed by a symmetric key encoded using the 837 method described in Section 13.5. 839 The value "m" in the above formulas is derived from the session key 840 as follows. First, the session key is prefixed with a one-octet 841 algorithm identifier that specifies the symmetric encryption 842 algorithm used to encrypt the following Symmetrically Encrypted Data 843 Packet. Then a two-octet checksum is appended, which is equal to the 844 sum of the preceding session key octets, not including the algorithm 845 identifier, modulo 65536. This value is then encoded as described in 846 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 847 form the "m" value used in the formulas above. See Section 13.1 of 848 this document for notes on OpenPGP's use of PKCS#1. 850 Note that when an implementation forms several PKESKs with one 851 session key, forming a message that can be decrypted by several keys, 852 the implementation MUST make a new PKCS#1 encoding for each key. 854 An implementation MAY accept or use a Key ID of zero as a "wild card" 855 or "speculative" Key ID. In this case, the receiving implementation 856 would try all available private keys, checking for a valid decrypted 857 session key. This format helps reduce traffic analysis of messages. 859 5.2. {5.2} Signature Packet (Tag 2) 861 A Signature packet describes a binding between some public key and 862 some data. The most common signatures are a signature of a file or a 863 block of text, and a signature that is a certification of a User ID. 865 Two versions of Signature packets are defined. Version 3 provides 866 basic signature information, while version 4 provides an expandable 867 format with subpackets that can specify more information about the 868 signature. PGP 2.6.x only accepts version 3 signatures. 870 Implementations SHOULD accept V3 signatures. Implementations SHOULD 871 generate V4 signatures. 873 Note that if an implementation is creating an encrypted and signed 874 message that is encrypted to a V3 key, it is reasonable to create a 875 V3 signature. 877 5.2.1. {5.2.1} Signature Types 879 There are a number of possible meanings for a signature, which are 880 indicated in a signature type octet in any given signature. Please 881 note that the vagueness of these meanings is not a flaw, but a 882 feature of the system. Because OpenPGP places final authority for 883 validity upon the receiver of a signature, it may be that one 884 signer's casual act might be more rigorous than some other 885 authority's positive act. See Section 5.2.4, "Computing Signatures", 886 for detailed information on how to compute and verify signatures of 887 each type. 889 These meanings are as follows: 891 0x00 Signature of a binary document. This means the signer owns it, 892 created it, or certifies that it has not been modified. 894 0x01 Signature of a canonical text document. This means the signer 895 owns it, created it, or certifies that it has not been modified. 896 The signature is calculated over the text data with its line 897 endings converted to . 899 0x02 Standalone signature. This signature is a signature of only 900 its own subpacket contents. It is calculated identically to a 901 signature over a zero-length binary document. Note that it 902 doesn't make sense to have a V3 standalone signature. 904 0x10 Generic certification of a User ID and Public-Key packet. The 905 issuer of this certification does not make any particular 906 assertion as to how well the certifier has checked that the owner 907 of the key is in fact the person described by the User ID. 909 0x11 Persona certification of a User ID and Public-Key packet. The 910 issuer of this certification has not done any verification of the 911 claim that the owner of this key is the User ID specified. 913 0x12 Casual certification of a User ID and Public-Key packet. The 914 issuer of this certification has done some casual verification of 915 the claim of identity. 917 0x13 Positive certification of a User ID and Public-Key packet. The 918 issuer of this certification has done substantial verification of 919 the claim of identity. 921 Most OpenPGP implementations make their "key signatures" as 0x10 922 certifications. Some implementations can issue 0x11-0x13 923 certifications, but few differentiate between the types. 925 0x18 Subkey Binding Signature This signature is a statement by the 926 top-level signing key that indicates that it owns the subkey. 927 This signature is calculated directly on the primary key and 928 subkey, and not on any User ID or other packets. A signature that 929 binds a signing subkey MUST have an Embedded Signature subpacket 930 in this binding signature that contains a 0x19 signature made by 931 the signing subkey on the primary key and subkey. 933 0x19 Primary Key Binding Signature This signature is a statement by 934 a signing subkey, indicating that it is owned by the primary key 935 and subkey. This signature is calculated the same way as a 0x18 936 signature: directly on the primary key and subkey, and not on any 937 User ID or other packets. 939 0x1F Signature directly on a key This signature is calculated 940 directly on a key. It binds the information in the Signature 941 subpackets to the key, and is appropriate to be used for 942 subpackets that provide information about the key, such as the 943 Revocation Key subpacket. It is also appropriate for statements 944 that non-self certifiers want to make about the key itself, rather 945 than the binding between a key and a name. 947 0x20 Key revocation signature The signature is calculated directly 948 on the key being revoked. A revoked key is not to be used. Only 949 revocation signatures by the key being revoked, or by an 950 authorized revocation key, should be considered valid revocation 951 signatures. 953 0x28 Subkey revocation signature The signature is calculated 954 directly on the subkey being revoked. A revoked subkey is not to 955 be used. Only revocation signatures by the top-level signature 956 key that is bound to this subkey, or by an authorized revocation 957 key, should be considered valid revocation signatures. 959 0x30 Certification revocation signature This signature revokes an 960 earlier User ID certification signature (signature class 0x10 961 through 0x13) or direct-key signature (0x1F). It should be issued 962 by the same key that issued the revoked signature or an authorized 963 revocation key. The signature is computed over the same data as 964 the certificate that it revokes, and should have a later creation 965 date than that certificate. 967 0x40 Timestamp signature. This signature is only meaningful for the 968 timestamp contained in it. 970 0x50 Third-Party Confirmation signature. This signature is a 971 signature over some other OpenPGP Signature packet(s). It is 972 analogous to a notary seal on the signed data. A third-party 973 signature SHOULD include Signature Target subpacket(s) to give 974 easy identification. Note that we really do mean SHOULD. There 975 are plausible uses for this (such as a blind party that only sees 976 the signature, not the key or source document) that cannot include 977 a target subpacket. 979 5.2.2. {5.2.2} Version 3 Signature Packet Format 981 The body of a version 3 Signature Packet contains: 983 o One-octet version number (3). 985 o One-octet length of following hashed material. MUST be 5. 987 o One-octet signature type. 989 o Four-octet creation time. 991 o Eight-octet Key ID of signer. 993 o One-octet public-key algorithm. 995 o One-octet hash algorithm. 997 o Two-octet field holding left 16 bits of signed hash value. 999 o One or more multiprecision integers comprising the signature. 1000 This portion is algorithm specific, as described below. 1002 The concatenation of the data to be signed, the signature type, 1003 and creation time from the Signature packet (5 additional octets) 1004 is hashed. The resulting hash value is used in the signature 1005 algorithm. The high 16 bits (first two octets) of the hash are 1006 included in the Signature packet to provide a quick test to reject 1007 some invalid signatures. 1009 Algorithm-Specific Fields for RSA signatures: 1011 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1013 Algorithm-Specific Fields for DSA and ECDSA signatures: 1015 * MPI of DSA or ECDSA value r. 1017 * MPI of DSA or ECDSA value s. 1019 The signature calculation is based on a hash of the signed data, as 1020 described above. The details of the calculation are different for 1021 DSA signatures than for RSA signatures. 1023 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1024 type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This 1025 requires inserting the hash value as an octet string into an ASN.1 1026 structure. The object identifier for the type of hash being used is 1027 included in the structure. The hexadecimal representations for the 1028 currently defined hash algorithms are as follows: 1030 - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 1032 - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 1034 - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A 1036 - SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04 1038 - SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 1040 - SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 1042 - SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 1044 The ASN.1 Object Identifiers (OIDs) are as follows: 1046 - MD5: 1.2.840.113549.2.5 1048 - RIPEMD-160: 1.3.36.3.2.1 1050 - SHA-1: 1.3.14.3.2.26 1052 - SHA224: 2.16.840.1.101.3.4.2.4 1054 - SHA256: 2.16.840.1.101.3.4.2.1 1056 - SHA384: 2.16.840.1.101.3.4.2.2 1058 - SHA512: 2.16.840.1.101.3.4.2.3 1060 The full hash prefixes for these are as follows: 1062 - MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 1063 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 1064 0x04, 0x10 1066 - RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 1067 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 1069 - SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, 1070 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 1072 - SHA224: 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1073 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 1074 0x00, 0x04, 0x1C 1076 - SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1077 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 1078 0x00, 0x04, 0x20 1080 - SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1081 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 1082 0x00, 0x04, 0x30 1084 - SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1085 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 1086 0x00, 0x04, 0x40 1088 DSA signatures MUST use hashes that are equal in size to the number 1089 of bits of q, the group generated by the DSA key's generator value. 1091 If the output size of the chosen hash is larger than the number of 1092 bits of q, the hash result is truncated to fit by taking the number 1093 of leftmost bits equal to the number of bits of q. This (possibly 1094 truncated) hash function result is treated as a number and used 1095 directly in the DSA signature algorithm. 1097 5.2.3. {5.2.3} Version 4 Signature Packet Format 1099 The body of a version 4 Signature packet contains: 1101 o One-octet version number (4). 1103 o One-octet signature type. 1105 o One-octet public-key algorithm. 1107 o One-octet hash algorithm. 1109 o Two-octet scalar octet count for following hashed subpacket data. 1110 Note that this is the length in octets of all of the hashed 1111 subpackets; a pointer incremented by this number will skip over 1112 the hashed subpackets. 1114 o Hashed subpacket data set (zero or more subpackets). 1116 o Two-octet scalar octet count for the following unhashed subpacket 1117 data. Note that this is the length in octets of all of the 1118 unhashed subpackets; a pointer incremented by this number will 1119 skip over the unhashed subpackets. 1121 o Unhashed subpacket data set (zero or more subpackets). 1123 o Two-octet field holding the left 16 bits of the signed hash value. 1125 o One or more multiprecision integers comprising the signature. 1126 This portion is algorithm specific: 1128 Algorithm-Specific Fields for RSA signatures: 1130 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1132 Algorithm-Specific Fields for DSA or ECDSA signatures: 1134 * MPI of DSA or ECDSA value r. 1136 * MPI of DSA or ECDSA value s. 1138 Algorithm-Specific Fields for EdDSA signatures: 1140 * MPI of EdDSA compressed value r. 1142 * MPI of EdDSA compressed value s. 1144 The compressed version of R and S for use with EdDSA is described in 1145 [I-D.irtf-cfrg-eddsa]. The version 3 signature format MUST NOT be 1146 used with EdDSA. 1148 The concatenation of the data being signed and the signature data 1149 from the version number through the hashed subpacket data (inclusive) 1150 is hashed. The resulting hash value is what is signed. The left 16 1151 bits of the hash are included in the Signature packet to provide a 1152 quick test to reject some invalid signatures. 1154 There are two fields consisting of Signature subpackets. The first 1155 field is hashed with the rest of the signature data, while the second 1156 is unhashed. The second set of subpackets is not cryptographically 1157 protected by the signature and should include only advisory 1158 information. 1160 The algorithms for converting the hash function result to a signature 1161 are described in a section below. 1163 5.2.3.1. {5.2.3.1} Signature Subpacket Specification 1165 A subpacket data set consists of zero or more Signature subpackets. 1166 In Signature packets, the subpacket data set is preceded by a two- 1167 octet scalar count of the length in octets of all the subpackets. A 1168 pointer incremented by this number will skip over the subpacket data 1169 set. 1171 Each subpacket consists of a subpacket header and a body. The header 1172 consists of: 1174 o the subpacket length (1, 2, or 5 octets), 1176 o the subpacket type (1 octet), 1178 and is followed by the subpacket-specific data. 1180 The length includes the type octet but not this length. Its format 1181 is similar to the "new" format packet header lengths, but cannot have 1182 Partial Body Lengths. That is: 1184 if the 1st octet < 192, then 1185 lengthOfLength = 1 1186 subpacketLen = 1st_octet 1188 if the 1st octet >= 192 and < 255, then 1189 lengthOfLength = 2 1190 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1192 if the 1st octet = 255, then 1193 lengthOfLength = 5 1194 subpacket length = [four-octet scalar starting at 2nd_octet] 1196 The value of the subpacket type octet may be: 1198 +-------------+-----------------------------------------+ 1199 | Type | Description | 1200 +-------------+-----------------------------------------+ 1201 | 0 | Reserved | 1202 | 1 | Reserved | 1203 | 2 | Signature Creation Time | 1204 | 3 | Signature Expiration Time | 1205 | 4 | Exportable Certification | 1206 | 5 | Trust Signature | 1207 | 6 | Regular Expression | 1208 | 7 | Revocable | 1209 | 8 | Reserved | 1210 | 9 | Key Expiration Time | 1211 | 10 | Placeholder for backward compatibility | 1212 | 11 | Preferred Symmetric Algorithms | 1213 | 12 | Revocation Key | 1214 | 13 to 15 | Reserved | 1215 | 16 | Issuer | 1216 | 17 to 19 | Reserved | 1217 | 20 | Notation Data | 1218 | 21 | Preferred Hash Algorithms | 1219 | 22 | Preferred Compression Algorithms | 1220 | 23 | Key Server Preferences | 1221 | 24 | Preferred Key Server | 1222 | 25 | Primary User ID | 1223 | 26 | Policy URI | 1224 | 27 | Key Flags | 1225 | 28 | Signer's User ID | 1226 | 29 | Reason for Revocation | 1227 | 30 | Features | 1228 | 31 | Signature Target | 1229 | 32 | Embedded Signature | 1230 | 33 | Issuer Fingerprint | 1231 | 100 to 110 | Private or experimental | 1232 +-------------+-----------------------------------------+ 1234 An implementation SHOULD ignore any subpacket of a type that it does 1235 not recognize. 1237 Bit 7 of the subpacket type is the "critical" bit. If set, it 1238 denotes that the subpacket is one that is critical for the evaluator 1239 of the signature to recognize. If a subpacket is encountered that is 1240 marked critical but is unknown to the evaluating software, the 1241 evaluator SHOULD consider the signature to be in error. 1243 An evaluator may "recognize" a subpacket, but not implement it. The 1244 purpose of the critical bit is to allow the signer to tell an 1245 evaluator that it would prefer a new, unknown feature to generate an 1246 error than be ignored. 1248 Implementations SHOULD implement the three preferred algorithm 1249 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1250 subpacket. Note, however, that if an implementation chooses not to 1251 implement some of the preferences, it is required to behave in a 1252 polite manner to respect the wishes of those users who do implement 1253 these preferences. 1255 5.2.3.2. {5.2.3.2} Signature Subpacket Types 1257 A number of subpackets are currently defined. Some subpackets apply 1258 to the signature itself and some are attributes of the key. 1259 Subpackets that are found on a self-signature are placed on a 1260 certification made by the key itself. Note that a key may have more 1261 than one User ID, and thus may have more than one self-signature, and 1262 differing subpackets. 1264 A subpacket may be found either in the hashed or unhashed subpacket 1265 sections of a signature. If a subpacket is not hashed, then the 1266 information in it cannot be considered definitive because it is not 1267 part of the signature proper. 1269 5.2.3.3. {5.2.3.3} Notes on Self-Signatures 1271 A self-signature is a binding signature made by the key to which the 1272 signature refers. There are three types of self-signatures, the 1273 certification signatures (types 0x10-0x13), the direct-key signature 1274 (type 0x1F), and the subkey binding signature (type 0x18). For 1275 certification self-signatures, each User ID may have a self- 1276 signature, and thus different subpackets in those self-signatures. 1277 For subkey binding signatures, each subkey in fact has a self- 1278 signature. Subpackets that appear in a certification self-signature 1279 apply to the user name, and subpackets that appear in the subkey 1280 self-signature apply to the subkey. Lastly, subpackets on the 1281 direct-key signature apply to the entire key. 1283 Implementing software should interpret a self-signature's preference 1284 subpackets as narrowly as possible. For example, suppose a key has 1285 two user names, Alice and Bob. Suppose that Alice prefers the 1286 symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the 1287 software locates this key via Alice's name, then the preferred 1288 algorithm is CAST5; if software locates the key via Bob's name, then 1289 the preferred algorithm is IDEA. If the key is located by Key ID, 1290 the algorithm of the primary User ID of the key provides the 1291 preferred symmetric algorithm. 1293 Revoking a self-signature or allowing it to expire has a semantic 1294 meaning that varies with the signature type. Revoking the self- 1295 signature on a User ID effectively retires that user name. The self- 1296 signature is a statement, "My name X is tied to my signing key K" and 1297 is corroborated by other users' certifications. If another user 1298 revokes their certification, they are effectively saying that they no 1299 longer believe that name and that key are tied together. Similarly, 1300 if the users themselves revoke their self-signature, then the users 1301 no longer go by that name, no longer have that email address, etc. 1302 Revoking a binding signature effectively retires that subkey. 1303 Revoking a direct-key signature cancels that signature. Please see 1304 the "Reason for Revocation" subpacket (Section 5.2.3.23) for more 1305 relevant detail. 1307 Since a self-signature contains important information about the key's 1308 use, an implementation SHOULD allow the user to rewrite the self- 1309 signature, and important information in it, such as preferences and 1310 key expiration. 1312 It is good practice to verify that a self-signature imported into an 1313 implementation doesn't advertise features that the implementation 1314 doesn't support, rewriting the signature as appropriate. 1316 An implementation that encounters multiple self-signatures on the 1317 same object may resolve the ambiguity in any way it sees fit, but it 1318 is RECOMMENDED that priority be given to the most recent self- 1319 signature. 1321 5.2.3.4. {5.2.3.4} Signature Creation Time 1323 (4-octet time field) 1325 The time the signature was made. 1327 MUST be present in the hashed area. 1329 5.2.3.5. {5.2.3.5} Issuer 1331 (8-octet Key ID) 1333 The OpenPGP Key ID of the key issuing the signature. If the version 1334 of that key is greater than 4, this subpacket MUST NOT be included in 1335 the signature. 1337 5.2.3.6. {5.2.3.6} Key Expiration Time 1339 (4-octet time field) 1341 The validity period of the key. This is the number of seconds after 1342 the key creation time that the key expires. If this is not present 1343 or has a value of zero, the key never expires. This is found only on 1344 a self-signature. 1346 5.2.3.7. {5.2.3.7} Preferred Symmetric Algorithms 1348 (array of one-octet values) 1350 Symmetric algorithm numbers that indicate which algorithms the key 1351 holder prefers to use. The subpacket body is an ordered list of 1352 octets with the most preferred listed first. It is assumed that only 1353 algorithms listed are supported by the recipient's software. 1354 Algorithm numbers are in Section 9. This is only found on a self- 1355 signature. 1357 5.2.3.8. {5.2.3.8} Preferred Hash Algorithms 1359 (array of one-octet values) 1361 Message digest algorithm numbers that indicate which algorithms the 1362 key holder prefers to receive. Like the preferred symmetric 1363 algorithms, the list is ordered. Algorithm numbers are in Section 9. 1364 This is only found on a self-signature. 1366 5.2.3.9. {5.2.3.9} Preferred Compression Algorithms 1368 (array of one-octet values) 1370 Compression algorithm numbers that indicate which algorithms the key 1371 holder prefers to use. Like the preferred symmetric algorithms, the 1372 list is ordered. Algorithm numbers are in Section 9. If this 1373 subpacket is not included, ZIP is preferred. A zero denotes that 1374 uncompressed data is preferred; the key holder's software might have 1375 no compression software in that implementation. This is only found 1376 on a self-signature. 1378 5.2.3.10. {5.2.3.10} Signature Expiration Time 1380 (4-octet time field) 1382 The validity period of the signature. This is the number of seconds 1383 after the signature creation time that the signature expires. If 1384 this is not present or has a value of zero, it never expires. 1386 5.2.3.11. {5.2.3.11} Exportable Certification 1388 (1 octet of exportability, 0 for not, 1 for exportable) 1390 This subpacket denotes whether a certification signature is 1391 "exportable", to be used by other users than the signature's issuer. 1392 The packet body contains a Boolean flag indicating whether the 1393 signature is exportable. If this packet is not present, the 1394 certification is exportable; it is equivalent to a flag containing a 1395 1. 1397 Non-exportable, or "local", certifications are signatures made by a 1398 user to mark a key as valid within that user's implementation only. 1400 Thus, when an implementation prepares a user's copy of a key for 1401 transport to another user (this is the process of "exporting" the 1402 key), any local certification signatures are deleted from the key. 1404 The receiver of a transported key "imports" it, and likewise trims 1405 any local certifications. In normal operation, there won't be any, 1406 assuming the import is performed on an exported key. However, there 1407 are instances where this can reasonably happen. For example, if an 1408 implementation allows keys to be imported from a key database in 1409 addition to an exported key, then this situation can arise. 1411 Some implementations do not represent the interest of a single user 1412 (for example, a key server). Such implementations always trim local 1413 certifications from any key they handle. 1415 5.2.3.12. {5.2.3.12} Revocable 1417 (1 octet of revocability, 0 for not, 1 for revocable) 1419 Signature's revocability status. The packet body contains a Boolean 1420 flag indicating whether the signature is revocable. Signatures that 1421 are not revocable have any later revocation signatures ignored. They 1422 represent a commitment by the signer that he cannot revoke his 1423 signature for the life of his key. If this packet is not present, 1424 the signature is revocable. 1426 5.2.3.13. {5.2.3.13} Trust Signature 1428 (1 octet "level" (depth), 1 octet of trust amount) 1430 Signer asserts that the key is not only valid but also trustworthy at 1431 the specified level. Level 0 has the same meaning as an ordinary 1432 validity signature. Level 1 means that the signed key is asserted to 1433 be a valid trusted introducer, with the 2nd octet of the body 1434 specifying the degree of trust. Level 2 means that the signed key is 1435 asserted to be trusted to issue level 1 trust signatures, i.e., that 1436 it is a "meta introducer". Generally, a level n trust signature 1437 asserts that a key is trusted to issue level n-1 trust signatures. 1438 The trust amount is in a range from 0-255, interpreted such that 1439 values less than 120 indicate partial trust and values of 120 or 1440 greater indicate complete trust. Implementations SHOULD emit values 1441 of 60 for partial trust and 120 for complete trust. 1443 5.2.3.14. {5.2.3.14} Regular Expression 1445 (null-terminated regular expression) 1447 Used in conjunction with trust Signature packets (of level > 0) to 1448 limit the scope of trust that is extended. Only signatures by the 1449 target key on User IDs that match the regular expression in the body 1450 of this packet have trust extended by the trust Signature subpacket. 1451 The regular expression uses the same syntax as the Henry Spencer's 1452 "almost public domain" regular expression [REGEX] package. A 1453 description of the syntax is found in Section 8 below. 1455 5.2.3.15. {5.2.3.15} Revocation Key 1457 (1 octet of class, 1 octet of public-key algorithm ID, 20 octets of 1458 fingerprint) 1460 Authorizes the specified key to issue revocation signatures for this 1461 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1462 then this means that the revocation information is sensitive. Other 1463 bits are for future expansion to other kinds of authorizations. This 1464 is found on a self-signature. 1466 If the "sensitive" flag is set, the keyholder feels this subpacket 1467 contains private trust information that describes a real-world 1468 sensitive relationship. If this flag is set, implementations SHOULD 1469 NOT export this signature to other users except in cases where the 1470 data needs to be available: when the signature is being sent to the 1471 designated revoker, or when it is accompanied by a revocation 1472 signature from that revoker. Note that it may be appropriate to 1473 isolate this subpacket within a separate signature so that it is not 1474 combined with other subpackets that need to be exported. 1476 5.2.3.16. {5.2.3.16} Notation Data 1478 (4 octets of flags, 2 octets of name length (M), 1479 2 octets of value length (N), 1480 M octets of name data, 1481 N octets of value data) 1483 This subpacket describes a "notation" on the signature that the 1484 issuer wishes to make. The notation has a name and a value, each of 1485 which are strings of octets. There may be more than one notation in 1486 a signature. Notations can be used for any extension the issuer of 1487 the signature cares to make. The "flags" field holds four octets of 1488 flags. 1490 All undefined flags MUST be zero. Defined flags are as follows: 1492 First octet: 0x80 = human-readable. This note value is text. 1493 Other octets: none. 1495 Notation names are arbitrary strings encoded in UTF-8. They reside 1496 in two namespaces: The IETF namespace and the user namespace. 1498 The IETF namespace is registered with IANA. These names MUST NOT 1499 contain the "@" character (0x40). This is a tag for the user 1500 namespace. 1502 Names in the user namespace consist of a UTF-8 string tag followed by 1503 "@" followed by a DNS domain name. Note that the tag MUST NOT 1504 contain an "@" character. For example, the "sample" tag used by 1505 Example Corporation could be "sample@example.com". 1507 Names in a user space are owned and controlled by the owners of that 1508 domain. Obviously, it's bad form to create a new name in a DNS space 1509 that you don't own. 1511 Since the user namespace is in the form of an email address, 1512 implementers MAY wish to arrange for that address to reach a person 1513 who can be consulted about the use of the named tag. Note that due 1514 to UTF-8 encoding, not all valid user space name tags are valid email 1515 addresses. 1517 If there is a critical notation, the criticality applies to that 1518 specific notation and not to notations in general. 1520 The following subsections define a set of standard notations. 1522 5.2.3.16.1. The 'manu' Notation 1524 The "manu" notation is a string that declares the device 1525 manufacturer's name. The certifier key is asserting this string 1526 (which may or may not be related to the User ID of the certifier's 1527 key). 1529 5.2.3.16.2. The 'make' Notation 1531 This notation defines the product make. It is a free form string. 1533 5.2.3.16.3. The 'model' Notation 1535 This notation defines the product model name/number. It is a free 1536 form string. 1538 5.2.3.16.4. The 'prodid' Notation 1540 This notation contains the product identifier. It is a free form 1541 string. 1543 5.2.3.16.5. The 'pvers' Notation 1545 This notation defines the product version number (which could be a 1546 release number, year, or some other identifier to differentiate 1547 different versions of the same make/model). It is a free form 1548 string. 1550 5.2.3.16.6. The 'lot' Notation 1552 This notation defines the product lot number (which is an indicator 1553 of the batch of product). It is a free form string. 1555 5.2.3.16.7. The 'qty' Notation 1557 This notation defines the quantity of items in this package. It is a 1558 decimal integer representation with no punctuation, e.g. "10", 1559 "1000", "10000", etc. 1561 5.2.3.16.8. The 'loc' and 'dest' Notations 1563 The "loc" and 'dest' notations declare a GeoLocation as defined by 1564 RFC 5870 [RFC5870] but without the leading "geo:" header. For 1565 example, if you had a GeoLocation URI of "geo:13.4125,103.8667" you 1566 would encode that in these notations as "13.4125,103.8667". 1568 The 'loc' notation is meant to encode the geo location where the 1569 signature was made. The 'dest' notation is meant to encode the geo 1570 location where the device is "destined" (i.e., a "destination" for 1571 the device). 1573 5.2.3.16.9. The 'hash' Notation 1575 A 'hash' notation is a means to include external data in the contents 1576 of a signature without including the data itself. This is done by 1577 hashing the external data separately and then including the data's 1578 name and hash in the signature via this notation. This is useful, 1579 for example, to have an external "manifest," "image," or other data 1580 that might not be vital to the signature itself but still needs to be 1581 protected and authenticated without requiring a second signature. 1583 The 'hash' notation has the following structure: * A single byte 1584 specifying the length of the name of the hashed data * A UTF-8 string 1585 of the name of the hashed data * A single byte specifying the hash 1586 algorithm (see section 9.4) * The binary hash output of the hashed 1587 data using the specified algorithm. (The length of this data is 1588 implicit based on the algorithm specified). 1590 Due to its nature a 'hash' notation is not human readable and MUST 1591 NOT be marked as such when used. 1593 5.2.3.17. {5.2.3.17} Key Server Preferences 1595 (N octets of flags) 1597 This is a list of one-bit flags that indicate preferences that the 1598 key holder has about how the key is handled on a key server. All 1599 undefined flags MUST be zero. 1601 First octet: 0x80 = No-modify the key holder requests that this key 1602 only be modified or updated by the key holder or an administrator of 1603 the key server. 1605 This is found only on a self-signature. 1607 5.2.3.18. {5.2.3.18} Preferred Key Server 1609 (String) 1611 This is a URI of a key server that the key holder prefers be used for 1612 updates. Note that keys with multiple User IDs can have a preferred 1613 key server for each User ID. Note also that since this is a URI, the 1614 key server can actually be a copy of the key retrieved by ftp, http, 1615 finger, etc. 1617 5.2.3.19. {5.2.3.19} Primary User ID 1619 (1 octet, Boolean) 1621 This is a flag in a User ID's self-signature that states whether this 1622 User ID is the main User ID for this key. It is reasonable for an 1623 implementation to resolve ambiguities in preferences, etc. by 1624 referring to the primary User ID. If this flag is absent, its value 1625 is zero. If more than one User ID in a key is marked as primary, the 1626 implementation may resolve the ambiguity in any way it sees fit, but 1627 it is RECOMMENDED that priority be given to the User ID with the most 1628 recent self-signature. 1630 When appearing on a self-signature on a User ID packet, this 1631 subpacket applies only to User ID packets. When appearing on a self- 1632 signature on a User Attribute packet, this subpacket applies only to 1633 User Attribute packets. That is to say, there are two different and 1634 independent "primaries" -- one for User IDs, and one for User 1635 Attributes. 1637 5.2.3.20. {5.2.3.20} Policy URI 1639 (String) 1641 This subpacket contains a URI of a document that describes the policy 1642 under which the signature was issued. 1644 5.2.3.21. {5.2.3.21} Key Flags 1646 (N octets of flags) 1648 This subpacket contains a list of binary flags that hold information 1649 about a key. It is a string of octets, and an implementation MUST 1650 NOT assume a fixed size. This is so it can grow over time. If a 1651 list is shorter than an implementation expects, the unstated flags 1652 are considered to be zero. The defined flags are as follows: 1654 0x01 This key may be used to certify other keys. 1656 0x02 This key may be used to sign data. 1658 0x04 This key may be used to encrypt communications. 1660 0x08 This key may be used to encrypt storage. 1662 0x10 The private component of this key may have been split by a 1663 secret-sharing mechanism. 1665 0x20 This key may be used for authentication. 1667 0x80 The private component of this key may be in the possession of 1668 more than one person. 1670 Usage notes: 1672 The flags in this packet may appear in self-signatures or in 1673 certification signatures. They mean different things depending on 1674 who is making the statement --- for example, a certification 1675 signature that has the "sign data" flag is stating that the 1676 certification is for that use. On the other hand, the 1677 "communications encryption" flag in a self-signature is stating a 1678 preference that a given key be used for communications. Note 1679 however, that it is a thorny issue to determine what is 1680 "communications" and what is "storage". This decision is left wholly 1681 up to the implementation; the authors of this document do not claim 1682 any special wisdom on the issue and realize that accepted opinion may 1683 change. 1685 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1686 self-signature only; they are meaningless on a certification 1687 signature. They SHOULD be placed only on a direct-key signature 1688 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1689 key the flag applies to. 1691 5.2.3.22. {5.2.3.22} Signer's User ID 1693 (String) 1695 This subpacket allows a keyholder to state which User ID is 1696 responsible for the signing. Many keyholders use a single key for 1697 different purposes, such as business communications as well as 1698 personal communications. This subpacket allows such a keyholder to 1699 state which of their roles is making a signature. 1701 This subpacket is not appropriate to use to refer to a User Attribute 1702 packet. 1704 5.2.3.23. {5.2.3.23} Reason for Revocation 1706 (1 octet of revocation code, N octets of reason string) 1708 This subpacket is used only in key revocation and certification 1709 revocation signatures. It describes the reason why the key or 1710 certificate was revoked. 1712 The first octet contains a machine-readable code that denotes the 1713 reason for the revocation: 1715 +----------+--------------------------------------------------------+ 1716 | Code | Reason | 1717 +----------+--------------------------------------------------------+ 1718 | 0 | No reason specified (key revocations or cert | 1719 | | revocations) | 1720 | 1 | Key is superseded (key revocations) | 1721 | 2 | Key material has been compromised (key revocations) | 1722 | 3 | Key is retired and no longer used (key revocations) | 1723 | 32 | User ID information is no longer valid (cert | 1724 | | revocations) | 1725 | 100-110 | Private Use | 1726 +----------+--------------------------------------------------------+ 1728 Following the revocation code is a string of octets that gives 1729 information about the Reason for Revocation in human-readable form 1730 (UTF-8). The string may be null, that is, of zero length. The 1731 length of the subpacket is the length of the reason string plus one. 1732 An implementation SHOULD implement this subpacket, include it in all 1733 revocation signatures, and interpret revocations appropriately. 1734 There are important semantic differences between the reasons, and 1735 there are thus important reasons for revoking signatures. 1737 If a key has been revoked because of a compromise, all signatures 1738 created by that key are suspect. However, if it was merely 1739 superseded or retired, old signatures are still valid. If the 1740 revoked signature is the self-signature for certifying a User ID, a 1741 revocation denotes that that user name is no longer in use. Such a 1742 revocation SHOULD include a 0x20 code. 1744 Note that any signature may be revoked, including a certification on 1745 some other person's key. There are many good reasons for revoking a 1746 certification signature, such as the case where the keyholder leaves 1747 the employ of a business with an email address. A revoked 1748 certification is no longer a part of validity calculations. 1750 5.2.3.24. {5.2.3.24} Features 1752 (N octets of flags) 1754 The Features subpacket denotes which advanced OpenPGP features a 1755 user's implementation supports. This is so that as features are 1756 added to OpenPGP that cannot be backwards-compatible, a user can 1757 state that they can use that feature. The flags are single bits that 1758 indicate that a given feature is supported. 1760 This subpacket is similar to a preferences subpacket, and only 1761 appears in a self-signature. 1763 An implementation SHOULD NOT use a feature listed when sending to a 1764 user who does not state that they can use it. 1766 Defined features are as follows: 1768 First octet: 1770 0x01 - Modification Detection (packets 18 and 19) 1772 If an implementation implements any of the defined features, it 1773 SHOULD implement the Features subpacket, too. 1775 An implementation may freely infer features from other suitable 1776 implementation-dependent mechanisms. 1778 5.2.3.25. {5.2.3.25} Signature Target 1780 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1782 This subpacket identifies a specific target signature to which a 1783 signature refers. For revocation signatures, this subpacket provides 1784 explicit designation of which signature is being revoked. For a 1785 third-party or timestamp signature, this designates what signature is 1786 signed. All arguments are an identifier of that target signature. 1788 The N octets of hash data MUST be the size of the hash of the 1789 signature. For example, a target signature with a SHA-1 hash MUST 1790 have 20 octets of hash data. 1792 5.2.3.26. {5.2.3.26} Embedded Signature 1794 (1 signature packet body) 1796 This subpacket contains a complete Signature packet body as specified 1797 in Section 5.2 above. It is useful when one signature needs to refer 1798 to, or be incorporated in, another signature. 1800 5.2.3.27. Issuer Fingerprint 1802 (1 octet key version number, N octets of fingerprint) 1804 The OpenPGP Key fingerprint of the key issuing the signature. This 1805 subpacket SHOULD be included in all signatures. If the version of 1806 the issuing key is 4 and an Issuer subpacket is also included in the 1807 signature, the key ID of the Issuer subpacket MUST match the low 64 1808 bits of the fingerprint. 1810 Note that the length N of the fingerprint for a version 4 key is 20 1811 octets. 1813 5.2.4. {5.2.4} Computing Signatures 1815 All signatures are formed by producing a hash over the signature 1816 data, and then using the resulting hash in the signature algorithm. 1818 For binary document signatures (type 0x00), the document data is 1819 hashed directly. For text document signatures (type 0x01), the 1820 document is canonicalized by converting line endings to , and 1821 the resulting data is hashed. 1823 When a signature is made over a key, the hash data starts with the 1824 octet 0x99, followed by a two-octet length of the key, and then body 1825 of the key packet. (Note that this is an old-style packet header for 1826 a key packet with two-octet length.) A subkey binding signature 1827 (type 0x18) or primary key binding signature (type 0x19) then hashes 1828 the subkey using the same format as the main key (also using 0x99 as 1829 the first octet). Primary key revocation signatures (type 0x20) hash 1830 only the key being revoked. Subkey revocation signature (type 0x28) 1831 hash first the primary key and then the subkey being revoked. 1833 A certification signature (type 0x10 through 0x13) hashes the User ID 1834 being bound to the key into the hash context after the above data. A 1835 V3 certification hashes the contents of the User ID or attribute 1836 packet packet, without any header. A V4 certification hashes the 1837 constant 0xB4 for User ID certifications or the constant 0xD1 for 1838 User Attribute certifications, followed by a four-octet number giving 1839 the length of the User ID or User Attribute data, and then the User 1840 ID or User Attribute data. 1842 When a signature is made over a Signature packet (type 0x50), the 1843 hash data starts with the octet 0x88, followed by the four-octet 1844 length of the signature, and then the body of the Signature packet. 1845 (Note that this is an old-style packet header for a Signature packet 1846 with the length-of-length set to zero.) The unhashed subpacket data 1847 of the Signature packet being hashed is not included in the hash, and 1848 the unhashed subpacket data length value is set to zero. 1850 Once the data body is hashed, then a trailer is hashed. A V3 1851 signature hashes five octets of the packet body, starting from the 1852 signature type field. This data is the signature type, followed by 1853 the four-octet signature time. A V4 signature hashes the packet body 1854 starting from its first field, the version number, through the end of 1855 the hashed subpacket data. Thus, the fields hashed are the signature 1856 version, the signature type, the public-key algorithm, the hash 1857 algorithm, the hashed subpacket length, and the hashed subpacket 1858 body. 1860 V4 signatures also hash in a final trailer of six octets: the version 1861 of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, big- 1862 endian number that is the length of the hashed data from the 1863 Signature packet (note that this number does not include these final 1864 six octets). 1866 After all this has been hashed in a single hash context, the 1867 resulting hash field is used in the signature algorithm and placed at 1868 the end of the Signature packet. 1870 5.2.4.1. {5.2.4.1} Subpacket Hints 1872 It is certainly possible for a signature to contain conflicting 1873 information in subpackets. For example, a signature may contain 1874 multiple copies of a preference or multiple expiration times. In 1875 most cases, an implementation SHOULD use the last subpacket in the 1876 signature, but MAY use any conflict resolution scheme that makes more 1877 sense. Please note that we are intentionally leaving conflict 1878 resolution to the implementer; most conflicts are simply syntax 1879 errors, and the wishy-washy language here allows a receiver to be 1880 generous in what they accept, while putting pressure on a creator to 1881 be stingy in what they generate. 1883 Some apparent conflicts may actually make sense -- for example, 1884 suppose a keyholder has a V3 key and a V4 key that share the same RSA 1885 key material. Either of these keys can verify a signature created by 1886 the other, and it may be reasonable for a signature to contain an 1887 issuer subpacket for each key, as a way of explicitly tying those 1888 keys to the signature. 1890 5.3. {5.3} Symmetric-Key Encrypted Session Key Packets (Tag 3) 1892 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 1893 key encryption of a session key used to encrypt a message. Zero or 1894 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 1895 Encrypted Session Key packets may precede a Symmetrically Encrypted 1896 Data packet that holds an encrypted message. The message is 1897 encrypted with a session key, and the session key is itself encrypted 1898 and stored in the Encrypted Session Key packet or the Symmetric-Key 1899 Encrypted Session Key packet. 1901 If the Symmetrically Encrypted Data packet is preceded by one or more 1902 Symmetric-Key Encrypted Session Key packets, each specifies a 1903 passphrase that may be used to decrypt the message. This allows a 1904 message to be encrypted to a number of public keys, and also to one 1905 or more passphrases. This packet type is new and is not generated by 1906 PGP 2.x or PGP 5.0. 1908 The body of this packet consists of: 1910 o A one-octet version number. The only currently defined version is 1911 4. 1913 o A one-octet number describing the symmetric algorithm used. 1915 o A string-to-key (S2K) specifier, length as defined above. 1917 o Optionally, the encrypted session key itself, which is decrypted 1918 with the string-to-key object. 1920 If the encrypted session key is not present (which can be detected on 1921 the basis of packet length and S2K specifier size), then the S2K 1922 algorithm applied to the passphrase produces the session key for 1923 decrypting the file, using the symmetric cipher algorithm from the 1924 Symmetric-Key Encrypted Session Key packet. 1926 If the encrypted session key is present, the result of applying the 1927 S2K algorithm to the passphrase is used to decrypt just that 1928 encrypted session key field, using CFB mode with an IV of all zeros. 1929 The decryption result consists of a one-octet algorithm identifier 1930 that specifies the symmetric-key encryption algorithm used to encrypt 1931 the following Symmetrically Encrypted Data packet, followed by the 1932 session key octets themselves. 1934 Note: because an all-zero IV is used for this decryption, the S2K 1935 specifier MUST use a salt value, either a Salted S2K or an Iterated- 1936 Salted S2K. The salt value will ensure that the decryption key is 1937 not repeated even if the passphrase is reused. 1939 5.4. {5.4} One-Pass Signature Packets (Tag 4) 1941 The One-Pass Signature packet precedes the signed data and contains 1942 enough information to allow the receiver to begin calculating any 1943 hashes needed to verify the signature. It allows the Signature 1944 packet to be placed at the end of the message, so that the signer can 1945 compute the entire signed message in one pass. 1947 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 1949 The body of this packet consists of: 1951 o A one-octet version number. The current version is 3. 1953 o A one-octet signature type. Signature types are described in 1954 Section 5.2.1. 1956 o A one-octet number describing the hash algorithm used. 1958 o A one-octet number describing the public-key algorithm used. 1960 o An eight-octet number holding the Key ID of the signing key. 1962 o A one-octet number holding a flag showing whether the signature is 1963 nested. A zero value indicates that the next packet is another 1964 One-Pass Signature packet that describes another signature to be 1965 applied to the same message data. 1967 Note that if a message contains more than one one-pass signature, 1968 then the Signature packets bracket the message; that is, the first 1969 Signature packet after the message corresponds to the last one-pass 1970 packet and the final Signature packet corresponds to the first one- 1971 pass packet. 1973 5.5. {5.5} Key Material Packet 1975 A key material packet contains all the information about a public or 1976 private key. There are four variants of this packet type, and two 1977 major versions. Consequently, this section is complex. 1979 5.5.1. {5.5.1} Key Packet Variants 1981 5.5.1.1. {5.5.1.1} Public-Key Packet (Tag 6) 1983 A Public-Key packet starts a series of packets that forms an OpenPGP 1984 key (sometimes called an OpenPGP certificate). 1986 5.5.1.2. {5.5.1.2} Public-Subkey Packet (Tag 14) 1988 A Public-Subkey packet (tag 14) has exactly the same format as a 1989 Public-Key packet, but denotes a subkey. One or more subkeys may be 1990 associated with a top-level key. By convention, the top-level key 1991 provides signature services, and the subkeys provide encryption 1992 services. 1994 Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet. 1995 This tag was selected for reuse because no previous version of PGP 1996 ever emitted comment packets but they did properly ignore them. 1997 Public-Subkey packets are ignored by PGP 2.6.x and do not cause it to 1998 fail, providing a limited degree of backward compatibility. 2000 5.5.1.3. {5.5.1.3} Secret-Key Packet (Tag 5) 2002 A Secret-Key packet contains all the information that is found in a 2003 Public-Key packet, including the public-key material, but also 2004 includes the secret-key material after all the public-key fields. 2006 5.5.1.4. {5.5.1.4} Secret-Subkey Packet (Tag 7) 2008 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2009 packet and has exactly the same format. 2011 5.5.2. {5.5.2} Public-Key Packet Formats 2013 There are two versions of key-material packets. Version 3 packets 2014 were first generated by PGP 2.6. Version 4 keys first appeared in 2015 PGP 5.0 and are the preferred key version for OpenPGP. 2017 OpenPGP implementations MUST create keys with version 4 format. V3 2018 keys are deprecated; an implementation MUST NOT generate a V3 key, 2019 but MAY accept it. 2021 A version 3 public key or public-subkey packet contains: 2023 o A one-octet version number (3). 2025 o A four-octet number denoting the time that the key was created. 2027 o A two-octet number denoting the time in days that this key is 2028 valid. If this number is zero, then it does not expire. 2030 o A one-octet number denoting the public-key algorithm of this key. 2032 o A series of multiprecision integers comprising the key material: 2034 * a multiprecision integer (MPI) of RSA public modulus n; 2036 * an MPI of RSA public encryption exponent e. 2038 V3 keys are deprecated. They contain three weaknesses. First, it is 2039 relatively easy to construct a V3 key that has the same Key ID as any 2040 other key because the Key ID is simply the low 64 bits of the public 2041 modulus. Secondly, because the fingerprint of a V3 key hashes the 2042 key material, but not its length, there is an increased opportunity 2043 for fingerprint collisions. Third, there are weaknesses in the MD5 2044 hash algorithm that make developers prefer other algorithms. See 2045 below for a fuller discussion of Key IDs and fingerprints. 2047 V2 keys are identical to the deprecated V3 keys except for the 2048 version number. An implementation MUST NOT generate them and MAY 2049 accept or reject them as it sees fit. 2051 The version 4 format is similar to the version 3 format except for 2052 the absence of a validity period. This has been moved to the 2053 Signature packet. In addition, fingerprints of version 4 keys are 2054 calculated differently from version 3 keys, as described in the 2055 section "Enhanced Key Formats". 2057 A version 4 packet contains: 2059 o A one-octet version number (4). 2061 o A four-octet number denoting the time that the key was created. 2063 o A one-octet number denoting the public-key algorithm of this key. 2065 o A series of multiprecision integers comprising the key material. 2066 This algorithm-specific portion is: 2068 Algorithm-Specific Fields for RSA public keys: 2070 * multiprecision integer (MPI) of RSA public modulus n; 2072 * MPI of RSA public encryption exponent e. 2074 Algorithm-Specific Fields for DSA public keys: 2076 * MPI of DSA prime p; 2078 * MPI of DSA group order q (q is a prime divisor of p-1); 2080 * MPI of DSA group generator g; 2082 * MPI of DSA public-key value y (= g**x mod p where x is secret). 2084 Algorithm-Specific Fields for Elgamal public keys: 2086 * MPI of Elgamal prime p; 2088 * MPI of Elgamal group generator g; 2090 * MPI of Elgamal public key value y (= g**x mod p where x is 2091 secret). 2093 Algorithm-Specific Fields for ECDSA keys: 2095 * a variable-length field containing a curve OID, formatted as 2096 follows: 2098 + a one-octet size of the following field; values 0 and 0xFF 2099 are reserved for future extensions, 2101 + the octets representing a curve OID, defined in section 2102 11{FIXME}; 2104 * a MPI of an EC point representing a public key. 2106 Algorithm-Specific Fields for EdDSA keys: 2108 * a variable-length field containing a curve OID, formatted as 2109 follows: 2111 + a one-octet size of the following field; values 0 and 0xFF 2112 are reserved for future extensions, 2114 + the octets representing a curve OID, defined in section 2115 NN{FIXME}; 2117 * a MPI of an EC point representing a public key Q as described 2118 under EdDSA Point Format below. 2120 Algorithm-Specific Fields for ECDH keys: 2122 * a variable-length field containing a curve OID, formatted as 2123 follows: 2125 + a one-octet size of the following field; values 0 and 0xFF 2126 are reserved for future extensions, 2128 + the octets representing a curve OID, defined in 2129 Section 11{FIXME}; 2131 * a MPI of an EC point representing a public key; 2133 * a variable-length field containing KDF parameters, formatted as 2134 follows: 2136 + a one-octet size of the following fields; values 0 and 0xff 2137 are reserved for future extensions; 2139 + a one-octet value 1, reserved for future extensions; 2141 + a one-octet hash function ID used with a KDF; 2142 + a one-octet algorithm ID for the symmetric algorithm used to 2143 wrap the symmetric key used for the message encryption; see 2144 Section 8 for details. 2146 Observe that an ECDH public key is composed of the same sequence of 2147 fields that define an ECDSA key, plus the KDF parameters field. 2149 5.5.3. {5.5.3} Secret-Key Packet Formats 2151 The Secret-Key and Secret-Subkey packets contain all the data of the 2152 Public-Key and Public-Subkey packets, with additional algorithm- 2153 specific secret-key data appended, usually in encrypted form. 2155 The packet contains: 2157 o A Public-Key or Public-Subkey packet, as described above. 2159 o One octet indicating string-to-key usage conventions. Zero 2160 indicates that the secret-key data is not encrypted. 255 or 254 2161 indicates that a string-to-key specifier is being given. Any 2162 other value is a symmetric-key encryption algorithm identifier. 2164 o [Optional] If string-to-key usage octet was 255 or 254, a one- 2165 octet symmetric encryption algorithm. 2167 o [Optional] If string-to-key usage octet was 255 or 254, a string- 2168 to-key specifier. The length of the string-to-key specifier is 2169 implied by its type, as described above. 2171 o [Optional] If secret data is encrypted (string-to-key usage octet 2172 not zero), an Initial Vector (IV) of the same length as the 2173 cipher's block size. 2175 o Plain or encrypted multiprecision integers comprising the secret 2176 key data. These algorithm-specific fields are as described below. 2178 o If the string-to-key usage octet is zero or 255, then a two-octet 2179 checksum of the plaintext of the algorithm-specific portion (sum 2180 of all octets, mod 65536). If the string-to-key usage octet was 2181 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2182 specific portion. This checksum or hash is encrypted together 2183 with the algorithm-specific fields (if string-to-key usage octet 2184 is not zero). Note that for all other values, a two-octet 2185 checksum is required. 2187 Algorithm-Specific Fields for RSA secret keys: 2189 * multiprecision integer (MPI) of RSA secret exponent d. 2191 * MPI of RSA secret prime value p. 2193 * MPI of RSA secret prime value q (p < q). 2195 * MPI of u, the multiplicative inverse of p, mod q. 2197 Algorithm-Specific Fields for DSA secret keys: 2199 * MPI of DSA secret exponent x. 2201 Algorithm-Specific Fields for Elgamal secret keys: 2203 * MPI of Elgamal secret exponent x. 2205 Algorithm-Specific Fields for ECDH or ECDSA secret keys: 2207 * MPI of an integer representing the secret key, which is a 2208 scalar of the public EC point. 2210 Algorithm-Specific Fields for EdDSA keys: 2212 * MPI of an integer representing the secret key, which is a 2213 scalar of the public EC point. 2215 Secret MPI values can be encrypted using a passphrase. If a string- 2216 to-key specifier is given, that describes the algorithm for 2217 converting the passphrase to a key, else a simple MD5 hash of the 2218 passphrase is used. Implementations MUST use a string-to-key 2219 specifier; the simple hash is for backward compatibility and is 2220 deprecated, though implementations MAY continue to use existing 2221 private keys in the old format. The cipher for encrypting the MPIs 2222 is specified in the Secret-Key packet. 2224 Encryption/decryption of the secret data is done in CFB mode using 2225 the key created from the passphrase and the Initial Vector from the 2226 packet. A different mode is used with V3 keys (which are only RSA) 2227 than with other key formats. With V3 keys, the MPI bit count prefix 2228 (i.e., the first two octets) is not encrypted. Only the MPI non- 2229 prefix data is encrypted. Furthermore, the CFB state is 2230 resynchronized at the beginning of each new MPI value, so that the 2231 CFB block boundary is aligned with the start of the MPI data. 2233 With V4 keys, a simpler method is used. All secret MPI values are 2234 encrypted in CFB mode, including the MPI bitcount prefix. 2236 The two-octet checksum that follows the algorithm-specific portion is 2237 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2238 specific octets (including MPI prefix and data). With V3 keys, the 2239 checksum is stored in the clear. With V4 keys, the checksum is 2240 encrypted like the algorithm-specific data. This value is used to 2241 check that the passphrase was correct. However, this checksum is 2242 deprecated; an implementation SHOULD NOT use it, but should rather 2243 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2244 this is that there are some attacks that involve undetectably 2245 modifying the secret key. 2247 5.6. {5.6} Compressed Data Packet (Tag 8) 2249 The Compressed Data packet contains compressed data. Typically, this 2250 packet is found as the contents of an encrypted packet, or following 2251 a Signature or One-Pass Signature packet, and contains a literal data 2252 packet. 2254 The body of this packet consists of: 2256 o One octet that gives the algorithm used to compress the packet. 2258 o Compressed data, which makes up the remainder of the packet. 2260 A Compressed Data Packet's body contains an block that compresses 2261 some set of packets. See section "Packet Composition" for details on 2262 how messages are formed. 2264 ZIP-compressed packets are compressed with raw RFC 1951 [RFC1951] 2265 DEFLATE blocks. Note that PGP V2.6 uses 13 bits of compression. If 2266 an implementation uses more bits of compression, PGP V2.6 cannot 2267 decompress it. 2269 ZLIB-compressed packets are compressed with RFC 1950 [RFC1950] ZLIB- 2270 style blocks. 2272 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2273 algorithm. 2275 5.7. {5.7} Symmetrically Encrypted Data Packet (Tag 9) 2277 The Symmetrically Encrypted Data packet contains data encrypted with 2278 a symmetric-key algorithm. When it has been decrypted, it contains 2279 other packets (usually a literal data packet or compressed data 2280 packet, but in theory other Symmetrically Encrypted Data packets or 2281 sequences of packets that form whole OpenPGP messages). 2283 The body of this packet consists of: 2285 o Encrypted data, the output of the selected symmetric-key cipher 2286 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2288 The symmetric cipher used may be specified in a Public-Key or 2289 Symmetric-Key Encrypted Session Key packet that precedes the 2290 Symmetrically Encrypted Data packet. In that case, the cipher 2291 algorithm octet is prefixed to the session key before it is 2292 encrypted. If no packets of these types precede the encrypted data, 2293 the IDEA algorithm is used with the session key calculated as the MD5 2294 hash of the passphrase, though this use is deprecated. 2296 The data is encrypted in CFB mode, with a CFB shift size equal to the 2297 cipher's block size. The Initial Vector (IV) is specified as all 2298 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2299 equal to the block size of the cipher plus two to the data before it 2300 is encrypted. The first block-size octets (for example, 8 octets for 2301 a 64-bit block length) are random, and the following two octets are 2302 copies of the last two octets of the IV. For example, in an 8-octet 2303 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2304 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2305 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2306 in both these examples, we consider the first octet to be numbered 1. 2308 After encrypting the first block-size-plus-two octets, the CFB state 2309 is resynchronized. The last block-size octets of ciphertext are 2310 passed through the cipher and the block boundary is reset. 2312 The repetition of 16 bits in the random data prefixed to the message 2313 allows the receiver to immediately check whether the session key is 2314 incorrect. See the "Security Considerations" section for hints on 2315 the proper use of this "quick check". 2317 5.8. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) 2319 An experimental version of PGP used this packet as the Literal 2320 packet, but no released version of PGP generated Literal packets with 2321 this tag. With PGP 5.x, this packet has been reassigned and is 2322 reserved for use as the Marker packet. 2324 The body of this packet consists of: 2326 o The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2328 Such a packet MUST be ignored when received. It may be placed at the 2329 beginning of a message that uses features not available in PGP 2.6.x 2330 in order to cause that version to report that newer software is 2331 necessary to process the message. 2333 5.9. {5.9} Literal Data Packet (Tag 11) 2335 A Literal Data packet contains the body of a message; data that is 2336 not to be further interpreted. 2338 The body of this packet consists of: 2340 o A one-octet field that describes how the data is formatted. 2342 If it is a 'b' (0x62), then the Literal packet contains binary 2343 data. If it is a 't' (0x74), then it contains text data, and thus 2344 may need line ends converted to local form, or other text-mode 2345 changes. The tag 'u' (0x75) means the same as 't', but also 2346 indicates that implementation believes that the literal data 2347 contains UTF-8 text. 2349 Early versions of PGP also defined a value of 'l' as a 'local' 2350 mode for machine-local conversions. RFC 1991 [RFC1991] 2351 incorrectly stated this local mode flag as '1' (ASCII numeral 2352 one). Both of these local modes are deprecated. 2354 o File name as a string (one-octet length, followed by a file name). 2355 This may be a zero-length string. Commonly, if the source of the 2356 encrypted data is a file, this will be the name of the encrypted 2357 file. An implementation MAY consider the file name in the Literal 2358 packet to be a more authoritative name than the actual file name. 2360 If the special name "_CONSOLE" is used, the message is considered 2361 to be "for your eyes only". This advises that the message data is 2362 unusually sensitive, and the receiving program should process it 2363 more carefully, perhaps avoiding storing the received data to 2364 disk, for example. 2366 o A four-octet number that indicates a date associated with the 2367 literal data. Commonly, the date might be the modification date 2368 of a file, or the time the packet was created, or a zero that 2369 indicates no specific time. 2371 o The remainder of the packet is literal data. 2373 Text data is stored with text endings (i.e., network- 2374 normal line endings). These should be converted to native line 2375 endings by the receiving software. 2377 5.10. {5.10} Trust Packet (Tag 12) 2379 The Trust packet is used only within keyrings and is not normally 2380 exported. Trust packets contain data that record the user's 2381 specifications of which key holders are trustworthy introducers, 2382 along with other information that implementing software uses for 2383 trust information. The format of Trust packets is defined by a given 2384 implementation. 2386 Trust packets SHOULD NOT be emitted to output streams that are 2387 transferred to other users, and they SHOULD be ignored on any input 2388 other than local keyring files. 2390 5.11. {5.11} User ID Packet (Tag 13) 2392 A User ID packet consists of UTF-8 text that is intended to represent 2393 the name and email address of the key holder. By convention, it 2394 includes an RFC 2822 [RFC2822] mail name-addr, but there are no 2395 restrictions on its content. The packet length in the header 2396 specifies the length of the User ID. 2398 5.12. {5.12} User Attribute Packet (Tag 17) 2400 The User Attribute packet is a variation of the User ID packet. It 2401 is capable of storing more types of data than the User ID packet, 2402 which is limited to text. Like the User ID packet, a User Attribute 2403 packet may be certified by the key owner ("self-signed") or any other 2404 key owner who cares to certify it. Except as noted, a User Attribute 2405 packet may be used anywhere that a User ID packet may be used. 2407 While User Attribute packets are not a required part of the OpenPGP 2408 standard, implementations SHOULD provide at least enough 2409 compatibility to properly handle a certification signature on the 2410 User Attribute packet. A simple way to do this is by treating the 2411 User Attribute packet as a User ID packet with opaque contents, but 2412 an implementation may use any method desired. 2414 The User Attribute packet is made up of one or more attribute 2415 subpackets. Each subpacket consists of a subpacket header and a 2416 body. The header consists of: 2418 o the subpacket length (1, 2, or 5 octets) 2420 o the subpacket type (1 octet) 2422 and is followed by the subpacket specific data. 2424 The following table lists the currently known subpackets: 2426 +----------+------------------------------+ 2427 | Type | Attribute Subpacket | 2428 +----------+------------------------------+ 2429 | 1 | Image Attribute Subpacket | 2430 | [TBD1] | User ID Attribute Subpacket | 2431 | 100-110 | Private/Experimental Use | 2432 +----------+------------------------------+ 2434 An implementation SHOULD ignore any subpacket of a type that it does 2435 not recognize. 2437 5.12.1. {5.12.1} The Image Attribute Subpacket 2439 The Image Attribute subpacket is used to encode an image, presumably 2440 (but not required to be) that of the key owner. 2442 The Image Attribute subpacket begins with an image header. The first 2443 two octets of the image header contain the length of the image 2444 header. Note that unlike other multi-octet numerical values in this 2445 document, due to a historical accident this value is encoded as a 2446 little-endian number. The image header length is followed by a 2447 single octet for the image header version. The only currently 2448 defined version of the image header is 1, which is a 16-octet image 2449 header. The first three octets of a version 1 image header are thus 2450 0x10, 0x00, 0x01. 2452 The fourth octet of a version 1 image header designates the encoding 2453 format of the image. The only currently defined encoding format is 2454 the value 1 to indicate JPEG. Image format types 100 through 110 are 2455 reserved for private or experimental use. The rest of the version 1 2456 image header is made up of 12 reserved octets, all of which MUST be 2457 set to 0. 2459 The rest of the image subpacket contains the image itself. As the 2460 only currently defined image type is JPEG, the image is encoded in 2461 the JPEG File Interchange Format (JFIF), a standard file format for 2462 JPEG images [JFIF]. 2464 An implementation MAY try to determine the type of an image by 2465 examination of the image data if it is unable to handle a particular 2466 version of the image header or if a specified encoding format value 2467 is not recognized. 2469 5.12.2. User ID Attribute Subpacket 2471 A User ID Attribute subpacket has type #[IANA -- assignment TBD1]. 2473 A User ID Attribute subpacket, just like a User ID packet, consists 2474 of UTF-8 text that is intended to represent the name and email 2475 address of the key holder. By convention, it includes an RFC 2822 2476 [RFC2822] mail name-addr, but there are no restrictions on its 2477 content. For devices using OpenPGP for device certificates, it may 2478 just be the device identifier. The packet length in the header 2479 specifies the length of the User ID. 2481 Because User Attribute subpackets can be used anywhere a User ID 2482 packet can be used, implementations MAY choose to trust a signed User 2483 Attribute subpacket that includes a User ID Attribute subpacket. 2485 5.13. {5.13} Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2487 The Symmetrically Encrypted Integrity Protected Data packet is a 2488 variant of the Symmetrically Encrypted Data packet. It is a new 2489 feature created for OpenPGP that addresses the problem of detecting a 2490 modification to encrypted data. It is used in combination with a 2491 Modification Detection Code packet. 2493 There is a corresponding feature in the features Signature subpacket 2494 that denotes that an implementation can properly use this packet 2495 type. An implementation MUST support decrypting these packets and 2496 SHOULD prefer generating them to the older Symmetrically Encrypted 2497 Data packet when possible. Since this data packet protects against 2498 modification attacks, this standard encourages its proliferation. 2499 While blanket adoption of this data packet would create 2500 interoperability problems, rapid adoption is nevertheless important. 2501 An implementation SHOULD specifically denote support for this packet, 2502 but it MAY infer it from other mechanisms. 2504 For example, an implementation might infer from the use of a cipher 2505 such as Advanced Encryption Standard (AES) or Twofish that a user 2506 supports this feature. It might place in the unhashed portion of 2507 another user's key signature a Features subpacket. It might also 2508 present a user with an opportunity to regenerate their own self- 2509 signature with a Features subpacket. 2511 This packet contains data encrypted with a symmetric-key algorithm 2512 and protected against modification by the SHA-1 hash algorithm. When 2513 it has been decrypted, it will typically contain other packets (often 2514 a Literal Data packet or Compressed Data packet). The last decrypted 2515 packet in this packet's payload MUST be a Modification Detection Code 2516 packet. 2518 The body of this packet consists of: 2520 o A one-octet version number. The only currently defined value is 2521 1. 2523 o Encrypted data, the output of the selected symmetric-key cipher 2524 operating in Cipher Feedback mode with shift amount equal to the 2525 block size of the cipher (CFB-n where n is the block size). 2527 The symmetric cipher used MUST be specified in a Public-Key or 2528 Symmetric-Key Encrypted Session Key packet that precedes the 2529 Symmetrically Encrypted Data packet. In either case, the cipher 2530 algorithm octet is prefixed to the session key before it is 2531 encrypted. 2533 The data is encrypted in CFB mode, with a CFB shift size equal to the 2534 cipher's block size. The Initial Vector (IV) is specified as all 2535 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2536 the data before it is encrypted. The length of the octet string 2537 equals the block size of the cipher in octets, plus two. The first 2538 octets in the group, of length equal to the block size of the cipher, 2539 are random; the last two octets are each copies of their 2nd 2540 preceding octet. For example, with a cipher whose block size is 128 2541 bits or 16 octets, the prefix data will contain 16 random octets, 2542 then two more octets, which are copies of the 15th and 16th octets, 2543 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2544 special CFB resynchronization is done after encrypting this prefix 2545 data. See "OpenPGP CFB Mode" below for more details. 2547 The repetition of 16 bits in the random data prefixed to the message 2548 allows the receiver to immediately check whether the session key is 2549 incorrect. 2551 The plaintext of the data to be encrypted is passed through the SHA-1 2552 hash function, and the result of the hash is appended to the 2553 plaintext in a Modification Detection Code packet. The input to the 2554 hash function includes the prefix data described above; it includes 2555 all of the plaintext, and then also includes two octets of values 2556 0xD3, 0x14. These represent the encoding of a Modification Detection 2557 Code packet tag and length field of 20 octets. 2559 The resulting hash value is stored in a Modification Detection Code 2560 (MDC) packet, which MUST use the two octet encoding just given to 2561 represent its tag and length field. The body of the MDC packet is 2562 the 20-octet output of the SHA-1 hash. 2564 The Modification Detection Code packet is appended to the plaintext 2565 and encrypted along with the plaintext using the same CFB context. 2567 During decryption, the plaintext data should be hashed with SHA-1, 2568 including the prefix data as well as the packet tag and length field 2569 of the Modification Detection Code packet. The body of the MDC 2570 packet, upon decryption, is compared with the result of the SHA-1 2571 hash. 2573 Any failure of the MDC indicates that the message has been modified 2574 and MUST be treated as a security problem. Failures include a 2575 difference in the hash values, but also the absence of an MDC packet, 2576 or an MDC packet in any position other than the end of the plaintext. 2577 Any failure SHOULD be reported to the user. 2579 Note: future designs of new versions of this packet should consider 2580 rollback attacks since it will be possible for an attacker to change 2581 the version back to 1. 2583 NON-NORMATIVE EXPLANATION 2585 The MDC system, as packets 18 and 19 are called, were created to 2586 provide an integrity mechanism that is less strong than a 2587 signature, yet stronger than bare CFB encryption. 2589 It is a limitation of CFB encryption that damage to the 2590 ciphertext will corrupt the affected cipher blocks and the block 2591 following. Additionally, if data is removed from the end of a 2592 CFB-encrypted block, that removal is undetectable. (Note also 2593 that CBC mode has a similar limitation, but data removed from 2594 the front of the block is undetectable.) 2596 The obvious way to protect or authenticate an encrypted block is 2597 to digitally sign it. However, many people do not wish to 2598 habitually sign data, for a large number of reasons beyond the 2599 scope of this document. Suffice it to say that many people 2600 consider properties such as deniability to be as valuable as 2601 integrity. 2603 OpenPGP addresses this desire to have more security than raw 2604 encryption and yet preserve deniability with the MDC system. An 2605 MDC is intentionally not a MAC. Its name was not selected by 2606 accident. It is analogous to a checksum. 2608 Despite the fact that it is a relatively modest system, it has 2609 proved itself in the real world. It is an effective defense to 2610 several attacks that have surfaced since it has been created. 2611 It has met its modest goals admirably. 2613 Consequently, because it is a modest security system, it has 2614 modest requirements on the hash function(s) it employs. It does 2615 not rely on a hash function being collision-free, it relies on a 2616 hash function being one-way. If a forger, Frank, wishes to send 2617 Alice a (digitally) unsigned message that says, "I've always 2618 secretly loved you, signed Bob", it is far easier for him to 2619 construct a new message than it is to modify anything 2620 intercepted from Bob. (Note also that if Bob wishes to 2621 communicate secretly with Alice, but without authentication or 2622 identification and with a threat model that includes forgers, he 2623 has a problem that transcends mere cryptography.) 2625 Note also that unlike nearly every other OpenPGP subsystem, 2626 there are no parameters in the MDC system. It hard-defines 2627 SHA-1 as its hash function. This is not an accident. It is an 2628 intentional choice to avoid downgrade and cross-grade attacks 2629 while making a simple, fast system. (A downgrade attack would 2630 be an attack that replaced SHA-256 with SHA-1, for example. A 2631 cross-grade attack would replace SHA-1 with another 160-bit 2632 hash, such as RIPE-MD/160, for example.) 2634 However, given the present state of hash function cryptanalysis 2635 and cryptography, it may be desirable to upgrade the MDC system 2636 to a new hash function. See Section 13.11 in the "IANA 2637 Considerations" for guidance. 2639 5.14. {5.14} Modification Detection Code Packet (Tag 19) 2641 The Modification Detection Code packet contains a SHA-1 hash of 2642 plaintext data, which is used to detect message modification. It is 2643 only used with a Symmetrically Encrypted Integrity Protected Data 2644 packet. The Modification Detection Code packet MUST be the last 2645 packet in the plaintext data that is encrypted in the Symmetrically 2646 Encrypted Integrity Protected Data packet, and MUST appear in no 2647 other place. 2649 A Modification Detection Code packet MUST have a length of 20 octets. 2651 The body of this packet consists of: 2653 o A 20-octet SHA-1 hash of the preceding plaintext data of the 2654 Symmetrically Encrypted Integrity Protected Data packet, including 2655 prefix data, the tag octet, and length octet of the Modification 2656 Detection Code packet. 2658 Note that the Modification Detection Code packet MUST always use a 2659 new format encoding of the packet tag, and a one-octet encoding of 2660 the packet length. The reason for this is that the hashing rules for 2661 modification detection include a one-octet tag and one-octet length 2662 in the data hash. While this is a bit restrictive, it reduces 2663 complexity. 2665 6. {6} Radix-64 Conversions 2667 As stated in the introduction, OpenPGP's underlying native 2668 representation for objects is a stream of arbitrary octets, and some 2669 systems desire these objects to be immune to damage caused by 2670 character set translation, data conversions, etc. 2672 In principle, any printable encoding scheme that met the requirements 2673 of the unsafe channel would suffice, since it would not change the 2674 underlying binary bit streams of the native OpenPGP data structures. 2675 The OpenPGP standard specifies one such printable encoding scheme to 2676 ensure interoperability. 2678 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2679 encoding of the binary data and a checksum. The base64 encoding is 2680 identical to the MIME base64 content-transfer-encoding [RFC2045]. 2682 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 2683 four characters of radix-64 encoding by the same MIME base64 2684 transformation, preceded by an equal sign (=). The CRC is computed 2685 by using the generator 0x864CFB and an initialization of 0xB704CE. 2686 The accumulation is done on the data before it is converted to radix- 2687 64, rather than on the converted data. A sample implementation of 2688 this algorithm is in the next section. 2690 The checksum with its leading equal sign MAY appear on the first line 2691 after the base64 encoded data. 2693 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2694 base64. The nonzero initialization can detect more errors than a 2695 zero initialization. 2697 6.1. {6.1} An Implementation of the CRC-24 in "C" 2698 2699 #define CRC24_INIT 0xB704CEL 2700 #define CRC24_POLY 0x1864CFBL 2702 typedef long crc24; 2703 crc24 crc_octets(unsigned char *octets, size_t len) 2704 { 2705 crc24 crc = CRC24_INIT; 2706 int i; 2707 while (len--) { 2708 crc ^= (*octets++) << 16; 2709 for (i = 0; i < 8; i++) { 2710 crc <<= 1; 2711 if (crc & 0x1000000) 2712 crc ^= CRC24_POLY; 2713 } 2714 } 2715 return crc & 0xFFFFFFL; 2716 } 2717 2719 6.2. {6.2} Forming ASCII Armor 2721 When OpenPGP encodes data into ASCII Armor, it puts specific headers 2722 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 2723 later. An OpenPGP implementation MAY use ASCII armor to protect raw 2724 binary data. OpenPGP informs the user what kind of data is encoded 2725 in the ASCII armor through the use of the headers. 2727 Concatenating the following data creates ASCII Armor: 2729 o An Armor Header Line, appropriate for the type of data 2731 o Armor Headers 2733 o A blank (zero-length, or containing only whitespace) line 2735 o The ASCII-Armored data 2737 o An Armor Checksum 2739 o The Armor Tail, which depends on the Armor Header Line 2741 An Armor Header Line consists of the appropriate header line text 2742 surrounded by five (5) dashes ('-', 0x2D) on either side of the 2743 header line text. The header line text is chosen based upon the type 2744 of data that is being encoded in Armor, and how it is being encoded. 2745 Header line texts include the following strings: 2747 BEGIN PGP MESSAGE Used for signed, encrypted, or compressed files. 2749 BEGIN PGP PUBLIC KEY BLOCK Used for armoring public keys. 2751 BEGIN PGP PRIVATE KEY BLOCK Used for armoring private keys. 2753 BEGIN PGP MESSAGE, PART X/Y Used for multi-part messages, where the 2754 armor is split amongst Y parts, and this is the Xth part out of Y. 2756 BEGIN PGP MESSAGE, PART X Used for multi-part messages, where this 2757 is the Xth part of an unspecified number of parts. Requires the 2758 MESSAGE-ID Armor Header to be used. 2760 BEGIN PGP SIGNATURE Used for detached signatures, OpenPGP/MIME 2761 signatures, and cleartext signatures. Note that PGP 2.x uses 2762 BEGIN PGP MESSAGE for detached signatures. 2764 Note that all these Armor Header Lines are to consist of a complete 2765 line. That is to say, there is always a line ending preceding the 2766 starting five dashes, and following the ending five dashes. The 2767 header lines, therefore, MUST start at the beginning of a line, and 2768 MUST NOT have text other than whitespace following them on the same 2769 line. These line endings are considered a part of the Armor Header 2770 Line for the purposes of determining the content they delimit. This 2771 is particularly important when computing a cleartext signature (see 2772 below). 2774 The Armor Headers are pairs of strings that can give the user or the 2775 receiving OpenPGP implementation some information about how to decode 2776 or use the message. The Armor Headers are a part of the armor, not a 2777 part of the message, and hence are not protected by any signatures 2778 applied to the message. 2780 The format of an Armor Header is that of a key-value pair. A colon 2781 (':' 0x38) and a single space (0x20) separate the key and value. 2782 OpenPGP should consider improperly formatted Armor Headers to be 2783 corruption of the ASCII Armor. Unknown keys should be reported to 2784 the user, but OpenPGP should continue to process the message. 2786 Note that some transport methods are sensitive to line length. While 2787 there is a limit of 76 characters for the Radix-64 data 2788 (Section 6.3), there is no limit to the length of Armor Headers. 2789 Care should be taken that the Armor Headers are short enough to 2790 survive transport. One way to do this is to repeat an Armor Header 2791 key multiple times with different values for each so that no one line 2792 is overly long. 2794 Currently defined Armor Header Keys are as follows: 2796 o "Version", which states the OpenPGP implementation and version 2797 used to encode the message. 2799 o "Comment", a user-defined comment. OpenPGP defines all text to be 2800 in UTF-8. A comment may be any UTF-8 string. However, the whole 2801 point of armoring is to provide seven-bit-clean data. 2802 Consequently, if a comment has characters that are outside the US- 2803 ASCII range of UTF, they may very well not survive transport. 2805 o "Hash", a comma-separated list of hash algorithms used in this 2806 message. This is used only in cleartext signed messages. 2808 o "MessageID", a 32-character string of printable characters. The 2809 string must be the same for all parts of a multi-part message that 2810 uses the "PART X" Armor Header. MessageID strings should be 2811 unique enough that the recipient of the mail can associate all the 2812 parts of a message with each other. A good checksum or 2813 cryptographic hash function is sufficient. 2815 The MessageID SHOULD NOT appear unless it is in a multi-part 2816 message. If it appears at all, it MUST be computed from the 2817 finished (encrypted, signed, etc.) message in a deterministic 2818 fashion, rather than contain a purely random value. This is to 2819 allow the legitimate recipient to determine that the MessageID 2820 cannot serve as a covert means of leaking cryptographic key 2821 information. 2823 o "Charset", a description of the character set that the plaintext 2824 is in. Please note that OpenPGP defines text to be in UTF-8. An 2825 implementation will get best results by translating into and out 2826 of UTF-8. However, there are many instances where this is easier 2827 said than done. Also, there are communities of users who have no 2828 need for UTF-8 because they are all happy with a character set 2829 like ISO Latin-5 or a Japanese character set. In such instances, 2830 an implementation MAY override the UTF-8 default by using this 2831 header key. An implementation MAY implement this key and any 2832 translations it cares to; an implementation MAY ignore it and 2833 assume all text is UTF-8. 2835 The Armor Tail Line is composed in the same manner as the Armor 2836 Header Line, except the string "BEGIN" is replaced by the string 2837 "END". 2839 6.3. {6.3} Encoding Binary in Radix-64 2841 The encoding process represents 24-bit groups of input bits as output 2842 strings of 4 encoded characters. Proceeding from left to right, a 2843 24-bit input group is formed by concatenating three 8-bit input 2844 groups. These 24 bits are then treated as four concatenated 6-bit 2845 groups, each of which is translated into a single digit in the 2846 Radix-64 alphabet. When encoding a bit stream with the Radix-64 2847 encoding, the bit stream must be presumed to be ordered with the most 2848 significant bit first. That is, the first bit in the stream will be 2849 the high-order bit in the first 8-bit octet, and the eighth bit will 2850 be the low-order bit in the first 8-bit octet, and so on. 2852 +--first octet--+-second octet--+--third octet--+ 2853 |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| 2854 +-----------+---+-------+-------+---+-----------+ 2855 |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| 2856 +--1.index--+--2.index--+--3.index--+--4.index--+ 2858 Each 6-bit group is used as an index into an array of 64 printable 2859 characters from the table below. The character referenced by the 2860 index is placed in the output string. 2862 Value Encoding Value Encoding Value Encoding Value Encoding 2863 0 A 17 R 34 i 51 z 2864 1 B 18 S 35 j 52 0 2865 2 C 19 T 36 k 53 1 2866 3 D 20 U 37 l 54 2 2867 4 E 21 V 38 m 55 3 2868 5 F 22 W 39 n 56 4 2869 6 G 23 X 40 o 57 5 2870 7 H 24 Y 41 p 58 6 2871 8 I 25 Z 42 q 59 7 2872 9 J 26 a 43 r 60 8 2873 10 K 27 b 44 s 61 9 2874 11 L 28 c 45 t 62 + 2875 12 M 29 d 46 u 63 / 2876 13 N 30 e 47 v 2877 14 O 31 f 48 w (pad) = 2878 15 P 32 g 49 x 2879 16 Q 33 h 50 y 2881 The encoded output stream must be represented in lines of no more 2882 than 76 characters each. 2884 Special processing is performed if fewer than 24 bits are available 2885 at the end of the data being encoded. There are three possibilities: 2887 1. The last data group has 24 bits (3 octets). No special 2888 processing is needed. 2890 2. The last data group has 16 bits (2 octets). The first two 2891 6-bit groups are processed as above. The third (incomplete) 2892 data group has two zero-value bits added to it, and is 2893 processed as above. A pad character (=) is added to the 2894 output. 2896 3. The last data group has 8 bits (1 octet). The first 6-bit 2897 group is processed as above. The second (incomplete) data 2898 group has four zero-value bits added to it, and is processed 2899 as above. Two pad characters (=) are added to the output. 2901 6.4. {6.4} Decoding Radix-64 2903 In Radix-64 data, characters other than those in the table, line 2904 breaks, and other white space probably indicate a transmission error, 2905 about which a warning message or even a message rejection might be 2906 appropriate under some circumstances. Decoding software must ignore 2907 all white space. 2909 Because it is used only for padding at the end of the data, the 2910 occurrence of any "=" characters may be taken as evidence that the 2911 end of the data has been reached (without truncation in transit). No 2912 such assurance is possible, however, when the number of octets 2913 transmitted was a multiple of three and no "=" characters are 2914 present. 2916 6.5. {6.5} Examples of Radix-64 2917 Input data: 0x14FB9C03D97E 2918 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 2919 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 2920 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 2921 Decimal: 5 15 46 28 0 61 37 62 2922 Output: F P u c A 9 l + 2923 Input data: 0x14FB9C03D9 2924 Hex: 1 4 F B 9 C | 0 3 D 9 2925 8-bit: 00010100 11111011 10011100 | 00000011 11011001 2926 pad with 00 2927 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 2928 Decimal: 5 15 46 28 0 61 36 2929 pad with = 2930 Output: F P u c A 9 k = 2931 Input data: 0x14FB9C03 2932 Hex: 1 4 F B 9 C | 0 3 2933 8-bit: 00010100 11111011 10011100 | 00000011 2934 pad with 0000 2935 6-bit: 000101 001111 101110 011100 | 000000 110000 2936 Decimal: 5 15 46 28 0 48 2937 pad with = = 2938 Output: F P u c A w = = 2940 6.6. {6.6} Example of an ASCII Armored Message 2942 -----BEGIN PGP MESSAGE----- 2943 Version: OpenPrivacy 0.99 2945 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 2946 vBSFjNSiVHsuAA== 2947 =njUN 2948 -----END PGP MESSAGE----- 2950 Note that this example has extra indenting; an actual armored message 2951 would have no leading whitespace. 2953 7. {7} Cleartext Signature Framework 2955 It is desirable to be able to sign a textual octet stream without 2956 ASCII armoring the stream itself, so the signed text is still 2957 readable without special software. In order to bind a signature to 2958 such a cleartext, this framework is used. (Note that this framework 2959 is not intended to be reversible. RFC 3156 [RFC3156] defines another 2960 way to sign cleartext messages for environments that support MIME.) 2962 The cleartext signed message consists of: 2964 o The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a 2965 single line, 2967 o One or more "Hash" Armor Headers, 2969 o Exactly one empty line not included into the message digest, 2971 o The dash-escaped cleartext that is included into the message 2972 digest, 2974 o The ASCII armored signature(s) including the '-----BEGIN PGP 2975 SIGNATURE-----' Armor Header and Armor Tail Lines. 2977 If the "Hash" Armor Header is given, the specified message digest 2978 algorithm(s) are used for the signature. If there are no such 2979 headers, MD5 is used. If MD5 is the only hash used, then an 2980 implementation MAY omit this header for improved V2.x compatibility. 2981 If more than one message digest is used in the signature, the "Hash" 2982 armor header contains a comma-delimited list of used message digests. 2984 Current message digest names are described below with the algorithm 2985 IDs. 2987 An implementation SHOULD add a line break after the cleartext, but 2988 MAY omit it if the cleartext ends with a line break. This is for 2989 visual clarity. 2991 7.1. {7.1} Dash-Escaped Text 2993 The cleartext content of the message must also be dash-escaped. 2995 Dash-escaped cleartext is the ordinary cleartext where every line 2996 starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' 2997 (0x2D) and space ' ' (0x20). This prevents the parser from 2998 recognizing armor headers of the cleartext itself. An implementation 2999 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3000 followed by a space, and MUST dash-escape any line commencing in a 3001 dash. The message digest is computed using the cleartext itself, not 3002 the dash-escaped form. 3004 As with binary signatures on text documents, a cleartext signature is 3005 calculated on the text using canonical line endings. The 3006 line ending (i.e., the ) before the '-----BEGIN PGP 3007 SIGNATURE-----' line that terminates the signed text is not 3008 considered part of the signed text. 3010 When reversing dash-escaping, an implementation MUST strip the string 3011 "- " if it occurs at the beginning of a line, and SHOULD warn on "-" 3012 and any character other than a space at the beginning of a line. 3014 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 3015 the end of any line is removed when the cleartext signature is 3016 generated. 3018 8. {8} Regular Expressions 3020 A regular expression is zero or more branches, separated by '|'. It 3021 matches anything that matches one of the branches. 3023 A branch is zero or more pieces, concatenated. It matches a match 3024 for the first, followed by a match for the second, etc. 3026 A piece is an atom possibly followed by '_', '+', or '?'. An atom 3027 followed by '_' matches a sequence of 0 or more matches of the atom. 3028 An atom followed by '+' matches a sequence of 1 or more matches of 3029 the atom. An atom followed by '?' matches a match of the atom, or 3030 the null string. 3032 An atom is a regular expression in parentheses (matching a match for 3033 the regular expression), a range (see below), '.' (matching any 3034 single character), '^' (matching the null string at the beginning of 3035 the input string), '$' (matching the null string at the end of the 3036 input string), a '' followed by a single character (matching that 3037 character), or a single character with no other significance 3038 (matching that character). 3040 A range is a sequence of characters enclosed in '[]'. It normally 3041 matches any single character from the sequence. If the sequence 3042 begins with '^', it matches any single character not from the rest of 3043 the sequence. If two characters in the sequence are separated by 3044 '-', this is shorthand for the full list of ASCII characters between 3045 them (e.g., '[0-9]' matches any decimal digit). To include a literal 3046 ']' in the sequence, make it the first character (following a 3047 possible '^'). To include a literal '-', make it the first or last 3048 character. 3050 9. {9} Constants 3052 This section describes the constants used in OpenPGP. 3054 Note that these tables are not exhaustive lists; an implementation 3055 MAY implement an algorithm not on these lists, so long as the 3056 algorithm numbers are chosen from the private or experimental 3057 algorithm range. 3059 See the section "Notes on Algorithms" below for more discussion of 3060 the algorithms. 3062 9.1. {9.1} Public-Key Algorithms 3064 +-----------+----------------------------------------------------+ 3065 | ID | Algorithm | 3066 +-----------+----------------------------------------------------+ 3067 | 1 | RSA (Encrypt or Sign) [HAC] | 3068 | 2 | RSA Encrypt-Only [HAC] | 3069 | 3 | RSA Sign-Only [HAC] | 3070 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3071 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3072 | 18 | ECDH public key algorithm | 3073 | 19 | ECDSA public key algorithm [FIPS186-3] | 3074 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3075 | 21 | Reserved for Diffie-Hellman | 3076 | | (X9.42, as defined for IETF-S/MIME) | 3077 | 22 | EdDSA [I-D.irtf-cfrg-eddsa] | 3078 | 100--110 | Private/Experimental algorithm | 3079 +-----------+----------------------------------------------------+ 3081 Implementations MUST implement DSA and ECDSA for signatures, and 3082 Elgamal and ECDH for encryption. Implementations SHOULD implement 3083 RSA keys (1). RSA Encrypt-Only (2) and RSA Sign-Only are deprecated 3084 and SHOULD NOT be generated, but may be interpreted. See 3085 Section 13.5. See Section 13.8 for notes Elgamal Encrypt or Sign 3086 (20), and X9.42 (21). Implementations MAY implement any other 3087 algorithm. 3089 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3090 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this 3091 document. 3093 9.2. ECC Curve OID 3095 The parameter curve OID is an array of octets that define a named 3096 curve. The table below specifies the exact sequence of bytes for 3097 each named curve referenced in this document: 3099 +------------------------+-----+----------------------+-------------+ 3100 | ASN.1 Object | OID | Curve OID bytes in | Curve name | 3101 | Identifier | len | hexadecimal | | 3102 | | | representation | | 3103 +------------------------+-----+----------------------+-------------+ 3104 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D 03 01 | NIST curve | 3105 | | | 07 | P-256 | 3106 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST curve | 3107 | | | | P-384 | 3108 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST curve | 3109 | | | | P-521 | 3110 | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 DA 47 | Ed25519 | 3111 | | | 0F 01 | | 3112 +------------------------+-----+----------------------+-------------+ 3114 The sequence of octets in the third column is the result of applying 3115 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3116 with subsequent truncation. The truncation removes the two fields of 3117 encoded Object Identifier. The first omitted field is one octet 3118 representing the Object Identifier tag, and the second omitted field 3119 is the length of the Object Identifier body. For example, the 3120 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3121 86 48 CE 3D 03 01 07", from which the first entry in the table above 3122 is constructed by omitting the first two octets. Only the truncated 3123 sequence of octets is the valid representation of a curve OID. 3125 9.3. {9.2} Symmetric-Key Algorithms 3127 +-----------+-----------------------------------------------+ 3128 | ID | Algorithm | 3129 +-----------+-----------------------------------------------+ 3130 | 0 | Plaintext or unencrypted data | 3131 | 1 | IDEA [IDEA] | 3132 | 2 | TripleDES (DES-EDE, [SCHNEIER] [HAC] | 3133 | | - 168 bit key derived from 192) | 3134 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3135 | 4 | Blowfish (128 bit key, 16 rounds) [BLOWFISH] | 3136 | 5 | Reserved | 3137 | 6 | Reserved | 3138 | 7 | AES with 128-bit key [AES] | 3139 | 8 | AES with 192-bit key | 3140 | 9 | AES with 256-bit key | 3141 | 10 | Twofish with 256-bit key [TWOFISH] | 3142 | 11 | Camellia with 128-bit key [RFC3713] | 3143 | 12 | Camellia with 192-bit key | 3144 | 13 | Camellia with 256-bit key | 3145 | 100--110 | Private/Experimental algorithm | 3146 +-----------+-----------------------------------------------+ 3148 Implementations MUST implement TripleDES. Implementations SHOULD 3149 implement AES-128 and CAST5. Implementations that interoperate with 3150 PGP 2.6 or earlier need to support IDEA, as that is the only 3151 symmetric cipher those versions use. Implementations MAY implement 3152 any other algorithm. 3154 9.4. {9.3} Compression Algorithms 3156 +-----------+---------------------------------+ 3157 | ID | Algorithm | 3158 +-----------+---------------------------------+ 3159 | 0 | Uncompressed | 3160 | 1 | ZIP [RFC1951] | 3161 | 2 | ZLIB [RFC1950] | 3162 | 3 | BZip2 [BZ2] | 3163 | 100--110 | Private/Experimental algorithm | 3164 +-----------+---------------------------------+ 3166 Implementations MUST implement uncompressed data. Implementations 3167 SHOULD implement ZIP. Implementations MAY implement any other 3168 algorithm. 3170 9.5. {9.4} Hash Algorithms 3172 +-----------+---------------------------------+--------------+ 3173 | ID | Algorithm | Text Name | 3174 +-----------+---------------------------------+--------------+ 3175 | 1 | MD5 [HAC] | "MD5" | 3176 | 2 | SHA-1 [FIPS180] | "SHA1" | 3177 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3178 | 4 | Reserved | | 3179 | 5 | Reserved | | 3180 | 6 | Reserved | | 3181 | 7 | Reserved | | 3182 | 8 | SHA256 [FIPS180] | "SHA256" | 3183 | 9 | SHA384 [FIPS180] | "SHA384" | 3184 | 10 | SHA512 [FIPS180] | "SHA512" | 3185 | 11 | SHA224 [FIPS180] | "SHA224" | 3186 | 100--110 | Private/Experimental algorithm | | 3187 +-----------+---------------------------------+--------------+ 3189 Implementations MUST implement SHA-1. Implementations MAY implement 3190 other algorithms. MD5 is deprecated. 3192 10. {10} IANA Considerations 3194 OpenPGP is highly parameterized, and consequently there are a number 3195 of considerations for allocating parameters for extensions. This 3196 section describes how IANA should look at extensions to the protocol 3197 as described in this document. 3199 10.1. {10.1} New String-to-Key Specifier Types 3201 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3202 a string into a key. This specification creates a registry of S2K 3203 specifier types. The registry includes the S2K type, the name of the 3204 S2K, and a reference to the defining specification. The initial 3205 values for this registry can be found in Section 3.7.1. Adding a new 3206 S2K specifier MUST be done through the IETF CONSENSUS method, as 3207 described in [RFC2434]. 3209 10.2. {10.2} New Packets 3211 Major new features of OpenPGP are defined through new packet types. 3212 This specification creates a registry of packet types. The registry 3213 includes the packet type, the name of the packet, and a reference to 3214 the defining specification. The initial values for this registry can 3215 be found in Section 4.3. Adding a new packet type MUST be done 3216 through the IETF CONSENSUS method, as described in [RFC2434]. 3218 10.2.1. {10.2.1} User Attribute Types 3220 The User Attribute packet permits an extensible mechanism for other 3221 types of certificate identification. This specification creates a 3222 registry of User Attribute types. The registry includes the User 3223 Attribute type, the name of the User Attribute, and a reference to 3224 the defining specification. The initial values for this registry can 3225 be found in Section 5.12. Adding a new User Attribute type MUST be 3226 done through the IETF CONSENSUS method, as described in [RFC2434]. 3228 This document requests that IANA register the User ID Attribute Type 3229 found in Section 5.12.2: 3231 +--------+------------+-----------------------------+ 3232 | Value | Attribute | Reference | 3233 +--------+------------+-----------------------------+ 3234 | TBD1 | User ID | This Document Section 5.12 | 3235 +--------+------------+-----------------------------+ 3237 10.2.2. {10.2.1.1} Image Format Subpacket Types 3239 Within User Attribute packets, there is an extensible mechanism for 3240 other types of image-based user attributes. This specification 3241 creates a registry of Image Attribute subpacket types. The registry 3242 includes the Image Attribute subpacket type, the name of the Image 3243 Attribute subpacket, and a reference to the defining specification. 3244 The initial values for this registry can be found in Section 5.12.1. 3245 Adding a new Image Attribute subpacket type MUST be done through the 3246 IETF CONSENSUS method, as described in [RFC2434]. 3248 10.2.3. {10.2.2} New Signature Subpackets 3250 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3251 to be added to them for a variety of purposes in the Signature 3252 subpackets as discussed in Section 5.2.3.1. This specification 3253 creates a registry of Signature subpacket types. The registry 3254 includes the Signature subpacket type, the name of the subpacket, and 3255 a reference to the defining specification. The initial values for 3256 this registry can be found in Section 5.2.3.1. Adding a new 3257 Signature subpacket MUST be done through the IETF CONSENSUS method, 3258 as described in [RFC2434]. 3260 10.2.3.1. {10.2.2.1} Signature Notation Data Subpackets 3262 OpenPGP signatures further contain a mechanism for extensions in 3263 signatures. These are the Notation Data subpackets, which contain a 3264 key/value pair. Notations contain a user space that is completely 3265 unmanaged and an IETF space. 3267 This specification creates a registry of Signature Notation Data 3268 types. The registry includes the Signature Notation Data type, the 3269 name of the Signature Notation Data, its allowed values, and a 3270 reference to the defining specification. The initial values for this 3271 registry can be found in Section 5.2.3.16. Adding a new Signature 3272 Notation Data subpacket MUST be done through the EXPERT REVIEW 3273 method, as described in [RFC2434]. 3275 This document requests IANA register the following Signature Notation 3276 Data types: 3278 +---------------+--------+--------------------+---------------------+ 3279 | Allowed | Name | Type | Reference | 3280 | Values | | | | 3281 +---------------+--------+--------------------+---------------------+ 3282 | Any String | manu | Manufacturer Name | This Doc Section | 3283 | | | | 5.2.3.16.1 | 3284 | Any String | make | Product Make | This Doc Section | 3285 | | | | 5.2.3.16.2 | 3286 | Any String | model | Product Model | This Doc Section | 3287 | | | | 5.2.3.16.3 | 3288 | Any String | prodid | Product ID | This Doc Section | 3289 | | | | 5.2.3.16.4 | 3290 | Any String | pvers | Product Version | This Doc Section | 3291 | | | | 5.2.3.16.5 | 3292 | Any String | lot | Product Lot Number | This Doc Section | 3293 | | | | 5.2.3.16.6 | 3294 | Decimal | qty | Package Quantity | This Doc Section | 3295 | Integer | | | 5.2.3.16.7 | 3296 | String | | | | 3297 | A geo: URI | loc | Current Geo- | This Doc Section | 3298 | | | | 5.2.3.16.8 | 3299 | without the | | location | | 3300 | "geo:" | | Latitude/Longitude | | 3301 | A geo: URI | dest | Destination Geo- | This Doc Section | 3302 | | | | 5.2.3.16.8 | 3303 | without the | | location | | 3304 | "geo:" | | Latitude/Longitude | | 3305 | Hash Notation | hash | The Hash of | This Doc Section | 3306 | | | | 5.2.3.16.9 | 3307 | data | | external data | | 3308 +---------------+--------+--------------------+---------------------+ 3310 10.2.3.2. {10.2.2.2} Key Server Preference Extensions 3312 OpenPGP signatures contain a mechanism for preferences to be 3313 specified about key servers. This specification creates a registry 3314 of key server preferences. The registry includes the key server 3315 preference, the name of the preference, and a reference to the 3316 defining specification. The initial values for this registry can be 3317 found in Section 5.2.3.17. Adding a new key server preference MUST 3318 be done through the IETF CONSENSUS method, as described in [RFC2434]. 3320 10.2.3.3. {10.2.2.3} Key Flags Extensions 3322 OpenPGP signatures contain a mechanism for flags to be specified 3323 about key usage. This specification creates a registry of key usage 3324 flags. The registry includes the key flags value, the name of the 3325 flag, and a reference to the defining specification. The initial 3326 values for this registry can be found in Section 5.2.3.21. Adding a 3327 new key usage flag MUST be done through the IETF CONSENSUS method, as 3328 described in [RFC2434]. 3330 10.2.3.4. {10.2.2.4} Reason for Revocation Extensions 3332 OpenPGP signatures contain a mechanism for flags to be specified 3333 about why a key was revoked. This specification creates a registry 3334 of "Reason for Revocation" flags. The registry includes the "Reason 3335 for Revocation" flags value, the name of the flag, and a reference to 3336 the defining specification. The initial values for this registry can 3337 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3338 through the IETF CONSENSUS method, as described in [RFC2434]. 3340 10.2.3.5. {10.2.2.5} Implementation Features 3342 OpenPGP signatures contain a mechanism for flags to be specified 3343 stating which optional features an implementation supports. This 3344 specification creates a registry of feature-implementation flags. 3345 The registry includes the feature-implementation flags value, the 3346 name of the flag, and a reference to the defining specification. The 3347 initial values for this registry can be found in Section 5.2.3.24. 3348 Adding a new feature-implementation flag MUST be done through the 3349 IETF CONSENSUS method, as described in [RFC2434]. 3351 Also see Section 13.12 for more information about when feature flags 3352 are needed. 3354 10.2.4. {10.2.3} New Packet Versions 3356 The core OpenPGP packets all have version numbers, and can be revised 3357 by introducing a new version of an existing packet. This 3358 specification creates a registry of packet types. The registry 3359 includes the packet type, the number of the version, and a reference 3360 to the defining specification. The initial values for this registry 3361 can be found in Section 5. Adding a new packet version MUST be done 3362 through the IETF CONSENSUS method, as described in [RFC2434]. 3364 10.3. {10.3} New Algorithms 3366 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3367 new algorithm is usually simple. For example, adding in a new 3368 symmetric cipher usually would not need anything more than allocating 3369 a constant for that cipher. If that cipher had other than a 64-bit 3370 or 128-bit block size, there might need to be additional 3371 documentation describing how OpenPGP-CFB mode would be adjusted. 3372 Similarly, when DSA was expanded from a maximum of 1024-bit public 3373 keys to 3072-bit public keys, the revision of FIPS 186 contained 3374 enough information itself to allow implementation. Changes to this 3375 document were made mainly for emphasis. 3377 10.3.1. {10.3.1} Public-Key Algorithms 3379 OpenPGP specifies a number of public-key algorithms. This 3380 specification creates a registry of public-key algorithm identifiers. 3381 The registry includes the algorithm name, its key sizes and 3382 parameters, and a reference to the defining specification. The 3383 initial values for this registry can be found in Section 9. Adding a 3384 new public-key algorithm MUST be done through the IETF CONSENSUS 3385 method, as described in [RFC2434]. 3387 This document requests IANA register the following public-key 3388 algorithm: 3390 +-----+-----------------------------+------------+ 3391 | ID | Algorithm | Reference | 3392 +-----+-----------------------------+------------+ 3393 | 22 | EdDSA public key algorithm | This doc | 3394 +-----+-----------------------------+------------+ 3396 [Notes to RFC-Editor: Please remove the table above on publication. 3397 It is desirable not to reuse old or reserved algorithms because some 3398 existing tools might print a wrong description. A higher number is 3399 also an indication for a newer algorithm. As of now 22 is the next 3400 free number.] 3402 10.3.2. {10.3.2} Symmetric-Key Algorithms 3404 OpenPGP specifies a number of symmetric-key algorithms. This 3405 specification creates a registry of symmetric-key algorithm 3406 identifiers. The registry includes the algorithm name, its key sizes 3407 and block size, and a reference to the defining specification. The 3408 initial values for this registry can be found in Section 9. Adding a 3409 new symmetric-key algorithm MUST be done through the IETF CONSENSUS 3410 method, as described in [RFC2434]. 3412 10.3.3. {10.3.3} Hash Algorithms 3414 OpenPGP specifies a number of hash algorithms. This specification 3415 creates a registry of hash algorithm identifiers. The registry 3416 includes the algorithm name, a text representation of that name, its 3417 block size, an OID hash prefix, and a reference to the defining 3418 specification. The initial values for this registry can be found in 3419 Section 9 for the algorithm identifiers and text names, and 3420 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3421 new hash algorithm MUST be done through the IETF CONSENSUS method, as 3422 described in [RFC2434]. 3424 10.3.4. {10.3.4} Compression Algorithms 3426 OpenPGP specifies a number of compression algorithms. This 3427 specification creates a registry of compression algorithm 3428 identifiers. The registry includes the algorithm name and a 3429 reference to the defining specification. The initial values for this 3430 registry can be found in Section 9.3. Adding a new compression key 3431 algorithm MUST be done through the IETF CONSENSUS method, as 3432 described in [RFC2434]. 3434 11. {11} Packet Composition 3436 OpenPGP packets are assembled into sequences in order to create 3437 messages and to transfer keys. Not all possible packet sequences are 3438 meaningful and correct. This section describes the rules for how 3439 packets should be placed into sequences. 3441 11.1. {11.1} Transferable Public Keys 3443 OpenPGP users may transfer public keys. The essential elements of a 3444 transferable public key are as follows: 3446 o One Public-Key packet 3448 o Zero or more revocation signatures 3450 o Zero or more User ID packets 3452 o After each User ID packet, zero or more Signature packets 3453 (certifications) 3455 o Zero or more User Attribute packets 3457 o After each User Attribute packet, zero or more Signature packets 3458 (certifications) 3460 o Zero or more Subkey packets 3462 o After each Subkey packet, one Signature packet, plus optionally a 3463 revocation 3465 The Public-Key packet occurs first. Each of the following User ID 3466 packets provides the identity of the owner of this public key. If 3467 there are multiple User ID packets, this corresponds to multiple 3468 means of identifying the same unique individual user; for example, a 3469 user may have more than one email address, and construct a User ID 3470 for each one. 3472 Immediately following each User ID packet, there are zero or more 3473 Signature packets. Each Signature packet is calculated on the 3474 immediately preceding User ID packet and the initial Public-Key 3475 packet. The signature serves to certify the corresponding public key 3476 and User ID. In effect, the signer is testifying to his or her 3477 belief that this public key belongs to the user identified by this 3478 User ID. 3480 Within the same section as the User ID packets, there are zero or 3481 more User Attribute packets. Like the User ID packets, a User 3482 Attribute packet is followed by zero or more Signature packets 3483 calculated on the immediately preceding User Attribute packet and the 3484 initial Public-Key packet. 3486 User Attribute packets and User ID packets may be freely intermixed 3487 in this section, so long as the signatures that follow them are 3488 maintained on the proper User Attribute or User ID packet. 3490 After the User ID packet or Attribute packet, there may be zero or 3491 more Subkey packets. In general, subkeys are provided in cases where 3492 the top-level public key is a signature-only key. However, any V4 3493 key may have subkeys, and the subkeys may be encryption-only keys, 3494 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3495 subkeys. 3497 Each Subkey packet MUST be followed by one Signature packet, which 3498 should be a subkey binding signature issued by the top-level key. 3499 For subkeys that can issue signatures, the subkey binding signature 3500 MUST contain an Embedded Signature subpacket with a primary key 3501 binding signature (0x19) issued by the subkey on the top-level key. 3503 Subkey and Key packets may each be followed by a revocation Signature 3504 packet to indicate that the key is revoked. Revocation signatures 3505 are only accepted if they are issued by the key itself, or by a key 3506 that is authorized to issue revocations via a Revocation Key 3507 subpacket in a self-signature by the top-level key. 3509 Transferable public-key packet sequences may be concatenated to allow 3510 transferring multiple public keys in one operation. 3512 11.2. {11.2} Transferable Secret Keys 3514 OpenPGP users may transfer secret keys. The format of a transferable 3515 secret key is the same as a transferable public key except that 3516 secret-key and secret-subkey packets are used instead of the public 3517 key and public-subkey packets. Implementations SHOULD include self- 3518 signatures on any user IDs and subkeys, as this allows for a complete 3519 public key to be automatically extracted from the transferable secret 3520 key. Implementations MAY choose to omit the self-signatures, 3521 especially if a transferable public key accompanies the transferable 3522 secret key. 3524 11.3. {11.3} OpenPGP Messages 3526 An OpenPGP message is a packet or sequence of packets that 3527 corresponds to the following grammatical rules (comma represents 3528 sequential composition, and vertical bar separates alternatives): 3530 OpenPGP Message :- Encrypted Message | Signed Message | 3531 Compressed Message | Literal Message. 3533 Compressed Message :- Compressed Data Packet. 3535 Literal Message :- Literal Data Packet. 3537 ESK :- Public-Key Encrypted Session Key Packet | 3538 Symmetric-Key Encrypted Session Key Packet. 3540 ESK Sequence :- ESK | ESK Sequence, ESK. 3542 Encrypted Data :- Symmetrically Encrypted Data Packet | 3543 Symmetrically Encrypted Integrity Protected Data Packet 3545 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3547 One-Pass Signed Message :- One-Pass Signature Packet, 3548 OpenPGP Message, Corresponding Signature Packet. 3550 Signed Message :- Signature Packet, OpenPGP Message | 3551 One-Pass Signed Message. 3553 In addition, decrypting a Symmetrically Encrypted Data packet or a 3554 Symmetrically Encrypted Integrity Protected Data packet as well as 3555 decompressing a Compressed Data packet must yield a valid OpenPGP 3556 Message. 3558 11.4. {11.4} Detached Signatures 3560 Some OpenPGP applications use so-called "detached signatures". For 3561 example, a program bundle may contain a file, and with it a second 3562 file that is a detached signature of the first file. These detached 3563 signatures are simply a Signature packet stored separately from the 3564 data for which they are a signature. 3566 12. {12} Enhanced Key Formats 3568 12.1. {12.1} Key Structures 3570 The format of an OpenPGP V3 key is as follows. Entries in square 3571 brackets are optional and ellipses indicate repetition. 3573 RSA Public Key 3574 [Revocation Self Signature] 3575 User ID [Signature ...] 3576 [User ID [Signature ...] ...] 3578 Each signature certifies the RSA public key and the preceding User 3579 ID. The RSA public key can have many User IDs and each User ID can 3580 have many signatures. V3 keys are deprecated. Implementations MUST 3581 NOT generate new V3 keys, but MAY continue to use existing ones. 3583 The format of an OpenPGP V4 key that uses multiple public keys is 3584 similar except that the other keys are added to the end as "subkeys" 3585 of the primary key. 3587 Primary-Key 3588 [Revocation Self Signature] 3589 [Direct Key Signature...] 3590 [User ID [Signature ...] ...] 3591 [User Attribute [Signature ...] ...] 3592 [[Subkey [Binding-Signature-Revocation] 3593 Primary-Key-Binding-Signature] ...] 3595 A subkey always has a single signature after it that is issued using 3596 the primary key to tie the two keys together. This binding signature 3597 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3598 issue signatures MUST have a V4 binding signature due to the REQUIRED 3599 embedded primary key binding signature. 3601 In the above diagram, if the binding signature of a subkey has been 3602 revoked, the revoked key may be removed, leaving only one key. 3604 In a V4 key, the primary key SHOULD be a key capable of 3605 certification. There are cases, such as device certificates, where 3606 the primary key may not be capable of certification. A primary key 3607 capable of making signatures SHOULD be accompanied by either a 3608 certification signature (on a User ID or User Attribute) or a 3609 signature directly on the key. 3611 Implementations SHOULD accept encryption-only primary keys without a 3612 signature. It also SHOULD allow importing any key accompanied either 3613 by a certification signature or a signature on itself. It MAY accept 3614 signature-capable primary keys without an accompanying signature. 3616 The subkeys may be keys of any other type. There may be other 3617 constructions of V4 keys, too. For example, there may be a single- 3618 key RSA key in V4 format, a DSA primary key with an RSA encryption 3619 key, or RSA primary key with an Elgamal subkey, etc. 3621 It is also possible to have a signature-only subkey. This permits a 3622 primary key that collects certifications (key signatures), but is 3623 used only for certifying subkeys that are used for encryption and 3624 signatures. 3626 12.2. {12.2} Key IDs and Fingerprints 3628 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3629 the public modulus of the RSA key. 3631 The fingerprint of a V3 key is formed by hashing the body (but not 3632 the two-octet length) of the MPIs that form the key material (public 3633 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3634 and MD5 are deprecated. 3636 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3637 followed by the two-octet packet length, followed by the entire 3638 Public-Key packet starting with the version field. The Key ID is the 3639 low-order 64 bits of the fingerprint. Here are the fields of the 3640 hash material, with the example of a DSA key: 3642 a.1) 0x99 (1 octet) 3644 a.2) high-order length octet of (b)-(e) (1 octet) 3646 a.3) low-order length octet of (b)-(e) (1 octet) 3648 b) version number = 4 (1 octet); 3650 c) timestamp of key creation (4 octets); 3652 d) algorithm (1 octet): 17 = DSA (example); 3654 e) Algorithm-specific fields. 3656 Algorithm-Specific Fields for DSA keys (example): 3658 e.1) MPI of DSA prime p; 3660 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 3662 e.3) MPI of DSA group generator g; 3664 e.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 3666 Note that it is possible for there to be collisions of Key IDs -- two 3667 different keys with the same Key ID. Note that there is a much 3668 smaller, but still non-zero, probability that two different keys have 3669 the same fingerprint. 3671 Also note that if V3 and V4 format keys share the same RSA key 3672 material, they will have different Key IDs as well as different 3673 fingerprints. 3675 Finally, the Key ID and fingerprint of a subkey are calculated in the 3676 same way as for a primary key, including the 0x99 as the first octet 3677 (even though this is not a valid packet ID for a public subkey). 3679 13. Elliptic Curve Cryptography 3681 This section descripes algorithms and parameters used with Elliptic 3682 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 3683 found in [KOBLITZ]. 3685 13.1. Supported ECC Curves 3687 This document references three named prime field curves, defined in 3688 [FIPS186-3] as "Curve P-256", "Curve P-384", and "Curve P-521". 3690 Further curve "Ed25519", defined in [I-D.irtf-cfrg-eddsa] is 3691 referenced for use with the EdDSA algorithm. 3693 The named curves are referenced as a sequence of bytes in this 3694 document, called throughout, curve OID. Section 9.2 describes in 3695 detail how this sequence of bytes is formed. 3697 13.2. ECDSA and ECDH Conversion Primitives 3699 This document only defines the uncompressed point format for ECDSA 3700 and ECDH. The point is encoded in the Multiprecision Integer (MPI) 3701 format. The content of the MPI is the following: 3703 B = 04 || x || y 3705 where x and y are coordinates of the point P = (x, y), each encoded 3706 in the big-endian format and zero-padded to the adjusted underlying 3707 field size. The adjusted underlying field size is the underlying 3708 field size that is rounded up to the nearest 8-bit boundary. 3710 Therefore, the exact size of the MPI payload is 515 bits for "Curve 3711 P-256", 771 for "Curve P-384", and 1059 for "Curve P-521". 3713 Even though the zero point, also called the point at infinity, may 3714 occur as a result of arithmetic operations on points of an elliptic 3715 curve, it SHALL NOT appear in data structures defined in this 3716 document. 3718 This encoding is compatible with the definition given in [SEC1]. 3720 If other conversion methods are defined in the future, a compliant 3721 application MUST NOT use a new format when in doubt that any 3722 recipient can support it. Consider, for example, that while both the 3723 public key and the per-recipient ECDH data structure, respectively 3724 defined in Sections 9{FIXME} and 10{FIXME}, contain an encoded point 3725 field, the format changes to the field in Section 10{FIXME} only 3726 affect a given recipient of a given message. 3728 13.3. EdDSA Point Format 3730 The EdDSA algorithm defines a specific point compression format. To 3731 indicate the use of this compression format and to make sure that the 3732 key can be represented in the Multiprecision Integer (MPI) format the 3733 octet string specifying the point is prefixed with the octet 0x40. 3734 This encoding is an extension of the encoding given in [SEC1] which 3735 uses 0x04 to indicate an uncompressed point. 3737 For example, the length of a public key for the curve Ed25519 is 263 3738 bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the 3739 native value of the public key. 3741 13.4. Key Derivation Function 3743 A key derivation function (KDF) is necessary to implement the EC 3744 encryption. The Concatenation Key Derivation Function (Approved 3745 Alternative 1) [SP800-56A] with the KDF hash function that is 3746 SHA2-256 [FIPS180-3] or stronger is REQUIRED. See Section 12{FIXME} 3747 for the details regarding the choice of the hash function. 3749 For convenience, the synopsis of the encoding method is given below 3750 with significant simplifications attributable to the restricted 3751 choice of hash functions in this document. However, [SP800-56A] is 3752 the normative source of the definition. 3754 // Implements KDF( X, oBits, Param ); 3755 // Input: point X = (x,y) 3756 // oBits - the desired size of output 3757 // hBits - the size of output of hash function Hash 3758 // Param - octets representing the parameters 3759 // Assumes that oBits <= hBits 3760 // Convert the point X to the octet string, see section 6{FIXME}: 3761 // ZB' = 04 || x || y 3762 // and extract the x portion from ZB' 3763 ZB = x; 3764 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 3765 return oBits leftmost bits of MB. 3767 Note that ZB in the KDF description above is the compact 3768 representation of X, defined in Section 4.2 of [RFC6090]. 3770 13.5. EC DH Algorithm (ECDH) 3772 The method is a combination of an ECC Diffie-Hellman method to 3773 establish a shared secret, a key derivation method to process the 3774 shared secret into a derived key, and a key wrapping method that uses 3775 the derived key to protect a session key used to encrypt a message. 3777 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 3778 be implemented with the following restrictions: the ECC CDH primitive 3779 employed by this method is modified to always assume the cofactor as 3780 1, the KDF specified in Section 7 is used, and the KDF parameters 3781 specified below are used. 3783 The KDF parameters are encoded as a concatenation of the following 5 3784 variable-length and fixed-length fields, compatible with the 3785 definition of the OtherInfo bitstring [SP800-56A]: 3787 o a variable-length field containing a curve OID, formatted as 3788 follows: 3790 * a one-octet size of the following field 3792 * the octets representing a curve OID, defined in Section 11 3794 o a one-octet public key algorithm ID defined in Section 5 3796 o a variable-length field containing KDF parameters, identical to 3797 the corresponding field in the ECDH public key, formatted as 3798 follows: 3800 * a one-octet size of the following fields; values 0 and 0xff are 3801 reserved for future extensions 3803 * a one-octet value 01, reserved for future extensions 3805 * a one-octet hash function ID used with the KDF 3807 * a one-octet algorithm ID for the symmetric algorithm used to 3808 wrap the symmetric key for message encryption; see Section 8 3809 for details 3811 o 20 octets representing the UTF-8 encoding of the string "Anonymous 3812 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 73 3813 20 53 65 6E 64 65 72 20 20 20 20 3815 o 20 octets representing a recipient encryption subkey or a master 3816 key fingerprint, identifying the key material that is needed for 3817 the decryption. 3819 The size of the KDF parameters sequence, defined above, is either 54 3820 for the NIST curve P-256 or 51 for the curves P-384 and P-521. 3822 The key wrapping method is described in [RFC3394]. KDF produces a 3823 symmetric key that is used as a key-encryption key (KEK) as specified 3824 in [RFC3394]. Refer to Section 13{FIXME} for the details regarding 3825 the choice of the KEK algorithm, which SHOULD be one of three AES 3826 algorithms. Key wrapping and unwrapping is performed with the 3827 default initial value of [RFC3394]. 3829 The input to the key wrapping method is the value "m" derived from 3830 the session key, as described in Section 5.1{FIXME}, "Public-Key 3831 Encrypted Session Key Packets (Tag 1)", except that the PKCS #1.5 3832 padding step is omitted. The result is padded using the method 3833 described in [PKCS5] to the 8-byte granularity. For example, the 3834 following AES-256 session key, in which 32 octets are denoted from k0 3835 to k31, is composed to form the following 40 octet sequence: 3837 09 k0 k1 ... k31 c0 c1 05 05 05 05 05 3839 The octets c0 and c1 above denote the checksum. This encoding allows 3840 the sender to obfuscate the size of the symmetric encryption key used 3841 to encrypt the data. For example, assuming that an AES algorithm is 3842 used for the session key, the sender MAY use 21, 13, and 5 bytes of 3843 padding for AES-128, AES-192, and AES-256, respectively, to provide 3844 the same number of octets, 40 total, as an input to the key wrapping 3845 method. 3847 The output of the method consists of two fields. The first field is 3848 the MPI containing the ephemeral key used to establish the shared 3849 secret. The second field is composed of the following two fields: 3851 o a one-octet encoding the size in octets of the result of the key 3852 wrapping method; the value 255 is reserved for future extensions; 3854 o up to 254 octets representing the result of the key wrapping 3855 method, applied to the 8-byte padded session key, as described 3856 above. 3858 Note that for session key sizes 128, 192, and 256 bits, the size of 3859 the result of the key wrapping method is, respectively, 32, 40, and 3860 48 octets, unless the size obfuscation is used. 3862 For convenience, the synopsis of the encoding method is given below; 3863 however, this section, [SP800-56A], and [RFC3394] are the normative 3864 sources of the definition. 3866 Obtain the authenticated recipient public key R 3867 Generate an ephemeral key pair {v, V=vG} 3868 Compute the shared point S = vR; 3869 m = symm_alg_ID || session key || checksum || pkcs5_padding; 3870 curve_OID_len = (byte)len(curve_OID); 3871 Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 3872 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 3873 Sender " || recipient_fingerprint; 3874 Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 3875 Compute Z = KDF( S, Z_len, Param ); 3876 Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 3877 VB = convert point V to the octet string 3878 Output (MPI(VB) || len(C) || C). 3880 The decryption is the inverse of the method given. Note that the 3881 recipient obtains the shared secret by calculating 3883 S = rV = rvG, where (r,R) is the recipient's key pair. 3885 Consistent with Section 5.13{FIXME}, "Sym. Encrypted Integrity 3886 Protected Data Packet (Tag 18)", a Modification Detection Code (MDC) 3887 MUST be used anytime the symmetric key is protected by ECDH. 3889 14. {13} Notes on Algorithms 3891 14.1. {13.1} PKCS#1 Encoding in OpenPGP 3893 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 3894 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 3895 has changed in the past. To avoid potential confusion and 3896 interoperability problems, we are including local copies in this 3897 document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447 3898 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 3899 Nonetheless, we believe that there is value in having a self- 3900 contained document that avoids problems in the future with needed 3901 changes in the conventions. 3903 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE 3904 Input: 3906 k = the length in octets of the key modulus 3908 M = message to be encoded, an octet string of length mLen, where mLen 3909 \<= k - 11 3911 Output: 3913 EM = encoded message, an octet string of length k 3915 Error: "message too long" 3917 1. Length checking: If mLen > k - 11, output "message too long" 3918 and stop. 3920 2. Generate an octet string PS of length k - mLen - 3 consisting 3921 of pseudo-randomly generated nonzero octets. The length of PS 3922 will be at least eight octets. 3924 3. Concatenate PS, the message M, and other padding to form an 3925 encoded message EM of length k octets as 3927 EM = 0x00 || 0x02 || PS || 0x00 || M. 3929 4. Output EM. 3931 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE 3933 Input: 3935 EM = encoded message, an octet string 3937 Output: 3939 M = message, an octet string 3941 Error: "decryption error" 3943 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 3944 into an octet string PS consisting of nonzero octets and a message M 3945 as follows 3947 EM = 0x00 || 0x02 || PS || 0x00 || M. 3949 If the first octet of EM does not have hexadecimal value 0x00, if the 3950 second octet of EM does not have hexadecimal value 0x02, if there is 3951 no octet with hexadecimal value 0x00 to separate PS from M, or if the 3952 length of PS is less than 8 octets, output "decryption error" and 3953 stop. See also the security note in Section 14 regarding differences 3954 in reporting between a decryption error and a padding error. 3956 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 3958 This encoding method is deterministic and only has an encoding 3959 operation. 3961 Option: 3963 Hash - a hash function in which hLen denotes the length in octets 3964 of the hash function output 3966 Input: 3968 M = message to be encoded 3970 emLen = intended length in octets of the encoded message, at least 3971 tLen + 11, where tLen is the octet length of the DER encoding 3972 T of a certain value computed during the encoding operation 3974 Output: 3976 EM = encoded message, an octet string of length emLen 3978 Errors: "message too long"; 3979 "intended encoded message length too short" 3981 Steps: 3983 1. Apply the hash function to the message M to produce a hash 3984 value H: 3986 H = Hash(M). 3988 If the hash function outputs "message too long," output 3989 "message too long" and stop. 3991 2. Using the list in Section 5.2.2, produce an ASN.1 DER value 3992 for the hash function used. Let T be the full hash prefix 3993 from Section 5.2.2, and let tLen be the length in octets of T. 3995 3. If emLen < tLen + 11, output "intended encoded message length 3996 too short" and stop. 3998 4. Generate an octet string PS consisting of emLen - tLen - 3 3999 octets with hexadecimal value 0xFF. The length of PS will be 4000 at least 8 octets. 4002 5. Concatenate PS, the hash prefix T, and other padding to form 4003 the encoded message EM as 4005 EM = 0x00 || 0x01 || PS || 0x00 || T. 4007 6. Output EM. 4009 14.2. {13.2} Symmetric Algorithm Preferences 4011 The symmetric algorithm preference is an ordered list of algorithms 4012 that the keyholder accepts. Since it is found on a self-signature, 4013 it is possible that a keyholder may have multiple, different 4014 preferences. For example, Alice may have TripleDES only specified 4015 for "alice@work.com" but CAST5, Blowfish, and TripleDES specified for 4016 "alice@home.org". Note that it is also possible for preferences to 4017 be in a subkey's binding signature. 4019 Since TripleDES is the MUST-implement algorithm, if it is not 4020 explicitly in the list, it is tacitly at the end. However, it is 4021 good form to place it there explicitly. Note also that if an 4022 implementation does not implement the preference, then it is 4023 implicitly a TripleDES-only implementation. 4025 An implementation MUST NOT use a symmetric algorithm that is not in 4026 the recipient's preference list. When encrypting to more than one 4027 recipient, the implementation finds a suitable algorithm by taking 4028 the intersection of the preferences of the recipients. Note that the 4029 MUST-implement algorithm, TripleDES, ensures that the intersection is 4030 not null. The implementation may use any mechanism to pick an 4031 algorithm in the intersection. 4033 If an implementation can decrypt a message that a keyholder doesn't 4034 have in their preferences, the implementation SHOULD decrypt the 4035 message anyway, but MUST warn the keyholder that the protocol has 4036 been violated. For example, suppose that Alice, above, has software 4037 that implements all algorithms in this specification. Nonetheless, 4038 she prefers subsets for work or home. If she is sent a message 4039 encrypted with IDEA, which is not in her preferences, the software 4040 warns her that someone sent her an IDEA-encrypted message, but it 4041 would ideally decrypt it anyway. 4043 14.3. {13.3} Other Algorithm Preferences 4045 Other algorithm preferences work similarly to the symmetric algorithm 4046 preference, in that they specify which algorithms the keyholder 4047 accepts. There are two interesting cases that other comments need to 4048 be made about, though, the compression preferences and the hash 4049 preferences. 4051 14.3.1. {13.3.1} Compression Preferences 4053 Compression has been an integral part of PGP since its first days. 4054 OpenPGP and all previous versions of PGP have offered compression. 4055 In this specification, the default is for messages to be compressed, 4056 although an implementation is not required to do so. Consequently, 4057 the compression preference gives a way for a keyholder to request 4058 that messages not be compressed, presumably because they are using a 4059 minimal implementation that does not include compression. 4060 Additionally, this gives a keyholder a way to state that it can 4061 support alternate algorithms. 4063 Like the algorithm preferences, an implementation MUST NOT use an 4064 algorithm that is not in the preference vector. If the preferences 4065 are not present, then they are assumed to be [ZIP(1), 4066 Uncompressed(0)]. 4068 Additionally, an implementation MUST implement this preference to the 4069 degree of recognizing when to send an uncompressed message. A robust 4070 implementation would satisfy this requirement by looking at the 4071 recipient's preference and acting accordingly. A minimal 4072 implementation can satisfy this requirement by never generating a 4073 compressed message, since all implementations can handle messages 4074 that have not been compressed. 4076 14.3.2. {13.3.2} Hash Algorithm Preferences 4078 Typically, the choice of a hash algorithm is something the signer 4079 does, rather than the verifier, because a signer rarely knows who is 4080 going to be verifying the signature. This preference, though, allows 4081 a protocol based upon digital signatures ease in negotiation. 4083 Thus, if Alice is authenticating herself to Bob with a signature, it 4084 makes sense for her to use a hash algorithm that Bob's software uses. 4085 This preference allows Bob to state in his key which algorithms Alice 4086 may use. 4088 Since SHA1 is the MUST-implement hash algorithm, if it is not 4089 explicitly in the list, it is tacitly at the end. However, it is 4090 good form to place it there explicitly. 4092 14.4. {13.4} Plaintext 4094 Algorithm 0, "plaintext", may only be used to denote secret keys that 4095 are stored in the clear. Implementations MUST NOT use plaintext in 4096 Symmetrically Encrypted Data packets; they must use Literal Data 4097 packets to encode unencrypted or literal data. 4099 14.5. {13.5} RSA 4101 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4102 keys. These types are deprecated. The "key flags" subpacket in a 4103 signature is a much better way to express the same idea, and 4104 generalizes it to all algorithms. An implementation SHOULD NOT 4105 create such a key, but MAY interpret it. 4107 An implementation SHOULD NOT implement RSA keys of size less than 4108 1024 bits. 4110 14.6. {13.6} DSA 4112 An implementation SHOULD NOT implement DSA keys of size less than 4113 1024 bits. It MUST NOT implement a DSA key with a q size of less 4114 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4115 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4116 (DSS) [FIPS186] specifies that DSA be used in one of the following 4117 ways: 4119 o 1024-bit key, 160-bit q, SHA-1, SHA-224, SHA-256, SHA-384, or 4120 SHA-512 hash 4122 o 2048-bit key, 224-bit q, SHA-224, SHA-256, SHA-384, or SHA-512 4123 hash 4125 o 2048-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash 4127 o 3072-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash 4129 The above key and q size pairs were chosen to best balance the 4130 strength of the key with the strength of the hash. Implementations 4131 SHOULD use one of the above key and q size pairs when generating DSA 4132 keys. If DSS compliance is desired, one of the specified SHA hashes 4133 must be used as well. [FIPS186] is the ultimate authority on DSS, 4134 and should be consulted for all questions of DSS compliance. 4136 Note that earlier versions of this standard only allowed a 160-bit q 4137 with no truncation allowed, so earlier implementations may not be 4138 able to handle signatures with a different q size or a truncated 4139 hash. 4141 14.7. {13.7} Elgamal 4143 An implementation SHOULD NOT implement Elgamal keys of size less than 4144 1024 bits. 4146 14.8. EdDSA 4148 Although the EdDSA algorithm allows arbitrary data as input, its use 4149 with OpenPGP requires that a digest of the message is used as input 4150 (pre-hashed). See section XXXXX, "Computing Signatures" for details. 4151 Truncation of the resulting digest is never applied; the resulting 4152 digest value is used verbatim as input to the EdDSA algorithm. 4154 14.9. {13.8} Reserved Algorithm Numbers 4156 A number of algorithm IDs have been reserved for algorithms that 4157 would be useful to use in an OpenPGP implementation, yet there are 4158 issues that prevent an implementer from actually implementing the 4159 algorithm. These are marked in Section 9.1, "Public-Key Algorithms", 4160 as "reserved for". 4162 The reserved public-key algorithm X9.42 (21) does not have the 4163 necessary parameters, parameter order, or semantics defined. 4165 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4166 with a public-key identifier of 20. These are no longer permitted. 4167 An implementation MUST NOT generate such keys. An implementation 4168 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4170 14.10. {13.9} OpenPGP CFB Mode 4172 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4173 mode (CFB mode). This section describes the procedure it uses in 4174 detail. This mode is what is used for Symmetrically Encrypted Data 4175 Packets; the mechanism used for encrypting secret-key material is 4176 similar, and is described in the sections above. 4178 In the description below, the value BS is the block size in octets of 4179 the cipher. Most ciphers have a block size of 8 octets. The AES and 4180 Twofish have a block size of 16 octets. Also note that the 4181 description below assumes that the IV and CFB arrays start with an 4182 index of 1 (unlike the C language, which assumes arrays start with a 4183 zero index). 4185 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4186 prefixes the plaintext with BS+2 octets of random data, such that 4187 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4188 resynchronization after encrypting those BS+2 octets. 4190 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4191 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4192 octets 9 and 10. For an algorithm with a block size of 16 octets 4193 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4194 octets 15 and 16. Those extra two octets are an easy check for a 4195 correct key. 4197 Step by step, here is the procedure: 4199 1. The feedback register (FR) is set to the IV, which is all zeros. 4201 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4202 encryption of an all-zero value. 4204 3. FRE is xored with the first BS octets of random data prefixed to 4205 the plaintext to produce C[1] through C[BS], the first BS octets 4206 of ciphertext. 4208 4. FR is loaded with C[1] through C[BS]. 4210 5. FR is encrypted to produce FRE, the encryption of the first BS 4211 octets of ciphertext. 4213 6. The left two octets of FRE get xored with the next two octets of 4214 data that were prefixed to the plaintext. This produces C[BS+1] 4215 and C[BS+2], the next two octets of ciphertext. 4217 7. (The resynchronization step) FR is loaded with C[3] through 4218 C[BS+2]. 4220 8. FRE is xored with the first BS octets of the given plaintext, 4221 now that we have finished encrypting the BS+2 octets of prefixed 4222 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4223 octets of ciphertext. 4225 9. FR is encrypted to produce FRE. 4227 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4228 for an 8-octet block). 4230 11. FR is encrypted to produce FRE. 4232 12. FRE is xored with the next BS octets of plaintext, to produce 4233 the next BS octets of ciphertext. These are loaded into FR, and 4234 the process is repeated until the plaintext is used up. 4236 14.11. {13.10} Private or Experimental Parameters 4238 S2K specifiers, Signature subpacket types, user attribute types, 4239 image format types, and algorithms described in Section 9 all reserve 4240 the range 100 to 110 for private and experimental use. Packet types 4241 reserve the range 60 to 63 for private and experimental use. These 4242 are intentionally managed with the PRIVATE USE method, as described 4243 in [RFC2434]. 4245 However, implementations need to be careful with these and promote 4246 them to full IANA-managed parameters when they grow beyond the 4247 original, limited system. 4249 14.12. {13.11} Extension of the MDC System 4251 As described in the non-normative explanation in Section 5.13, the 4252 MDC system is uniquely unparameterized in OpenPGP. This was an 4253 intentional decision to avoid cross-grade attacks. If the MDC system 4254 is extended to a stronger hash function, care must be taken to avoid 4255 downgrade and cross-grade attacks. 4257 One simple way to do this is to create new packets for a new MDC. 4258 For example, instead of the MDC system using packets 18 and 19, a new 4259 MDC could use 20 and 21. This has obvious drawbacks (it uses two 4260 packet numbers for each new hash function in a space that is limited 4261 to a maximum of 60). 4263 Another simple way to extend the MDC system is to create new versions 4264 of packet 18, and reflect this in packet 19. For example, suppose 4265 that V2 of packet 18 implicitly used SHA-256. This would require 4266 packet 19 to have a length of 32 octets. The change in the version 4267 in packet 18 and the size of packet 19 prevent a downgrade attack. 4269 There are two drawbacks to this latter approach. The first is that 4270 using the version number of a packet to carry algorithm information 4271 is not tidy from a protocol-design standpoint. It is possible that 4272 there might be several versions of the MDC system in common use, but 4273 this untidiness would reflect untidiness in cryptographic consensus 4274 about hash function security. The second is that different versions 4275 of packet 19 would have to have unique sizes. If there were two 4276 versions each with 256-bit hashes, they could not both have 32-octet 4277 packet 19s without admitting the chance of a cross-grade attack. 4279 Yet another, complex approach to extend the MDC system would be a 4280 hybrid of the two above -- create a new pair of MDC packets that are 4281 fully parameterized, and yet protected from downgrade and cross- 4282 grade. 4284 Any change to the MDC system MUST be done through the IETF CONSENSUS 4285 method, as described in [RFC2434]. 4287 14.13. {13.12} Meta-Considerations for Expansion 4289 If OpenPGP is extended in a way that is not backwards-compatible, 4290 meaning that old implementations will not gracefully handle their 4291 absence of a new feature, the extension proposal can be declared in 4292 the key holder's self-signature as part of the Features signature 4293 subpacket. 4295 We cannot state definitively what extensions will not be upwards- 4296 compatible, but typically new algorithms are upwards-compatible, 4297 whereas new packets are not. 4299 If an extension proposal does not update the Features system, it 4300 SHOULD include an explanation of why this is unnecessary. If the 4301 proposal contains neither an extension to the Features system nor an 4302 explanation of why such an extension is unnecessary, the proposal 4303 SHOULD be rejected. 4305 15. {14} Security Considerations 4307 o As with any technology involving cryptography, you should check 4308 the current literature to determine if any algorithms used here 4309 have been found to be vulnerable to attack. 4311 o This specification uses Public-Key Cryptography technologies. It 4312 is assumed that the private key portion of a public-private key 4313 pair is controlled and secured by the proper party or parties. 4315 o Certain operations in this specification involve the use of random 4316 numbers. An appropriate entropy source should be used to generate 4317 these numbers (see [RFC4086]). 4319 o The MD5 hash algorithm has been found to have weaknesses, with 4320 collisions found in a number of cases. MD5 is deprecated for use 4321 in OpenPGP. Implementations MUST NOT generate new signatures 4322 using MD5 as a hash function. They MAY continue to consider old 4323 signatures that used MD5 as valid. 4325 o SHA-224 and SHA-384 require the same work as SHA-256 and SHA-512, 4326 respectively. In general, there are few reasons to use them 4327 outside of DSS compatibility. You need a situation where one 4328 needs more security than smaller hashes, but does not want to have 4329 the full 256-bit or 512-bit data length. 4331 o Many security protocol designers think that it is a bad idea to 4332 use a single key for both privacy (encryption) and integrity 4333 (signatures). In fact, this was one of the motivating forces 4334 behind the V4 key format with separate signature and encryption 4335 keys. If you as an implementer promote dual-use keys, you should 4336 at least be aware of this controversy. 4338 o The DSA algorithm will work with any hash, but is sensitive to the 4339 quality of the hash algorithm. Verifiers should be aware that 4340 even if the signer used a strong hash, an attacker could have 4341 modified the signature to use a weak one. Only signatures using 4342 acceptably strong hash algorithms should be accepted as valid. 4344 o As OpenPGP combines many different asymmetric, symmetric, and hash 4345 algorithms, each with different measures of strength, care should 4346 be taken that the weakest element of an OpenPGP message is still 4347 sufficiently strong for the purpose at hand. While consensus 4348 about the strength of a given algorithm may evolve, NIST Special 4349 Publication 800-57 [SP800-57] recommends the following list of 4350 equivalent strengths: 4352 Asymmetric | Hash | Symmetric 4353 key size | size | key size 4354 ------------+--------+----------- 4355 1024 160 80 4356 2048 224 112 4357 3072 256 128 4358 7680 384 192 4359 15360 512 256 4361 o There is a somewhat-related potential security problem in 4362 signatures. If an attacker can find a message that hashes to the 4363 same hash with a different algorithm, a bogus signature structure 4364 can be constructed that evaluates correctly. 4366 For example, suppose Alice DSA signs message M using hash 4367 algorithm H. Suppose that Mallet finds a message M' that has the 4368 same hash value as M with H'. Mallet can then construct a 4369 signature block that verifies as Alice's signature of M' with H'. 4370 However, this would also constitute a weakness in either H or H' 4371 or both. Should this ever occur, a revision will have to be made 4372 to this document to revise the allowed hash algorithms. 4374 o If you are building an authentication system, the recipient may 4375 specify a preferred signing algorithm. However, the signer would 4376 be foolish to use a weak algorithm simply because the recipient 4377 requests it. 4379 o Some of the encryption algorithms mentioned in this document have 4380 been analyzed less than others. For example, although CAST5 is 4381 presently considered strong, it has been analyzed less than 4382 TripleDES. Other algorithms may have other controversies 4383 surrounding them. 4385 o In late summer 2002, Jallad, Katz, and Schneier published an 4386 interesting attack on the OpenPGP protocol and some of its 4387 implementations [JKS02]. In this attack, the attacker modifies a 4388 message and sends it to a user who then returns the erroneously 4389 decrypted message to the attacker. The attacker is thus using the 4390 user as a random oracle, and can often decrypt the message. 4392 Compressing data can ameliorate this attack. The incorrectly 4393 decrypted data nearly always decompresses in ways that defeat the 4394 attack. However, this is not a rigorous fix, and leaves open some 4395 small vulnerabilities. For example, if an implementation does not 4396 compress a message before encryption (perhaps because it knows it 4397 was already compressed), then that message is vulnerable. Because 4398 of this happenstance -- that modification attacks can be thwarted 4399 by decompression errors -- an implementation SHOULD treat a 4400 decompression error as a security problem, not merely a data 4401 problem. 4403 This attack can be defeated by the use of Modification Detection, 4404 provided that the implementation does not let the user naively 4405 return the data to the attacker. An implementation MUST treat an 4406 MDC failure as a security problem, not merely a data problem. 4408 In either case, the implementation MAY allow the user access to 4409 the erroneous data, but MUST warn the user as to potential 4410 security problems should that data be returned to the sender. 4412 While this attack is somewhat obscure, requiring a special set of 4413 circumstances to create it, it is nonetheless quite serious as it 4414 permits someone to trick a user to decrypt a message. 4415 Consequently, it is important that: 4417 1. Implementers treat MDC errors and decompression failures as 4418 security problems. 4420 2. Implementers implement Modification Detection with all due 4421 speed and encourage its spread. 4423 3. Users migrate to implementations that support Modification 4424 Detection with all due speed. 4426 o PKCS#1 has been found to be vulnerable to attacks in which a 4427 system that reports errors in padding differently from errors in 4428 decryption becomes a random oracle that can leak the private key 4429 in mere millions of queries. Implementations must be aware of 4430 this attack and prevent it from happening. The simplest solution 4431 is to report a single error code for all variants of decryption 4432 errors so as not to leak information to an attacker. 4434 o Some technologies mentioned here may be subject to government 4435 control in some countries. 4437 o In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4438 released a paper describing a way that the "quick check" in 4439 OpenPGP CFB mode can be used with a random oracle to decrypt two 4440 octets of every cipher block [MZ05]. They recommend as prevention 4441 not using the quick check at all. 4443 Many implementers have taken this advice to heart for any data 4444 that is symmetrically encrypted and for which the session key is 4445 public-key encrypted. In this case, the quick check is not needed 4446 as the public-key encryption of the session key should guarantee 4447 that it is the right session key. In other cases, the 4448 implementation should use the quick check with care. 4450 On the one hand, there is a danger to using it if there is a 4451 random oracle that can leak information to an attacker. In 4452 plainer language, there is a danger to using the quick check if 4453 timing information about the check can be exposed to an attacker, 4454 particularly via an automated service that allows rapidly repeated 4455 queries. 4457 On the other hand, it is inconvenient to the user to be informed 4458 that they typed in the wrong passphrase only after a petabyte of 4459 data is decrypted. There are many cases in cryptographic 4460 engineering where the implementer must use care and wisdom, and 4461 this is one. 4463 o Refer to [FIPS186-3], B.4.1, for the method to generate a 4464 uniformly distributed ECC private key. 4466 o The curves proposed in this document correspond to the symmetric 4467 key sizes 128 bits, 192 bits, and 256 bits, as described in the 4468 table below. This allows a compliant application to offer 4469 balanced public key security, which is compatible with the 4470 symmetric key strength for each AES algorithm defined here. 4472 The following table defines the hash and the symmetric encryption 4473 algorithm that SHOULD be used with a given curve for ECDSA or 4474 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 4475 be used for a given ECC curve. However, note that the increase in 4476 the strength of the hash algorithm or the symmetric key algorithm 4477 may not increase the overall security offered by the given ECC 4478 key. 4480 Curve name | ECC | RSA | Hash size | Symmetric 4481 | strength | strength, | | key size 4482 | | informative | | 4483 -----------+----------+-------------+-----------+----------- 4484 NIST P-256 256 3072 256 128 4485 NIST P-384 384 7680 384 192 4486 NIST P-521 521 15360 512 256 4488 Requirement levels indicated elsewhere in this document lead to 4489 the following combinations of algorithms in the OpenPGP profile: 4490 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 4491 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 4492 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 4493 combinations. 4495 Consistent with the table above, the following table defines the 4496 KDF hash algorithm and the AES KEK encryption algorithm that 4497 SHOULD be used with a given curve for ECDH. A stronger KDF hash 4498 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 4500 Curve name | Recommended KDF | Recommended KEK 4501 | hash algorithm | encryption algorithm 4502 -----------+-----------------+----------------------- 4503 NIST P-256 SHA2-256 AES-128 4504 NIST P-384 SHA2-384 AES-192 4505 NIST P-521 SHA2-512 AES-256 4507 This document explicitly discourages the use of algorithms other 4508 than AES as a KEK algorithm because backward compatibility of the 4509 ECDH format is not a concern. The KEK algorithm is only used 4510 within the scope of a Public-Key Encrypted Session Key Packet, 4511 which represents an ECDH key recipient of a message. Compare this 4512 with the algorithm used for the session key of the message, which 4513 MAY be different from a KEK algorithm. 4515 Compliant applications SHOULD implement, advertise through key 4516 preferences, and use the strongest algorithms specified in this 4517 document. 4519 Note that the symmetric algorithm preference list may make it 4520 impossible to use the balanced strength of symmetric key 4521 algorithms for a corresponding public key. For example, the 4522 presence of the symmetric key algorithm IDs and their order in the 4523 key preference list affects the algorithm choices available to the 4524 encoding side, which in turn may make the adherence to the table 4525 above infeasible. Therefore, compliance with this specification 4526 is a concern throughout the life of the key, starting immediately 4527 after the key generation when the key preferences are first added 4528 to a key. It is generally advisable to position a symmetric 4529 algorithm ID of strength matching the public key at the head of 4530 the key preference list. 4532 Encryption to multiple recipients often results in an unordered 4533 intersection subset. For example, if the first recipient's set is 4534 {A, B} and the second's is {B, A}, the intersection is an 4535 unordered set of two algorithms, A and B. In this case, a 4536 compliant application SHOULD choose the stronger encryption 4537 algorithm. 4539 Resource constraints, such as limited computational power, is a 4540 likely reason why an application might prefer to use the weakest 4541 algorithm. On the other side of the spectrum are applications 4542 that can implement every algorithm defined in this document. Most 4543 applications are expected to fall into either of two categories. 4544 A compliant application in the second, or strongest, category 4545 SHOULD prefer AES-256 to AES-192. 4547 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 4548 method. 4550 MDC MUST be used when a symmetric encryption key is protected by 4551 ECDH. None of the ECC methods described in this document are 4552 allowed with deprecated V3 keys. A compliant application MUST 4553 only use iterated and salted S2K to protect private keys, as 4554 defined in Section 3.7.1.3{FIXME}, "Iterated and Salted S2K". 4556 Side channel attacks are a concern when a compliant application's 4557 use of the OpenPGP format can be modeled by a decryption or 4558 signing oracle model, for example, when an application is a 4559 network service performing decryption to unauthenticated remote 4560 users. ECC scalar multiplication operations used in ECDSA and 4561 ECDH are vulnerable to side channel attacks. Countermeasures can 4562 often be taken at the higher protocol level, such as limiting the 4563 number of allowed failures or time-blinding of the operations 4564 associated with each network interface. Mitigations at the scalar 4565 multiplication level seek to eliminate any measurable distinction 4566 between the ECC point addition and doubling operations. 4568 o Although technically possible, the EdDSA algorithm MUST NOT be 4569 used with a digest algorithms weaker than SHA-256. 4571 OpenPGP was designed with security in mind, with many smart, 4572 intelligent people spending a lot of time thinking about the 4573 ramifications of their decisions. Removing the requirement for self- 4574 certifying User ID (and User Attribute) packets on a key means that 4575 someone could surreptitiously add an unwanted ID to a key and sign 4576 it. If enough "trusted" people sign that surreptitious identity then 4577 other people might believe it. The attack could wind up sending 4578 encrypted mail destined for alice to some other target, bob, because 4579 someone added "alice" to bob's key without bob's consent. 4581 In the case of device certificates the device itself does not have 4582 any consent. It is given an identity by the device manufacturer and 4583 the manufacturer can insert that ID on the device certificate, 4584 signing it with the manufacturer's key. If another people wants to 4585 label the device by another name, they can do so. There is no harm 4586 in multiple IDs, because the verification is all done based on who 4587 has signed those IDs. 4589 When a key can self-sign, it is still suggested to self-certify IDs, 4590 even if it no longer required by this modification to OpenPGP. This 4591 at least signals to recipients of keys that yes, the owner of this 4592 key asserts that this identity belongs to herself. Note, however, 4593 that mallet could still assert that he is 'alice' and could even 4594 self-certify that. So the attack is not truly different. Moreover, 4595 in the case of device certificates, it's more the manufacturer than 4596 the device that wants to assert an identity (even if the device could 4597 self-certify). 4599 There is no signaling whether a key is using this looser-requirement 4600 key format. An attacker could therefore just remove the self- 4601 signature off a published key. However one would hope that wide 4602 publication would result in another copy still having that signature 4603 and it being returned quickly. However, the lack of signaling also 4604 means that a user with an application following RFC 4880 directly 4605 would see a key following this specification as "broken" and may not 4606 accept it. 4608 On a different note, including the "geo" notation could leak 4609 information about where a signer is located. However it is just an 4610 assertion (albeit a signed assertion) so there is no verifiable truth 4611 to the location information released. Similarly, all the rest of the 4612 signature notations are pure assertions, so they should be taken with 4613 the trustworthiness of the signer. 4615 Combining the User ID with the User Attribute means that an ID and 4616 image would not be separable. For a person this is probably not 4617 good, but for a device it's unlikely the image will change so it 4618 makes sense to combine the ID and image into a single signed packet 4619 with a single signature. 4621 16. Compatibility Profiles 4623 16.1. OpenPGP ECC Profile 4625 A compliant application MUST implement NIST curve P-256, MAY 4626 implement NIST curve P-384, and SHOULD implement NIST curve P-521, as 4627 defined in Section 11. A compliant application MUST implement 4628 SHA2-256 and SHOULD implement SHA2-384 and SHA2-512. A compliant 4629 application MUST implement AES-128 and SHOULD implement AES-256. 4631 A compliant application SHOULD follow Section 13{FIXME} regarding the 4632 choice of the following algorithms for each curve: 4634 o the KDF hash algorithm, 4636 o the KEK algorithm, 4637 o the message digest algorithm and the hash algorithm used in the 4638 key certifications, 4640 o the symmetric algorithm used for message encryption. 4642 It is recommended that the chosen symmetric algorithm for message 4643 encryption be no less secure than the KEK algorithm. 4645 16.2. Suite-B Profile 4647 A subset of algorithms allowed by this document can be used to 4648 achieve [SuiteB] compatibility. The references to [SuiteB] in this 4649 document are informative. This document is primarily concerned with 4650 format specification, leaving additional security restrictions 4651 unspecified, such as matching the assigned security level of 4652 information to authorized recipients or interoperability concerns 4653 arising from fewer allowed algorithms in [SuiteB] than allowed by 4654 this document. 4656 16.3. Security Strength at 192 Bits 4658 To achieve the security strength of 192 bits, [SuiteB] requires NIST 4659 curve P-384, AES-256, and SHA2-384. The symmetric algorithm 4660 restriction means that the algorithm of KEK used for key wrapping in 4661 Section 8 and an OpenPGP session key used for message encryption must 4662 be AES-256. The hash algorithm restriction means that the hash 4663 algorithms of KDF and the OpenPGP message digest calculation must be 4664 SHA-384. 4666 16.4. Security Strength at 128 Bits 4668 The set of algorithms in Section 12.2.1{FIXME} is extended to allow 4669 NIST curve P-256, AES-128, and SHA2-256. 4671 17. {15} Implementation Nits 4673 This section is a collection of comments to help an implementer, 4674 particularly with an eye to backward compatibility. Previous 4675 implementations of PGP are not OpenPGP compliant. Often the 4676 differences are small, but small differences are frequently more 4677 vexing than large differences. Thus, this is a non-comprehensive 4678 list of potential problems and gotchas for a developer who is trying 4679 to be backward-compatible. 4681 o The IDEA algorithm is patented, and yet it is required for PGP 2.x 4682 interoperability. It is also the de-facto preferred algorithm for 4683 a V3 key with a V3 self-signature (or no self- signature). 4685 o When exporting a private key, PGP 2.x generates the header "BEGIN 4686 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 4687 All previous versions ignore the implied data type, and look 4688 directly at the packet data type. 4690 o PGP 2.0 through 2.5 generated V2 Public-Key packets. These are 4691 identical to the deprecated V3 keys except for the version number. 4692 An implementation MUST NOT generate them and may accept or reject 4693 them as it sees fit. Some older PGP versions generated V2 PKESK 4694 packets (Tag 1) as well. An implementation may accept or reject 4695 V2 PKESK packets as it sees fit, and MUST NOT generate them. 4697 o PGP 2.6.x will not accept key-material packets with versions 4698 greater than 3. 4700 o There are many ways possible for two keys to have the same key 4701 material, but different fingerprints (and thus Key IDs). Perhaps 4702 the most interesting is an RSA key that has been "upgraded" to V4 4703 format, but since a V4 fingerprint is constructed by hashing the 4704 key creation time along with other things, two V4 keys created at 4705 different times, yet with the same key material will have 4706 different fingerprints. 4708 o If an implementation is using zlib to interoperate with PGP 2.x, 4709 then the "windowBits" parameter should be set to -13. 4711 o The 0x19 back signatures were not required for signing subkeys 4712 until relatively recently. Consequently, there may be keys in the 4713 wild that do not have these back signatures. Implementing 4714 software may handle these keys as it sees fit. 4716 o OpenPGP does not put limits on the size of public keys. However, 4717 larger keys are not necessarily better keys. Larger keys take 4718 more computation time to use, and this can quickly become 4719 impractical. Different OpenPGP implementations may also use 4720 different upper bounds for public key sizes, and so care should be 4721 taken when choosing sizes to maintain interoperability. As of 4722 2007 most implementations have an upper bound of 4096 bits. 4724 o ASCII armor is an optional feature of OpenPGP. The OpenPGP 4725 working group strives for a minimal set of mandatory-to-implement 4726 features, and since there could be useful implementations that 4727 only use binary object formats, this is not a "MUST" feature for 4728 an implementation. For example, an implementation that is using 4729 OpenPGP as a mechanism for file signatures may find ASCII armor 4730 unnecessary. OpenPGP permits an implementation to declare what 4731 features it does and does not support, but ASCII armor is not one 4732 of these. Since most implementations allow binary and armored 4733 objects to be used indiscriminately, an implementation that does 4734 not implement ASCII armor may find itself with compatibility 4735 issues with general-purpose implementations. Moreover, 4736 implementations of OpenPGP-MIME [RFC3156] already have a 4737 requirement for ASCII armor so those implementations will 4738 necessarily have support. 4740 18. References 4742 18.1. Normative References 4744 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 4745 November 2001, 4746 . 4749 [BLOWFISH] 4750 Schneier, B., "Description of a New Variable-Length Key, 4751 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 4752 Cambridge Security Workshop Proceedings, Springer-Verlag, 4753 1994, pp191-204, December 1993, 4754 . 4756 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 4757 . 4759 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 4760 Scheme Based on Discrete Logarithms,", IEEE Transactions 4761 on Information Theory v. IT-31, n. 4, 1985, pp. 469-472, . 4763 [FIPS180] NIST, "Secure Hash Signature Standard (SHS) (FIPS PUB 4764 180-2)", . 4767 [FIPS180-3] 4768 National Institute of Standards and Technology, U.S. 4769 Department of Commerce, "Secure Hash Standard (SHS), FIPS 4770 180-3", October 2008. 4772 [FIPS186] NIST, "Digital Signature Standard (DSS) (FIPS PUB 186-2)", 4773 . 4776 [FIPS186-3] 4777 National Institute of Standards and Technology, U.S. 4778 Department of Commerce, "Digital Signature Standard, FIPS 4779 186-3", June 2009. 4781 [HAC] Menezes, A., Oorschot, P., and S. Vanstone, "Handbook of 4782 Applied Cryptography", 1996. 4784 [I-D.irtf-cfrg-eddsa] 4785 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 4786 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-02 4787 (work in progress), January 2016. 4789 [IDEA] Lai, X., "On the design and security of block ciphers", 4790 ETH Series in Information Processing, J.L. Massey 4791 (editor), Vol. 1, Hartung-Gorre Verlag Konstanz, 4792 Technische Hochschule (Zurich), 1992. 4794 [ISO10646] 4795 International Organization for Standardization, 4796 "Information Technology - Universal Multiple-octet coded 4797 Character Set (UCS) - Part 1: Architecture and Basic 4798 Multilingual Plane", ISO Standard 10646-1, May 1993. 4800 [JFIF] Eric Hamilton, C-Cube Microsystems, Milpitas, CA, "JPEG 4801 File Interchange Format (Version 1.02).", September 1996. 4803 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 4804 Cryptography Standard", March 1999. 4806 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format 4807 Specification version 3.3", RFC 1950, May 1996. 4809 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 4810 version 1.3", RFC 1951, May 1996. 4812 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4813 Extensions (MIME) Part One: Format of Internet Message 4814 Bodies", RFC 2045, November 1996. 4816 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4817 Requirement Levels", BCP 14, RFC 2119, March 1997. 4819 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 4820 May 1997. 4822 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an 4823 IANA Considerations Section in RFCs", BCP 26, RFC 2434, 4824 October 1998. 4826 [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, April 4827 2001. 4829 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 4830 "MIME Security with OpenPGP", RFC 3156, August 2001. 4832 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4833 (AES) Key Wrap Algorithm", RFC 3394, September 2002. 4835 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4836 Standards (PKCS) #1: RSA Cryptography Specifications 4837 Version 2.1", RFC 3447, February 2003. 4839 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 4840 10646", STD 63, RFC 3629, November 2003. 4842 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 4843 the Camellia Encryption Algorithm", RFC 3713, April 2004. 4845 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 4846 Requirements for Security", BCP 106, RFC 4086, June 2005. 4848 [RFC5870] Mayrhofer, A. and C. Spanring, "A Uniform Resource 4849 Identifier for Geographic Locations ('geo' URI)", RFC 4850 5870, DOI 10.17487/RFC5870, June 2010, 4851 . 4853 [SCHNEIER] 4854 Schneier, B., "Applied Cryptography Second Edition: 4855 protocols, algorithms, and source code in C", 1996. 4857 [SP800-56A] 4858 Barker, E., Johnson, D., and M. Smid, "Recommendation for 4859 Pair-Wise Key Establishment Schemes Using Discrete 4860 Logarithm Cryptography", NIST Special Publication 800-56A 4861 Revision 1, March 2007. 4863 [SuiteB] National Security Agency, "NSA Suite B Cryptography", 4864 March 2010, 4865 . 4867 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 4868 C., and N. Ferguson, "The Twofish Encryption Algorithm", 4869 1999. 4871 18.2. Informative References 4873 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 4874 Chapter VI. Elliptic Curves, ISBN: 0-387-96576-9, 4875 Springer-Verlag", 1997. 4877 [RFC1423] Balenson, D., "Privacy Enhancement for Internet Electronic 4878 Mail: Part III: Algorithms, Modes, and Identifiers", RFC 4879 1423, February 1993. 4881 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 4882 Exchange Formats", RFC 1991, August 1996. 4884 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 4885 "OpenPGP Message Format", RFC 2440, November 1998. 4887 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 4888 Curve Cryptography Algorithms", RFC 6090, February 2011. 4890 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 4891 Elliptic Curve Cryptography", September 2000. 4893 [SP800-57] 4894 NIST, "Recommendation on Key Management", NIST Special 4895 Publication 800-57, March 2007, 4896 . 4899 Appendix A. Test vectors 4901 To help implementing this specification a non-normative example for 4902 the EdDSA algorithm is given. 4904 A.1. Sample EdDSA key 4906 The secret key used for this example is: 4908 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 4910 Note that this is the raw secret key used as input to the EdDSA 4911 signing operation. The key was created on 2014-08-19 14:28:27 and 4912 thus the fingerprint of the OpenPGP key is: 4914 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 4916 The algorithm specific input parameters without the MPI length 4917 headers are: 4919 oid: 2b06010401da470f01 4921 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 4923 The entire public key packet is thus: 4925 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 4926 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 4927 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 4928 43 ee 3b 24 06 4930 A.2. Sample EdDSA signature 4932 The signature is created using the sample key over the input data 4933 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 4934 function is: 4936 m: 4f70656e504750040016080006050255f95f9504ff0000000c 4938 Using the SHA-256 hash algorithm yields the digest: 4940 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 4942 Which is fed into the EdDSA signature function and yields this 4943 signature: 4945 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 4947 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 4949 The entire signature packet is thus: 4951 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 4952 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 4953 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 4954 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 4955 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 4956 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 4958 Appendix B. ECC Point compression flag bytes 4960 This specification introduces the new flag byte 0x40 to indicate the 4961 point compression format. The value has been chosen so that the high 4962 bit is not cleared and thus to avoid accidental sign extension. Two 4963 other values might also be interesting for other ECC specifications: 4965 Flag Description 4966 ---- ----------- 4967 0x04 Standard flag for uncompressed format 4968 0x40 Native point format of the curve follows 4969 0x41 Only X coordinate follows. 4970 0x42 Only Y coordinate follows. 4972 Appendix C. Changes since RFC-4880 4974 o Applied errata 2270, 2271, 2242, 3298. 4976 o Added Camellia cipher from RFC 5581. 4978 o Incorporated RFC 6637 (ECC for OpenPGP) 4980 o Added draft-atkins-openpgp-device-certificates 4982 o Added draft-koch-eddsa-for-openpgp-04 4984 o Added Issuer Fingerprint signature subpacket. 4986 { Informational rfcs: [RFC1423] } 4988 Appendix D. The principal authors of RFC-4880 are as follows: 4990 Jon Callas 4991 EMail: jon@callas.org 4993 Lutz Donnerhacke 4994 EMail: lutz@iks-jena.de 4996 Hal Finney 4998 David Shaw 4999 EMail: dshaw@jabberwocky.com 5001 Rodney Thayer 5002 EMail: rodney@canola-jones.com 5004 Author's Address 5006 Werner Koch 5008 Email: wk@gnupg.org