idnits 2.17.1 draft-ietf-openpgp-rfc4880bis-02.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 (June 30, 2017) is 2492 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 383 -- Looks like a reference, but probably isn't: '1' on line 4332 -- Looks like a reference, but probably isn't: '2' on line 383 -- Looks like a reference, but probably isn't: '3' on line 4341 == Missing Reference: 'REGEX' is mentioned on line 1459, but not defined == Missing Reference: 'Optional' is mentioned on line 2131, but not defined == Missing Reference: 'TBD1' is mentioned on line 2500, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3686, but not defined == Missing Reference: 'BLEICHENBACHER' is mentioned on line 4292, but not defined == Missing Reference: 'BS' is mentioned on line 4332, but not defined == Missing Reference: 'JKS02' is mentioned on line 4511, but not defined == Missing Reference: 'MZ05' is mentioned on line 4564, 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. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS202' -- 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 ** Downref: Normative reference to an Informational RFC: RFC 5639 -- 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: 12 errors (**), 0 flaws (~~), 10 warnings (==), 26 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) June 30, 2017 5 Intended status: Standards Track 6 Expires: January 1, 2018 8 OpenPGP Message Format 9 draft-ietf-openpgp-rfc4880bis-02 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 January 1, 2018. 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 . . . . . . . . . . . . . . . . . . . . 8 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 . . . . . . . . . . . . . . . . . . 9 75 3.2. {3.2} Multiprecision Integers . . . . . . . . . . . . . . 9 76 3.3. {3.3} Key IDs . . . . . . . . . . . . . . . . . . . . . . 9 77 3.4. {3.4} Text . . . . . . . . . . . . . . . . . . . . . . . 10 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 . . . . . . . . . . . . . . . . . . 14 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 . . . . . . . . . . 46 103 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 47 104 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 47 105 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 48 106 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 48 107 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 48 108 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 49 109 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 49 110 5.7. {5.6} Compressed Data Packet (Tag 8) . . . . . . . . . . 50 111 5.8. {5.7} Symmetrically Encrypted Data Packet (Tag 9) . . . . 51 112 5.9. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) . 52 113 5.10. {5.9} Literal Data Packet (Tag 11) . . . . . . . . . . . 52 114 5.11. {5.10} Trust Packet (Tag 12) . . . . . . . . . . . . . . 53 115 5.12. {5.11} User ID Packet (Tag 13) . . . . . . . . . . . . . 53 116 5.13. {5.12} User Attribute Packet (Tag 17) . . . . . . . . . . 53 117 5.13.1. {5.12.1} The Image Attribute Subpacket . . . . . . . 54 118 5.13.2. User ID Attribute Subpacket . . . . . . . . . . . . 55 119 5.14. {5.13} Sym. Encrypted Integrity Protected Data Packet 120 (Tag 18) . . . . . . . . . . . . . . . . . . . . . . . . 55 121 5.15. {5.14} Modification Detection Code Packet (Tag 19) . . . 58 122 6. {6} Radix-64 Conversions . . . . . . . . . . . . . . . . . . 59 123 6.1. {6.1} An Implementation of the CRC-24 in "C" . . . . . . 60 124 6.2. {6.2} Forming ASCII Armor . . . . . . . . . . . . . . . . 60 125 6.3. {6.3} Encoding Binary in Radix-64 . . . . . . . . . . . . 63 126 6.4. {6.4} Decoding Radix-64 . . . . . . . . . . . . . . . . . 64 127 6.5. {6.5} Examples of Radix-64 . . . . . . . . . . . . . . . 64 128 6.6. {6.6} Example of an ASCII Armored Message . . . . . . . . 65 129 7. {7} Cleartext Signature Framework . . . . . . . . . . . . . . 65 130 7.1. {7.1} Dash-Escaped Text . . . . . . . . . . . . . . . . . 66 131 8. {8} Regular Expressions . . . . . . . . . . . . . . . . . . . 67 132 9. {9} Constants . . . . . . . . . . . . . . . . . . . . . . . . 67 133 9.1. {9.1} Public-Key Algorithms . . . . . . . . . . . . . . . 68 134 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 68 135 9.3. {9.2} Symmetric-Key Algorithms . . . . . . . . . . . . . 69 136 9.4. {9.3} Compression Algorithms . . . . . . . . . . . . . . 70 137 9.5. {9.4} Hash Algorithms . . . . . . . . . . . . . . . . . . 70 138 10. {10} IANA Considerations . . . . . . . . . . . . . . . . . . 71 139 10.1. {10.1} New String-to-Key Specifier Types . . . . . . . . 71 140 10.2. {10.2} New Packets . . . . . . . . . . . . . . . . . . . 71 141 10.2.1. {10.2.1} User Attribute Types . . . . . . . . . . . 72 142 10.2.2. {10.2.1.1} Image Format Subpacket Types . . . . . . 72 143 10.2.3. {10.2.2} New Signature Subpackets . . . . . . . . . 72 144 10.2.4. {10.2.3} New Packet Versions . . . . . . . . . . . . 75 145 10.3. {10.3} New Algorithms . . . . . . . . . . . . . . . . . 75 146 10.3.1. {10.3.1} Public-Key Algorithms . . . . . . . . . . . 76 147 10.3.2. {10.3.2} Symmetric-Key Algorithms . . . . . . . . . 76 148 10.3.3. {10.3.3} Hash Algorithms . . . . . . . . . . . . . . 76 149 10.3.4. {10.3.4} Compression Algorithms . . . . . . . . . . 77 150 11. {11} Packet Composition . . . . . . . . . . . . . . . . . . . 77 151 11.1. {11.1} Transferable Public Keys . . . . . . . . . . . . 77 152 11.2. {11.2} Transferable Secret Keys . . . . . . . . . . . . 79 153 11.3. {11.3} OpenPGP Messages . . . . . . . . . . . . . . . . 79 154 11.4. {11.4} Detached Signatures . . . . . . . . . . . . . . . 80 155 12. {12} Enhanced Key Formats . . . . . . . . . . . . . . . . . . 80 156 12.1. {12.1} Key Structures . . . . . . . . . . . . . . . . . 80 157 12.2. {12.2} Key IDs and Fingerprints . . . . . . . . . . . . 82 158 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 83 159 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 84 160 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 84 161 13.3. EdDSA Point Format . . . . . . . . . . . . . . . . . . . 84 162 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 85 163 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 85 164 14. {13} Notes on Algorithms . . . . . . . . . . . . . . . . . . 88 165 14.1. {13.1} PKCS#1 Encoding in OpenPGP . . . . . . . . . . . 88 166 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . 88 167 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE . . . . . . . . . . . 89 168 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . 90 169 14.2. {13.2} Symmetric Algorithm Preferences . . . . . . . . . 91 170 14.3. {13.3} Other Algorithm Preferences . . . . . . . . . . . 92 171 14.3.1. {13.3.1} Compression Preferences . . . . . . . . . . 92 172 14.3.2. {13.3.2} Hash Algorithm Preferences . . . . . . . . 93 173 14.4. {13.4} Plaintext . . . . . . . . . . . . . . . . . . . . 93 174 14.5. {13.5} RSA . . . . . . . . . . . . . . . . . . . . . . . 93 175 14.6. {13.6} DSA . . . . . . . . . . . . . . . . . . . . . . . 93 176 14.7. {13.7} Elgamal . . . . . . . . . . . . . . . . . . . . . 94 177 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 94 178 14.9. {13.8} Reserved Algorithm Numbers . . . . . . . . . . . 94 179 14.10. {13.9} OpenPGP CFB Mode . . . . . . . . . . . . . . . . 95 180 14.11. {13.10} Private or Experimental Parameters . . . . . . . 96 181 14.12. {13.11} Extension of the MDC System . . . . . . . . . . 96 182 14.13. {13.12} Meta-Considerations for Expansion . . . . . . . 97 183 15. {14} Security Considerations . . . . . . . . . . . . . . . . 97 184 16. Compatibility Profiles . . . . . . . . . . . . . . . . . . . 104 185 16.1. OpenPGP ECC Profile . . . . . . . . . . . . . . . . . . 104 186 16.2. Suite-B Profile . . . . . . . . . . . . . . . . . . . . 105 187 16.3. Security Strength at 192 Bits . . . . . . . . . . . . . 105 188 16.4. Security Strength at 128 Bits . . . . . . . . . . . . . 105 189 17. {15} Implementation Nits . . . . . . . . . . . . . . . . . . 105 190 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 107 191 18.1. Normative References . . . . . . . . . . . . . . . . . . 107 192 18.2. Informative References . . . . . . . . . . . . . . . . . 110 193 Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 110 194 A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 110 195 A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 111 196 Appendix B. ECC Point compression flag bytes . . . . . . . . . . 111 197 Appendix C. Changes since RFC-4880 . . . . . . . . . . . . . . . 112 198 Appendix D. The principal authors of RFC-4880 are as follows: . 112 199 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 113 201 1. {1} Introduction 203 { This is work in progress to update OpenPGP. Editorial notes are 204 enclosed in curly braces. The section numbers from RFC4880 are also 205 indicated in curly braces. } 207 This document provides information on the message-exchange packet 208 formats used by OpenPGP to provide encryption, decryption, signing, 209 and key management functions. It is a revision of RFC 2440, "OpenPGP 210 Message Format", which itself replaces RFC 1991, "PGP Message 211 Exchange Formats" [RFC1991] [RFC2440]. 213 This document obsoletes: RFC 5581 (Camellia cipher) and RFC 6637 (ECC 214 for OpenPGP) 216 1.1. {1.1} Terms 218 o OpenPGP - This is a term for security software that uses PGP 5.x 219 as a basis, formalized in RFC 2440 and this document. 221 o PGP - Pretty Good Privacy. PGP is a family of software systems 222 developed by Philip R. Zimmermann from which OpenPGP is based. 224 o PGP 2.6.x - This version of PGP has many variants, hence the term 225 PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic 226 transforms. An informational RFC, RFC 1991, was written 227 describing this version of PGP. 229 o PGP 5.x - This version of PGP is formerly known as "PGP 3" in the 230 community and also in the predecessor of this document, RFC 1991. 231 It has new formats and corrects a number of problems in the PGP 232 2.6.x design. It is referred to here as PGP 5.x because that 233 software was the first release of the "PGP 3" code base. 235 o GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 236 implementation that avoids all encumbered algorithms. 237 Consequently, early versions of GnuPG did not include RSA public 238 keys. GnuPG may or may not have (depending on version) support 239 for IDEA or other encumbered algorithms. 241 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 242 Corporation and are used with permission. The term "OpenPGP" refers 243 to the protocol described in this and related documents. 245 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 246 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 247 document are to be interpreted as described in [RFC2119]. 249 The key words "PRIVATE USE", "HIERARCHICAL ALLOCATION", "FIRST COME 250 FIRST SERVED", "EXPERT REVIEW", "SPECIFICATION REQUIRED", "IESG 251 APPROVAL", "IETF CONSENSUS", and "STANDARDS ACTION" that appear in 252 this document when used to describe namespace allocation are to be 253 interpreted as described in [RFC2434]. 255 2. {2} General functions 257 OpenPGP provides data integrity services for messages and data files 258 by using these core technologies: 260 o digital signatures 262 o encryption 264 o compression 266 o Radix-64 conversion 268 In addition, OpenPGP provides key management and certificate 269 services, but many of these are beyond the scope of this document. 271 2.1. {2.1} Confidentiality via Encryption 273 OpenPGP combines symmetric-key encryption and public-key encryption 274 to provide confidentiality. When made confidential, first the object 275 is encrypted using a symmetric encryption algorithm. Each symmetric 276 key is used only once, for a single object. A new "session key" is 277 generated as a random number for each object (sometimes referred to 278 as a session). Since it is used only once, the session key is bound 279 to the message and transmitted with it. To protect the key, it is 280 encrypted with the receiver's public key. The sequence is as 281 follows: 283 1. The sender creates a message. 285 2. The sending OpenPGP generates a random number to be used as a 286 session key for this message only. 288 3. The session key is encrypted using each recipient's public key. 289 These "encrypted session keys" start the message. 291 4. The sending OpenPGP encrypts the message using the session key, 292 which forms the remainder of the message. Note that the message 293 is also usually compressed. 295 5. The receiving OpenPGP decrypts the session key using the 296 recipient's private key. 298 6. The receiving OpenPGP decrypts the message using the session key. 299 If the message was compressed, it will be decompressed. 301 With symmetric-key encryption, an object may be encrypted with a 302 symmetric key derived from a passphrase (or other shared secret), or 303 a two-stage mechanism similar to the public-key method described 304 above in which a session key is itself encrypted with a symmetric 305 algorithm keyed from a shared secret. 307 Both digital signature and confidentiality services may be applied to 308 the same message. First, a signature is generated for the message 309 and attached to the message. Then the message plus signature is 310 encrypted using a symmetric session key. Finally, the session key is 311 encrypted using public-key encryption and prefixed to the encrypted 312 block. 314 2.2. {2.2} Authentication via Digital Signature 316 The digital signature uses a hash code or message digest algorithm, 317 and a public-key signature algorithm. The sequence is as follows: 319 1. The sender creates a message. 321 2. The sending software generates a hash code of the message. 323 3. The sending software generates a signature from the hash code 324 using the sender's private key. 326 4. The binary signature is attached to the message. 328 5. The receiving software keeps a copy of the message signature. 330 6. The receiving software generates a new hash code for the received 331 message and verifies it using the message's signature. If the 332 verification is successful, the message is accepted as authentic. 334 2.3. {2.3} Compression 336 OpenPGP implementations SHOULD compress the message after applying 337 the signature but before encryption. 339 If an implementation does not implement compression, its authors 340 should be aware that most OpenPGP messages in the world are 341 compressed. Thus, it may even be wise for a space-constrained 342 implementation to implement decompression, but not compression. 344 Furthermore, compression has the added side effect that some types of 345 attacks can be thwarted by the fact that slightly altered, compressed 346 data rarely uncompresses without severe errors. This is hardly 347 rigorous, but it is operationally useful. These attacks can be 348 rigorously prevented by implementing and using Modification Detection 349 Codes as described in sections following. 351 2.4. {2.4} Conversion to Radix-64 353 OpenPGP's underlying native representation for encrypted messages, 354 signature certificates, and keys is a stream of arbitrary octets. 355 Some systems only permit the use of blocks consisting of seven-bit, 356 printable text. For transporting OpenPGP's native raw binary octets 357 through channels that are not safe to raw binary data, a printable 358 encoding of these binary octets is needed. OpenPGP provides the 359 service of converting the raw 8-bit binary octet stream to a stream 360 of printable ASCII characters, called Radix-64 encoding or ASCII 361 Armor. 363 Implementations SHOULD provide Radix-64 conversions. 365 2.5. {2.5} Signature-Only Applications 367 OpenPGP is designed for applications that use both encryption and 368 signatures, but there are a number of problems that are solved by a 369 signature-only implementation. Although this specification requires 370 both encryption and signatures, it is reasonable for there to be 371 subset implementations that are non-conformant only in that they omit 372 encryption. 374 3. {3} Data Element Formats 376 This section describes the data elements used by OpenPGP. 378 3.1. {3.1} Scalar Numbers 380 Scalar numbers are unsigned and are always stored in big-endian 381 format. Using n[k] to refer to the kth octet being interpreted, the 382 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 383 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 384 n[3]). 386 3.2. {3.2} Multiprecision Integers 388 Multiprecision integers (also called MPIs) are unsigned integers used 389 to hold large integers such as the ones used in cryptographic 390 calculations. 392 An MPI consists of two pieces: a two-octet scalar that is the length 393 of the MPI in bits followed by a string of octets that contain the 394 actual integer. 396 These octets form a big-endian number; a big-endian number can be 397 made into an MPI by prefixing it with the appropriate length. 399 Examples: 401 (all numbers are in hexadecimal) 403 The string of octets [00 01 01] forms an MPI with the value 1. The 404 string [00 09 01 FF] forms an MPI with the value of 511. 406 Additional rules: 408 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 410 The length field of an MPI describes the length starting from its 411 most significant non-zero bit. Thus, the MPI [00 02 01] is not 412 formed correctly. It should be [00 01 01]. 414 Unused bits of an MPI MUST be zero. 416 Also note that when an MPI is encrypted, the length refers to the 417 plaintext MPI. It may be ill-formed in its ciphertext. 419 3.3. {3.3} Key IDs 421 A Key ID is an eight-octet scalar that identifies a key. 422 Implementations SHOULD NOT assume that Key IDs are unique. The 423 section "Enhanced Key Formats" below describes how Key IDs are 424 formed. 426 3.4. {3.4} Text 428 Unless otherwise specified, the character set for text is the UTF-8 429 [RFC3629] encoding of Unicode [ISO10646]. 431 3.5. {3.5} Time Fields 433 A time field is an unsigned four-octet number containing the number 434 of seconds elapsed since midnight, 1 January 1970 UTC. 436 3.6. {3.6} Keyrings 438 A keyring is a collection of one or more keys in a file or database. 439 Traditionally, a keyring is simply a sequential list of keys, but may 440 be any suitable database. It is beyond the scope of this standard to 441 discuss the details of keyrings or other databases. 443 3.7. {3.7} String-to-Key (S2K) Specifiers 445 String-to-key (S2K) specifiers are used to convert passphrase strings 446 into symmetric-key encryption/decryption keys. They are used in two 447 places, currently: to encrypt the secret part of private keys in the 448 private keyring, and to convert passphrases to encryption keys for 449 symmetrically encrypted messages. 451 3.7.1. {3.7.1} String-to-Key (S2K) Specifier Types 453 There are three types of S2K specifiers currently supported, and some 454 reserved values: 456 +-------------+---------------------------+ 457 | ID | S2K Type | 458 +-------------+---------------------------+ 459 | 0 | Simple S2K | 460 | 1 | Salted S2K | 461 | 2 | Reserved value | 462 | 3 | Iterated and Salted S2K | 463 | 100 to 110 | Private/Experimental S2K | 464 +-------------+---------------------------+ 466 These are described in the following Sections. 468 3.7.1.1. {3.7.1.1} Simple S2K 470 This directly hashes the string to produce the key data. See below 471 for how this hashing is done. 473 Octet 0: 0x00 474 Octet 1: hash algorithm 476 Simple S2K hashes the passphrase to produce the session key. The 477 manner in which this is done depends on the size of the session key 478 (which will depend on the cipher used) and the size of the hash 479 algorithm's output. If the hash size is greater than the session key 480 size, the high-order (leftmost) octets of the hash are used as the 481 key. 483 If the hash size is less than the key size, multiple instances of the 484 hash context are created -- enough to produce the required key data. 485 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 486 is to say, the first instance has no preloading, the second gets 487 preloaded with 1 octet of zero, the third is preloaded with two 488 octets of zeros, and so forth). 490 As the data is hashed, it is given independently to each hash 491 context. Since the contexts have been initialized differently, they 492 will each produce different hash output. Once the passphrase is 493 hashed, the output data from the multiple hashes is concatenated, 494 first hash leftmost, to produce the key data, with any excess octets 495 on the right discarded. 497 3.7.1.2. {3.7.1.2} Salted S2K 499 This includes a "salt" value in the S2K specifier -- some arbitrary 500 data -- that gets hashed along with the passphrase string, to help 501 prevent dictionary attacks. 503 Octet 0: 0x01 504 Octet 1: hash algorithm 505 Octets 2-9: 8-octet salt value 507 Salted S2K is exactly like Simple S2K, except that the input to the 508 hash function(s) consists of the 8 octets of salt from the S2K 509 specifier, followed by the passphrase. 511 3.7.1.3. {3.7.1.3} Iterated and Salted S2K 513 This includes both a salt and an octet count. The salt is combined 514 with the passphrase and the resulting value is hashed repeatedly. 515 This further increases the amount of work an attacker must do to try 516 dictionary attacks. 518 Octet 0: 0x03 519 Octet 1: hash algorithm 520 Octets 2-9: 8-octet salt value 521 Octet 10: count, a one-octet, coded value 523 The count is coded into a one-octet number using the following 524 formula: 526 #define EXPBIAS 6 527 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 529 The above formula is in C, where "Int32" is a type for a 32-bit 530 integer, and the variable "c" is the coded count, Octet 10. 532 Iterated-Salted S2K hashes the passphrase and salt data multiple 533 times. The total number of octets to be hashed is specified in the 534 encoded count in the S2K specifier. Note that the resulting count 535 value is an octet count of how many octets will be hashed, not an 536 iteration count. 538 Initially, one or more hash contexts are set up as with the other S2K 539 algorithms, depending on how many octets of key data are needed. 540 Then the salt, followed by the passphrase data, is repeatedly hashed 541 until the number of octets specified by the octet count has been 542 hashed. The one exception is that if the octet count is less than 543 the size of the salt plus passphrase, the full salt plus passphrase 544 will be hashed even though that is greater than the octet count. 545 After the hashing is done, the data is unloaded from the hash 546 context(s) as with the other S2K algorithms. 548 3.7.2. {3.7.2} String-to-Key Usage 550 Implementations SHOULD use salted or iterated-and-salted S2K 551 specifiers, as simple S2K specifiers are more vulnerable to 552 dictionary attacks. 554 3.7.2.1. {3.7.2.1} Secret-Key Encryption 556 An S2K specifier can be stored in the secret keyring to specify how 557 to convert the passphrase to a key that unlocks the secret data. 558 Older versions of PGP just stored a cipher algorithm octet preceding 559 the secret data or a zero to indicate that the secret data was 560 unencrypted. The MD5 hash function was always used to convert the 561 passphrase to a key for the specified cipher algorithm. 563 For compatibility, when an S2K specifier is used, the special value 564 254 or 255 is stored in the position where the hash algorithm octet 565 would have been in the old data structure. This is then followed 566 immediately by a one-octet algorithm identifier, and then by the S2K 567 specifier as encoded above. 569 Therefore, preceding the secret data there will be one of these 570 possibilities: 572 0: secret data is unencrypted (no passphrase) 573 255 or 254: followed by algorithm octet and S2K specifier 574 Cipher alg: use Simple S2K algorithm using MD5 hash 576 This last possibility, the cipher algorithm number with an implicit 577 use of MD5 and IDEA, is provided for backward compatibility; it MAY 578 be understood, but SHOULD NOT be generated, and is deprecated. 580 These are followed by an Initial Vector of the same length as the 581 block size of the cipher for the decryption of the secret values, if 582 they are encrypted, and then the secret-key values themselves. 584 3.7.2.2. {3.7.2.2} Symmetric-Key Message Encryption 586 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 587 at the front of a message. This is used to allow S2K specifiers to 588 be used for the passphrase conversion or to create messages with a 589 mix of symmetric-key ESKs and public-key ESKs. This allows a message 590 to be decrypted either with a passphrase or a public-key pair. 592 PGP 2.X always used IDEA with Simple string-to-key conversion when 593 encrypting a message with a symmetric algorithm. This is deprecated, 594 but MAY be used for backward-compatibility. 596 4. {4} Packet Syntax 598 This section describes the packets used by OpenPGP. 600 4.1. {4.1} Overview 602 An OpenPGP message is constructed from a number of records that are 603 traditionally called packets. A packet is a chunk of data that has a 604 tag specifying its meaning. An OpenPGP message, keyring, 605 certificate, and so forth consists of a number of packets. Some of 606 those packets may contain other OpenPGP packets (for example, a 607 compressed data packet, when uncompressed, contains OpenPGP packets). 609 Each packet consists of a packet header, followed by the packet body. 610 The packet header is of variable length. 612 4.2. {4.2} Packet Headers 614 The first octet of the packet header is called the "Packet Tag". It 615 determines the format of the header and denotes the packet contents. 616 The remainder of the packet header is the length of the packet. 618 Note that the most significant bit is the leftmost bit, called bit 7. 619 A mask for this bit is 0x80 in hexadecimal. 621 +---------------+ 622 PTag |7 6 5 4 3 2 1 0| 623 +---------------+ 624 Bit 7 -- Always one 625 Bit 6 -- New packet format if set 627 PGP 2.6.x only uses old format packets. Thus, software that 628 interoperates with those versions of PGP must only use old format 629 packets. If interoperability is not an issue, the new packet format 630 is RECOMMENDED. Note that old format packets have four bits of 631 packet tags, and new format packets have six; some features cannot be 632 used and still be backward-compatible. 634 Also note that packets with a tag greater than or equal to 16 MUST 635 use new format packets. The old format packets can only express tags 636 less than or equal to 15. 638 Old format packets contain: 640 Bits 5-2 -- packet tag 641 Bits 1-0 -- length-type 643 New format packets contain: 645 Bits 5-0 -- packet tag 647 4.2.1. {4.2.1} Old Format Packet Lengths 649 The meaning of the length-type in old format packets is: 651 0 The packet has a one-octet length. The header is 2 octets long. 653 1 The packet has a two-octet length. The header is 3 octets long. 655 2 The packet has a four-octet length. The header is 5 octets long. 657 3 The packet is of indeterminate length. The header is 1 octet 658 long, and the implementation must determine how long the packet 659 is. If the packet is in a file, this means that the packet 660 extends until the end of the file. In general, an implementation 661 SHOULD NOT use indeterminate-length packets except where the end 662 of the data will be clear from the context, and even then it is 663 better to use a definite length, or a new format header. The new 664 format headers described below have a mechanism for precisely 665 encoding data of indeterminate length. 667 4.2.2. {4.2.2} New Format Packet Lengths 669 New format packets have four possible ways of encoding length: 671 1. A one-octet Body Length header encodes packet lengths of up to 672 191 octets. 674 2. A two-octet Body Length header encodes packet lengths of 192 to 675 8383 octets. 677 3. A five-octet Body Length header encodes packet lengths of up to 678 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 679 encodes a four-octet scalar number.) 681 4. When the length of the packet body is not known in advance by the 682 issuer, Partial Body Length headers encode a packet of 683 indeterminate length, effectively making it a stream. 685 4.2.2.1. {4.2.2.1} One-Octet Lengths 687 A one-octet Body Length header encodes a length of 0 to 191 octets. 688 This type of length header is recognized because the one octet value 689 is less than 192. The body length is equal to: 691 bodyLen = 1st_octet; 693 4.2.2.2. {4.2.2.2} Two-Octet Lengths 695 A two-octet Body Length header encodes a length of 192 to 8383 696 octets. It is recognized because its first octet is in the range 192 697 to 223. The body length is equal to: 699 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 701 4.2.2.3. {4.2.2.3} Five-Octet Lengths 703 A five-octet Body Length header consists of a single octet holding 704 the value 255, followed by a four-octet scalar. The body length is 705 equal to: 707 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 708 (4th_octet << 8) | 5th_octet 710 This basic set of one, two, and five-octet lengths is also used 711 internally to some packets. 713 4.2.2.4. {4.2.2.4} Partial Body Lengths 715 A Partial Body Length header is one octet long and encodes the length 716 of only part of the data packet. This length is a power of 2, from 1 717 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 718 octet value that is greater than or equal to 224, and less than 255. 719 The Partial Body Length is equal to: 721 partialBodyLen = 1 << (1st_octet & 0x1F); 723 Each Partial Body Length header is followed by a portion of the 724 packet body data. The Partial Body Length header specifies this 725 portion's length. Another length header (one octet, two-octet, five- 726 octet, or partial) follows that portion. The last length header in 727 the packet MUST NOT be a Partial Body Length header. Partial Body 728 Length headers may only be used for the non-final parts of the 729 packet. 731 Note also that the last Body Length header can be a zero-length 732 header. 734 An implementation MAY use Partial Body Lengths for data packets, be 735 they literal, compressed, or encrypted. The first partial length 736 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 737 used for any other packet types. 739 4.2.3. {4.2.3} Packet Length Examples 741 These examples show ways that new format packets might encode the 742 packet lengths. 744 A packet with length 100 may have its length encoded in one octet: 745 0x64. This is followed by 100 octets of data. 747 A packet with length 1723 may have its length encoded in two octets: 748 0xC5, 0xFB. This header is followed by the 1723 octets of data. 750 A packet with length 100000 may have its length encoded in five 751 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 753 It might also be encoded in the following octet stream: 0xEF, first 754 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 755 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 756 octets of data. This is just one possible encoding, and many 757 variations are possible on the size of the Partial Body Length 758 headers, as long as a regular Body Length header encodes the last 759 portion of the data. 761 Please note that in all of these explanations, the total length of 762 the packet is the length of the header(s) plus the length of the 763 body. 765 4.3. {4.3} Packet Tags 767 The packet tag denotes what type of packet the body holds. Note that 768 old format headers can only have tags less than 16, whereas new 769 format headers can have tags as great as 63. The defined tags (in 770 decimal) are as follows: 772 +-----------+-----------------------------------------------------+ 773 | Tag | Packet Type | 774 +-----------+-----------------------------------------------------+ 775 | 0 | Reserved - a packet tag MUST NOT have this value | 776 | 1 | Public-Key Encrypted Session Key Packet | 777 | 2 | Signature Packet | 778 | 3 | Symmetric-Key Encrypted Session Key Packet | 779 | 4 | One-Pass Signature Packet | 780 | 5 | Secret-Key Packet | 781 | 6 | Public-Key Packet | 782 | 7 | Secret-Subkey Packet | 783 | 8 | Compressed Data Packet | 784 | 9 | Symmetrically Encrypted Data Packet | 785 | 10 | Marker Packet | 786 | 11 | Literal Data Packet | 787 | 12 | Trust Packet | 788 | 13 | User ID Packet | 789 | 14 | Public-Subkey Packet | 790 | 17 | User Attribute Packet | 791 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 792 | 19 | Modification Detection Code Packet | 793 | 60 to 63 | Private or Experimental Values | 794 +-----------+-----------------------------------------------------+ 796 5. {5} Packet Types 798 5.1. {5.1} Public-Key Encrypted Session Key Packets (Tag 1) 800 A Public-Key Encrypted Session Key packet holds the session key used 801 to encrypt a message. Zero or more Public-Key Encrypted Session Key 802 packets and/or Symmetric-Key Encrypted Session Key packets may 803 precede a Symmetrically Encrypted Data Packet, which holds an 804 encrypted message. The message is encrypted with the session key, 805 and the session key is itself encrypted and stored in the Encrypted 806 Session Key packet(s). The Symmetrically Encrypted Data Packet is 807 preceded by one Public-Key Encrypted Session Key packet for each 808 OpenPGP key to which the message is encrypted. The recipient of the 809 message finds a session key that is encrypted to their public key, 810 decrypts the session key, and then uses the session key to decrypt 811 the message. 813 The body of this packet consists of: 815 o A one-octet number giving the version number of the packet type. 816 The currently defined value for packet version is 3. 818 o An eight-octet number that gives the Key ID of the public key to 819 which the session key is encrypted. If the session key is 820 encrypted to a subkey, then the Key ID of this subkey is used here 821 instead of the Key ID of the primary key. 823 o A one-octet number giving the public-key algorithm used. 825 o A string of octets that is the encrypted session key. This string 826 takes up the remainder of the packet, and its contents are 827 dependent on the public-key algorithm used. 829 Algorithm Specific Fields for RSA encryption: 831 * Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 833 Algorithm Specific Fields for Elgamal encryption: 835 * MPI of Elgamal (Diffie-Hellman) value g**k mod p. 837 * MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 839 Algorithm-Specific Fields for ECDH encryption: 841 * MPI of an EC point representing an ephemeral public key. 843 * a one-octet size, followed by a symmetric key encoded using the 844 method described in Section 13.5. 846 The value "m" in the above formulas is derived from the session key 847 as follows. First, the session key is prefixed with a one-octet 848 algorithm identifier that specifies the symmetric encryption 849 algorithm used to encrypt the following Symmetrically Encrypted Data 850 Packet. Then a two-octet checksum is appended, which is equal to the 851 sum of the preceding session key octets, not including the algorithm 852 identifier, modulo 65536. This value is then encoded as described in 853 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 854 form the "m" value used in the formulas above. See Section 13.1 of 855 this document for notes on OpenPGP's use of PKCS#1. 857 Note that when an implementation forms several PKESKs with one 858 session key, forming a message that can be decrypted by several keys, 859 the implementation MUST make a new PKCS#1 encoding for each key. 861 An implementation MAY accept or use a Key ID of zero as a "wild card" 862 or "speculative" Key ID. In this case, the receiving implementation 863 would try all available private keys, checking for a valid decrypted 864 session key. This format helps reduce traffic analysis of messages. 866 5.2. {5.2} Signature Packet (Tag 2) 868 A Signature packet describes a binding between some public key and 869 some data. The most common signatures are a signature of a file or a 870 block of text, and a signature that is a certification of a User ID. 872 Two versions of Signature packets are defined. Version 3 provides 873 basic signature information, while version 4 provides an expandable 874 format with subpackets that can specify more information about the 875 signature. PGP 2.6.x only accepts version 3 signatures. 877 Implementations SHOULD accept V3 signatures. Implementations SHOULD 878 generate V4 signatures. 880 Note that if an implementation is creating an encrypted and signed 881 message that is encrypted to a V3 key, it is reasonable to create a 882 V3 signature. 884 5.2.1. {5.2.1} Signature Types 886 There are a number of possible meanings for a signature, which are 887 indicated in a signature type octet in any given signature. Please 888 note that the vagueness of these meanings is not a flaw, but a 889 feature of the system. Because OpenPGP places final authority for 890 validity upon the receiver of a signature, it may be that one 891 signer's casual act might be more rigorous than some other 892 authority's positive act. See Section 5.2.4, "Computing Signatures", 893 for detailed information on how to compute and verify signatures of 894 each type. 896 These meanings are as follows: 898 0x00 Signature of a binary document. This means the signer owns it, 899 created it, or certifies that it has not been modified. 901 0x01 Signature of a canonical text document. This means the signer 902 owns it, created it, or certifies that it has not been modified. 903 The signature is calculated over the text data with its line 904 endings converted to . 906 0x02 Standalone signature. This signature is a signature of only 907 its own subpacket contents. It is calculated identically to a 908 signature over a zero-length binary document. Note that it 909 doesn't make sense to have a V3 standalone signature. 911 0x10 Generic certification of a User ID and Public-Key packet. The 912 issuer of this certification does not make any particular 913 assertion as to how well the certifier has checked that the owner 914 of the key is in fact the person described by the User ID. 916 0x11 Persona certification of a User ID and Public-Key packet. The 917 issuer of this certification has not done any verification of the 918 claim that the owner of this key is the User ID specified. 920 0x12 Casual certification of a User ID and Public-Key packet. The 921 issuer of this certification has done some casual verification of 922 the claim of identity. 924 0x13 Positive certification of a User ID and Public-Key packet. The 925 issuer of this certification has done substantial verification of 926 the claim of identity. 928 Most OpenPGP implementations make their "key signatures" as 0x10 929 certifications. Some implementations can issue 0x11-0x13 930 certifications, but few differentiate between the types. 932 0x18 Subkey Binding Signature This signature is a statement by the 933 top-level signing key that indicates that it owns the subkey. 934 This signature is calculated directly on the primary key and 935 subkey, and not on any User ID or other packets. A signature that 936 binds a signing subkey MUST have an Embedded Signature subpacket 937 in this binding signature that contains a 0x19 signature made by 938 the signing subkey on the primary key and subkey. 940 0x19 Primary Key Binding Signature This signature is a statement by 941 a signing subkey, indicating that it is owned by the primary key 942 and subkey. This signature is calculated the same way as a 0x18 943 signature: directly on the primary key and subkey, and not on any 944 User ID or other packets. 946 0x1F Signature directly on a key This signature is calculated 947 directly on a key. It binds the information in the Signature 948 subpackets to the key, and is appropriate to be used for 949 subpackets that provide information about the key, such as the 950 Revocation Key subpacket. It is also appropriate for statements 951 that non-self certifiers want to make about the key itself, rather 952 than the binding between a key and a name. 954 0x20 Key revocation signature The signature is calculated directly 955 on the key being revoked. A revoked key is not to be used. Only 956 revocation signatures by the key being revoked, or by an 957 authorized revocation key, should be considered valid revocation 958 signatures. 960 0x28 Subkey revocation signature The signature is calculated 961 directly on the subkey being revoked. A revoked subkey is not to 962 be used. Only revocation signatures by the top-level signature 963 key that is bound to this subkey, or by an authorized revocation 964 key, should be considered valid revocation signatures. 966 0x30 Certification revocation signature This signature revokes an 967 earlier User ID certification signature (signature class 0x10 968 through 0x13) or direct-key signature (0x1F). It should be issued 969 by the same key that issued the revoked signature or an authorized 970 revocation key. The signature is computed over the same data as 971 the certificate that it revokes, and should have a later creation 972 date than that certificate. 974 0x40 Timestamp signature. This signature is only meaningful for the 975 timestamp contained in it. 977 0x50 Third-Party Confirmation signature. This signature is a 978 signature over some other OpenPGP Signature packet(s). It is 979 analogous to a notary seal on the signed data. A third-party 980 signature SHOULD include Signature Target subpacket(s) to give 981 easy identification. Note that we really do mean SHOULD. There 982 are plausible uses for this (such as a blind party that only sees 983 the signature, not the key or source document) that cannot include 984 a target subpacket. 986 5.2.2. {5.2.2} Version 3 Signature Packet Format 988 The body of a version 3 Signature Packet contains: 990 o One-octet version number (3). 992 o One-octet length of following hashed material. MUST be 5. 994 o One-octet signature type. 996 o Four-octet creation time. 998 o Eight-octet Key ID of signer. 1000 o One-octet public-key algorithm. 1002 o One-octet hash algorithm. 1004 o Two-octet field holding left 16 bits of signed hash value. 1006 o One or more multiprecision integers comprising the signature. 1007 This portion is algorithm specific, as described below. 1009 The concatenation of the data to be signed, the signature type, 1010 and creation time from the Signature packet (5 additional octets) 1011 is hashed. The resulting hash value is used in the signature 1012 algorithm. The high 16 bits (first two octets) of the hash are 1013 included in the Signature packet to provide a quick test to reject 1014 some invalid signatures. 1016 Algorithm-Specific Fields for RSA signatures: 1018 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1020 Algorithm-Specific Fields for DSA and ECDSA signatures: 1022 * MPI of DSA or ECDSA value r. 1024 * MPI of DSA or ECDSA value s. 1026 The signature calculation is based on a hash of the signed data, as 1027 described above. The details of the calculation are different for 1028 DSA signatures than for RSA signatures. 1030 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1031 type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This 1032 requires inserting the hash value as an octet string into an ASN.1 1033 structure. The object identifier for the type of hash being used is 1034 included in the structure. The hexadecimal representations for the 1035 currently defined hash algorithms are as follows: 1037 - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 1039 - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 1041 - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A 1043 - SHA2-224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04 1045 - SHA2-256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 1047 - SHA2-384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 1049 - SHA2-512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 1051 The ASN.1 Object Identifiers (OIDs) are as follows: 1053 - MD5: 1.2.840.113549.2.5 1055 - RIPEMD-160: 1.3.36.3.2.1 1057 - SHA-1: 1.3.14.3.2.26 1059 - SHA2-224: 2.16.840.1.101.3.4.2.4 1061 - SHA2-256: 2.16.840.1.101.3.4.2.1 1063 - SHA2-384: 2.16.840.1.101.3.4.2.2 1065 - SHA2-512: 2.16.840.1.101.3.4.2.3 1067 The full hash prefixes for these are as follows: 1069 - MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 1070 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 1071 0x04, 0x10 1073 - RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 1074 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 1076 - SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, 1077 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 1079 - SHA2-224: 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1080 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 1081 0x00, 0x04, 0x1C 1083 - SHA2-256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1084 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 1085 0x00, 0x04, 0x20 1087 - SHA2-384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1088 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 1089 0x00, 0x04, 0x30 1091 - SHA2-512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1092 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 1093 0x00, 0x04, 0x40 1095 DSA signatures MUST use hashes that are equal in size to the number 1096 of bits of q, the group generated by the DSA key's generator value. 1098 If the output size of the chosen hash is larger than the number of 1099 bits of q, the hash result is truncated to fit by taking the number 1100 of leftmost bits equal to the number of bits of q. This (possibly 1101 truncated) hash function result is treated as a number and used 1102 directly in the DSA signature algorithm. 1104 5.2.3. {5.2.3} Version 4 Signature Packet Format 1106 The body of a version 4 Signature packet contains: 1108 o One-octet version number (4). 1110 o One-octet signature type. 1112 o One-octet public-key algorithm. 1114 o One-octet hash algorithm. 1116 o Two-octet scalar octet count for following hashed subpacket data. 1117 Note that this is the length in octets of all of the hashed 1118 subpackets; a pointer incremented by this number will skip over 1119 the hashed subpackets. 1121 o Hashed subpacket data set (zero or more subpackets). 1123 o Two-octet scalar octet count for the following unhashed subpacket 1124 data. Note that this is the length in octets of all of the 1125 unhashed subpackets; a pointer incremented by this number will 1126 skip over the unhashed subpackets. 1128 o Unhashed subpacket data set (zero or more subpackets). 1130 o Two-octet field holding the left 16 bits of the signed hash value. 1132 o One or more multiprecision integers comprising the signature. 1133 This portion is algorithm specific: 1135 Algorithm-Specific Fields for RSA signatures: 1137 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1139 Algorithm-Specific Fields for DSA or ECDSA signatures: 1141 * MPI of DSA or ECDSA value r. 1143 * MPI of DSA or ECDSA value s. 1145 Algorithm-Specific Fields for EdDSA signatures: 1147 * MPI of EdDSA compressed value r. 1149 * MPI of EdDSA compressed value s. 1151 The compressed version of R and S for use with EdDSA is described in 1152 [I-D.irtf-cfrg-eddsa]. The version 3 signature format MUST NOT be 1153 used with EdDSA. 1155 The concatenation of the data being signed and the signature data 1156 from the version number through the hashed subpacket data (inclusive) 1157 is hashed. The resulting hash value is what is signed. The left 16 1158 bits of the hash are included in the Signature packet to provide a 1159 quick test to reject some invalid signatures. 1161 There are two fields consisting of Signature subpackets. The first 1162 field is hashed with the rest of the signature data, while the second 1163 is unhashed. The second set of subpackets is not cryptographically 1164 protected by the signature and should include only advisory 1165 information. 1167 The algorithms for converting the hash function result to a signature 1168 are described in a section below. 1170 5.2.3.1. {5.2.3.1} Signature Subpacket Specification 1172 A subpacket data set consists of zero or more Signature subpackets. 1173 In Signature packets, the subpacket data set is preceded by a two- 1174 octet scalar count of the length in octets of all the subpackets. A 1175 pointer incremented by this number will skip over the subpacket data 1176 set. 1178 Each subpacket consists of a subpacket header and a body. The header 1179 consists of: 1181 o the subpacket length (1, 2, or 5 octets), 1183 o the subpacket type (1 octet), 1185 and is followed by the subpacket-specific data. 1187 The length includes the type octet but not this length. Its format 1188 is similar to the "new" format packet header lengths, but cannot have 1189 Partial Body Lengths. That is: 1191 if the 1st octet < 192, then 1192 lengthOfLength = 1 1193 subpacketLen = 1st_octet 1195 if the 1st octet >= 192 and < 255, then 1196 lengthOfLength = 2 1197 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1199 if the 1st octet = 255, then 1200 lengthOfLength = 5 1201 subpacket length = [four-octet scalar starting at 2nd_octet] 1203 The value of the subpacket type octet may be: 1205 +-------------+-----------------------------------------+ 1206 | Type | Description | 1207 +-------------+-----------------------------------------+ 1208 | 0 | Reserved | 1209 | 1 | Reserved | 1210 | 2 | Signature Creation Time | 1211 | 3 | Signature Expiration Time | 1212 | 4 | Exportable Certification | 1213 | 5 | Trust Signature | 1214 | 6 | Regular Expression | 1215 | 7 | Revocable | 1216 | 8 | Reserved | 1217 | 9 | Key Expiration Time | 1218 | 10 | Placeholder for backward compatibility | 1219 | 11 | Preferred Symmetric Algorithms | 1220 | 12 | Revocation Key | 1221 | 13 to 15 | Reserved | 1222 | 16 | Issuer | 1223 | 17 to 19 | Reserved | 1224 | 20 | Notation Data | 1225 | 21 | Preferred Hash Algorithms | 1226 | 22 | Preferred Compression Algorithms | 1227 | 23 | Key Server Preferences | 1228 | 24 | Preferred Key Server | 1229 | 25 | Primary User ID | 1230 | 26 | Policy URI | 1231 | 27 | Key Flags | 1232 | 28 | Signer's User ID | 1233 | 29 | Reason for Revocation | 1234 | 30 | Features | 1235 | 31 | Signature Target | 1236 | 32 | Embedded Signature | 1237 | 33 | Issuer Fingerprint | 1238 | 100 to 110 | Private or experimental | 1239 +-------------+-----------------------------------------+ 1241 An implementation SHOULD ignore any subpacket of a type that it does 1242 not recognize. 1244 Bit 7 of the subpacket type is the "critical" bit. If set, it 1245 denotes that the subpacket is one that is critical for the evaluator 1246 of the signature to recognize. If a subpacket is encountered that is 1247 marked critical but is unknown to the evaluating software, the 1248 evaluator SHOULD consider the signature to be in error. 1250 An evaluator may "recognize" a subpacket, but not implement it. The 1251 purpose of the critical bit is to allow the signer to tell an 1252 evaluator that it would prefer a new, unknown feature to generate an 1253 error than be ignored. 1255 Implementations SHOULD implement the three preferred algorithm 1256 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1257 subpacket. Note, however, that if an implementation chooses not to 1258 implement some of the preferences, it is required to behave in a 1259 polite manner to respect the wishes of those users who do implement 1260 these preferences. 1262 5.2.3.2. {5.2.3.2} Signature Subpacket Types 1264 A number of subpackets are currently defined. Some subpackets apply 1265 to the signature itself and some are attributes of the key. 1266 Subpackets that are found on a self-signature are placed on a 1267 certification made by the key itself. Note that a key may have more 1268 than one User ID, and thus may have more than one self-signature, and 1269 differing subpackets. 1271 A subpacket may be found either in the hashed or unhashed subpacket 1272 sections of a signature. If a subpacket is not hashed, then the 1273 information in it cannot be considered definitive because it is not 1274 part of the signature proper. 1276 5.2.3.3. {5.2.3.3} Notes on Self-Signatures 1278 A self-signature is a binding signature made by the key to which the 1279 signature refers. There are three types of self-signatures, the 1280 certification signatures (types 0x10-0x13), the direct-key signature 1281 (type 0x1F), and the subkey binding signature (type 0x18). For 1282 certification self-signatures, each User ID may have a self- 1283 signature, and thus different subpackets in those self-signatures. 1284 For subkey binding signatures, each subkey in fact has a self- 1285 signature. Subpackets that appear in a certification self-signature 1286 apply to the user name, and subpackets that appear in the subkey 1287 self-signature apply to the subkey. Lastly, subpackets on the 1288 direct-key signature apply to the entire key. 1290 Implementing software should interpret a self-signature's preference 1291 subpackets as narrowly as possible. For example, suppose a key has 1292 two user names, Alice and Bob. Suppose that Alice prefers the 1293 symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the 1294 software locates this key via Alice's name, then the preferred 1295 algorithm is CAST5; if software locates the key via Bob's name, then 1296 the preferred algorithm is IDEA. If the key is located by Key ID, 1297 the algorithm of the primary User ID of the key provides the 1298 preferred symmetric algorithm. 1300 Revoking a self-signature or allowing it to expire has a semantic 1301 meaning that varies with the signature type. Revoking the self- 1302 signature on a User ID effectively retires that user name. The self- 1303 signature is a statement, "My name X is tied to my signing key K" and 1304 is corroborated by other users' certifications. If another user 1305 revokes their certification, they are effectively saying that they no 1306 longer believe that name and that key are tied together. Similarly, 1307 if the users themselves revoke their self-signature, then the users 1308 no longer go by that name, no longer have that email address, etc. 1309 Revoking a binding signature effectively retires that subkey. 1310 Revoking a direct-key signature cancels that signature. Please see 1311 the "Reason for Revocation" subpacket (Section 5.2.3.23) for more 1312 relevant detail. 1314 Since a self-signature contains important information about the key's 1315 use, an implementation SHOULD allow the user to rewrite the self- 1316 signature, and important information in it, such as preferences and 1317 key expiration. 1319 It is good practice to verify that a self-signature imported into an 1320 implementation doesn't advertise features that the implementation 1321 doesn't support, rewriting the signature as appropriate. 1323 An implementation that encounters multiple self-signatures on the 1324 same object may resolve the ambiguity in any way it sees fit, but it 1325 is RECOMMENDED that priority be given to the most recent self- 1326 signature. 1328 5.2.3.4. {5.2.3.4} Signature Creation Time 1330 (4-octet time field) 1332 The time the signature was made. 1334 MUST be present in the hashed area. 1336 5.2.3.5. {5.2.3.5} Issuer 1338 (8-octet Key ID) 1340 The OpenPGP Key ID of the key issuing the signature. If the version 1341 of that key is greater than 4, this subpacket MUST NOT be included in 1342 the signature. 1344 5.2.3.6. {5.2.3.6} Key Expiration Time 1346 (4-octet time field) 1348 The validity period of the key. This is the number of seconds after 1349 the key creation time that the key expires. If this is not present 1350 or has a value of zero, the key never expires. This is found only on 1351 a self-signature. 1353 5.2.3.7. {5.2.3.7} Preferred Symmetric Algorithms 1355 (array of one-octet values) 1357 Symmetric algorithm numbers that indicate which algorithms the key 1358 holder prefers to use. The subpacket body is an ordered list of 1359 octets with the most preferred listed first. It is assumed that only 1360 algorithms listed are supported by the recipient's software. 1361 Algorithm numbers are in Section 9. This is only found on a self- 1362 signature. 1364 5.2.3.8. {5.2.3.8} Preferred Hash Algorithms 1366 (array of one-octet values) 1368 Message digest algorithm numbers that indicate which algorithms the 1369 key holder prefers to receive. Like the preferred symmetric 1370 algorithms, the list is ordered. Algorithm numbers are in Section 9. 1371 This is only found on a self-signature. 1373 5.2.3.9. {5.2.3.9} Preferred Compression Algorithms 1375 (array of one-octet values) 1377 Compression algorithm numbers that indicate which algorithms the key 1378 holder prefers to use. Like the preferred symmetric algorithms, the 1379 list is ordered. Algorithm numbers are in Section 9. If this 1380 subpacket is not included, ZIP is preferred. A zero denotes that 1381 uncompressed data is preferred; the key holder's software might have 1382 no compression software in that implementation. This is only found 1383 on a self-signature. 1385 5.2.3.10. {5.2.3.10} Signature Expiration Time 1387 (4-octet time field) 1389 The validity period of the signature. This is the number of seconds 1390 after the signature creation time that the signature expires. If 1391 this is not present or has a value of zero, it never expires. 1393 5.2.3.11. {5.2.3.11} Exportable Certification 1395 (1 octet of exportability, 0 for not, 1 for exportable) 1397 This subpacket denotes whether a certification signature is 1398 "exportable", to be used by other users than the signature's issuer. 1399 The packet body contains a Boolean flag indicating whether the 1400 signature is exportable. If this packet is not present, the 1401 certification is exportable; it is equivalent to a flag containing a 1402 1. 1404 Non-exportable, or "local", certifications are signatures made by a 1405 user to mark a key as valid within that user's implementation only. 1407 Thus, when an implementation prepares a user's copy of a key for 1408 transport to another user (this is the process of "exporting" the 1409 key), any local certification signatures are deleted from the key. 1411 The receiver of a transported key "imports" it, and likewise trims 1412 any local certifications. In normal operation, there won't be any, 1413 assuming the import is performed on an exported key. However, there 1414 are instances where this can reasonably happen. For example, if an 1415 implementation allows keys to be imported from a key database in 1416 addition to an exported key, then this situation can arise. 1418 Some implementations do not represent the interest of a single user 1419 (for example, a key server). Such implementations always trim local 1420 certifications from any key they handle. 1422 5.2.3.12. {5.2.3.12} Revocable 1424 (1 octet of revocability, 0 for not, 1 for revocable) 1426 Signature's revocability status. The packet body contains a Boolean 1427 flag indicating whether the signature is revocable. Signatures that 1428 are not revocable have any later revocation signatures ignored. They 1429 represent a commitment by the signer that he cannot revoke his 1430 signature for the life of his key. If this packet is not present, 1431 the signature is revocable. 1433 5.2.3.13. {5.2.3.13} Trust Signature 1435 (1 octet "level" (depth), 1 octet of trust amount) 1437 Signer asserts that the key is not only valid but also trustworthy at 1438 the specified level. Level 0 has the same meaning as an ordinary 1439 validity signature. Level 1 means that the signed key is asserted to 1440 be a valid trusted introducer, with the 2nd octet of the body 1441 specifying the degree of trust. Level 2 means that the signed key is 1442 asserted to be trusted to issue level 1 trust signatures, i.e., that 1443 it is a "meta introducer". Generally, a level n trust signature 1444 asserts that a key is trusted to issue level n-1 trust signatures. 1445 The trust amount is in a range from 0-255, interpreted such that 1446 values less than 120 indicate partial trust and values of 120 or 1447 greater indicate complete trust. Implementations SHOULD emit values 1448 of 60 for partial trust and 120 for complete trust. 1450 5.2.3.14. {5.2.3.14} Regular Expression 1452 (null-terminated regular expression) 1454 Used in conjunction with trust Signature packets (of level > 0) to 1455 limit the scope of trust that is extended. Only signatures by the 1456 target key on User IDs that match the regular expression in the body 1457 of this packet have trust extended by the trust Signature subpacket. 1458 The regular expression uses the same syntax as the Henry Spencer's 1459 "almost public domain" regular expression [REGEX] package. A 1460 description of the syntax is found in Section 8 below. 1462 5.2.3.15. {5.2.3.15} Revocation Key 1464 (1 octet of class, 1 octet of public-key algorithm ID, 20 or 25 1465 octets of fingerprint) 1467 V4 keys use the full 20 octet fingerprint; V5 keys use the leftmost 1468 25 octets of the fingerprint 1470 Authorizes the specified key to issue revocation signatures for this 1471 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1472 then this means that the revocation information is sensitive. Other 1473 bits are for future expansion to other kinds of authorizations. This 1474 is found on a self-signature. 1476 If the "sensitive" flag is set, the keyholder feels this subpacket 1477 contains private trust information that describes a real-world 1478 sensitive relationship. If this flag is set, implementations SHOULD 1479 NOT export this signature to other users except in cases where the 1480 data needs to be available: when the signature is being sent to the 1481 designated revoker, or when it is accompanied by a revocation 1482 signature from that revoker. Note that it may be appropriate to 1483 isolate this subpacket within a separate signature so that it is not 1484 combined with other subpackets that need to be exported. 1486 5.2.3.16. {5.2.3.16} Notation Data 1488 (4 octets of flags, 2 octets of name length (M), 1489 2 octets of value length (N), 1490 M octets of name data, 1491 N octets of value data) 1493 This subpacket describes a "notation" on the signature that the 1494 issuer wishes to make. The notation has a name and a value, each of 1495 which are strings of octets. There may be more than one notation in 1496 a signature. Notations can be used for any extension the issuer of 1497 the signature cares to make. The "flags" field holds four octets of 1498 flags. 1500 All undefined flags MUST be zero. Defined flags are as follows: 1502 First octet: 0x80 = human-readable. This note value is text. 1503 Other octets: none. 1505 Notation names are arbitrary strings encoded in UTF-8. They reside 1506 in two namespaces: The IETF namespace and the user namespace. 1508 The IETF namespace is registered with IANA. These names MUST NOT 1509 contain the "@" character (0x40). This is a tag for the user 1510 namespace. 1512 Names in the user namespace consist of a UTF-8 string tag followed by 1513 "@" followed by a DNS domain name. Note that the tag MUST NOT 1514 contain an "@" character. For example, the "sample" tag used by 1515 Example Corporation could be "sample@example.com". 1517 Names in a user space are owned and controlled by the owners of that 1518 domain. Obviously, it's bad form to create a new name in a DNS space 1519 that you don't own. 1521 Since the user namespace is in the form of an email address, 1522 implementers MAY wish to arrange for that address to reach a person 1523 who can be consulted about the use of the named tag. Note that due 1524 to UTF-8 encoding, not all valid user space name tags are valid email 1525 addresses. 1527 If there is a critical notation, the criticality applies to that 1528 specific notation and not to notations in general. 1530 The following subsections define a set of standard notations. 1532 5.2.3.16.1. The 'manu' Notation 1534 The "manu" notation is a string that declares the device 1535 manufacturer's name. The certifier key is asserting this string 1536 (which may or may not be related to the User ID of the certifier's 1537 key). 1539 5.2.3.16.2. The 'make' Notation 1541 This notation defines the product make. It is a free form string. 1543 5.2.3.16.3. The 'model' Notation 1545 This notation defines the product model name/number. It is a free 1546 form string. 1548 5.2.3.16.4. The 'prodid' Notation 1550 This notation contains the product identifier. It is a free form 1551 string. 1553 5.2.3.16.5. The 'pvers' Notation 1555 This notation defines the product version number (which could be a 1556 release number, year, or some other identifier to differentiate 1557 different versions of the same make/model). It is a free form 1558 string. 1560 5.2.3.16.6. The 'lot' Notation 1562 This notation defines the product lot number (which is an indicator 1563 of the batch of product). It is a free form string. 1565 5.2.3.16.7. The 'qty' Notation 1567 This notation defines the quantity of items in this package. It is a 1568 decimal integer representation with no punctuation, e.g. "10", 1569 "1000", "10000", etc. 1571 5.2.3.16.8. The 'loc' and 'dest' Notations 1573 The "loc" and 'dest' notations declare a GeoLocation as defined by 1574 RFC 5870 [RFC5870] but without the leading "geo:" header. For 1575 example, if you had a GeoLocation URI of "geo:13.4125,103.8667" you 1576 would encode that in these notations as "13.4125,103.8667". 1578 The 'loc' notation is meant to encode the geo location where the 1579 signature was made. The 'dest' notation is meant to encode the geo 1580 location where the device is "destined" (i.e., a "destination" for 1581 the device). 1583 5.2.3.16.9. The 'hash' Notation 1585 A 'hash' notation is a means to include external data in the contents 1586 of a signature without including the data itself. This is done by 1587 hashing the external data separately and then including the data's 1588 name and hash in the signature via this notation. This is useful, 1589 for example, to have an external "manifest," "image," or other data 1590 that might not be vital to the signature itself but still needs to be 1591 protected and authenticated without requiring a second signature. 1593 The 'hash' notation has the following structure: * A single byte 1594 specifying the length of the name of the hashed data * A UTF-8 string 1595 of the name of the hashed data * A single byte specifying the hash 1596 algorithm (see section 9.4) * The binary hash output of the hashed 1597 data using the specified algorithm. (The length of this data is 1598 implicit based on the algorithm specified). 1600 Due to its nature a 'hash' notation is not human readable and MUST 1601 NOT be marked as such when used. 1603 5.2.3.17. {5.2.3.17} Key Server Preferences 1605 (N octets of flags) 1607 This is a list of one-bit flags that indicate preferences that the 1608 key holder has about how the key is handled on a key server. All 1609 undefined flags MUST be zero. 1611 First octet: 0x80 = No-modify the key holder requests that this key 1612 only be modified or updated by the key holder or an administrator of 1613 the key server. 1615 This is found only on a self-signature. 1617 5.2.3.18. {5.2.3.18} Preferred Key Server 1619 (String) 1621 This is a URI of a key server that the key holder prefers be used for 1622 updates. Note that keys with multiple User IDs can have a preferred 1623 key server for each User ID. Note also that since this is a URI, the 1624 key server can actually be a copy of the key retrieved by ftp, http, 1625 finger, etc. 1627 5.2.3.19. {5.2.3.19} Primary User ID 1629 (1 octet, Boolean) 1631 This is a flag in a User ID's self-signature that states whether this 1632 User ID is the main User ID for this key. It is reasonable for an 1633 implementation to resolve ambiguities in preferences, etc. by 1634 referring to the primary User ID. If this flag is absent, its value 1635 is zero. If more than one User ID in a key is marked as primary, the 1636 implementation may resolve the ambiguity in any way it sees fit, but 1637 it is RECOMMENDED that priority be given to the User ID with the most 1638 recent self-signature. 1640 When appearing on a self-signature on a User ID packet, this 1641 subpacket applies only to User ID packets. When appearing on a self- 1642 signature on a User Attribute packet, this subpacket applies only to 1643 User Attribute packets. That is to say, there are two different and 1644 independent "primaries" -- one for User IDs, and one for User 1645 Attributes. 1647 5.2.3.20. {5.2.3.20} Policy URI 1649 (String) 1651 This subpacket contains a URI of a document that describes the policy 1652 under which the signature was issued. 1654 5.2.3.21. {5.2.3.21} Key Flags 1656 (N octets of flags) 1658 This subpacket contains a list of binary flags that hold information 1659 about a key. It is a string of octets, and an implementation MUST 1660 NOT assume a fixed size. This is so it can grow over time. If a 1661 list is shorter than an implementation expects, the unstated flags 1662 are considered to be zero. The defined flags are as follows: 1664 0x01 This key may be used to certify other keys. 1666 0x02 This key may be used to sign data. 1668 0x04 This key may be used to encrypt communications. 1670 0x08 This key may be used to encrypt storage. 1672 0x10 The private component of this key may have been split by a 1673 secret-sharing mechanism. 1675 0x20 This key may be used for authentication. 1677 0x80 The private component of this key may be in the possession of 1678 more than one person. 1680 Usage notes: 1682 The flags in this packet may appear in self-signatures or in 1683 certification signatures. They mean different things depending on 1684 who is making the statement --- for example, a certification 1685 signature that has the "sign data" flag is stating that the 1686 certification is for that use. On the other hand, the 1687 "communications encryption" flag in a self-signature is stating a 1688 preference that a given key be used for communications. Note 1689 however, that it is a thorny issue to determine what is 1690 "communications" and what is "storage". This decision is left wholly 1691 up to the implementation; the authors of this document do not claim 1692 any special wisdom on the issue and realize that accepted opinion may 1693 change. 1695 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1696 self-signature only; they are meaningless on a certification 1697 signature. They SHOULD be placed only on a direct-key signature 1698 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1699 key the flag applies to. 1701 5.2.3.22. {5.2.3.22} Signer's User ID 1703 (String) 1705 This subpacket allows a keyholder to state which User ID is 1706 responsible for the signing. Many keyholders use a single key for 1707 different purposes, such as business communications as well as 1708 personal communications. This subpacket allows such a keyholder to 1709 state which of their roles is making a signature. 1711 This subpacket is not appropriate to use to refer to a User Attribute 1712 packet. 1714 5.2.3.23. {5.2.3.23} Reason for Revocation 1716 (1 octet of revocation code, N octets of reason string) 1718 This subpacket is used only in key revocation and certification 1719 revocation signatures. It describes the reason why the key or 1720 certificate was revoked. 1722 The first octet contains a machine-readable code that denotes the 1723 reason for the revocation: 1725 +----------+--------------------------------------------------------+ 1726 | Code | Reason | 1727 +----------+--------------------------------------------------------+ 1728 | 0 | No reason specified (key revocations or cert | 1729 | | revocations) | 1730 | 1 | Key is superseded (key revocations) | 1731 | 2 | Key material has been compromised (key revocations) | 1732 | 3 | Key is retired and no longer used (key revocations) | 1733 | 32 | User ID information is no longer valid (cert | 1734 | | revocations) | 1735 | 100-110 | Private Use | 1736 +----------+--------------------------------------------------------+ 1738 Following the revocation code is a string of octets that gives 1739 information about the Reason for Revocation in human-readable form 1740 (UTF-8). The string may be null, that is, of zero length. The 1741 length of the subpacket is the length of the reason string plus one. 1742 An implementation SHOULD implement this subpacket, include it in all 1743 revocation signatures, and interpret revocations appropriately. 1744 There are important semantic differences between the reasons, and 1745 there are thus important reasons for revoking signatures. 1747 If a key has been revoked because of a compromise, all signatures 1748 created by that key are suspect. However, if it was merely 1749 superseded or retired, old signatures are still valid. If the 1750 revoked signature is the self-signature for certifying a User ID, a 1751 revocation denotes that that user name is no longer in use. Such a 1752 revocation SHOULD include a 0x20 code. 1754 Note that any signature may be revoked, including a certification on 1755 some other person's key. There are many good reasons for revoking a 1756 certification signature, such as the case where the keyholder leaves 1757 the employ of a business with an email address. A revoked 1758 certification is no longer a part of validity calculations. 1760 5.2.3.24. {5.2.3.24} Features 1762 (N octets of flags) 1764 The Features subpacket denotes which advanced OpenPGP features a 1765 user's implementation supports. This is so that as features are 1766 added to OpenPGP that cannot be backwards-compatible, a user can 1767 state that they can use that feature. The flags are single bits that 1768 indicate that a given feature is supported. 1770 This subpacket is similar to a preferences subpacket, and only 1771 appears in a self-signature. 1773 An implementation SHOULD NOT use a feature listed when sending to a 1774 user who does not state that they can use it. 1776 Defined features are as follows: 1778 First octet: 1780 0x01 - Modification Detection (packets 18 and 19) 1782 If an implementation implements any of the defined features, it 1783 SHOULD implement the Features subpacket, too. 1785 An implementation may freely infer features from other suitable 1786 implementation-dependent mechanisms. 1788 5.2.3.25. {5.2.3.25} Signature Target 1790 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1792 This subpacket identifies a specific target signature to which a 1793 signature refers. For revocation signatures, this subpacket provides 1794 explicit designation of which signature is being revoked. For a 1795 third-party or timestamp signature, this designates what signature is 1796 signed. All arguments are an identifier of that target signature. 1798 The N octets of hash data MUST be the size of the hash of the 1799 signature. For example, a target signature with a SHA-1 hash MUST 1800 have 20 octets of hash data. 1802 5.2.3.26. {5.2.3.26} Embedded Signature 1804 (1 signature packet body) 1806 This subpacket contains a complete Signature packet body as specified 1807 in Section 5.2 above. It is useful when one signature needs to refer 1808 to, or be incorporated in, another signature. 1810 5.2.3.27. Issuer Fingerprint 1812 (1 octet key version number, N octets of fingerprint) 1814 The OpenPGP Key fingerprint of the key issuing the signature. This 1815 subpacket SHOULD be included in all signatures. If the version of 1816 the issuing key is 4 and an Issuer subpacket is also included in the 1817 signature, the key ID of the Issuer subpacket MUST match the low 64 1818 bits of the fingerprint. 1820 Note that the length N of the fingerprint for a version 4 key is 20 1821 octets. For a version 5 key the leftmost 25 octets of the 1822 fingerprint are used (N=25). 1824 5.2.4. {5.2.4} Computing Signatures 1826 All signatures are formed by producing a hash over the signature 1827 data, and then using the resulting hash in the signature algorithm. 1829 For binary document signatures (type 0x00), the document data is 1830 hashed directly. For text document signatures (type 0x01), the 1831 document is canonicalized by converting line endings to , and 1832 the resulting data is hashed. 1834 When a signature is made over a key, the hash data starts with the 1835 octet 0x99, followed by a two-octet length of the key, and then body 1836 of the key packet. (Note that this is an old-style packet header for 1837 a key packet with two-octet length.) A subkey binding signature 1838 (type 0x18) or primary key binding signature (type 0x19) then hashes 1839 the subkey using the same format as the main key (also using 0x99 as 1840 the first octet). Primary key revocation signatures (type 0x20) hash 1841 only the key being revoked. Subkey revocation signature (type 0x28) 1842 hash first the primary key and then the subkey being revoked. 1844 A certification signature (type 0x10 through 0x13) hashes the User ID 1845 being bound to the key into the hash context after the above data. A 1846 V3 certification hashes the contents of the User ID or attribute 1847 packet packet, without any header. A V4 or V5 certification hashes 1848 the constant 0xB4 for User ID certifications or the constant 0xD1 for 1849 User Attribute certifications, followed by a four-octet number giving 1850 the length of the User ID or User Attribute data, and then the User 1851 ID or User Attribute data. 1853 When a signature is made over a Signature packet (type 0x50), the 1854 hash data starts with the octet 0x88, followed by the four-octet 1855 length of the signature, and then the body of the Signature packet. 1856 (Note that this is an old-style packet header for a Signature packet 1857 with the length-of-length set to zero.) The unhashed subpacket data 1858 of the Signature packet being hashed is not included in the hash, and 1859 the unhashed subpacket data length value is set to zero. 1861 Once the data body is hashed, then a trailer is hashed. A V3 1862 signature hashes five octets of the packet body, starting from the 1863 signature type field. This data is the signature type, followed by 1864 the four-octet signature time. A V4 or V5 signature hashes the 1865 packet body starting from its first field, the version number, 1866 through the end of the hashed subpacket data. Thus, the fields 1867 hashed are the signature version, the signature type, the public-key 1868 algorithm, the hash algorithm, the hashed subpacket length, and the 1869 hashed subpacket body. 1871 V4 signatures also hash in a final trailer of six octets: the version 1872 of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, big- 1873 endian number that is the length of the hashed data from the 1874 Signature packet (note that this number does not include these final 1875 six octets). 1877 V5 signatures instead hash in a ten-octet trailer: the version of the 1878 Signature packet, i.e., 0x05; 0xFF; and an eight-octet, big-endian 1879 number that is the length of the hashed data from the Signature 1880 packet (note that this number does not include these final ten 1881 octets). 1883 After all this has been hashed in a single hash context, the 1884 resulting hash field is used in the signature algorithm and placed at 1885 the end of the Signature packet. 1887 5.2.4.1. {5.2.4.1} Subpacket Hints 1889 It is certainly possible for a signature to contain conflicting 1890 information in subpackets. For example, a signature may contain 1891 multiple copies of a preference or multiple expiration times. In 1892 most cases, an implementation SHOULD use the last subpacket in the 1893 signature, but MAY use any conflict resolution scheme that makes more 1894 sense. Please note that we are intentionally leaving conflict 1895 resolution to the implementer; most conflicts are simply syntax 1896 errors, and the wishy-washy language here allows a receiver to be 1897 generous in what they accept, while putting pressure on a creator to 1898 be stingy in what they generate. 1900 Some apparent conflicts may actually make sense -- for example, 1901 suppose a keyholder has a V3 key and a V4 key that share the same RSA 1902 key material. Either of these keys can verify a signature created by 1903 the other, and it may be reasonable for a signature to contain an 1904 issuer subpacket for each key, as a way of explicitly tying those 1905 keys to the signature. 1907 5.3. {5.3} Symmetric-Key Encrypted Session Key Packets (Tag 3) 1909 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 1910 key encryption of a session key used to encrypt a message. Zero or 1911 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 1912 Encrypted Session Key packets may precede a Symmetrically Encrypted 1913 Data packet that holds an encrypted message. The message is 1914 encrypted with a session key, and the session key is itself encrypted 1915 and stored in the Encrypted Session Key packet or the Symmetric-Key 1916 Encrypted Session Key packet. 1918 If the Symmetrically Encrypted Data packet is preceded by one or more 1919 Symmetric-Key Encrypted Session Key packets, each specifies a 1920 passphrase that may be used to decrypt the message. This allows a 1921 message to be encrypted to a number of public keys, and also to one 1922 or more passphrases. This packet type is new and is not generated by 1923 PGP 2.x or PGP 5.0. 1925 The body of this packet consists of: 1927 o A one-octet version number. The only currently defined version is 1928 4. 1930 o A one-octet number describing the symmetric algorithm used. 1932 o A string-to-key (S2K) specifier, length as defined above. 1934 o Optionally, the encrypted session key itself, which is decrypted 1935 with the string-to-key object. 1937 If the encrypted session key is not present (which can be detected on 1938 the basis of packet length and S2K specifier size), then the S2K 1939 algorithm applied to the passphrase produces the session key for 1940 decrypting the file, using the symmetric cipher algorithm from the 1941 Symmetric-Key Encrypted Session Key packet. 1943 If the encrypted session key is present, the result of applying the 1944 S2K algorithm to the passphrase is used to decrypt just that 1945 encrypted session key field, using CFB mode with an IV of all zeros. 1946 The decryption result consists of a one-octet algorithm identifier 1947 that specifies the symmetric-key encryption algorithm used to encrypt 1948 the following Symmetrically Encrypted Data packet, followed by the 1949 session key octets themselves. 1951 Note: because an all-zero IV is used for this decryption, the S2K 1952 specifier MUST use a salt value, either a Salted S2K or an Iterated- 1953 Salted S2K. The salt value will ensure that the decryption key is 1954 not repeated even if the passphrase is reused. 1956 5.4. {5.4} One-Pass Signature Packets (Tag 4) 1958 The One-Pass Signature packet precedes the signed data and contains 1959 enough information to allow the receiver to begin calculating any 1960 hashes needed to verify the signature. It allows the Signature 1961 packet to be placed at the end of the message, so that the signer can 1962 compute the entire signed message in one pass. 1964 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 1966 The body of this packet consists of: 1968 o A one-octet version number. The current version is 3. 1970 o A one-octet signature type. Signature types are described in 1971 Section 5.2.1. 1973 o A one-octet number describing the hash algorithm used. 1975 o A one-octet number describing the public-key algorithm used. 1977 o An eight-octet number holding the Key ID of the signing key. 1979 o A one-octet number holding a flag showing whether the signature is 1980 nested. A zero value indicates that the next packet is another 1981 One-Pass Signature packet that describes another signature to be 1982 applied to the same message data. 1984 Note that if a message contains more than one one-pass signature, 1985 then the Signature packets bracket the message; that is, the first 1986 Signature packet after the message corresponds to the last one-pass 1987 packet and the final Signature packet corresponds to the first one- 1988 pass packet. 1990 5.5. {5.5} Key Material Packet 1992 A key material packet contains all the information about a public or 1993 private key. There are four variants of this packet type, and two 1994 major versions. Consequently, this section is complex. 1996 5.5.1. {5.5.1} Key Packet Variants 1998 5.5.1.1. {5.5.1.1} Public-Key Packet (Tag 6) 2000 A Public-Key packet starts a series of packets that forms an OpenPGP 2001 key (sometimes called an OpenPGP certificate). 2003 5.5.1.2. {5.5.1.2} Public-Subkey Packet (Tag 14) 2005 A Public-Subkey packet (tag 14) has exactly the same format as a 2006 Public-Key packet, but denotes a subkey. One or more subkeys may be 2007 associated with a top-level key. By convention, the top-level key 2008 provides signature services, and the subkeys provide encryption 2009 services. 2011 Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet. 2012 This tag was selected for reuse because no previous version of PGP 2013 ever emitted comment packets but they did properly ignore them. 2014 Public-Subkey packets are ignored by PGP 2.6.x and do not cause it to 2015 fail, providing a limited degree of backward compatibility. 2017 5.5.1.3. {5.5.1.3} Secret-Key Packet (Tag 5) 2019 A Secret-Key packet contains all the information that is found in a 2020 Public-Key packet, including the public-key material, but also 2021 includes the secret-key material after all the public-key fields. 2023 5.5.1.4. {5.5.1.4} Secret-Subkey Packet (Tag 7) 2025 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2026 packet and has exactly the same format. 2028 5.5.2. {5.5.2} Public-Key Packet Formats 2030 There are two versions of key-material packets. Version 3 packets 2031 were first generated by PGP 2.6. Version 4 keys first appeared in 2032 PGP 5.0 and are the preferred key version for OpenPGP. 2034 OpenPGP implementations MUST create keys with version 4 format. V3 2035 keys are deprecated; an implementation MUST NOT generate a V3 key, 2036 but MAY accept it. 2038 A version 3 public key or public-subkey packet contains: 2040 o A one-octet version number (3). 2042 o A four-octet number denoting the time that the key was created. 2044 o A two-octet number denoting the time in days that this key is 2045 valid. If this number is zero, then it does not expire. 2047 o A one-octet number denoting the public-key algorithm of this key. 2049 o A series of multiprecision integers comprising the key material: 2051 * a multiprecision integer (MPI) of RSA public modulus n; 2053 * an MPI of RSA public encryption exponent e. 2055 V3 keys are deprecated. They contain three weaknesses. First, it is 2056 relatively easy to construct a V3 key that has the same Key ID as any 2057 other key because the Key ID is simply the low 64 bits of the public 2058 modulus. Secondly, because the fingerprint of a V3 key hashes the 2059 key material, but not its length, there is an increased opportunity 2060 for fingerprint collisions. Third, there are weaknesses in the MD5 2061 hash algorithm that make developers prefer other algorithms. See 2062 below for a fuller discussion of Key IDs and fingerprints. 2064 V2 keys are identical to the deprecated V3 keys except for the 2065 version number. An implementation MUST NOT generate them and MAY 2066 accept or reject them as it sees fit. 2068 The version 4 format is similar to the version 3 format except for 2069 the absence of a validity period. This has been moved to the 2070 Signature packet. In addition, fingerprints of version 4 keys are 2071 calculated differently from version 3 keys, as described in the 2072 section "Enhanced Key Formats". 2074 A version 4 packet contains: 2076 o A one-octet version number (4). 2078 o A four-octet number denoting the time that the key was created. 2080 o A one-octet number denoting the public-key algorithm of this key. 2082 o A series of values comprising the key material. This is 2083 algorithm-specific and described in section XXXX. 2085 The version 5 format is similar to the version 4 format except for 2086 the addition of a count for the key material. This count helps 2087 parsing secret key packets (which are an extension of the public key 2088 packet format) in the case of an unknown algoritm. In addition, 2089 fingerprints of version 5 keys are calculated differently from 2090 version 4 keys, as described in the section "Enhanced Key Formats". 2092 A version 5 packet contains: 2094 o A one-octet version number (5). 2096 o A four-octet number denoting the time that the key was created. 2098 o A one-octet number denoting the public-key algorithm of this key. 2100 o A four-octet scalar octet count for the following key material. 2102 o A series of values comprising the key material. This is 2103 algorithm-specific and described in section XXXX. 2105 5.5.3. {5.5.3} Secret-Key Packet Formats 2107 The Secret-Key and Secret-Subkey packets contain all the data of the 2108 Public-Key and Public-Subkey packets, with additional algorithm- 2109 specific secret-key data appended, usually in encrypted form. 2111 The packet contains: 2113 o A Public-Key or Public-Subkey packet, as described above. 2115 o One octet indicating string-to-key usage conventions. Zero 2116 indicates that the secret-key data is not encrypted. 255 or 254 2117 indicates that a string-to-key specifier is being given. Any 2118 other value is a symmetric-key encryption algorithm identifier. A 2119 version 5 packet MUST NOT use the value 255. 2121 o Only for a version 5 packet, a one-octet scalar octet count of the 2122 next 3 optional fields. 2124 o [Optional] If string-to-key usage octet was 255 or 254, a one- 2125 octet symmetric encryption algorithm. 2127 o [Optional] If string-to-key usage octet was 255 or 254, a string- 2128 to-key specifier. The length of the string-to-key specifier is 2129 implied by its type, as described above. 2131 o [Optional] If secret data is encrypted (string-to-key usage octet 2132 not zero), an Initial Vector (IV) of the same length as the 2133 cipher's block size. 2135 o Only for a version 5 packet, a four-octet scalar octet count for 2136 the following key material. 2138 o Plain or encrypted series of values comprising the secret key 2139 material. This is algorithm-specific and described in section 2140 XXXX. 2142 o If the string-to-key usage octet is zero or 255, then a two-octet 2143 checksum of the plaintext of the algorithm-specific portion (sum 2144 of all octets, mod 65536). If the string-to-key usage octet was 2145 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2146 specific portion. This checksum or hash is encrypted together 2147 with the algorithm-specific fields (if string-to-key usage octet 2148 is not zero). Note that for all other values, a two-octet 2149 checksum is required. 2151 Note that the version 5 packet format adds two count values to help 2152 parsing packets with unknown S2K or public key algorithms. 2154 Secret MPI values can be encrypted using a passphrase. If a string- 2155 to-key specifier is given, that describes the algorithm for 2156 converting the passphrase to a key, else a simple MD5 hash of the 2157 passphrase is used. Implementations MUST use a string-to-key 2158 specifier; the simple hash is for backward compatibility and is 2159 deprecated, though implementations MAY continue to use existing 2160 private keys in the old format. The cipher for encrypting the MPIs 2161 is specified in the Secret-Key packet. 2163 Encryption/decryption of the secret data is done in CFB mode using 2164 the key created from the passphrase and the Initial Vector from the 2165 packet. A different mode is used with V3 keys (which are only RSA) 2166 than with other key formats. With V3 keys, the MPI bit count prefix 2167 (i.e., the first two octets) is not encrypted. Only the MPI non- 2168 prefix data is encrypted. Furthermore, the CFB state is 2169 resynchronized at the beginning of each new MPI value, so that the 2170 CFB block boundary is aligned with the start of the MPI data. 2172 With V4 and V5 keys, a simpler method is used. All secret MPI values 2173 are encrypted in CFB mode, including the MPI bitcount prefix. 2175 The two-octet checksum that follows the algorithm-specific portion is 2176 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2177 specific octets (including MPI prefix and data). With V3 keys, the 2178 checksum is stored in the clear. With V4 keys, the checksum is 2179 encrypted like the algorithm-specific data. This value is used to 2180 check that the passphrase was correct. However, this checksum is 2181 deprecated; an implementation SHOULD NOT use it, but should rather 2182 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2183 this is that there are some attacks that involve undetectably 2184 modifying the secret key. 2186 5.6. Algorithm-specific Parts of Keys 2188 The public and secret key format specifies algorithm-specific parts 2189 of a key. The following sections describe them in detail. 2191 5.6.1. Algorithm-Specific Part for RSA Keys 2193 The public key is this series of multiprecision integers: 2195 o MPI of RSA public modulus n; 2197 o MPI of RSA public encryption exponent e. 2199 The secret key is this series of multiprecision integers: 2201 o MPI of RSA secret exponent d; 2203 o MPI of RSA secret prime value p; 2205 o MPI of RSA secret prime value q (p < q); 2207 o MPI of u, the multiplicative inverse of p, mod q. 2209 5.6.2. Algorithm-Specific Part for DSA Keys 2211 The public key is this series of multiprecision integers: 2213 o MPI of DSA prime p; 2215 o MPI of DSA group order q (q is a prime divisor of p-1); 2217 o MPI of DSA group generator g; 2219 o MPI of DSA public-key value y (= g**x mod p where x is secret). 2221 The secret key is this single multiprecision integer: 2223 o MPI of DSA secret exponent x. 2225 5.6.3. Algorithm-Specific Part for Elgamal Keys 2227 The public key is this series of multiprecision integers: 2229 o MPI of Elgamal prime p; 2231 o MPI of Elgamal group generator g; 2233 o MPI of Elgamal public key value y (= g**x mod p where x is 2234 secret). 2236 The secret key is this single multiprecision integer: 2238 o MPI of Elgamal secret exponent x. 2240 5.6.4. Algorithm-Specific Part for ECDSA Keys 2242 The public key is this series of values: 2244 o a variable-length field containing a curve OID, formatted as 2245 follows: 2247 * a one-octet size of the following field; values 0 and 0xFF are 2248 reserved for future extensions, 2250 * the octets representing a curve OID, defined in section 2251 11{FIXME}; 2253 o a MPI of an EC point representing a public key. 2255 The secret key is this single multiprecision integer: 2257 o MPI of an integer representing the secret key, which is a scalar 2258 of the public EC point. 2260 5.6.5. Algorithm-Specific Part for EdDSA Keys 2262 The public key is this series of values: 2264 o a variable-length field containing a curve OID, formatted as 2265 follows: 2267 * a one-octet size of the following field; values 0 and 0xFF are 2268 reserved for future extensions, 2270 * the octets representing a curve OID, defined in section 2271 NN{FIXME}; 2273 o a MPI of an EC point representing a public key Q as described 2274 under EdDSA Point Format below. 2276 The secret key is this single multiprecision integer: 2278 o MPI of an integer representing the secret key, which is a scalar 2279 of the public EC point. 2281 5.6.6. Algorithm-Specific Part for ECDH Keys 2283 The public key is this series of values: 2285 o a variable-length field containing a curve OID, formatted as 2286 follows: 2288 * a one-octet size of the following field; values 0 and 0xFF are 2289 reserved for future extensions, 2291 * the octets representing a curve OID, defined in 2292 Section 11{FIXME}; 2294 o a MPI of an EC point representing a public key; 2295 o a variable-length field containing KDF parameters, formatted as 2296 follows: 2298 * a one-octet size of the following fields; values 0 and 0xff are 2299 reserved for future extensions; 2301 * a one-octet value 1, reserved for future extensions; 2303 * a one-octet hash function ID used with a KDF; 2305 * a one-octet algorithm ID for the symmetric algorithm used to 2306 wrap the symmetric key used for the message encryption; see 2307 Section 8 for details. 2309 Observe that an ECDH public key is composed of the same sequence of 2310 fields that define an ECDSA key, plus the KDF parameters field. 2312 The secret key is this single multiprecision integer: 2314 o MPI of an integer representing the secret key, which is a scalar 2315 of the public EC point. 2317 5.7. {5.6} Compressed Data Packet (Tag 8) 2319 The Compressed Data packet contains compressed data. Typically, this 2320 packet is found as the contents of an encrypted packet, or following 2321 a Signature or One-Pass Signature packet, and contains a literal data 2322 packet. 2324 The body of this packet consists of: 2326 o One octet that gives the algorithm used to compress the packet. 2328 o Compressed data, which makes up the remainder of the packet. 2330 A Compressed Data Packet's body contains an block that compresses 2331 some set of packets. See section "Packet Composition" for details on 2332 how messages are formed. 2334 ZIP-compressed packets are compressed with raw RFC 1951 [RFC1951] 2335 DEFLATE blocks. Note that PGP V2.6 uses 13 bits of compression. If 2336 an implementation uses more bits of compression, PGP V2.6 cannot 2337 decompress it. 2339 ZLIB-compressed packets are compressed with RFC 1950 [RFC1950] ZLIB- 2340 style blocks. 2342 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2343 algorithm. 2345 5.8. {5.7} Symmetrically Encrypted Data Packet (Tag 9) 2347 The Symmetrically Encrypted Data packet contains data encrypted with 2348 a symmetric-key algorithm. When it has been decrypted, it contains 2349 other packets (usually a literal data packet or compressed data 2350 packet, but in theory other Symmetrically Encrypted Data packets or 2351 sequences of packets that form whole OpenPGP messages). 2353 The body of this packet consists of: 2355 o Encrypted data, the output of the selected symmetric-key cipher 2356 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2358 The symmetric cipher used may be specified in a Public-Key or 2359 Symmetric-Key Encrypted Session Key packet that precedes the 2360 Symmetrically Encrypted Data packet. In that case, the cipher 2361 algorithm octet is prefixed to the session key before it is 2362 encrypted. If no packets of these types precede the encrypted data, 2363 the IDEA algorithm is used with the session key calculated as the MD5 2364 hash of the passphrase, though this use is deprecated. 2366 The data is encrypted in CFB mode, with a CFB shift size equal to the 2367 cipher's block size. The Initial Vector (IV) is specified as all 2368 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2369 equal to the block size of the cipher plus two to the data before it 2370 is encrypted. The first block-size octets (for example, 8 octets for 2371 a 64-bit block length) are random, and the following two octets are 2372 copies of the last two octets of the IV. For example, in an 8-octet 2373 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2374 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2375 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2376 in both these examples, we consider the first octet to be numbered 1. 2378 After encrypting the first block-size-plus-two octets, the CFB state 2379 is resynchronized. The last block-size octets of ciphertext are 2380 passed through the cipher and the block boundary is reset. 2382 The repetition of 16 bits in the random data prefixed to the message 2383 allows the receiver to immediately check whether the session key is 2384 incorrect. See the "Security Considerations" section for hints on 2385 the proper use of this "quick check". 2387 5.9. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) 2389 An experimental version of PGP used this packet as the Literal 2390 packet, but no released version of PGP generated Literal packets with 2391 this tag. With PGP 5.x, this packet has been reassigned and is 2392 reserved for use as the Marker packet. 2394 The body of this packet consists of: 2396 o The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2398 Such a packet MUST be ignored when received. It may be placed at the 2399 beginning of a message that uses features not available in PGP 2.6.x 2400 in order to cause that version to report that newer software is 2401 necessary to process the message. 2403 5.10. {5.9} Literal Data Packet (Tag 11) 2405 A Literal Data packet contains the body of a message; data that is 2406 not to be further interpreted. 2408 The body of this packet consists of: 2410 o A one-octet field that describes how the data is formatted. 2412 If it is a 'b' (0x62), then the Literal packet contains binary 2413 data. If it is a 't' (0x74), then it contains text data, and thus 2414 may need line ends converted to local form, or other text-mode 2415 changes. The tag 'u' (0x75) means the same as 't', but also 2416 indicates that implementation believes that the literal data 2417 contains UTF-8 text. 2419 Early versions of PGP also defined a value of 'l' as a 'local' 2420 mode for machine-local conversions. RFC 1991 [RFC1991] 2421 incorrectly stated this local mode flag as '1' (ASCII numeral 2422 one). Both of these local modes are deprecated. 2424 o File name as a string (one-octet length, followed by a file name). 2425 This may be a zero-length string. Commonly, if the source of the 2426 encrypted data is a file, this will be the name of the encrypted 2427 file. An implementation MAY consider the file name in the Literal 2428 packet to be a more authoritative name than the actual file name. 2430 If the special name "_CONSOLE" is used, the message is considered 2431 to be "for your eyes only". This advises that the message data is 2432 unusually sensitive, and the receiving program should process it 2433 more carefully, perhaps avoiding storing the received data to 2434 disk, for example. 2436 o A four-octet number that indicates a date associated with the 2437 literal data. Commonly, the date might be the modification date 2438 of a file, or the time the packet was created, or a zero that 2439 indicates no specific time. 2441 o The remainder of the packet is literal data. 2443 Text data is stored with text endings (i.e., network- 2444 normal line endings). These should be converted to native line 2445 endings by the receiving software. 2447 5.11. {5.10} Trust Packet (Tag 12) 2449 The Trust packet is used only within keyrings and is not normally 2450 exported. Trust packets contain data that record the user's 2451 specifications of which key holders are trustworthy introducers, 2452 along with other information that implementing software uses for 2453 trust information. The format of Trust packets is defined by a given 2454 implementation. 2456 Trust packets SHOULD NOT be emitted to output streams that are 2457 transferred to other users, and they SHOULD be ignored on any input 2458 other than local keyring files. 2460 5.12. {5.11} User ID Packet (Tag 13) 2462 A User ID packet consists of UTF-8 text that is intended to represent 2463 the name and email address of the key holder. By convention, it 2464 includes an RFC 2822 [RFC2822] mail name-addr, but there are no 2465 restrictions on its content. The packet length in the header 2466 specifies the length of the User ID. 2468 5.13. {5.12} User Attribute Packet (Tag 17) 2470 The User Attribute packet is a variation of the User ID packet. It 2471 is capable of storing more types of data than the User ID packet, 2472 which is limited to text. Like the User ID packet, a User Attribute 2473 packet may be certified by the key owner ("self-signed") or any other 2474 key owner who cares to certify it. Except as noted, a User Attribute 2475 packet may be used anywhere that a User ID packet may be used. 2477 While User Attribute packets are not a required part of the OpenPGP 2478 standard, implementations SHOULD provide at least enough 2479 compatibility to properly handle a certification signature on the 2480 User Attribute packet. A simple way to do this is by treating the 2481 User Attribute packet as a User ID packet with opaque contents, but 2482 an implementation may use any method desired. 2484 The User Attribute packet is made up of one or more attribute 2485 subpackets. Each subpacket consists of a subpacket header and a 2486 body. The header consists of: 2488 o the subpacket length (1, 2, or 5 octets) 2490 o the subpacket type (1 octet) 2492 and is followed by the subpacket specific data. 2494 The following table lists the currently known subpackets: 2496 +----------+------------------------------+ 2497 | Type | Attribute Subpacket | 2498 +----------+------------------------------+ 2499 | 1 | Image Attribute Subpacket | 2500 | [TBD1] | User ID Attribute Subpacket | 2501 | 100-110 | Private/Experimental Use | 2502 +----------+------------------------------+ 2504 An implementation SHOULD ignore any subpacket of a type that it does 2505 not recognize. 2507 5.13.1. {5.12.1} The Image Attribute Subpacket 2509 The Image Attribute subpacket is used to encode an image, presumably 2510 (but not required to be) that of the key owner. 2512 The Image Attribute subpacket begins with an image header. The first 2513 two octets of the image header contain the length of the image 2514 header. Note that unlike other multi-octet numerical values in this 2515 document, due to a historical accident this value is encoded as a 2516 little-endian number. The image header length is followed by a 2517 single octet for the image header version. The only currently 2518 defined version of the image header is 1, which is a 16-octet image 2519 header. The first three octets of a version 1 image header are thus 2520 0x10, 0x00, 0x01. 2522 The fourth octet of a version 1 image header designates the encoding 2523 format of the image. The only currently defined encoding format is 2524 the value 1 to indicate JPEG. Image format types 100 through 110 are 2525 reserved for private or experimental use. The rest of the version 1 2526 image header is made up of 12 reserved octets, all of which MUST be 2527 set to 0. 2529 The rest of the image subpacket contains the image itself. As the 2530 only currently defined image type is JPEG, the image is encoded in 2531 the JPEG File Interchange Format (JFIF), a standard file format for 2532 JPEG images [JFIF]. 2534 An implementation MAY try to determine the type of an image by 2535 examination of the image data if it is unable to handle a particular 2536 version of the image header or if a specified encoding format value 2537 is not recognized. 2539 5.13.2. User ID Attribute Subpacket 2541 A User ID Attribute subpacket has type #[IANA -- assignment TBD1]. 2543 A User ID Attribute subpacket, just like a User ID packet, consists 2544 of UTF-8 text that is intended to represent the name and email 2545 address of the key holder. By convention, it includes an RFC 2822 2546 [RFC2822] mail name-addr, but there are no restrictions on its 2547 content. For devices using OpenPGP for device certificates, it may 2548 just be the device identifier. The packet length in the header 2549 specifies the length of the User ID. 2551 Because User Attribute subpackets can be used anywhere a User ID 2552 packet can be used, implementations MAY choose to trust a signed User 2553 Attribute subpacket that includes a User ID Attribute subpacket. 2555 5.14. {5.13} Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2557 The Symmetrically Encrypted Integrity Protected Data packet is a 2558 variant of the Symmetrically Encrypted Data packet. It is a new 2559 feature created for OpenPGP that addresses the problem of detecting a 2560 modification to encrypted data. It is used in combination with a 2561 Modification Detection Code packet. 2563 There is a corresponding feature in the features Signature subpacket 2564 that denotes that an implementation can properly use this packet 2565 type. An implementation MUST support decrypting these packets and 2566 SHOULD prefer generating them to the older Symmetrically Encrypted 2567 Data packet when possible. Since this data packet protects against 2568 modification attacks, this standard encourages its proliferation. 2569 While blanket adoption of this data packet would create 2570 interoperability problems, rapid adoption is nevertheless important. 2571 An implementation SHOULD specifically denote support for this packet, 2572 but it MAY infer it from other mechanisms. 2574 For example, an implementation might infer from the use of a cipher 2575 such as Advanced Encryption Standard (AES) or Twofish that a user 2576 supports this feature. It might place in the unhashed portion of 2577 another user's key signature a Features subpacket. It might also 2578 present a user with an opportunity to regenerate their own self- 2579 signature with a Features subpacket. 2581 This packet contains data encrypted with a symmetric-key algorithm 2582 and protected against modification by the SHA-1 hash algorithm. When 2583 it has been decrypted, it will typically contain other packets (often 2584 a Literal Data packet or Compressed Data packet). The last decrypted 2585 packet in this packet's payload MUST be a Modification Detection Code 2586 packet. 2588 The body of this packet consists of: 2590 o A one-octet version number. The only currently defined value is 2591 1. 2593 o Encrypted data, the output of the selected symmetric-key cipher 2594 operating in Cipher Feedback mode with shift amount equal to the 2595 block size of the cipher (CFB-n where n is the block size). 2597 The symmetric cipher used MUST be specified in a Public-Key or 2598 Symmetric-Key Encrypted Session Key packet that precedes the 2599 Symmetrically Encrypted Data packet. In either case, the cipher 2600 algorithm octet is prefixed to the session key before it is 2601 encrypted. 2603 The data is encrypted in CFB mode, with a CFB shift size equal to the 2604 cipher's block size. The Initial Vector (IV) is specified as all 2605 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2606 the data before it is encrypted. The length of the octet string 2607 equals the block size of the cipher in octets, plus two. The first 2608 octets in the group, of length equal to the block size of the cipher, 2609 are random; the last two octets are each copies of their 2nd 2610 preceding octet. For example, with a cipher whose block size is 128 2611 bits or 16 octets, the prefix data will contain 16 random octets, 2612 then two more octets, which are copies of the 15th and 16th octets, 2613 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2614 special CFB resynchronization is done after encrypting this prefix 2615 data. See "OpenPGP CFB Mode" below for more details. 2617 The repetition of 16 bits in the random data prefixed to the message 2618 allows the receiver to immediately check whether the session key is 2619 incorrect. 2621 The plaintext of the data to be encrypted is passed through the SHA-1 2622 hash function, and the result of the hash is appended to the 2623 plaintext in a Modification Detection Code packet. The input to the 2624 hash function includes the prefix data described above; it includes 2625 all of the plaintext, and then also includes two octets of values 2626 0xD3, 0x14. These represent the encoding of a Modification Detection 2627 Code packet tag and length field of 20 octets. 2629 The resulting hash value is stored in a Modification Detection Code 2630 (MDC) packet, which MUST use the two octet encoding just given to 2631 represent its tag and length field. The body of the MDC packet is 2632 the 20-octet output of the SHA-1 hash. 2634 The Modification Detection Code packet is appended to the plaintext 2635 and encrypted along with the plaintext using the same CFB context. 2637 During decryption, the plaintext data should be hashed with SHA-1, 2638 including the prefix data as well as the packet tag and length field 2639 of the Modification Detection Code packet. The body of the MDC 2640 packet, upon decryption, is compared with the result of the SHA-1 2641 hash. 2643 Any failure of the MDC indicates that the message has been modified 2644 and MUST be treated as a security problem. Failures include a 2645 difference in the hash values, but also the absence of an MDC packet, 2646 or an MDC packet in any position other than the end of the plaintext. 2647 Any failure SHOULD be reported to the user. 2649 Note: future designs of new versions of this packet should consider 2650 rollback attacks since it will be possible for an attacker to change 2651 the version back to 1. 2653 NON-NORMATIVE EXPLANATION 2655 The MDC system, as packets 18 and 19 are called, were created to 2656 provide an integrity mechanism that is less strong than a 2657 signature, yet stronger than bare CFB encryption. 2659 It is a limitation of CFB encryption that damage to the 2660 ciphertext will corrupt the affected cipher blocks and the block 2661 following. Additionally, if data is removed from the end of a 2662 CFB-encrypted block, that removal is undetectable. (Note also 2663 that CBC mode has a similar limitation, but data removed from 2664 the front of the block is undetectable.) 2666 The obvious way to protect or authenticate an encrypted block is 2667 to digitally sign it. However, many people do not wish to 2668 habitually sign data, for a large number of reasons beyond the 2669 scope of this document. Suffice it to say that many people 2670 consider properties such as deniability to be as valuable as 2671 integrity. 2673 OpenPGP addresses this desire to have more security than raw 2674 encryption and yet preserve deniability with the MDC system. An 2675 MDC is intentionally not a MAC. Its name was not selected by 2676 accident. It is analogous to a checksum. 2678 Despite the fact that it is a relatively modest system, it has 2679 proved itself in the real world. It is an effective defense to 2680 several attacks that have surfaced since it has been created. 2681 It has met its modest goals admirably. 2683 Consequently, because it is a modest security system, it has 2684 modest requirements on the hash function(s) it employs. It does 2685 not rely on a hash function being collision-free, it relies on a 2686 hash function being one-way. If a forger, Frank, wishes to send 2687 Alice a (digitally) unsigned message that says, "I've always 2688 secretly loved you, signed Bob", it is far easier for him to 2689 construct a new message than it is to modify anything 2690 intercepted from Bob. (Note also that if Bob wishes to 2691 communicate secretly with Alice, but without authentication or 2692 identification and with a threat model that includes forgers, he 2693 has a problem that transcends mere cryptography.) 2695 Note also that unlike nearly every other OpenPGP subsystem, 2696 there are no parameters in the MDC system. It hard-defines 2697 SHA-1 as its hash function. This is not an accident. It is an 2698 intentional choice to avoid downgrade and cross-grade attacks 2699 while making a simple, fast system. (A downgrade attack would 2700 be an attack that replaced SHA2-256 with SHA-1, for example. A 2701 cross-grade attack would replace SHA-1 with another 160-bit 2702 hash, such as RIPE-MD/160, for example.) 2704 However, given the present state of hash function cryptanalysis 2705 and cryptography, it may be desirable to upgrade the MDC system 2706 to a new hash function. See Section 13.11 in the "IANA 2707 Considerations" for guidance. 2709 5.15. {5.14} Modification Detection Code Packet (Tag 19) 2711 The Modification Detection Code packet contains a SHA-1 hash of 2712 plaintext data, which is used to detect message modification. It is 2713 only used with a Symmetrically Encrypted Integrity Protected Data 2714 packet. The Modification Detection Code packet MUST be the last 2715 packet in the plaintext data that is encrypted in the Symmetrically 2716 Encrypted Integrity Protected Data packet, and MUST appear in no 2717 other place. 2719 A Modification Detection Code packet MUST have a length of 20 octets. 2721 The body of this packet consists of: 2723 o A 20-octet SHA-1 hash of the preceding plaintext data of the 2724 Symmetrically Encrypted Integrity Protected Data packet, including 2725 prefix data, the tag octet, and length octet of the Modification 2726 Detection Code packet. 2728 Note that the Modification Detection Code packet MUST always use a 2729 new format encoding of the packet tag, and a one-octet encoding of 2730 the packet length. The reason for this is that the hashing rules for 2731 modification detection include a one-octet tag and one-octet length 2732 in the data hash. While this is a bit restrictive, it reduces 2733 complexity. 2735 6. {6} Radix-64 Conversions 2737 As stated in the introduction, OpenPGP's underlying native 2738 representation for objects is a stream of arbitrary octets, and some 2739 systems desire these objects to be immune to damage caused by 2740 character set translation, data conversions, etc. 2742 In principle, any printable encoding scheme that met the requirements 2743 of the unsafe channel would suffice, since it would not change the 2744 underlying binary bit streams of the native OpenPGP data structures. 2745 The OpenPGP standard specifies one such printable encoding scheme to 2746 ensure interoperability. 2748 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2749 encoding of the binary data and a checksum. The base64 encoding is 2750 identical to the MIME base64 content-transfer-encoding [RFC2045]. 2752 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 2753 four characters of radix-64 encoding by the same MIME base64 2754 transformation, preceded by an equal sign (=). The CRC is computed 2755 by using the generator 0x864CFB and an initialization of 0xB704CE. 2756 The accumulation is done on the data before it is converted to radix- 2757 64, rather than on the converted data. A sample implementation of 2758 this algorithm is in the next section. 2760 The checksum with its leading equal sign MAY appear on the first line 2761 after the base64 encoded data. 2763 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2764 base64. The nonzero initialization can detect more errors than a 2765 zero initialization. 2767 6.1. {6.1} An Implementation of the CRC-24 in "C" 2769 2770 #define CRC24_INIT 0xB704CEL 2771 #define CRC24_POLY 0x1864CFBL 2773 typedef long crc24; 2774 crc24 crc_octets(unsigned char *octets, size_t len) 2775 { 2776 crc24 crc = CRC24_INIT; 2777 int i; 2778 while (len--) { 2779 crc ^= (*octets++) << 16; 2780 for (i = 0; i < 8; i++) { 2781 crc <<= 1; 2782 if (crc & 0x1000000) 2783 crc ^= CRC24_POLY; 2784 } 2785 } 2786 return crc & 0xFFFFFFL; 2787 } 2788 2790 6.2. {6.2} Forming ASCII Armor 2792 When OpenPGP encodes data into ASCII Armor, it puts specific headers 2793 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 2794 later. An OpenPGP implementation MAY use ASCII armor to protect raw 2795 binary data. OpenPGP informs the user what kind of data is encoded 2796 in the ASCII armor through the use of the headers. 2798 Concatenating the following data creates ASCII Armor: 2800 o An Armor Header Line, appropriate for the type of data 2802 o Armor Headers 2804 o A blank (zero-length, or containing only whitespace) line 2806 o The ASCII-Armored data 2808 o An Armor Checksum 2810 o The Armor Tail, which depends on the Armor Header Line 2812 An Armor Header Line consists of the appropriate header line text 2813 surrounded by five (5) dashes ('-', 0x2D) on either side of the 2814 header line text. The header line text is chosen based upon the type 2815 of data that is being encoded in Armor, and how it is being encoded. 2816 Header line texts include the following strings: 2818 BEGIN PGP MESSAGE Used for signed, encrypted, or compressed files. 2820 BEGIN PGP PUBLIC KEY BLOCK Used for armoring public keys. 2822 BEGIN PGP PRIVATE KEY BLOCK Used for armoring private keys. 2824 BEGIN PGP MESSAGE, PART X/Y Used for multi-part messages, where the 2825 armor is split amongst Y parts, and this is the Xth part out of Y. 2827 BEGIN PGP MESSAGE, PART X Used for multi-part messages, where this 2828 is the Xth part of an unspecified number of parts. Requires the 2829 MESSAGE-ID Armor Header to be used. 2831 BEGIN PGP SIGNATURE Used for detached signatures, OpenPGP/MIME 2832 signatures, and cleartext signatures. Note that PGP 2.x uses 2833 BEGIN PGP MESSAGE for detached signatures. 2835 Note that all these Armor Header Lines are to consist of a complete 2836 line. That is to say, there is always a line ending preceding the 2837 starting five dashes, and following the ending five dashes. The 2838 header lines, therefore, MUST start at the beginning of a line, and 2839 MUST NOT have text other than whitespace following them on the same 2840 line. These line endings are considered a part of the Armor Header 2841 Line for the purposes of determining the content they delimit. This 2842 is particularly important when computing a cleartext signature (see 2843 below). 2845 The Armor Headers are pairs of strings that can give the user or the 2846 receiving OpenPGP implementation some information about how to decode 2847 or use the message. The Armor Headers are a part of the armor, not a 2848 part of the message, and hence are not protected by any signatures 2849 applied to the message. 2851 The format of an Armor Header is that of a key-value pair. A colon 2852 (':' 0x38) and a single space (0x20) separate the key and value. 2853 OpenPGP should consider improperly formatted Armor Headers to be 2854 corruption of the ASCII Armor. Unknown keys should be reported to 2855 the user, but OpenPGP should continue to process the message. 2857 Note that some transport methods are sensitive to line length. While 2858 there is a limit of 76 characters for the Radix-64 data 2859 (Section 6.3), there is no limit to the length of Armor Headers. 2860 Care should be taken that the Armor Headers are short enough to 2861 survive transport. One way to do this is to repeat an Armor Header 2862 key multiple times with different values for each so that no one line 2863 is overly long. 2865 Currently defined Armor Header Keys are as follows: 2867 o "Version", which states the OpenPGP implementation and version 2868 used to encode the message. 2870 o "Comment", a user-defined comment. OpenPGP defines all text to be 2871 in UTF-8. A comment may be any UTF-8 string. However, the whole 2872 point of armoring is to provide seven-bit-clean data. 2873 Consequently, if a comment has characters that are outside the US- 2874 ASCII range of UTF, they may very well not survive transport. 2876 o "Hash", a comma-separated list of hash algorithms used in this 2877 message. This is used only in cleartext signed messages. 2879 o "MessageID", a 32-character string of printable characters. The 2880 string must be the same for all parts of a multi-part message that 2881 uses the "PART X" Armor Header. MessageID strings should be 2882 unique enough that the recipient of the mail can associate all the 2883 parts of a message with each other. A good checksum or 2884 cryptographic hash function is sufficient. 2886 The MessageID SHOULD NOT appear unless it is in a multi-part 2887 message. If it appears at all, it MUST be computed from the 2888 finished (encrypted, signed, etc.) message in a deterministic 2889 fashion, rather than contain a purely random value. This is to 2890 allow the legitimate recipient to determine that the MessageID 2891 cannot serve as a covert means of leaking cryptographic key 2892 information. 2894 o "Charset", a description of the character set that the plaintext 2895 is in. Please note that OpenPGP defines text to be in UTF-8. An 2896 implementation will get best results by translating into and out 2897 of UTF-8. However, there are many instances where this is easier 2898 said than done. Also, there are communities of users who have no 2899 need for UTF-8 because they are all happy with a character set 2900 like ISO Latin-5 or a Japanese character set. In such instances, 2901 an implementation MAY override the UTF-8 default by using this 2902 header key. An implementation MAY implement this key and any 2903 translations it cares to; an implementation MAY ignore it and 2904 assume all text is UTF-8. 2906 The Armor Tail Line is composed in the same manner as the Armor 2907 Header Line, except the string "BEGIN" is replaced by the string 2908 "END". 2910 6.3. {6.3} Encoding Binary in Radix-64 2912 The encoding process represents 24-bit groups of input bits as output 2913 strings of 4 encoded characters. Proceeding from left to right, a 2914 24-bit input group is formed by concatenating three 8-bit input 2915 groups. These 24 bits are then treated as four concatenated 6-bit 2916 groups, each of which is translated into a single digit in the 2917 Radix-64 alphabet. When encoding a bit stream with the Radix-64 2918 encoding, the bit stream must be presumed to be ordered with the most 2919 significant bit first. That is, the first bit in the stream will be 2920 the high-order bit in the first 8-bit octet, and the eighth bit will 2921 be the low-order bit in the first 8-bit octet, and so on. 2923 +--first octet--+-second octet--+--third octet--+ 2924 |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| 2925 +-----------+---+-------+-------+---+-----------+ 2926 |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| 2927 +--1.index--+--2.index--+--3.index--+--4.index--+ 2929 Each 6-bit group is used as an index into an array of 64 printable 2930 characters from the table below. The character referenced by the 2931 index is placed in the output string. 2933 Value Encoding Value Encoding Value Encoding Value Encoding 2934 0 A 17 R 34 i 51 z 2935 1 B 18 S 35 j 52 0 2936 2 C 19 T 36 k 53 1 2937 3 D 20 U 37 l 54 2 2938 4 E 21 V 38 m 55 3 2939 5 F 22 W 39 n 56 4 2940 6 G 23 X 40 o 57 5 2941 7 H 24 Y 41 p 58 6 2942 8 I 25 Z 42 q 59 7 2943 9 J 26 a 43 r 60 8 2944 10 K 27 b 44 s 61 9 2945 11 L 28 c 45 t 62 + 2946 12 M 29 d 46 u 63 / 2947 13 N 30 e 47 v 2948 14 O 31 f 48 w (pad) = 2949 15 P 32 g 49 x 2950 16 Q 33 h 50 y 2952 The encoded output stream must be represented in lines of no more 2953 than 76 characters each. 2955 Special processing is performed if fewer than 24 bits are available 2956 at the end of the data being encoded. There are three possibilities: 2958 1. The last data group has 24 bits (3 octets). No special 2959 processing is needed. 2961 2. The last data group has 16 bits (2 octets). The first two 2962 6-bit groups are processed as above. The third (incomplete) 2963 data group has two zero-value bits added to it, and is 2964 processed as above. A pad character (=) is added to the 2965 output. 2967 3. The last data group has 8 bits (1 octet). The first 6-bit 2968 group is processed as above. The second (incomplete) data 2969 group has four zero-value bits added to it, and is processed 2970 as above. Two pad characters (=) are added to the output. 2972 6.4. {6.4} Decoding Radix-64 2974 In Radix-64 data, characters other than those in the table, line 2975 breaks, and other white space probably indicate a transmission error, 2976 about which a warning message or even a message rejection might be 2977 appropriate under some circumstances. Decoding software must ignore 2978 all white space. 2980 Because it is used only for padding at the end of the data, the 2981 occurrence of any "=" characters may be taken as evidence that the 2982 end of the data has been reached (without truncation in transit). No 2983 such assurance is possible, however, when the number of octets 2984 transmitted was a multiple of three and no "=" characters are 2985 present. 2987 6.5. {6.5} Examples of Radix-64 2988 Input data: 0x14FB9C03D97E 2989 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 2990 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 2991 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 2992 Decimal: 5 15 46 28 0 61 37 62 2993 Output: F P u c A 9 l + 2994 Input data: 0x14FB9C03D9 2995 Hex: 1 4 F B 9 C | 0 3 D 9 2996 8-bit: 00010100 11111011 10011100 | 00000011 11011001 2997 pad with 00 2998 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 2999 Decimal: 5 15 46 28 0 61 36 3000 pad with = 3001 Output: F P u c A 9 k = 3002 Input data: 0x14FB9C03 3003 Hex: 1 4 F B 9 C | 0 3 3004 8-bit: 00010100 11111011 10011100 | 00000011 3005 pad with 0000 3006 6-bit: 000101 001111 101110 011100 | 000000 110000 3007 Decimal: 5 15 46 28 0 48 3008 pad with = = 3009 Output: F P u c A w = = 3011 6.6. {6.6} Example of an ASCII Armored Message 3013 -----BEGIN PGP MESSAGE----- 3014 Version: OpenPrivacy 0.99 3016 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3017 vBSFjNSiVHsuAA== 3018 =njUN 3019 -----END PGP MESSAGE----- 3021 Note that this example has extra indenting; an actual armored message 3022 would have no leading whitespace. 3024 7. {7} Cleartext Signature Framework 3026 It is desirable to be able to sign a textual octet stream without 3027 ASCII armoring the stream itself, so the signed text is still 3028 readable without special software. In order to bind a signature to 3029 such a cleartext, this framework is used. (Note that this framework 3030 is not intended to be reversible. RFC 3156 [RFC3156] defines another 3031 way to sign cleartext messages for environments that support MIME.) 3033 The cleartext signed message consists of: 3035 o The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a 3036 single line, 3038 o One or more "Hash" Armor Headers, 3040 o Exactly one empty line not included into the message digest, 3042 o The dash-escaped cleartext that is included into the message 3043 digest, 3045 o The ASCII armored signature(s) including the '-----BEGIN PGP 3046 SIGNATURE-----' Armor Header and Armor Tail Lines. 3048 If the "Hash" Armor Header is given, the specified message digest 3049 algorithm(s) are used for the signature. If there are no such 3050 headers, MD5 is used. If MD5 is the only hash used, then an 3051 implementation MAY omit this header for improved V2.x compatibility. 3052 If more than one message digest is used in the signature, the "Hash" 3053 armor header contains a comma-delimited list of used message digests. 3055 Current message digest names are described below with the algorithm 3056 IDs. 3058 An implementation SHOULD add a line break after the cleartext, but 3059 MAY omit it if the cleartext ends with a line break. This is for 3060 visual clarity. 3062 7.1. {7.1} Dash-Escaped Text 3064 The cleartext content of the message must also be dash-escaped. 3066 Dash-escaped cleartext is the ordinary cleartext where every line 3067 starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' 3068 (0x2D) and space ' ' (0x20). This prevents the parser from 3069 recognizing armor headers of the cleartext itself. An implementation 3070 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3071 followed by a space, and MUST dash-escape any line commencing in a 3072 dash. The message digest is computed using the cleartext itself, not 3073 the dash-escaped form. 3075 As with binary signatures on text documents, a cleartext signature is 3076 calculated on the text using canonical line endings. The 3077 line ending (i.e., the ) before the '-----BEGIN PGP 3078 SIGNATURE-----' line that terminates the signed text is not 3079 considered part of the signed text. 3081 When reversing dash-escaping, an implementation MUST strip the string 3082 "- " if it occurs at the beginning of a line, and SHOULD warn on "-" 3083 and any character other than a space at the beginning of a line. 3085 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 3086 the end of any line is removed when the cleartext signature is 3087 generated. 3089 8. {8} Regular Expressions 3091 A regular expression is zero or more branches, separated by '|'. It 3092 matches anything that matches one of the branches. 3094 A branch is zero or more pieces, concatenated. It matches a match 3095 for the first, followed by a match for the second, etc. 3097 A piece is an atom possibly followed by '_', '+', or '?'. An atom 3098 followed by '_' matches a sequence of 0 or more matches of the atom. 3099 An atom followed by '+' matches a sequence of 1 or more matches of 3100 the atom. An atom followed by '?' matches a match of the atom, or 3101 the null string. 3103 An atom is a regular expression in parentheses (matching a match for 3104 the regular expression), a range (see below), '.' (matching any 3105 single character), '^' (matching the null string at the beginning of 3106 the input string), '$' (matching the null string at the end of the 3107 input string), a '' followed by a single character (matching that 3108 character), or a single character with no other significance 3109 (matching that character). 3111 A range is a sequence of characters enclosed in '[]'. It normally 3112 matches any single character from the sequence. If the sequence 3113 begins with '^', it matches any single character not from the rest of 3114 the sequence. If two characters in the sequence are separated by 3115 '-', this is shorthand for the full list of ASCII characters between 3116 them (e.g., '[0-9]' matches any decimal digit). To include a literal 3117 ']' in the sequence, make it the first character (following a 3118 possible '^'). To include a literal '-', make it the first or last 3119 character. 3121 9. {9} Constants 3123 This section describes the constants used in OpenPGP. 3125 Note that these tables are not exhaustive lists; an implementation 3126 MAY implement an algorithm not on these lists, so long as the 3127 algorithm numbers are chosen from the private or experimental 3128 algorithm range. 3130 See the section "Notes on Algorithms" below for more discussion of 3131 the algorithms. 3133 9.1. {9.1} Public-Key Algorithms 3135 +-----------+----------------------------------------------------+ 3136 | ID | Algorithm | 3137 +-----------+----------------------------------------------------+ 3138 | 1 | RSA (Encrypt or Sign) [HAC] | 3139 | 2 | RSA Encrypt-Only [HAC] | 3140 | 3 | RSA Sign-Only [HAC] | 3141 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3142 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3143 | 18 | ECDH public key algorithm | 3144 | 19 | ECDSA public key algorithm [FIPS186] | 3145 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3146 | 21 | Reserved for Diffie-Hellman | 3147 | | (X9.42, as defined for IETF-S/MIME) | 3148 | 22 | EdDSA [I-D.irtf-cfrg-eddsa] | 3149 | 100--110 | Private/Experimental algorithm | 3150 +-----------+----------------------------------------------------+ 3152 Implementations MUST implement DSA and ECDSA for signatures, and 3153 Elgamal and ECDH for encryption. Implementations SHOULD implement 3154 RSA keys (1). RSA Encrypt-Only (2) and RSA Sign-Only are deprecated 3155 and SHOULD NOT be generated, but may be interpreted. See 3156 Section 13.5. See Section 13.8 for notes on Elgamal Encrypt or Sign 3157 (20), and X9.42 (21). Implementations MAY implement any other 3158 algorithm. 3160 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3161 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this 3162 document. 3164 9.2. ECC Curve OID 3166 The parameter curve OID is an array of octets that define a named 3167 curve. The table below specifies the exact sequence of bytes for 3168 each named curve referenced in this document: 3170 +------------------------+-----+------------------+-----------------+ 3171 | ASN.1 Object | OID | Curve OID bytes | Curve name | 3172 | Identifier | len | in hexadecimal | | 3173 | | | representation | | 3174 +------------------------+-----+------------------+-----------------+ 3175 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | 3176 | | | 03 01 07 | | 3177 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | 3178 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | 3179 | 1.3.36.3.3.2.8.1.1.7 | 9 | 2B 24 03 03 02 | brainpoolP256r1 | 3180 | | | 08 01 01 07 | | 3181 | 1.3.36.3.3.2.8.1.1.13 | 9 | 2B 24 03 03 02 | brainpoolP512r1 | 3182 | | | 08 01 01 0D | | 3183 | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 | Ed25519 | 3184 | | | DA 47 0F 01 | | 3185 | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | 3186 | | | 97 55 01 05 01 | | 3187 +------------------------+-----+------------------+-----------------+ 3189 The sequence of octets in the third column is the result of applying 3190 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3191 with subsequent truncation. The truncation removes the two fields of 3192 encoded Object Identifier. The first omitted field is one octet 3193 representing the Object Identifier tag, and the second omitted field 3194 is the length of the Object Identifier body. For example, the 3195 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3196 86 48 CE 3D 03 01 07", from which the first entry in the table above 3197 is constructed by omitting the first two octets. Only the truncated 3198 sequence of octets is the valid representation of a curve OID. 3200 9.3. {9.2} Symmetric-Key Algorithms 3201 +-----------+-----------------------------------------------+ 3202 | ID | Algorithm | 3203 +-----------+-----------------------------------------------+ 3204 | 0 | Plaintext or unencrypted data | 3205 | 1 | IDEA [IDEA] | 3206 | 2 | TripleDES (DES-EDE, [SCHNEIER] [HAC] | 3207 | | - 168 bit key derived from 192) | 3208 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3209 | 4 | Blowfish (128 bit key, 16 rounds) [BLOWFISH] | 3210 | 5 | Reserved | 3211 | 6 | Reserved | 3212 | 7 | AES with 128-bit key [AES] | 3213 | 8 | AES with 192-bit key | 3214 | 9 | AES with 256-bit key | 3215 | 10 | Twofish with 256-bit key [TWOFISH] | 3216 | 11 | Camellia with 128-bit key [RFC3713] | 3217 | 12 | Camellia with 192-bit key | 3218 | 13 | Camellia with 256-bit key | 3219 | 100--110 | Private/Experimental algorithm | 3220 +-----------+-----------------------------------------------+ 3222 Implementations MUST implement TripleDES. Implementations SHOULD 3223 implement AES-128 and CAST5. Implementations that interoperate with 3224 PGP 2.6 or earlier need to support IDEA, as that is the only 3225 symmetric cipher those versions use. Implementations MAY implement 3226 any other algorithm. 3228 9.4. {9.3} Compression Algorithms 3230 +-----------+---------------------------------+ 3231 | ID | Algorithm | 3232 +-----------+---------------------------------+ 3233 | 0 | Uncompressed | 3234 | 1 | ZIP [RFC1951] | 3235 | 2 | ZLIB [RFC1950] | 3236 | 3 | BZip2 [BZ2] | 3237 | 100--110 | Private/Experimental algorithm | 3238 +-----------+---------------------------------+ 3240 Implementations MUST implement uncompressed data. Implementations 3241 SHOULD implement ZIP. Implementations MAY implement any other 3242 algorithm. 3244 9.5. {9.4} Hash Algorithms 3245 +-----------+---------------------------------+--------------+ 3246 | ID | Algorithm | Text Name | 3247 +-----------+---------------------------------+--------------+ 3248 | 1 | MD5 [HAC] | "MD5" | 3249 | 2 | SHA-1 [FIPS180] | "SHA1" | 3250 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3251 | 4 | Reserved | | 3252 | 5 | Reserved | | 3253 | 6 | Reserved | | 3254 | 7 | Reserved | | 3255 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3256 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3257 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3258 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3259 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3260 | 13 | Reserved | | 3261 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3262 | 100--110 | Private/Experimental algorithm | | 3263 +-----------+---------------------------------+--------------+ 3265 Implementations MUST implement SHA2-256. Implementations MAY 3266 implement other algorithms. Implementations SHOULD NOT create 3267 messages which require the use of SHA-1 with the exception of 3268 computing version 4 key fingerprints and for purposes of the MDC 3269 packet. Implementations SHOULD NOT use MD5 or RIPE-MD/160. 3271 10. {10} IANA Considerations 3273 OpenPGP is highly parameterized, and consequently there are a number 3274 of considerations for allocating parameters for extensions. This 3275 section describes how IANA should look at extensions to the protocol 3276 as described in this document. 3278 10.1. {10.1} New String-to-Key Specifier Types 3280 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3281 a string into a key. This specification creates a registry of S2K 3282 specifier types. The registry includes the S2K type, the name of the 3283 S2K, and a reference to the defining specification. The initial 3284 values for this registry can be found in Section 3.7.1. Adding a new 3285 S2K specifier MUST be done through the IETF CONSENSUS method, as 3286 described in [RFC2434]. 3288 10.2. {10.2} New Packets 3290 Major new features of OpenPGP are defined through new packet types. 3291 This specification creates a registry of packet types. The registry 3292 includes the packet type, the name of the packet, and a reference to 3293 the defining specification. The initial values for this registry can 3294 be found in Section 4.3. Adding a new packet type MUST be done 3295 through the IETF CONSENSUS method, as described in [RFC2434]. 3297 10.2.1. {10.2.1} User Attribute Types 3299 The User Attribute packet permits an extensible mechanism for other 3300 types of certificate identification. This specification creates a 3301 registry of User Attribute types. The registry includes the User 3302 Attribute type, the name of the User Attribute, and a reference to 3303 the defining specification. The initial values for this registry can 3304 be found in Section 5.12. Adding a new User Attribute type MUST be 3305 done through the IETF CONSENSUS method, as described in [RFC2434]. 3307 This document requests that IANA register the User ID Attribute Type 3308 found in Section 5.12.2: 3310 +--------+------------+-----------------------------+ 3311 | Value | Attribute | Reference | 3312 +--------+------------+-----------------------------+ 3313 | TBD1 | User ID | This Document Section 5.12 | 3314 +--------+------------+-----------------------------+ 3316 10.2.2. {10.2.1.1} Image Format Subpacket Types 3318 Within User Attribute packets, there is an extensible mechanism for 3319 other types of image-based user attributes. This specification 3320 creates a registry of Image Attribute subpacket types. The registry 3321 includes the Image Attribute subpacket type, the name of the Image 3322 Attribute subpacket, and a reference to the defining specification. 3323 The initial values for this registry can be found in Section 5.12.1. 3324 Adding a new Image Attribute subpacket type MUST be done through the 3325 IETF CONSENSUS method, as described in [RFC2434]. 3327 10.2.3. {10.2.2} New Signature Subpackets 3329 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3330 to be added to them for a variety of purposes in the Signature 3331 subpackets as discussed in Section 5.2.3.1. This specification 3332 creates a registry of Signature subpacket types. The registry 3333 includes the Signature subpacket type, the name of the subpacket, and 3334 a reference to the defining specification. The initial values for 3335 this registry can be found in Section 5.2.3.1. Adding a new 3336 Signature subpacket MUST be done through the IETF CONSENSUS method, 3337 as described in [RFC2434]. 3339 10.2.3.1. {10.2.2.1} Signature Notation Data Subpackets 3341 OpenPGP signatures further contain a mechanism for extensions in 3342 signatures. These are the Notation Data subpackets, which contain a 3343 key/value pair. Notations contain a user space that is completely 3344 unmanaged and an IETF space. 3346 This specification creates a registry of Signature Notation Data 3347 types. The registry includes the Signature Notation Data type, the 3348 name of the Signature Notation Data, its allowed values, and a 3349 reference to the defining specification. The initial values for this 3350 registry can be found in Section 5.2.3.16. Adding a new Signature 3351 Notation Data subpacket MUST be done through the EXPERT REVIEW 3352 method, as described in [RFC2434]. 3354 This document requests IANA register the following Signature Notation 3355 Data types: 3357 +---------------+--------+--------------------+---------------------+ 3358 | Allowed | Name | Type | Reference | 3359 | Values | | | | 3360 +---------------+--------+--------------------+---------------------+ 3361 | Any String | manu | Manufacturer Name | This Doc Section | 3362 | | | | 5.2.3.16.1 | 3363 | Any String | make | Product Make | This Doc Section | 3364 | | | | 5.2.3.16.2 | 3365 | Any String | model | Product Model | This Doc Section | 3366 | | | | 5.2.3.16.3 | 3367 | Any String | prodid | Product ID | This Doc Section | 3368 | | | | 5.2.3.16.4 | 3369 | Any String | pvers | Product Version | This Doc Section | 3370 | | | | 5.2.3.16.5 | 3371 | Any String | lot | Product Lot Number | This Doc Section | 3372 | | | | 5.2.3.16.6 | 3373 | Decimal | qty | Package Quantity | This Doc Section | 3374 | Integer | | | 5.2.3.16.7 | 3375 | String | | | | 3376 | A geo: URI | loc | Current Geo- | This Doc Section | 3377 | | | | 5.2.3.16.8 | 3378 | without the | | location | | 3379 | "geo:" | | Latitude/Longitude | | 3380 | A geo: URI | dest | Destination Geo- | This Doc Section | 3381 | | | | 5.2.3.16.8 | 3382 | without the | | location | | 3383 | "geo:" | | Latitude/Longitude | | 3384 | Hash Notation | hash | The Hash of | This Doc Section | 3385 | | | | 5.2.3.16.9 | 3386 | data | | external data | | 3387 +---------------+--------+--------------------+---------------------+ 3389 10.2.3.2. {10.2.2.2} Key Server Preference Extensions 3391 OpenPGP signatures contain a mechanism for preferences to be 3392 specified about key servers. This specification creates a registry 3393 of key server preferences. The registry includes the key server 3394 preference, the name of the preference, and a reference to the 3395 defining specification. The initial values for this registry can be 3396 found in Section 5.2.3.17. Adding a new key server preference MUST 3397 be done through the IETF CONSENSUS method, as described in [RFC2434]. 3399 10.2.3.3. {10.2.2.3} Key Flags Extensions 3401 OpenPGP signatures contain a mechanism for flags to be specified 3402 about key usage. This specification creates a registry of key usage 3403 flags. The registry includes the key flags value, the name of the 3404 flag, and a reference to the defining specification. The initial 3405 values for this registry can be found in Section 5.2.3.21. Adding a 3406 new key usage flag MUST be done through the IETF CONSENSUS method, as 3407 described in [RFC2434]. 3409 10.2.3.4. {10.2.2.4} Reason for Revocation Extensions 3411 OpenPGP signatures contain a mechanism for flags to be specified 3412 about why a key was revoked. This specification creates a registry 3413 of "Reason for Revocation" flags. The registry includes the "Reason 3414 for Revocation" flags value, the name of the flag, and a reference to 3415 the defining specification. The initial values for this registry can 3416 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3417 through the IETF CONSENSUS method, as described in [RFC2434]. 3419 10.2.3.5. {10.2.2.5} Implementation Features 3421 OpenPGP signatures contain a mechanism for flags to be specified 3422 stating which optional features an implementation supports. This 3423 specification creates a registry of feature-implementation flags. 3424 The registry includes the feature-implementation flags value, the 3425 name of the flag, and a reference to the defining specification. The 3426 initial values for this registry can be found in Section 5.2.3.24. 3427 Adding a new feature-implementation flag MUST be done through the 3428 IETF CONSENSUS method, as described in [RFC2434]. 3430 Also see Section 13.12 for more information about when feature flags 3431 are needed. 3433 10.2.4. {10.2.3} New Packet Versions 3435 The core OpenPGP packets all have version numbers, and can be revised 3436 by introducing a new version of an existing packet. This 3437 specification creates a registry of packet types. The registry 3438 includes the packet type, the number of the version, and a reference 3439 to the defining specification. The initial values for this registry 3440 can be found in Section 5. Adding a new packet version MUST be done 3441 through the IETF CONSENSUS method, as described in [RFC2434]. 3443 10.3. {10.3} New Algorithms 3445 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3446 new algorithm is usually simple. For example, adding in a new 3447 symmetric cipher usually would not need anything more than allocating 3448 a constant for that cipher. If that cipher had other than a 64-bit 3449 or 128-bit block size, there might need to be additional 3450 documentation describing how OpenPGP-CFB mode would be adjusted. 3451 Similarly, when DSA was expanded from a maximum of 1024-bit public 3452 keys to 3072-bit public keys, the revision of FIPS 186 contained 3453 enough information itself to allow implementation. Changes to this 3454 document were made mainly for emphasis. 3456 10.3.1. {10.3.1} Public-Key Algorithms 3458 OpenPGP specifies a number of public-key algorithms. This 3459 specification creates a registry of public-key algorithm identifiers. 3460 The registry includes the algorithm name, its key sizes and 3461 parameters, and a reference to the defining specification. The 3462 initial values for this registry can be found in Section 9. Adding a 3463 new public-key algorithm MUST be done through the IETF CONSENSUS 3464 method, as described in [RFC2434]. 3466 This document requests IANA register the following public-key 3467 algorithm: 3469 +-----+-----------------------------+------------+ 3470 | ID | Algorithm | Reference | 3471 +-----+-----------------------------+------------+ 3472 | 22 | EdDSA public key algorithm | This doc | 3473 +-----+-----------------------------+------------+ 3475 [Notes to RFC-Editor: Please remove the table above on publication. 3476 It is desirable not to reuse old or reserved algorithms because some 3477 existing tools might print a wrong description. A higher number is 3478 also an indication for a newer algorithm. As of now 22 is the next 3479 free number.] 3481 10.3.2. {10.3.2} Symmetric-Key Algorithms 3483 OpenPGP specifies a number of symmetric-key algorithms. This 3484 specification creates a registry of symmetric-key algorithm 3485 identifiers. The registry includes the algorithm name, its key sizes 3486 and block size, and a reference to the defining specification. The 3487 initial values for this registry can be found in Section 9. Adding a 3488 new symmetric-key algorithm MUST be done through the IETF CONSENSUS 3489 method, as described in [RFC2434]. 3491 10.3.3. {10.3.3} Hash Algorithms 3493 OpenPGP specifies a number of hash algorithms. This specification 3494 creates a registry of hash algorithm identifiers. The registry 3495 includes the algorithm name, a text representation of that name, its 3496 block size, an OID hash prefix, and a reference to the defining 3497 specification. The initial values for this registry can be found in 3498 Section 9 for the algorithm identifiers and text names, and 3499 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3500 new hash algorithm MUST be done through the IETF CONSENSUS method, as 3501 described in [RFC2434]. 3503 This document requests IANA register the following hash algorithms: 3505 +-----+------------+------------+ 3506 | ID | Algorithm | Reference | 3507 +-----+------------+------------+ 3508 | 12 | SHA3-256 | This doc | 3509 | 13 | Reserved | | 3510 | 14 | SHA3-512 | This doc | 3511 +-----+------------+------------+ 3513 [Notes to RFC-Editor: Please remove the table above on publication. 3514 It is desirable not to reuse old or reserved algorithms because some 3515 existing tools might print a wrong description. The ID 13 has been 3516 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 3517 counterparts.] 3519 10.3.4. {10.3.4} Compression Algorithms 3521 OpenPGP specifies a number of compression algorithms. This 3522 specification creates a registry of compression algorithm 3523 identifiers. The registry includes the algorithm name and a 3524 reference to the defining specification. The initial values for this 3525 registry can be found in Section 9.3. Adding a new compression key 3526 algorithm MUST be done through the IETF CONSENSUS method, as 3527 described in [RFC2434]. 3529 11. {11} Packet Composition 3531 OpenPGP packets are assembled into sequences in order to create 3532 messages and to transfer keys. Not all possible packet sequences are 3533 meaningful and correct. This section describes the rules for how 3534 packets should be placed into sequences. 3536 11.1. {11.1} Transferable Public Keys 3538 OpenPGP users may transfer public keys. The essential elements of a 3539 transferable public key are as follows: 3541 o One Public-Key packet 3543 o Zero or more revocation signatures 3545 o Zero or more User ID packets 3546 o After each User ID packet, zero or more Signature packets 3547 (certifications) 3549 o Zero or more User Attribute packets 3551 o After each User Attribute packet, zero or more Signature packets 3552 (certifications) 3554 o Zero or more Subkey packets 3556 o After each Subkey packet, one Signature packet, plus optionally a 3557 revocation 3559 The Public-Key packet occurs first. Each of the following User ID 3560 packets provides the identity of the owner of this public key. If 3561 there are multiple User ID packets, this corresponds to multiple 3562 means of identifying the same unique individual user; for example, a 3563 user may have more than one email address, and construct a User ID 3564 for each one. 3566 Immediately following each User ID packet, there are zero or more 3567 Signature packets. Each Signature packet is calculated on the 3568 immediately preceding User ID packet and the initial Public-Key 3569 packet. The signature serves to certify the corresponding public key 3570 and User ID. In effect, the signer is testifying to his or her 3571 belief that this public key belongs to the user identified by this 3572 User ID. 3574 Within the same section as the User ID packets, there are zero or 3575 more User Attribute packets. Like the User ID packets, a User 3576 Attribute packet is followed by zero or more Signature packets 3577 calculated on the immediately preceding User Attribute packet and the 3578 initial Public-Key packet. 3580 User Attribute packets and User ID packets may be freely intermixed 3581 in this section, so long as the signatures that follow them are 3582 maintained on the proper User Attribute or User ID packet. 3584 After the User ID packet or Attribute packet, there may be zero or 3585 more Subkey packets. In general, subkeys are provided in cases where 3586 the top-level public key is a signature-only key. However, any V4 3587 key may have subkeys, and the subkeys may be encryption-only keys, 3588 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3589 subkeys. 3591 Each Subkey packet MUST be followed by one Signature packet, which 3592 should be a subkey binding signature issued by the top-level key. 3593 For subkeys that can issue signatures, the subkey binding signature 3594 MUST contain an Embedded Signature subpacket with a primary key 3595 binding signature (0x19) issued by the subkey on the top-level key. 3597 Subkey and Key packets may each be followed by a revocation Signature 3598 packet to indicate that the key is revoked. Revocation signatures 3599 are only accepted if they are issued by the key itself, or by a key 3600 that is authorized to issue revocations via a Revocation Key 3601 subpacket in a self-signature by the top-level key. 3603 Transferable public-key packet sequences may be concatenated to allow 3604 transferring multiple public keys in one operation. 3606 11.2. {11.2} Transferable Secret Keys 3608 OpenPGP users may transfer secret keys. The format of a transferable 3609 secret key is the same as a transferable public key except that 3610 secret-key and secret-subkey packets are used instead of the public 3611 key and public-subkey packets. Implementations SHOULD include self- 3612 signatures on any user IDs and subkeys, as this allows for a complete 3613 public key to be automatically extracted from the transferable secret 3614 key. Implementations MAY choose to omit the self-signatures, 3615 especially if a transferable public key accompanies the transferable 3616 secret key. 3618 11.3. {11.3} OpenPGP Messages 3620 An OpenPGP message is a packet or sequence of packets that 3621 corresponds to the following grammatical rules (comma represents 3622 sequential composition, and vertical bar separates alternatives): 3624 OpenPGP Message :- Encrypted Message | Signed Message | 3625 Compressed Message | Literal Message. 3627 Compressed Message :- Compressed Data Packet. 3629 Literal Message :- Literal Data Packet. 3631 ESK :- Public-Key Encrypted Session Key Packet | 3632 Symmetric-Key Encrypted Session Key Packet. 3634 ESK Sequence :- ESK | ESK Sequence, ESK. 3636 Encrypted Data :- Symmetrically Encrypted Data Packet | 3637 Symmetrically Encrypted Integrity Protected Data Packet 3639 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3641 One-Pass Signed Message :- One-Pass Signature Packet, 3642 OpenPGP Message, Corresponding Signature Packet. 3644 Signed Message :- Signature Packet, OpenPGP Message | 3645 One-Pass Signed Message. 3647 In addition, decrypting a Symmetrically Encrypted Data packet or a 3648 Symmetrically Encrypted Integrity Protected Data packet as well as 3649 decompressing a Compressed Data packet must yield a valid OpenPGP 3650 Message. 3652 11.4. {11.4} Detached Signatures 3654 Some OpenPGP applications use so-called "detached signatures". For 3655 example, a program bundle may contain a file, and with it a second 3656 file that is a detached signature of the first file. These detached 3657 signatures are simply a Signature packet stored separately from the 3658 data for which they are a signature. 3660 12. {12} Enhanced Key Formats 3662 12.1. {12.1} Key Structures 3664 The format of an OpenPGP V3 key is as follows. Entries in square 3665 brackets are optional and ellipses indicate repetition. 3667 RSA Public Key 3668 [Revocation Self Signature] 3669 User ID [Signature ...] 3670 [User ID [Signature ...] ...] 3672 Each signature certifies the RSA public key and the preceding User 3673 ID. The RSA public key can have many User IDs and each User ID can 3674 have many signatures. V3 keys are deprecated. Implementations MUST 3675 NOT generate new V3 keys, but MAY continue to use existing ones. 3677 The format of an OpenPGP V4 key that uses multiple public keys is 3678 similar except that the other keys are added to the end as "subkeys" 3679 of the primary key. 3681 Primary-Key 3682 [Revocation Self Signature] 3683 [Direct Key Signature...] 3684 [User ID [Signature ...] ...] 3685 [User Attribute [Signature ...] ...] 3686 [[Subkey [Binding-Signature-Revocation] 3687 Primary-Key-Binding-Signature] ...] 3689 A subkey always has a single signature after it that is issued using 3690 the primary key to tie the two keys together. This binding signature 3691 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3692 issue signatures MUST have a V4 binding signature due to the REQUIRED 3693 embedded primary key binding signature. 3695 In the above diagram, if the binding signature of a subkey has been 3696 revoked, the revoked key may be removed, leaving only one key. 3698 In a V4 key, the primary key SHOULD be a key capable of 3699 certification. There are cases, such as device certificates, where 3700 the primary key may not be capable of certification. A primary key 3701 capable of making signatures SHOULD be accompanied by either a 3702 certification signature (on a User ID or User Attribute) or a 3703 signature directly on the key. 3705 Implementations SHOULD accept encryption-only primary keys without a 3706 signature. It also SHOULD allow importing any key accompanied either 3707 by a certification signature or a signature on itself. It MAY accept 3708 signature-capable primary keys without an accompanying signature. 3710 The subkeys may be keys of any other type. There may be other 3711 constructions of V4 keys, too. For example, there may be a single- 3712 key RSA key in V4 format, a DSA primary key with an RSA encryption 3713 key, or RSA primary key with an Elgamal subkey, etc. 3715 It is also possible to have a signature-only subkey. This permits a 3716 primary key that collects certifications (key signatures), but is 3717 used only for certifying subkeys that are used for encryption and 3718 signatures. 3720 12.2. {12.2} Key IDs and Fingerprints 3722 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3723 the public modulus of the RSA key. 3725 The fingerprint of a V3 key is formed by hashing the body (but not 3726 the two-octet length) of the MPIs that form the key material (public 3727 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3728 and MD5 are deprecated. 3730 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3731 followed by the two-octet packet length, followed by the entire 3732 Public-Key packet starting with the version field. The Key ID is the 3733 low-order 64 bits of the fingerprint. Here are the fields of the 3734 hash material, with the example of a DSA key: 3736 a.1) 0x99 (1 octet) 3738 a.2) two-octet scalar octet count of (b)-(e) 3740 b) version number = 4 (1 octet); 3742 c) timestamp of key creation (4 octets); 3744 d) algorithm (1 octet): 17 = DSA (example); 3746 e) Algorithm-specific fields. 3748 Algorithm-Specific Fields for DSA keys (example): 3750 e.1) MPI of DSA prime p; 3752 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 3754 e.3) MPI of DSA group generator g; 3756 e.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 3758 A V5 fingerprint is the 256-bit SHA2-256 hash of the octet 0x99, 3759 followed by the four-octet packet length, followed by the entire 3760 Public-Key packet starting with the version field. The Key ID is the 3761 high-order 64 bits of the fingerprint. Here are the fields of the 3762 hash material, with the example of a DSA key: 3764 a.1) 0x9A (1 octet) 3766 a.2) four-octet scalar octet count of (b)-(f) 3768 b) version number = 5 (1 octet); 3770 c) timestamp of key creation (4 octets); 3772 d) algorithm (1 octet): 17 = DSA (example); 3774 e) four-octet scalar octet count for the following key material; 3776 f) algorithm-specific fields. 3778 Algorithm-Specific Fields for DSA keys (example): 3780 f.1) MPI of DSA prime p; 3782 f.2) MPI of DSA group order q (q is a prime divisor of p-1); 3784 f.3) MPI of DSA group generator g; 3786 f.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 3788 Note that it is possible for there to be collisions of Key IDs -- two 3789 different keys with the same Key ID. Note that there is a much 3790 smaller, but still non-zero, probability that two different keys have 3791 the same fingerprint. 3793 Also note that if V3, V4, and V5 format keys share the same RSA key 3794 material, they will have different Key IDs as well as different 3795 fingerprints. 3797 Finally, the Key ID and fingerprint of a subkey are calculated in the 3798 same way as for a primary key, including the 0x99 (V3 and V4 key) or 3799 0x9A (V5 key) as the first octet (even though this is not a valid 3800 packet ID for a public subkey). 3802 13. Elliptic Curve Cryptography 3804 This section descripes algorithms and parameters used with Elliptic 3805 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 3806 found in [KOBLITZ]. 3808 13.1. Supported ECC Curves 3810 This document references five named prime field curves, defined in 3811 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521"; and 3812 defined in [RFC5639] as "brainpoolP256r1", and "brainpoolP512r1". 3813 Further curve "Ed25519", defined in [I-D.irtf-cfrg-eddsa] is 3814 referenced for use with the EdDSA algorithm. 3816 The named curves are referenced as a sequence of bytes in this 3817 document, called throughout, curve OID. Section 9.2 describes in 3818 detail how this sequence of bytes is formed. 3820 13.2. ECDSA and ECDH Conversion Primitives 3822 This document only defines the uncompressed point format for ECDSA 3823 and ECDH. The point is encoded in the Multiprecision Integer (MPI) 3824 format. The content of the MPI is the following: 3826 B = 04 || x || y 3828 where x and y are coordinates of the point P = (x, y), each encoded 3829 in the big-endian format and zero-padded to the adjusted underlying 3830 field size. The adjusted underlying field size is the underlying 3831 field size that is rounded up to the nearest 8-bit boundary. 3833 Therefore, the exact size of the MPI payload is 515 bits for "Curve 3834 P-256", 771 for "Curve P-384", and 1059 for "Curve P-521". 3836 Even though the zero point, also called the point at infinity, may 3837 occur as a result of arithmetic operations on points of an elliptic 3838 curve, it SHALL NOT appear in data structures defined in this 3839 document. 3841 This encoding is compatible with the definition given in [SEC1]. 3843 If other conversion methods are defined in the future, a compliant 3844 application MUST NOT use a new format when in doubt that any 3845 recipient can support it. Consider, for example, that while both the 3846 public key and the per-recipient ECDH data structure, respectively 3847 defined in Sections 9{FIXME} and 10{FIXME}, contain an encoded point 3848 field, the format changes to the field in Section 10{FIXME} only 3849 affect a given recipient of a given message. 3851 13.3. EdDSA Point Format 3853 The EdDSA algorithm defines a specific point compression format. To 3854 indicate the use of this compression format and to make sure that the 3855 key can be represented in the Multiprecision Integer (MPI) format the 3856 octet string specifying the point is prefixed with the octet 0x40. 3857 This encoding is an extension of the encoding given in [SEC1] which 3858 uses 0x04 to indicate an uncompressed point. 3860 For example, the length of a public key for the curve Ed25519 is 263 3861 bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the 3862 native value of the public key. 3864 13.4. Key Derivation Function 3866 A key derivation function (KDF) is necessary to implement the EC 3867 encryption. The Concatenation Key Derivation Function (Approved 3868 Alternative 1) [SP800-56A] with the KDF hash function that is 3869 SHA2-256 [FIPS180] or stronger is REQUIRED. See Section 12{FIXME} 3870 for the details regarding the choice of the hash function. 3872 For convenience, the synopsis of the encoding method is given below 3873 with significant simplifications attributable to the restricted 3874 choice of hash functions in this document. However, [SP800-56A] is 3875 the normative source of the definition. 3877 // Implements KDF( X, oBits, Param ); 3878 // Input: point X = (x,y) 3879 // oBits - the desired size of output 3880 // hBits - the size of output of hash function Hash 3881 // Param - octets representing the parameters 3882 // Assumes that oBits <= hBits 3883 // Convert the point X to the octet string, see section 6{FIXME}: 3884 // ZB' = 04 || x || y 3885 // and extract the x portion from ZB' 3886 ZB = x; 3887 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 3888 return oBits leftmost bits of MB. 3890 Note that ZB in the KDF description above is the compact 3891 representation of X, defined in Section 4.2 of [RFC6090]. 3893 13.5. EC DH Algorithm (ECDH) 3895 The method is a combination of an ECC Diffie-Hellman method to 3896 establish a shared secret, a key derivation method to process the 3897 shared secret into a derived key, and a key wrapping method that uses 3898 the derived key to protect a session key used to encrypt a message. 3900 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 3901 be implemented with the following restrictions: the ECC CDH primitive 3902 employed by this method is modified to always assume the cofactor as 3903 1, the KDF specified in Section 7 is used, and the KDF parameters 3904 specified below are used. 3906 The KDF parameters are encoded as a concatenation of the following 5 3907 variable-length and fixed-length fields, compatible with the 3908 definition of the OtherInfo bitstring [SP800-56A]: 3910 o a variable-length field containing a curve OID, formatted as 3911 follows: 3913 * a one-octet size of the following field 3915 * the octets representing a curve OID, defined in Section 11 3917 o a one-octet public key algorithm ID defined in Section 5 3919 o a variable-length field containing KDF parameters, identical to 3920 the corresponding field in the ECDH public key, formatted as 3921 follows: 3923 * a one-octet size of the following fields; values 0 and 0xff are 3924 reserved for future extensions 3926 * a one-octet value 01, reserved for future extensions 3928 * a one-octet hash function ID used with the KDF 3930 * a one-octet algorithm ID for the symmetric algorithm used to 3931 wrap the symmetric key for message encryption; see Section 8 3932 for details 3934 o 20 octets representing the UTF-8 encoding of the string "Anonymous 3935 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 73 3936 20 53 65 6E 64 65 72 20 20 20 20 3938 o 20 octets representing a recipient encryption subkey or a master 3939 key fingerprint, identifying the key material that is needed for 3940 the decryption. For version 5 keys the 20 leftmost octets of the 3941 fingerprint are used. 3943 The size of the KDF parameters sequence, defined above, is either 54 3944 for the NIST curve P-256 or 51 for the curves P-384 and P-521. 3946 The key wrapping method is described in [RFC3394]. KDF produces a 3947 symmetric key that is used as a key-encryption key (KEK) as specified 3948 in [RFC3394]. Refer to Section 13{FIXME} for the details regarding 3949 the choice of the KEK algorithm, which SHOULD be one of three AES 3950 algorithms. Key wrapping and unwrapping is performed with the 3951 default initial value of [RFC3394]. 3953 The input to the key wrapping method is the value "m" derived from 3954 the session key, as described in Section 5.1{FIXME}, "Public-Key 3955 Encrypted Session Key Packets (Tag 1)", except that the PKCS #1.5 3956 padding step is omitted. The result is padded using the method 3957 described in [PKCS5] to the 8-byte granularity. For example, the 3958 following AES-256 session key, in which 32 octets are denoted from k0 3959 to k31, is composed to form the following 40 octet sequence: 3961 09 k0 k1 ... k31 c0 c1 05 05 05 05 05 3963 The octets c0 and c1 above denote the checksum. This encoding allows 3964 the sender to obfuscate the size of the symmetric encryption key used 3965 to encrypt the data. For example, assuming that an AES algorithm is 3966 used for the session key, the sender MAY use 21, 13, and 5 bytes of 3967 padding for AES-128, AES-192, and AES-256, respectively, to provide 3968 the same number of octets, 40 total, as an input to the key wrapping 3969 method. 3971 The output of the method consists of two fields. The first field is 3972 the MPI containing the ephemeral key used to establish the shared 3973 secret. The second field is composed of the following two fields: 3975 o a one-octet encoding the size in octets of the result of the key 3976 wrapping method; the value 255 is reserved for future extensions; 3978 o up to 254 octets representing the result of the key wrapping 3979 method, applied to the 8-byte padded session key, as described 3980 above. 3982 Note that for session key sizes 128, 192, and 256 bits, the size of 3983 the result of the key wrapping method is, respectively, 32, 40, and 3984 48 octets, unless the size obfuscation is used. 3986 For convenience, the synopsis of the encoding method is given below; 3987 however, this section, [SP800-56A], and [RFC3394] are the normative 3988 sources of the definition. 3990 Obtain the authenticated recipient public key R 3991 Generate an ephemeral key pair {v, V=vG} 3992 Compute the shared point S = vR; 3993 m = symm_alg_ID || session key || checksum || pkcs5_padding; 3994 curve_OID_len = (byte)len(curve_OID); 3995 Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 3996 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 3997 Sender " || recipient_fingerprint; 3998 Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 3999 Compute Z = KDF( S, Z_len, Param ); 4000 Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4001 VB = convert point V to the octet string 4002 Output (MPI(VB) || len(C) || C). 4004 The decryption is the inverse of the method given. Note that the 4005 recipient obtains the shared secret by calculating 4007 S = rV = rvG, where (r,R) is the recipient's key pair. 4009 Consistent with Section 5.13{FIXME}, "Sym. Encrypted Integrity 4010 Protected Data Packet (Tag 18)", a Modification Detection Code (MDC) 4011 MUST be used anytime the symmetric key is protected by ECDH. 4013 14. {13} Notes on Algorithms 4015 14.1. {13.1} PKCS#1 Encoding in OpenPGP 4017 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4018 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4019 has changed in the past. To avoid potential confusion and 4020 interoperability problems, we are including local copies in this 4021 document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447 4022 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4023 Nonetheless, we believe that there is value in having a self- 4024 contained document that avoids problems in the future with needed 4025 changes in the conventions. 4027 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE 4028 Input: 4030 k = the length in octets of the key modulus 4032 M = message to be encoded, an octet string of length mLen, where mLen 4033 \<= k - 11 4035 Output: 4037 EM = encoded message, an octet string of length k 4039 Error: "message too long" 4041 1. Length checking: If mLen > k - 11, output "message too long" 4042 and stop. 4044 2. Generate an octet string PS of length k - mLen - 3 consisting 4045 of pseudo-randomly generated nonzero octets. The length of PS 4046 will be at least eight octets. 4048 3. Concatenate PS, the message M, and other padding to form an 4049 encoded message EM of length k octets as 4051 EM = 0x00 || 0x02 || PS || 0x00 || M. 4053 4. Output EM. 4055 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE 4057 Input: 4059 EM = encoded message, an octet string 4061 Output: 4063 M = message, an octet string 4065 Error: "decryption error" 4067 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4068 into an octet string PS consisting of nonzero octets and a message M 4069 as follows 4071 EM = 0x00 || 0x02 || PS || 0x00 || M. 4073 If the first octet of EM does not have hexadecimal value 0x00, if the 4074 second octet of EM does not have hexadecimal value 0x02, if there is 4075 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4076 length of PS is less than 8 octets, output "decryption error" and 4077 stop. See also the security note in Section 14 regarding differences 4078 in reporting between a decryption error and a padding error. 4080 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 4082 This encoding method is deterministic and only has an encoding 4083 operation. 4085 Option: 4087 Hash - a hash function in which hLen denotes the length in octets 4088 of the hash function output 4090 Input: 4092 M = message to be encoded 4094 emLen = intended length in octets of the encoded message, at least 4095 tLen + 11, where tLen is the octet length of the DER encoding 4096 T of a certain value computed during the encoding operation 4098 Output: 4100 EM = encoded message, an octet string of length emLen 4102 Errors: "message too long"; 4103 "intended encoded message length too short" 4105 Steps: 4107 1. Apply the hash function to the message M to produce a hash 4108 value H: 4110 H = Hash(M). 4112 If the hash function outputs "message too long," output 4113 "message too long" and stop. 4115 2. Using the list in Section 5.2.2, produce an ASN.1 DER value 4116 for the hash function used. Let T be the full hash prefix 4117 from Section 5.2.2, and let tLen be the length in octets of T. 4119 3. If emLen < tLen + 11, output "intended encoded message length 4120 too short" and stop. 4122 4. Generate an octet string PS consisting of emLen - tLen - 3 4123 octets with hexadecimal value 0xFF. The length of PS will be 4124 at least 8 octets. 4126 5. Concatenate PS, the hash prefix T, and other padding to form 4127 the encoded message EM as 4129 EM = 0x00 || 0x01 || PS || 0x00 || T. 4131 6. Output EM. 4133 14.2. {13.2} Symmetric Algorithm Preferences 4135 The symmetric algorithm preference is an ordered list of algorithms 4136 that the keyholder accepts. Since it is found on a self-signature, 4137 it is possible that a keyholder may have multiple, different 4138 preferences. For example, Alice may have TripleDES only specified 4139 for "alice@work.com" but CAST5, Blowfish, and TripleDES specified for 4140 "alice@home.org". Note that it is also possible for preferences to 4141 be in a subkey's binding signature. 4143 Since TripleDES is the MUST-implement algorithm, if it is not 4144 explicitly in the list, it is tacitly at the end. However, it is 4145 good form to place it there explicitly. Note also that if an 4146 implementation does not implement the preference, then it is 4147 implicitly a TripleDES-only implementation. 4149 An implementation MUST NOT use a symmetric algorithm that is not in 4150 the recipient's preference list. When encrypting to more than one 4151 recipient, the implementation finds a suitable algorithm by taking 4152 the intersection of the preferences of the recipients. Note that the 4153 MUST-implement algorithm, TripleDES, ensures that the intersection is 4154 not null. The implementation may use any mechanism to pick an 4155 algorithm in the intersection. 4157 If an implementation can decrypt a message that a keyholder doesn't 4158 have in their preferences, the implementation SHOULD decrypt the 4159 message anyway, but MUST warn the keyholder that the protocol has 4160 been violated. For example, suppose that Alice, above, has software 4161 that implements all algorithms in this specification. Nonetheless, 4162 she prefers subsets for work or home. If she is sent a message 4163 encrypted with IDEA, which is not in her preferences, the software 4164 warns her that someone sent her an IDEA-encrypted message, but it 4165 would ideally decrypt it anyway. 4167 14.3. {13.3} Other Algorithm Preferences 4169 Other algorithm preferences work similarly to the symmetric algorithm 4170 preference, in that they specify which algorithms the keyholder 4171 accepts. There are two interesting cases that other comments need to 4172 be made about, though, the compression preferences and the hash 4173 preferences. 4175 14.3.1. {13.3.1} Compression Preferences 4177 Compression has been an integral part of PGP since its first days. 4178 OpenPGP and all previous versions of PGP have offered compression. 4179 In this specification, the default is for messages to be compressed, 4180 although an implementation is not required to do so. Consequently, 4181 the compression preference gives a way for a keyholder to request 4182 that messages not be compressed, presumably because they are using a 4183 minimal implementation that does not include compression. 4184 Additionally, this gives a keyholder a way to state that it can 4185 support alternate algorithms. 4187 Like the algorithm preferences, an implementation MUST NOT use an 4188 algorithm that is not in the preference vector. If the preferences 4189 are not present, then they are assumed to be [ZIP(1), 4190 Uncompressed(0)]. 4192 Additionally, an implementation MUST implement this preference to the 4193 degree of recognizing when to send an uncompressed message. A robust 4194 implementation would satisfy this requirement by looking at the 4195 recipient's preference and acting accordingly. A minimal 4196 implementation can satisfy this requirement by never generating a 4197 compressed message, since all implementations can handle messages 4198 that have not been compressed. 4200 14.3.2. {13.3.2} Hash Algorithm Preferences 4202 Typically, the choice of a hash algorithm is something the signer 4203 does, rather than the verifier, because a signer rarely knows who is 4204 going to be verifying the signature. This preference, though, allows 4205 a protocol based upon digital signatures ease in negotiation. 4207 Thus, if Alice is authenticating herself to Bob with a signature, it 4208 makes sense for her to use a hash algorithm that Bob's software uses. 4209 This preference allows Bob to state in his key which algorithms Alice 4210 may use. 4212 Since SHA2-256 is the MUST-implement hash algorithm, if it is not 4213 explicitly in the list, it is tacitly at the end. However, it is 4214 good form to place it there explicitly. 4216 14.4. {13.4} Plaintext 4218 Algorithm 0, "plaintext", may only be used to denote secret keys that 4219 are stored in the clear. Implementations MUST NOT use plaintext in 4220 Symmetrically Encrypted Data packets; they must use Literal Data 4221 packets to encode unencrypted or literal data. 4223 14.5. {13.5} RSA 4225 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4226 keys. These types are deprecated. The "key flags" subpacket in a 4227 signature is a much better way to express the same idea, and 4228 generalizes it to all algorithms. An implementation SHOULD NOT 4229 create such a key, but MAY interpret it. 4231 An implementation SHOULD NOT implement RSA keys of size less than 4232 1024 bits. 4234 14.6. {13.6} DSA 4236 An implementation SHOULD NOT implement DSA keys of size less than 4237 1024 bits. It MUST NOT implement a DSA key with a q size of less 4238 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4239 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4240 (DSS) [FIPS186] specifies that DSA be used in one of the following 4241 ways: 4243 o 1024-bit key, 160-bit q, SHA-1, SHA2--224, SHA2-256, SHA2-384, or 4244 SHA2-512 hash 4246 o 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 4247 hash 4249 o 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4251 o 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4253 The above key and q size pairs were chosen to best balance the 4254 strength of the key with the strength of the hash. Implementations 4255 SHOULD use one of the above key and q size pairs when generating DSA 4256 keys. If DSS compliance is desired, one of the specified SHA hashes 4257 must be used as well. [FIPS186] is the ultimate authority on DSS, 4258 and should be consulted for all questions of DSS compliance. 4260 Note that earlier versions of this standard only allowed a 160-bit q 4261 with no truncation allowed, so earlier implementations may not be 4262 able to handle signatures with a different q size or a truncated 4263 hash. 4265 14.7. {13.7} Elgamal 4267 An implementation SHOULD NOT implement Elgamal keys of size less than 4268 1024 bits. 4270 14.8. EdDSA 4272 Although the EdDSA algorithm allows arbitrary data as input, its use 4273 with OpenPGP requires that a digest of the message is used as input 4274 (pre-hashed). See section XXXXX, "Computing Signatures" for details. 4275 Truncation of the resulting digest is never applied; the resulting 4276 digest value is used verbatim as input to the EdDSA algorithm. 4278 14.9. {13.8} Reserved Algorithm Numbers 4280 A number of algorithm IDs have been reserved for algorithms that 4281 would be useful to use in an OpenPGP implementation, yet there are 4282 issues that prevent an implementer from actually implementing the 4283 algorithm. These are marked in Section 9.1, "Public-Key Algorithms", 4284 as "reserved for". 4286 The reserved public-key algorithm X9.42 (21) does not have the 4287 necessary parameters, parameter order, or semantics defined. 4289 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4290 with a public-key identifier of 20. These are no longer permitted. 4291 An implementation MUST NOT generate such keys. An implementation 4292 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4294 14.10. {13.9} OpenPGP CFB Mode 4296 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4297 mode (CFB mode). This section describes the procedure it uses in 4298 detail. This mode is what is used for Symmetrically Encrypted Data 4299 Packets; the mechanism used for encrypting secret-key material is 4300 similar, and is described in the sections above. 4302 In the description below, the value BS is the block size in octets of 4303 the cipher. Most ciphers have a block size of 8 octets. The AES and 4304 Twofish have a block size of 16 octets. Also note that the 4305 description below assumes that the IV and CFB arrays start with an 4306 index of 1 (unlike the C language, which assumes arrays start with a 4307 zero index). 4309 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4310 prefixes the plaintext with BS+2 octets of random data, such that 4311 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4312 resynchronization after encrypting those BS+2 octets. 4314 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4315 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4316 octets 9 and 10. For an algorithm with a block size of 16 octets 4317 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4318 octets 15 and 16. Those extra two octets are an easy check for a 4319 correct key. 4321 Step by step, here is the procedure: 4323 1. The feedback register (FR) is set to the IV, which is all zeros. 4325 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4326 encryption of an all-zero value. 4328 3. FRE is xored with the first BS octets of random data prefixed to 4329 the plaintext to produce C[1] through C[BS], the first BS octets 4330 of ciphertext. 4332 4. FR is loaded with C[1] through C[BS]. 4334 5. FR is encrypted to produce FRE, the encryption of the first BS 4335 octets of ciphertext. 4337 6. The left two octets of FRE get xored with the next two octets of 4338 data that were prefixed to the plaintext. This produces C[BS+1] 4339 and C[BS+2], the next two octets of ciphertext. 4341 7. (The resynchronization step) FR is loaded with C[3] through 4342 C[BS+2]. 4344 8. FRE is xored with the first BS octets of the given plaintext, 4345 now that we have finished encrypting the BS+2 octets of prefixed 4346 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4347 octets of ciphertext. 4349 9. FR is encrypted to produce FRE. 4351 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4352 for an 8-octet block). 4354 11. FR is encrypted to produce FRE. 4356 12. FRE is xored with the next BS octets of plaintext, to produce 4357 the next BS octets of ciphertext. These are loaded into FR, and 4358 the process is repeated until the plaintext is used up. 4360 14.11. {13.10} Private or Experimental Parameters 4362 S2K specifiers, Signature subpacket types, user attribute types, 4363 image format types, and algorithms described in Section 9 all reserve 4364 the range 100 to 110 for private and experimental use. Packet types 4365 reserve the range 60 to 63 for private and experimental use. These 4366 are intentionally managed with the PRIVATE USE method, as described 4367 in [RFC2434]. 4369 However, implementations need to be careful with these and promote 4370 them to full IANA-managed parameters when they grow beyond the 4371 original, limited system. 4373 14.12. {13.11} Extension of the MDC System 4375 As described in the non-normative explanation in Section 5.13, the 4376 MDC system is uniquely unparameterized in OpenPGP. This was an 4377 intentional decision to avoid cross-grade attacks. If the MDC system 4378 is extended to a stronger hash function, care must be taken to avoid 4379 downgrade and cross-grade attacks. 4381 One simple way to do this is to create new packets for a new MDC. 4382 For example, instead of the MDC system using packets 18 and 19, a new 4383 MDC could use 20 and 21. This has obvious drawbacks (it uses two 4384 packet numbers for each new hash function in a space that is limited 4385 to a maximum of 60). 4387 Another simple way to extend the MDC system is to create new versions 4388 of packet 18, and reflect this in packet 19. For example, suppose 4389 that V2 of packet 18 implicitly used SHA2-256. This would require 4390 packet 19 to have a length of 32 octets. The change in the version 4391 in packet 18 and the size of packet 19 prevent a downgrade attack. 4393 There are two drawbacks to this latter approach. The first is that 4394 using the version number of a packet to carry algorithm information 4395 is not tidy from a protocol-design standpoint. It is possible that 4396 there might be several versions of the MDC system in common use, but 4397 this untidiness would reflect untidiness in cryptographic consensus 4398 about hash function security. The second is that different versions 4399 of packet 19 would have to have unique sizes. If there were two 4400 versions each with 256-bit hashes, they could not both have 32-octet 4401 packet 19s without admitting the chance of a cross-grade attack. 4403 Yet another, complex approach to extend the MDC system would be a 4404 hybrid of the two above -- create a new pair of MDC packets that are 4405 fully parameterized, and yet protected from downgrade and cross- 4406 grade. 4408 Any change to the MDC system MUST be done through the IETF CONSENSUS 4409 method, as described in [RFC2434]. 4411 14.13. {13.12} Meta-Considerations for Expansion 4413 If OpenPGP is extended in a way that is not backwards-compatible, 4414 meaning that old implementations will not gracefully handle their 4415 absence of a new feature, the extension proposal can be declared in 4416 the key holder's self-signature as part of the Features signature 4417 subpacket. 4419 We cannot state definitively what extensions will not be upwards- 4420 compatible, but typically new algorithms are upwards-compatible, 4421 whereas new packets are not. 4423 If an extension proposal does not update the Features system, it 4424 SHOULD include an explanation of why this is unnecessary. If the 4425 proposal contains neither an extension to the Features system nor an 4426 explanation of why such an extension is unnecessary, the proposal 4427 SHOULD be rejected. 4429 15. {14} Security Considerations 4431 o As with any technology involving cryptography, you should check 4432 the current literature to determine if any algorithms used here 4433 have been found to be vulnerable to attack. 4435 o This specification uses Public-Key Cryptography technologies. It 4436 is assumed that the private key portion of a public-private key 4437 pair is controlled and secured by the proper party or parties. 4439 o Certain operations in this specification involve the use of random 4440 numbers. An appropriate entropy source should be used to generate 4441 these numbers (see [RFC4086]). 4443 o The MD5 hash algorithm has been found to have weaknesses, with 4444 collisions found in a number of cases. MD5 is deprecated for use 4445 in OpenPGP. Implementations MUST NOT generate new signatures 4446 using MD5 as a hash function. They MAY continue to consider old 4447 signatures that used MD5 as valid. 4449 o SHA2-224 and SHA2-384 require the same work as SHA2-256 and 4450 SHA2-512, respectively. In general, there are few reasons to use 4451 them outside of DSS compatibility. You need a situation where one 4452 needs more security than smaller hashes, but does not want to have 4453 the full 256-bit or 512-bit data length. 4455 o Many security protocol designers think that it is a bad idea to 4456 use a single key for both privacy (encryption) and integrity 4457 (signatures). In fact, this was one of the motivating forces 4458 behind the V4 key format with separate signature and encryption 4459 keys. If you as an implementer promote dual-use keys, you should 4460 at least be aware of this controversy. 4462 o The DSA algorithm will work with any hash, but is sensitive to the 4463 quality of the hash algorithm. Verifiers should be aware that 4464 even if the signer used a strong hash, an attacker could have 4465 modified the signature to use a weak one. Only signatures using 4466 acceptably strong hash algorithms should be accepted as valid. 4468 o As OpenPGP combines many different asymmetric, symmetric, and hash 4469 algorithms, each with different measures of strength, care should 4470 be taken that the weakest element of an OpenPGP message is still 4471 sufficiently strong for the purpose at hand. While consensus 4472 about the strength of a given algorithm may evolve, NIST Special 4473 Publication 800-57 [SP800-57] recommends the following list of 4474 equivalent strengths: 4476 Asymmetric | Hash | Symmetric 4477 key size | size | key size 4478 ------------+--------+----------- 4479 1024 160 80 4480 2048 224 112 4481 3072 256 128 4482 7680 384 192 4483 15360 512 256 4485 o There is a somewhat-related potential security problem in 4486 signatures. If an attacker can find a message that hashes to the 4487 same hash with a different algorithm, a bogus signature structure 4488 can be constructed that evaluates correctly. 4490 For example, suppose Alice DSA signs message M using hash 4491 algorithm H. Suppose that Mallet finds a message M' that has the 4492 same hash value as M with H'. Mallet can then construct a 4493 signature block that verifies as Alice's signature of M' with H'. 4494 However, this would also constitute a weakness in either H or H' 4495 or both. Should this ever occur, a revision will have to be made 4496 to this document to revise the allowed hash algorithms. 4498 o If you are building an authentication system, the recipient may 4499 specify a preferred signing algorithm. However, the signer would 4500 be foolish to use a weak algorithm simply because the recipient 4501 requests it. 4503 o Some of the encryption algorithms mentioned in this document have 4504 been analyzed less than others. For example, although CAST5 is 4505 presently considered strong, it has been analyzed less than 4506 TripleDES. Other algorithms may have other controversies 4507 surrounding them. 4509 o In late summer 2002, Jallad, Katz, and Schneier published an 4510 interesting attack on the OpenPGP protocol and some of its 4511 implementations [JKS02]. In this attack, the attacker modifies a 4512 message and sends it to a user who then returns the erroneously 4513 decrypted message to the attacker. The attacker is thus using the 4514 user as a random oracle, and can often decrypt the message. 4516 Compressing data can ameliorate this attack. The incorrectly 4517 decrypted data nearly always decompresses in ways that defeat the 4518 attack. However, this is not a rigorous fix, and leaves open some 4519 small vulnerabilities. For example, if an implementation does not 4520 compress a message before encryption (perhaps because it knows it 4521 was already compressed), then that message is vulnerable. Because 4522 of this happenstance -- that modification attacks can be thwarted 4523 by decompression errors -- an implementation SHOULD treat a 4524 decompression error as a security problem, not merely a data 4525 problem. 4527 This attack can be defeated by the use of Modification Detection, 4528 provided that the implementation does not let the user naively 4529 return the data to the attacker. An implementation MUST treat an 4530 MDC failure as a security problem, not merely a data problem. 4532 In either case, the implementation MAY allow the user access to 4533 the erroneous data, but MUST warn the user as to potential 4534 security problems should that data be returned to the sender. 4536 While this attack is somewhat obscure, requiring a special set of 4537 circumstances to create it, it is nonetheless quite serious as it 4538 permits someone to trick a user to decrypt a message. 4539 Consequently, it is important that: 4541 1. Implementers treat MDC errors and decompression failures as 4542 security problems. 4544 2. Implementers implement Modification Detection with all due 4545 speed and encourage its spread. 4547 3. Users migrate to implementations that support Modification 4548 Detection with all due speed. 4550 o PKCS#1 has been found to be vulnerable to attacks in which a 4551 system that reports errors in padding differently from errors in 4552 decryption becomes a random oracle that can leak the private key 4553 in mere millions of queries. Implementations must be aware of 4554 this attack and prevent it from happening. The simplest solution 4555 is to report a single error code for all variants of decryption 4556 errors so as not to leak information to an attacker. 4558 o Some technologies mentioned here may be subject to government 4559 control in some countries. 4561 o In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4562 released a paper describing a way that the "quick check" in 4563 OpenPGP CFB mode can be used with a random oracle to decrypt two 4564 octets of every cipher block [MZ05]. They recommend as prevention 4565 not using the quick check at all. 4567 Many implementers have taken this advice to heart for any data 4568 that is symmetrically encrypted and for which the session key is 4569 public-key encrypted. In this case, the quick check is not needed 4570 as the public-key encryption of the session key should guarantee 4571 that it is the right session key. In other cases, the 4572 implementation should use the quick check with care. 4574 On the one hand, there is a danger to using it if there is a 4575 random oracle that can leak information to an attacker. In 4576 plainer language, there is a danger to using the quick check if 4577 timing information about the check can be exposed to an attacker, 4578 particularly via an automated service that allows rapidly repeated 4579 queries. 4581 On the other hand, it is inconvenient to the user to be informed 4582 that they typed in the wrong passphrase only after a petabyte of 4583 data is decrypted. There are many cases in cryptographic 4584 engineering where the implementer must use care and wisdom, and 4585 this is one. 4587 o Refer to [FIPS186], B.4.1, for the method to generate a uniformly 4588 distributed ECC private key. 4590 o The curves proposed in this document correspond to the symmetric 4591 key sizes 128 bits, 192 bits, and 256 bits, as described in the 4592 table below. This allows a compliant application to offer 4593 balanced public key security, which is compatible with the 4594 symmetric key strength for each AES algorithm defined here. 4596 The following table defines the hash and the symmetric encryption 4597 algorithm that SHOULD be used with a given curve for ECDSA or 4598 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 4599 be used for a given ECC curve. However, note that the increase in 4600 the strength of the hash algorithm or the symmetric key algorithm 4601 may not increase the overall security offered by the given ECC 4602 key. 4604 Curve name | ECC | RSA | Hash size | Symmetric 4605 | strength | strength, | | key size 4606 | | informative | | 4607 -----------+----------+-------------+-----------+----------- 4608 NIST P-256 256 3072 256 128 4609 NIST P-384 384 7680 384 192 4610 NIST P-521 521 15360 512 256 4612 Requirement levels indicated elsewhere in this document lead to 4613 the following combinations of algorithms in the OpenPGP profile: 4614 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 4615 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 4616 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 4617 combinations. 4619 Consistent with the table above, the following table defines the 4620 KDF hash algorithm and the AES KEK encryption algorithm that 4621 SHOULD be used with a given curve for ECDH. A stronger KDF hash 4622 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 4624 Curve name | Recommended KDF | Recommended KEK 4625 | hash algorithm | encryption algorithm 4626 -----------+-----------------+----------------------- 4627 NIST P-256 SHA2-256 AES-128 4628 NIST P-384 SHA2-384 AES-192 4629 NIST P-521 SHA2-512 AES-256 4631 This document explicitly discourages the use of algorithms other 4632 than AES as a KEK algorithm because backward compatibility of the 4633 ECDH format is not a concern. The KEK algorithm is only used 4634 within the scope of a Public-Key Encrypted Session Key Packet, 4635 which represents an ECDH key recipient of a message. Compare this 4636 with the algorithm used for the session key of the message, which 4637 MAY be different from a KEK algorithm. 4639 Compliant applications SHOULD implement, advertise through key 4640 preferences, and use the strongest algorithms specified in this 4641 document. 4643 Note that the symmetric algorithm preference list may make it 4644 impossible to use the balanced strength of symmetric key 4645 algorithms for a corresponding public key. For example, the 4646 presence of the symmetric key algorithm IDs and their order in the 4647 key preference list affects the algorithm choices available to the 4648 encoding side, which in turn may make the adherence to the table 4649 above infeasible. Therefore, compliance with this specification 4650 is a concern throughout the life of the key, starting immediately 4651 after the key generation when the key preferences are first added 4652 to a key. It is generally advisable to position a symmetric 4653 algorithm ID of strength matching the public key at the head of 4654 the key preference list. 4656 Encryption to multiple recipients often results in an unordered 4657 intersection subset. For example, if the first recipient's set is 4658 {A, B} and the second's is {B, A}, the intersection is an 4659 unordered set of two algorithms, A and B. In this case, a 4660 compliant application SHOULD choose the stronger encryption 4661 algorithm. 4663 Resource constraints, such as limited computational power, is a 4664 likely reason why an application might prefer to use the weakest 4665 algorithm. On the other side of the spectrum are applications 4666 that can implement every algorithm defined in this document. Most 4667 applications are expected to fall into either of two categories. 4668 A compliant application in the second, or strongest, category 4669 SHOULD prefer AES-256 to AES-192. 4671 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 4672 method. 4674 MDC MUST be used when a symmetric encryption key is protected by 4675 ECDH. None of the ECC methods described in this document are 4676 allowed with deprecated V3 keys. A compliant application MUST 4677 only use iterated and salted S2K to protect private keys, as 4678 defined in Section 3.7.1.3{FIXME}, "Iterated and Salted S2K". 4680 Side channel attacks are a concern when a compliant application's 4681 use of the OpenPGP format can be modeled by a decryption or 4682 signing oracle model, for example, when an application is a 4683 network service performing decryption to unauthenticated remote 4684 users. ECC scalar multiplication operations used in ECDSA and 4685 ECDH are vulnerable to side channel attacks. Countermeasures can 4686 often be taken at the higher protocol level, such as limiting the 4687 number of allowed failures or time-blinding of the operations 4688 associated with each network interface. Mitigations at the scalar 4689 multiplication level seek to eliminate any measurable distinction 4690 between the ECC point addition and doubling operations. 4692 o Although technically possible, the EdDSA algorithm MUST NOT be 4693 used with a digest algorithms weaker than SHA2-256. 4695 OpenPGP was designed with security in mind, with many smart, 4696 intelligent people spending a lot of time thinking about the 4697 ramifications of their decisions. Removing the requirement for self- 4698 certifying User ID (and User Attribute) packets on a key means that 4699 someone could surreptitiously add an unwanted ID to a key and sign 4700 it. If enough "trusted" people sign that surreptitious identity then 4701 other people might believe it. The attack could wind up sending 4702 encrypted mail destined for alice to some other target, bob, because 4703 someone added "alice" to bob's key without bob's consent. 4705 In the case of device certificates the device itself does not have 4706 any consent. It is given an identity by the device manufacturer and 4707 the manufacturer can insert that ID on the device certificate, 4708 signing it with the manufacturer's key. If another people wants to 4709 label the device by another name, they can do so. There is no harm 4710 in multiple IDs, because the verification is all done based on who 4711 has signed those IDs. 4713 When a key can self-sign, it is still suggested to self-certify IDs, 4714 even if it no longer required by this modification to OpenPGP. This 4715 at least signals to recipients of keys that yes, the owner of this 4716 key asserts that this identity belongs to herself. Note, however, 4717 that mallet could still assert that he is 'alice' and could even 4718 self-certify that. So the attack is not truly different. Moreover, 4719 in the case of device certificates, it's more the manufacturer than 4720 the device that wants to assert an identity (even if the device could 4721 self-certify). 4723 There is no signaling whether a key is using this looser-requirement 4724 key format. An attacker could therefore just remove the self- 4725 signature off a published key. However one would hope that wide 4726 publication would result in another copy still having that signature 4727 and it being returned quickly. However, the lack of signaling also 4728 means that a user with an application following RFC 4880 directly 4729 would see a key following this specification as "broken" and may not 4730 accept it. 4732 On a different note, including the "geo" notation could leak 4733 information about where a signer is located. However it is just an 4734 assertion (albeit a signed assertion) so there is no verifiable truth 4735 to the location information released. Similarly, all the rest of the 4736 signature notations are pure assertions, so they should be taken with 4737 the trustworthiness of the signer. 4739 Combining the User ID with the User Attribute means that an ID and 4740 image would not be separable. For a person this is probably not 4741 good, but for a device it's unlikely the image will change so it 4742 makes sense to combine the ID and image into a single signed packet 4743 with a single signature. 4745 16. Compatibility Profiles 4747 16.1. OpenPGP ECC Profile 4749 A compliant application MUST implement NIST curve P-256, SHOULD 4750 implement NIST curve P-521, SHOULD implemend Ed25519, SHOULD 4751 implement Curve25519, MAY implement NIST curve P-384, MAY implement 4752 brainpoolP256r1, MAY implement brainpoolP512r1, and MAY implement 4753 Curve25519, as defined in Section 11. A compliant application MUST 4754 implement SHA2-256 and SHOULD implement SHA2-384 and SHA2-512. A 4755 compliant application MUST implement AES-128 and SHOULD implement 4756 AES-256. 4758 A compliant application SHOULD follow Section 13{FIXME} regarding the 4759 choice of the following algorithms for each curve: 4761 o the KDF hash algorithm, 4762 o the KEK algorithm, 4764 o the message digest algorithm and the hash algorithm used in the 4765 key certifications, 4767 o the symmetric algorithm used for message encryption. 4769 It is recommended that the chosen symmetric algorithm for message 4770 encryption be no less secure than the KEK algorithm. 4772 16.2. Suite-B Profile 4774 A subset of algorithms allowed by this document can be used to 4775 achieve [SuiteB] compatibility. The references to [SuiteB] in this 4776 document are informative. This document is primarily concerned with 4777 format specification, leaving additional security restrictions 4778 unspecified, such as matching the assigned security level of 4779 information to authorized recipients or interoperability concerns 4780 arising from fewer allowed algorithms in [SuiteB] than allowed by 4781 this document. 4783 16.3. Security Strength at 192 Bits 4785 To achieve the security strength of 192 bits, [SuiteB] requires NIST 4786 curve P-384, AES-256, and SHA2-384. The symmetric algorithm 4787 restriction means that the algorithm of KEK used for key wrapping in 4788 Section 8 and an OpenPGP session key used for message encryption must 4789 be AES-256. The hash algorithm restriction means that the hash 4790 algorithms of KDF and the OpenPGP message digest calculation must be 4791 SHA2-384. 4793 16.4. Security Strength at 128 Bits 4795 The set of algorithms in Section 12.2.1{FIXME} is extended to allow 4796 NIST curve P-256, AES-128, and SHA2-256. 4798 17. {15} Implementation Nits 4800 This section is a collection of comments to help an implementer, 4801 particularly with an eye to backward compatibility. Previous 4802 implementations of PGP are not OpenPGP compliant. Often the 4803 differences are small, but small differences are frequently more 4804 vexing than large differences. Thus, this is a non-comprehensive 4805 list of potential problems and gotchas for a developer who is trying 4806 to be backward-compatible. 4808 o The IDEA algorithm is patented, and yet it is required for PGP 2.x 4809 interoperability. It is also the de-facto preferred algorithm for 4810 a V3 key with a V3 self-signature (or no self- signature). 4812 o When exporting a private key, PGP 2.x generates the header "BEGIN 4813 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 4814 All previous versions ignore the implied data type, and look 4815 directly at the packet data type. 4817 o PGP 2.0 through 2.5 generated V2 Public-Key packets. These are 4818 identical to the deprecated V3 keys except for the version number. 4819 An implementation MUST NOT generate them and may accept or reject 4820 them as it sees fit. Some older PGP versions generated V2 PKESK 4821 packets (Tag 1) as well. An implementation may accept or reject 4822 V2 PKESK packets as it sees fit, and MUST NOT generate them. 4824 o PGP 2.6.x will not accept key-material packets with versions 4825 greater than 3. 4827 o There are many ways possible for two keys to have the same key 4828 material, but different fingerprints (and thus Key IDs). Perhaps 4829 the most interesting is an RSA key that has been "upgraded" to V4 4830 format, but since a V4 fingerprint is constructed by hashing the 4831 key creation time along with other things, two V4 keys created at 4832 different times, yet with the same key material will have 4833 different fingerprints. 4835 o If an implementation is using zlib to interoperate with PGP 2.x, 4836 then the "windowBits" parameter should be set to -13. 4838 o The 0x19 back signatures were not required for signing subkeys 4839 until relatively recently. Consequently, there may be keys in the 4840 wild that do not have these back signatures. Implementing 4841 software may handle these keys as it sees fit. 4843 o OpenPGP does not put limits on the size of public keys. However, 4844 larger keys are not necessarily better keys. Larger keys take 4845 more computation time to use, and this can quickly become 4846 impractical. Different OpenPGP implementations may also use 4847 different upper bounds for public key sizes, and so care should be 4848 taken when choosing sizes to maintain interoperability. As of 4849 2007 most implementations have an upper bound of 4096 bits. 4851 o ASCII armor is an optional feature of OpenPGP. The OpenPGP 4852 working group strives for a minimal set of mandatory-to-implement 4853 features, and since there could be useful implementations that 4854 only use binary object formats, this is not a "MUST" feature for 4855 an implementation. For example, an implementation that is using 4856 OpenPGP as a mechanism for file signatures may find ASCII armor 4857 unnecessary. OpenPGP permits an implementation to declare what 4858 features it does and does not support, but ASCII armor is not one 4859 of these. Since most implementations allow binary and armored 4860 objects to be used indiscriminately, an implementation that does 4861 not implement ASCII armor may find itself with compatibility 4862 issues with general-purpose implementations. Moreover, 4863 implementations of OpenPGP-MIME [RFC3156] already have a 4864 requirement for ASCII armor so those implementations will 4865 necessarily have support. 4867 18. References 4869 18.1. Normative References 4871 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 4872 November 2001, 4873 . 4876 [BLOWFISH] 4877 Schneier, B., "Description of a New Variable-Length Key, 4878 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 4879 Cambridge Security Workshop Proceedings, Springer-Verlag, 4880 1994, pp191-204, December 1993, 4881 . 4883 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 4884 . 4886 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 4887 Scheme Based on Discrete Logarithms,", IEEE Transactions 4888 on Information Theory v. IT-31, n. 4, 1985, pp. 469-472, . 4890 [FIPS180] National Institute of Standards and Technology, U.S. 4891 Department of Commerce, "Secure Hash Standard (SHS), FIPS 4892 180-4", August 2015, 4893 . 4895 [FIPS186] National Institute of Standards and Technology, U.S. 4896 Department of Commerce, "Digital Signature Standard (DSS), 4897 FIPS 186-4", July 2013, 4898 . 4900 [FIPS202] National Institute of Standards and Technology, U.S. 4901 Department of Commerce, "SHA-3 Standard: Permutation-Based 4902 Hash and Extendable-Output Functions, FIPS 202", August 4903 2015, . 4905 [HAC] Menezes, A., Oorschot, P., and S. Vanstone, "Handbook of 4906 Applied Cryptography", 1996. 4908 [I-D.irtf-cfrg-eddsa] 4909 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 4910 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-02 4911 (work in progress), January 2016. 4913 [IDEA] Lai, X., "On the design and security of block ciphers", 4914 ETH Series in Information Processing, J.L. Massey 4915 (editor), Vol. 1, Hartung-Gorre Verlag Konstanz, 4916 Technische Hochschule (Zurich), 1992. 4918 [ISO10646] 4919 International Organization for Standardization, 4920 "Information Technology - Universal Multiple-octet coded 4921 Character Set (UCS) - Part 1: Architecture and Basic 4922 Multilingual Plane", ISO Standard 10646-1, May 1993. 4924 [JFIF] Eric Hamilton, C-Cube Microsystems, Milpitas, CA, "JPEG 4925 File Interchange Format (Version 1.02).", September 1996. 4927 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 4928 Cryptography Standard", March 1999. 4930 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format 4931 Specification version 3.3", RFC 1950, May 1996. 4933 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 4934 version 1.3", RFC 1951, May 1996. 4936 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4937 Extensions (MIME) Part One: Format of Internet Message 4938 Bodies", RFC 2045, November 1996. 4940 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4941 Requirement Levels", BCP 14, RFC 2119, March 1997. 4943 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 4944 May 1997. 4946 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an 4947 IANA Considerations Section in RFCs", BCP 26, RFC 2434, 4948 October 1998. 4950 [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, April 4951 2001. 4953 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 4954 "MIME Security with OpenPGP", RFC 3156, August 2001. 4956 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4957 (AES) Key Wrap Algorithm", RFC 3394, September 2002. 4959 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4960 Standards (PKCS) #1: RSA Cryptography Specifications 4961 Version 2.1", RFC 3447, February 2003. 4963 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 4964 10646", STD 63, RFC 3629, November 2003. 4966 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 4967 the Camellia Encryption Algorithm", RFC 3713, April 2004. 4969 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 4970 Requirements for Security", BCP 106, RFC 4086, June 2005. 4972 [RFC5639] Lochter, M. and J. Merkle, "Elliptic Curve Cryptography 4973 (ECC) Brainpool Standard Curves and Curve Generation", RFC 4974 5639, DOI 10.17487/RFC5639, March 2010, 4975 . 4977 [RFC5870] Mayrhofer, A. and C. Spanring, "A Uniform Resource 4978 Identifier for Geographic Locations ('geo' URI)", RFC 4979 5870, DOI 10.17487/RFC5870, June 2010, 4980 . 4982 [SCHNEIER] 4983 Schneier, B., "Applied Cryptography Second Edition: 4984 protocols, algorithms, and source code in C", 1996. 4986 [SP800-56A] 4987 Barker, E., Johnson, D., and M. Smid, "Recommendation for 4988 Pair-Wise Key Establishment Schemes Using Discrete 4989 Logarithm Cryptography", NIST Special Publication 800-56A 4990 Revision 1, March 2007. 4992 [SuiteB] National Security Agency, "NSA Suite B Cryptography", 4993 March 2010, 4994 . 4996 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 4997 C., and N. Ferguson, "The Twofish Encryption Algorithm", 4998 1999. 5000 18.2. Informative References 5002 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 5003 Chapter VI. Elliptic Curves, ISBN: 0-387-96576-9, 5004 Springer-Verlag", 1997. 5006 [RFC1423] Balenson, D., "Privacy Enhancement for Internet Electronic 5007 Mail: Part III: Algorithms, Modes, and Identifiers", RFC 5008 1423, February 1993. 5010 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5011 Exchange Formats", RFC 1991, August 1996. 5013 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5014 "OpenPGP Message Format", RFC 2440, November 1998. 5016 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5017 Curve Cryptography Algorithms", RFC 6090, February 2011. 5019 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5020 Elliptic Curve Cryptography", September 2000. 5022 [SP800-57] 5023 NIST, "Recommendation on Key Management", NIST Special 5024 Publication 800-57, March 2007, 5025 . 5028 Appendix A. Test vectors 5030 To help implementing this specification a non-normative example for 5031 the EdDSA algorithm is given. 5033 A.1. Sample EdDSA key 5035 The secret key used for this example is: 5037 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 5039 Note that this is the raw secret key used as input to the EdDSA 5040 signing operation. The key was created on 2014-08-19 14:28:27 and 5041 thus the fingerprint of the OpenPGP key is: 5043 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 5045 The algorithm specific input parameters without the MPI length 5046 headers are: 5048 oid: 2b06010401da470f01 5050 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 5052 The entire public key packet is thus: 5054 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 5055 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 5056 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 5057 43 ee 3b 24 06 5059 A.2. Sample EdDSA signature 5061 The signature is created using the sample key over the input data 5062 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 5063 function is: 5065 m: 4f70656e504750040016080006050255f95f9504ff0000000c 5067 Using the SHA2-256 hash algorithm yields the digest: 5069 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 5071 Which is fed into the EdDSA signature function and yields this 5072 signature: 5074 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 5076 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 5078 The entire signature packet is thus: 5080 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 5081 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 5082 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 5083 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 5084 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 5085 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 5087 Appendix B. ECC Point compression flag bytes 5089 This specification introduces the new flag byte 0x40 to indicate the 5090 point compression format. The value has been chosen so that the high 5091 bit is not cleared and thus to avoid accidental sign extension. Two 5092 other values might also be interesting for other ECC specifications: 5094 Flag Description 5095 ---- ----------- 5096 0x04 Standard flag for uncompressed format 5097 0x40 Native point format of the curve follows 5098 0x41 Only X coordinate follows. 5099 0x42 Only Y coordinate follows. 5101 Appendix C. Changes since RFC-4880 5103 o Applied errata 2270, 2271, 2242, 3298. 5105 o Added Camellia cipher from RFC 5581. 5107 o Incorporated RFC 6637 (ECC for OpenPGP) 5109 o Added draft-atkins-openpgp-device-certificates 5111 o Added draft-koch-eddsa-for-openpgp-04 5113 o Added Issuer Fingerprint signature subpacket. 5115 o Added a V5 key and fingerprint format. 5117 o Added OIDs for brainpool curves and Curve25519. 5119 o Marked SHA2-256 as MUST implement. 5121 o Marked Curve25519 and Ed25519 as SHOULD implement. 5123 o Marked SHA-1 as SHOULD NOT be used to create messages. 5125 o Marked MD5 as SHOULD NOT implement. 5127 { Informational rfcs: [RFC1423] } 5129 Appendix D. The principal authors of RFC-4880 are as follows: 5131 Jon Callas 5132 EMail: jon@callas.org 5134 Lutz Donnerhacke 5135 EMail: lutz@iks-jena.de 5137 Hal Finney 5139 David Shaw 5140 EMail: dshaw@jabberwocky.com 5142 Rodney Thayer 5143 EMail: rodney@canola-jones.com 5145 Author's Address 5147 Werner Koch 5149 Email: wk@gnupg.org