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