idnits 2.17.1 draft-ietf-openpgp-rfc4880bis-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) -- The draft header indicates that this document updates RFC4880, but the abstract doesn't seem to directly say this. It does mention RFC4880 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 5455 has weird spacing: '...0 dc ae dc 5b...' == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: This packet is obsolete. An implementation MUST not create this packet. An implementation MAY process such a packet but it MUST return a clear diagnostic that a non-integrity protected packet has been processed. The implementation SHOULD also return an error in this case and stop processing. (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 (July 26, 2018) is 2100 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 402 -- Looks like a reference, but probably isn't: '1' on line 4593 -- Looks like a reference, but probably isn't: '2' on line 402 -- Looks like a reference, but probably isn't: '3' on line 4602 == Missing Reference: 'REGEX' is mentioned on line 1492, but not defined == Missing Reference: 'Optional' is mentioned on line 2208, but not defined == Missing Reference: 'TBD1' is mentioned on line 2606, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3932, but not defined == Missing Reference: 'BLEICHENBACHER' is mentioned on line 4553, but not defined == Missing Reference: 'BS' is mentioned on line 4593, but not defined == Missing Reference: 'JKS02' is mentioned on line 4734, but not defined == Missing Reference: 'MZ05' is mentioned on line 4793, 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. 'EAX' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS202' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' == Outdated reference: A later version (-08) exists of draft-irtf-cfrg-eddsa-02 ** Downref: Normative reference to an Informational draft: draft-irtf-cfrg-eddsa (ref. 'I-D.irtf-cfrg-eddsa') -- Possible downref: Non-RFC (?) normative reference: ref. 'IDEA' -- Possible downref: Non-RFC (?) normative reference: ref. 'ISO10646' -- Possible downref: Non-RFC (?) normative reference: ref. 'JFIF' -- Possible downref: Non-RFC (?) normative reference: ref. 'PKCS5' ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Downref: Normative reference to an Informational RFC: RFC 1951 ** Downref: Normative reference to an Informational RFC: RFC 2144 ** Obsolete normative reference: RFC 2434 (Obsoleted by RFC 5226) ** Obsolete normative reference: RFC 2822 (Obsoleted by RFC 5322) ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Downref: Normative reference to an Informational RFC: RFC 3713 ** Downref: Normative reference to an Informational RFC: RFC 5639 ** Downref: Normative reference to an Informational RFC: RFC 7253 ** Downref: Normative reference to an Informational RFC: RFC 7748 -- 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: 14 errors (**), 0 flaws (~~), 12 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) July 26, 2018 5 Intended status: Standards Track 6 Expires: January 27, 2019 8 OpenPGP Message Format 9 draft-ietf-openpgp-rfc4880bis-05 11 Abstract 13 { Work in progress to update the OpenPGP specification from RFC4880 } 15 This document is maintained in order to publish all necessary 16 information needed to develop interoperable applications based on the 17 OpenPGP format. It is not a step-by-step cookbook for writing an 18 application. It describes only the format and methods needed to 19 read, check, generate, and write conforming packets crossing any 20 network. It does not deal with storage and implementation questions. 21 It does, however, discuss implementation issues necessary to avoid 22 security flaws. 24 OpenPGP software uses a combination of strong public-key and 25 symmetric cryptography to provide security services for electronic 26 communications and data storage. These services include 27 confidentiality, key management, authentication, and digital 28 signatures. This document specifies the message formats used in 29 OpenPGP. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at http://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on January 27, 2019. 48 Copyright Notice 50 Copyright (c) 2018 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 . . . . . . . . . . 7 69 2.2. {2.2} Authentication via Digital Signature . . . . . . . 8 70 2.3. {2.3} Compression . . . . . . . . . . . . . . . . . . . . 8 71 2.4. {2.4} Conversion to Radix-64 . . . . . . . . . . . . . . 8 72 2.5. {2.5} Signature-Only Applications . . . . . . . . . . . . 9 73 3. {3} Data Element Formats . . . . . . . . . . . . . . . . . . 9 74 3.1. {3.1} Scalar Numbers . . . . . . . . . . . . . . . . . . 9 75 3.2. {3.2} Multiprecision Integers . . . . . . . . . . . . . . 9 76 3.3. {3.3} Key IDs . . . . . . . . . . . . . . . . . . . . . . 10 77 3.4. {3.4} Text . . . . . . . . . . . . . . . . . . . . . . . 10 78 3.5. {3.5} Time Fields . . . . . . . . . . . . . . . . . . . . 10 79 3.6. {3.6} Keyrings . . . . . . . . . . . . . . . . . . . . . 10 80 3.7. {3.7} String-to-Key (S2K) Specifiers . . . . . . . . . . 10 81 3.7.1. {3.7.1} String-to-Key (S2K) Specifier Types . . . . . 10 82 3.7.2. {3.7.2} String-to-Key Usage . . . . . . . . . . . . . 13 83 4. {4} Packet Syntax . . . . . . . . . . . . . . . . . . . . . . 14 84 4.1. {4.1} Overview . . . . . . . . . . . . . . . . . . . . . 14 85 4.2. {4.2} Packet Headers . . . . . . . . . . . . . . . . . . 14 86 4.2.1. {4.2.1} Old Format Packet Lengths . . . . . . . . . . 15 87 4.2.2. {4.2.2} New Format Packet Lengths . . . . . . . . . . 15 88 4.2.3. {4.2.3} Packet Length Examples . . . . . . . . . . . 17 89 4.3. {4.3} Packet Tags . . . . . . . . . . . . . . . . . . . . 17 90 5. {5} Packet Types . . . . . . . . . . . . . . . . . . . . . . 18 91 5.1. {5.1} Public-Key Encrypted Session Key Packets (Tag 1) . 18 92 5.2. {5.2} Signature Packet (Tag 2) . . . . . . . . . . . . . 20 93 5.2.1. {5.2.1} Signature Types . . . . . . . . . . . . . . . 20 94 5.2.2. {5.2.2} Version 3 Signature Packet Format . . . . . . 22 95 5.2.3. {5.2.3} Version 4 Signature Packet Format . . . . . . 25 96 5.2.4. {5.2.4} Computing Signatures . . . . . . . . . . . . 41 97 5.3. {5.3} Symmetric-Key Encrypted Session Key Packets (Tag 3) 43 98 5.4. {5.4} One-Pass Signature Packets (Tag 4) . . . . . . . . 45 99 5.5. {5.5} Key Material Packet . . . . . . . . . . . . . . . . 45 100 5.5.1. {5.5.1} Key Packet Variants . . . . . . . . . . . . . 45 101 5.5.2. {5.5.2} Public-Key Packet Formats . . . . . . . . . . 46 102 5.5.3. {5.5.3} Secret-Key Packet Formats . . . . . . . . . . 48 103 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 50 104 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 50 105 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 50 106 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 51 107 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 51 108 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 51 109 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 52 110 5.7. {5.6} Compressed Data Packet (Tag 8) . . . . . . . . . . 53 111 5.8. {5.7} Symmetrically Encrypted Data Packet (Tag 9) . . . . 53 112 5.9. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) . 54 113 5.10. {5.9} Literal Data Packet (Tag 11) . . . . . . . . . . . 55 114 5.11. {5.10} Trust Packet (Tag 12) . . . . . . . . . . . . . . 56 115 5.12. {5.11} User ID Packet (Tag 13) . . . . . . . . . . . . . 56 116 5.13. {5.12} User Attribute Packet (Tag 17) . . . . . . . . . . 56 117 5.13.1. {5.12.1} The Image Attribute Subpacket . . . . . . . 57 118 5.13.2. User ID Attribute Subpacket . . . . . . . . . . . . 57 119 5.14. {5.13} Sym. Encrypted Integrity Protected Data Packet 120 (Tag 18) . . . . . . . . . . . . . . . . . . . . . . . . 58 121 5.15. {5.14} Modification Detection Code Packet (Tag 19) . . . 61 122 5.16. AEAD Encrypted Data Packet (Tag 20) . . . . . . . . . . . 62 123 5.16.1. EAX Mode . . . . . . . . . . . . . . . . . . . . . . 63 124 5.16.2. OCB Mode . . . . . . . . . . . . . . . . . . . . . . 63 125 6. {6} Radix-64 Conversions . . . . . . . . . . . . . . . . . . 64 126 6.1. {6.1} An Implementation of the CRC-24 in "C" . . . . . . 65 127 6.2. {6.2} Forming ASCII Armor . . . . . . . . . . . . . . . . 65 128 6.3. {6.3} Encoding Binary in Radix-64 . . . . . . . . . . . . 68 129 6.4. {6.4} Decoding Radix-64 . . . . . . . . . . . . . . . . . 69 130 6.5. {6.5} Examples of Radix-64 . . . . . . . . . . . . . . . 69 131 6.6. {6.6} Example of an ASCII Armored Message . . . . . . . . 70 132 7. {7} Cleartext Signature Framework . . . . . . . . . . . . . . 70 133 7.1. {7.1} Dash-Escaped Text . . . . . . . . . . . . . . . . . 71 134 8. {8} Regular Expressions . . . . . . . . . . . . . . . . . . . 72 135 9. {9} Constants . . . . . . . . . . . . . . . . . . . . . . . . 72 136 9.1. {9.1} Public-Key Algorithms . . . . . . . . . . . . . . . 73 137 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 73 138 9.3. {9.2} Symmetric-Key Algorithms . . . . . . . . . . . . . 74 139 9.4. {9.3} Compression Algorithms . . . . . . . . . . . . . . 75 140 9.5. {9.4} Hash Algorithms . . . . . . . . . . . . . . . . . . 76 141 9.6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . 76 142 10. {10} IANA Considerations . . . . . . . . . . . . . . . . . . 76 143 10.1. {10.1} New String-to-Key Specifier Types . . . . . . . . 77 144 10.2. {10.2} New Packets . . . . . . . . . . . . . . . . . . . 77 145 10.2.1. {10.2.1} User Attribute Types . . . . . . . . . . . 77 146 10.2.2. {10.2.1.1} Image Format Subpacket Types . . . . . . 77 147 10.2.3. {10.2.2} New Signature Subpackets . . . . . . . . . 78 148 10.2.4. {10.2.3} New Packet Versions . . . . . . . . . . . . 80 149 10.3. {10.3} New Algorithms . . . . . . . . . . . . . . . . . 80 150 10.3.1. {10.3.1} Public-Key Algorithms . . . . . . . . . . . 81 151 10.3.2. {10.3.2} Symmetric-Key Algorithms . . . . . . . . . 81 152 10.3.3. {10.3.3} Hash Algorithms . . . . . . . . . . . . . . 81 153 10.3.4. {10.3.4} Compression Algorithms . . . . . . . . . . 82 154 11. {11} Packet Composition . . . . . . . . . . . . . . . . . . . 82 155 11.1. {11.1} Transferable Public Keys . . . . . . . . . . . . 82 156 11.2. {11.2} Transferable Secret Keys . . . . . . . . . . . . 84 157 11.3. {11.3} OpenPGP Messages . . . . . . . . . . . . . . . . 84 158 11.4. {11.4} Detached Signatures . . . . . . . . . . . . . . . 85 159 12. {12} Enhanced Key Formats . . . . . . . . . . . . . . . . . . 85 160 12.1. {12.1} Key Structures . . . . . . . . . . . . . . . . . 85 161 12.2. {12.2} Key IDs and Fingerprints . . . . . . . . . . . . 87 162 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 88 163 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 89 164 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 89 165 13.3. EdDSA Point Format . . . . . . . . . . . . . . . . . . . 90 166 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 90 167 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 91 168 14. {13} Notes on Algorithms . . . . . . . . . . . . . . . . . . 93 169 14.1. {13.1} PKCS#1 Encoding in OpenPGP . . . . . . . . . . . 93 170 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . 93 171 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE . . . . . . . . . . . 94 172 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . 95 173 14.2. {13.2} Symmetric Algorithm Preferences . . . . . . . . . 96 174 14.3. {13.3} Other Algorithm Preferences . . . . . . . . . . . 97 175 14.3.1. {13.3.1} Compression Preferences . . . . . . . . . . 97 176 14.3.2. {13.3.2} Hash Algorithm Preferences . . . . . . . . 98 177 14.4. {13.4} Plaintext . . . . . . . . . . . . . . . . . . . . 98 178 14.5. {13.5} RSA . . . . . . . . . . . . . . . . . . . . . . . 98 179 14.6. {13.6} DSA . . . . . . . . . . . . . . . . . . . . . . . 98 180 14.7. {13.7} Elgamal . . . . . . . . . . . . . . . . . . . . . 99 181 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 99 182 14.9. {13.8} Reserved Algorithm Numbers . . . . . . . . . . . 99 183 14.10. {13.9} OpenPGP CFB Mode . . . . . . . . . . . . . . . . 100 184 14.11. {13.10} Private or Experimental Parameters . . . . . . . 101 185 14.12. {13.12} Meta-Considerations for Expansion . . . . . . . 101 186 15. {14} Security Considerations . . . . . . . . . . . . . . . . 102 187 16. Compatibility Profiles . . . . . . . . . . . . . . . . . . . 108 188 16.1. OpenPGP ECC Profile . . . . . . . . . . . . . . . . . . 108 189 16.2. Suite-B Profile . . . . . . . . . . . . . . . . . . . . 109 190 16.3. Security Strength at 192 Bits . . . . . . . . . . . . . 109 191 16.4. Security Strength at 128 Bits . . . . . . . . . . . . . 109 193 17. {15} Implementation Nits . . . . . . . . . . . . . . . . . . 109 194 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 111 195 18.1. Normative References . . . . . . . . . . . . . . . . . . 111 196 18.2. Informative References . . . . . . . . . . . . . . . . . 114 197 Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 115 198 A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 115 199 A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 115 200 A.3. Sample AEAD-EAX encryption and decryption . . . . . . . . 116 201 A.3.1. Sample Parameters . . . . . . . . . . . . . . . . . . 116 202 A.3.2. Sample symmetric-key encrypted session key packet 203 (v5) . . . . . . . . . . . . . . . . . . . . . . . . 116 204 A.3.3. Starting AEAD-EAX decryption of CEK . . . . . . . . . 117 205 A.3.4. Sample AEAD encrypted data packet . . . . . . . . . . 117 206 A.3.5. Decryption of data . . . . . . . . . . . . . . . . . 118 207 A.3.6. Complete AEAD-EAX encrypted packet sequence . . . . . 118 208 A.4. Sample AEAD-OCB encryption and decryption . . . . . . . . 119 209 A.4.1. Sample Parameters . . . . . . . . . . . . . . . . . . 119 210 A.4.2. Sample symmetric-key encrypted session key packet 211 (v5) . . . . . . . . . . . . . . . . . . . . . . . . 119 212 A.4.3. Starting AEAD-EAX decryption of CEK . . . . . . . . . 120 213 A.4.4. Sample AEAD encrypted data packet . . . . . . . . . . 120 214 A.4.5. Decryption of data . . . . . . . . . . . . . . . . . 121 215 A.4.6. Complete AEAD-OCB encrypted packet sequence . . . . . 121 216 Appendix B. ECC Point compression flag bytes . . . . . . . . . . 122 217 Appendix C. Changes since RFC-4880 . . . . . . . . . . . . . . . 122 218 Appendix D. The principal authors of RFC-4880 are as follows: . 123 219 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 123 221 1. {1} Introduction 223 { This is work in progress to update OpenPGP. Editorial notes are 224 enclosed in curly braces. The section numbers from RFC4880 are also 225 indicated in curly braces. } 227 This document provides information on the message-exchange packet 228 formats used by OpenPGP to provide encryption, decryption, signing, 229 and key management functions. It is a revision of RFC 2440, "OpenPGP 230 Message Format", which itself replaces RFC 1991, "PGP Message 231 Exchange Formats" [RFC1991] [RFC2440]. 233 This document obsoletes: RFC 5581 (Camellia cipher) and RFC 6637 (ECC 234 for OpenPGP) 236 1.1. {1.1} Terms 238 o OpenPGP - This is a term for security software that uses PGP 5.x 239 as a basis, formalized in RFC 2440 and this document. 241 o PGP - Pretty Good Privacy. PGP is a family of software systems 242 developed by Philip R. Zimmermann from which OpenPGP is based. 244 o PGP 2.6.x - This version of PGP has many variants, hence the term 245 PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic 246 transforms. An informational RFC, RFC 1991, was written 247 describing this version of PGP. 249 o PGP 5.x - This version of PGP is formerly known as "PGP 3" in the 250 community and also in the predecessor of this document, RFC 1991. 251 It has new formats and corrects a number of problems in the PGP 252 2.6.x design. It is referred to here as PGP 5.x because that 253 software was the first release of the "PGP 3" code base. 255 o GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 256 implementation that avoids all encumbered algorithms. 257 Consequently, early versions of GnuPG did not include RSA public 258 keys. GnuPG may or may not have (depending on version) support 259 for IDEA or other encumbered algorithms. 261 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 262 Corporation and are used with permission. The term "OpenPGP" refers 263 to the protocol described in this and related documents. 265 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 266 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 267 document are to be interpreted as described in [RFC2119]. 269 The key words "PRIVATE USE", "HIERARCHICAL ALLOCATION", "FIRST COME 270 FIRST SERVED", "EXPERT REVIEW", "SPECIFICATION REQUIRED", "IESG 271 APPROVAL", "IETF CONSENSUS", and "STANDARDS ACTION" that appear in 272 this document when used to describe namespace allocation are to be 273 interpreted as described in [RFC2434]. 275 2. {2} General functions 277 OpenPGP provides data integrity services for messages and data files 278 by using these core technologies: 280 o digital signatures 282 o encryption 284 o compression 286 o Radix-64 conversion 287 In addition, OpenPGP provides key management and certificate 288 services, but many of these are beyond the scope of this document. 290 2.1. {2.1} Confidentiality via Encryption 292 OpenPGP combines symmetric-key encryption and public-key encryption 293 to provide confidentiality. When made confidential, first the object 294 is encrypted using a symmetric encryption algorithm. Each symmetric 295 key is used only once, for a single object. A new "session key" is 296 generated as a random number for each object (sometimes referred to 297 as a session). Since it is used only once, the session key is bound 298 to the message and transmitted with it. To protect the key, it is 299 encrypted with the receiver's public key. The sequence is as 300 follows: 302 1. The sender creates a message. 304 2. The sending OpenPGP generates a random number to be used as a 305 session key for this message only. 307 3. The session key is encrypted using each recipient's public key. 308 These "encrypted session keys" start the message. 310 4. The sending OpenPGP encrypts the message using the session key, 311 which forms the remainder of the message. Note that the message 312 is also usually compressed. 314 5. The receiving OpenPGP decrypts the session key using the 315 recipient's private key. 317 6. The receiving OpenPGP decrypts the message using the session key. 318 If the message was compressed, it will be decompressed. 320 With symmetric-key encryption, an object may be encrypted with a 321 symmetric key derived from a passphrase (or other shared secret), or 322 a two-stage mechanism similar to the public-key method described 323 above in which a session key is itself encrypted with a symmetric 324 algorithm keyed from a shared secret. 326 Both digital signature and confidentiality services may be applied to 327 the same message. First, a signature is generated for the message 328 and attached to the message. Then the message plus signature is 329 encrypted using a symmetric session key. Finally, the session key is 330 encrypted using public-key encryption and prefixed to the encrypted 331 block. 333 2.2. {2.2} Authentication via Digital Signature 335 The digital signature uses a hash code or message digest algorithm, 336 and a public-key signature algorithm. The sequence is as follows: 338 1. The sender creates a message. 340 2. The sending software generates a hash code of the message. 342 3. The sending software generates a signature from the hash code 343 using the sender's private key. 345 4. The binary signature is attached to the message. 347 5. The receiving software keeps a copy of the message signature. 349 6. The receiving software generates a new hash code for the received 350 message and verifies it using the message's signature. If the 351 verification is successful, the message is accepted as authentic. 353 2.3. {2.3} Compression 355 OpenPGP implementations SHOULD compress the message after applying 356 the signature but before encryption. 358 If an implementation does not implement compression, its authors 359 should be aware that most OpenPGP messages in the world are 360 compressed. Thus, it may even be wise for a space-constrained 361 implementation to implement decompression, but not compression. 363 Furthermore, compression has the added side effect that some types of 364 attacks can be thwarted by the fact that slightly altered, compressed 365 data rarely uncompresses without severe errors. This is hardly 366 rigorous, but it is operationally useful. These attacks can be 367 rigorously prevented by implementing and using Modification Detection 368 Codes as described in sections following. 370 2.4. {2.4} Conversion to Radix-64 372 OpenPGP's underlying native representation for encrypted messages, 373 signature certificates, and keys is a stream of arbitrary octets. 374 Some systems only permit the use of blocks consisting of seven-bit, 375 printable text. For transporting OpenPGP's native raw binary octets 376 through channels that are not safe to raw binary data, a printable 377 encoding of these binary octets is needed. OpenPGP provides the 378 service of converting the raw 8-bit binary octet stream to a stream 379 of printable ASCII characters, called Radix-64 encoding or ASCII 380 Armor. 382 Implementations SHOULD provide Radix-64 conversions. 384 2.5. {2.5} Signature-Only Applications 386 OpenPGP is designed for applications that use both encryption and 387 signatures, but there are a number of problems that are solved by a 388 signature-only implementation. Although this specification requires 389 both encryption and signatures, it is reasonable for there to be 390 subset implementations that are non-conformant only in that they omit 391 encryption. 393 3. {3} Data Element Formats 395 This section describes the data elements used by OpenPGP. 397 3.1. {3.1} Scalar Numbers 399 Scalar numbers are unsigned and are always stored in big-endian 400 format. Using n[k] to refer to the kth octet being interpreted, the 401 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 402 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 403 n[3]). 405 3.2. {3.2} Multiprecision Integers 407 Multiprecision integers (also called MPIs) are unsigned integers used 408 to hold large integers such as the ones used in cryptographic 409 calculations. 411 An MPI consists of two pieces: a two-octet scalar that is the length 412 of the MPI in bits followed by a string of octets that contain the 413 actual integer. 415 These octets form a big-endian number; a big-endian number can be 416 made into an MPI by prefixing it with the appropriate length. 418 Examples: 420 (all numbers are in hexadecimal) 422 The string of octets [00 01 01] forms an MPI with the value 1. The 423 string [00 09 01 FF] forms an MPI with the value of 511. 425 Additional rules: 427 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 429 The length field of an MPI describes the length starting from its 430 most significant non-zero bit. Thus, the MPI [00 02 01] is not 431 formed correctly. It should be [00 01 01]. 433 Unused bits of an MPI MUST be zero. 435 Also note that when an MPI is encrypted, the length refers to the 436 plaintext MPI. It may be ill-formed in its ciphertext. 438 3.3. {3.3} Key IDs 440 A Key ID is an eight-octet scalar that identifies a key. 441 Implementations SHOULD NOT assume that Key IDs are unique. The 442 section "Enhanced Key Formats" below describes how Key IDs are 443 formed. 445 3.4. {3.4} Text 447 Unless otherwise specified, the character set for text is the UTF-8 448 [RFC3629] encoding of Unicode [ISO10646]. 450 3.5. {3.5} Time Fields 452 A time field is an unsigned four-octet number containing the number 453 of seconds elapsed since midnight, 1 January 1970 UTC. 455 3.6. {3.6} Keyrings 457 A keyring is a collection of one or more keys in a file or database. 458 Traditionally, a keyring is simply a sequential list of keys, but may 459 be any suitable database. It is beyond the scope of this standard to 460 discuss the details of keyrings or other databases. 462 3.7. {3.7} String-to-Key (S2K) Specifiers 464 String-to-key (S2K) specifiers are used to convert passphrase strings 465 into symmetric-key encryption/decryption keys. They are used in two 466 places, currently: to encrypt the secret part of private keys in the 467 private keyring, and to convert passphrases to encryption keys for 468 symmetrically encrypted messages. 470 3.7.1. {3.7.1} String-to-Key (S2K) Specifier Types 472 There are three types of S2K specifiers currently supported, and some 473 reserved values: 475 +-------------+---------------------------+ 476 | ID | S2K Type | 477 +-------------+---------------------------+ 478 | 0 | Simple S2K | 479 | 1 | Salted S2K | 480 | 2 | Reserved value | 481 | 3 | Iterated and Salted S2K | 482 | 100 to 110 | Private/Experimental S2K | 483 +-------------+---------------------------+ 485 These are described in the following Sections. 487 3.7.1.1. {3.7.1.1} Simple S2K 489 This directly hashes the string to produce the key data. See below 490 for how this hashing is done. 492 Octet 0: 0x00 493 Octet 1: hash algorithm 495 Simple S2K hashes the passphrase to produce the session key. The 496 manner in which this is done depends on the size of the session key 497 (which will depend on the cipher used) and the size of the hash 498 algorithm's output. If the hash size is greater than the session key 499 size, the high-order (leftmost) octets of the hash are used as the 500 key. 502 If the hash size is less than the key size, multiple instances of the 503 hash context are created -- enough to produce the required key data. 504 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 505 is to say, the first instance has no preloading, the second gets 506 preloaded with 1 octet of zero, the third is preloaded with two 507 octets of zeros, and so forth). 509 As the data is hashed, it is given independently to each hash 510 context. Since the contexts have been initialized differently, they 511 will each produce different hash output. Once the passphrase is 512 hashed, the output data from the multiple hashes is concatenated, 513 first hash leftmost, to produce the key data, with any excess octets 514 on the right discarded. 516 3.7.1.2. {3.7.1.2} Salted S2K 518 This includes a "salt" value in the S2K specifier -- some arbitrary 519 data -- that gets hashed along with the passphrase string, to help 520 prevent dictionary attacks. 522 Octet 0: 0x01 523 Octet 1: hash algorithm 524 Octets 2-9: 8-octet salt value 526 Salted S2K is exactly like Simple S2K, except that the input to the 527 hash function(s) consists of the 8 octets of salt from the S2K 528 specifier, followed by the passphrase. 530 3.7.1.3. {3.7.1.3} Iterated and Salted S2K 532 This includes both a salt and an octet count. The salt is combined 533 with the passphrase and the resulting value is hashed repeatedly. 534 This further increases the amount of work an attacker must do to try 535 dictionary attacks. 537 Octet 0: 0x03 538 Octet 1: hash algorithm 539 Octets 2-9: 8-octet salt value 540 Octet 10: count, a one-octet, coded value 542 The count is coded into a one-octet number using the following 543 formula: 545 #define EXPBIAS 6 546 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 548 The above formula is in C, where "Int32" is a type for a 32-bit 549 integer, and the variable "c" is the coded count, Octet 10. 551 Iterated-Salted S2K hashes the passphrase and salt data multiple 552 times. The total number of octets to be hashed is specified in the 553 encoded count in the S2K specifier. Note that the resulting count 554 value is an octet count of how many octets will be hashed, not an 555 iteration count. 557 Initially, one or more hash contexts are set up as with the other S2K 558 algorithms, depending on how many octets of key data are needed. 559 Then the salt, followed by the passphrase data, is repeatedly hashed 560 until the number of octets specified by the octet count has been 561 hashed. The one exception is that if the octet count is less than 562 the size of the salt plus passphrase, the full salt plus passphrase 563 will be hashed even though that is greater than the octet count. 564 After the hashing is done, the data is unloaded from the hash 565 context(s) as with the other S2K algorithms. 567 3.7.2. {3.7.2} String-to-Key Usage 569 Implementations SHOULD use salted or iterated-and-salted S2K 570 specifiers, as simple S2K specifiers are more vulnerable to 571 dictionary attacks. 573 3.7.2.1. {3.7.2.1} Secret-Key Encryption 575 An S2K specifier can be stored in the secret keyring to specify how 576 to convert the passphrase to a key that unlocks the secret data. 577 Older versions of PGP just stored a cipher algorithm octet preceding 578 the secret data or a zero to indicate that the secret data was 579 unencrypted. The MD5 hash function was always used to convert the 580 passphrase to a key for the specified cipher algorithm. 582 For compatibility, when an S2K specifier is used, the special value 583 253, 254, or 255 is stored in the position where the hash algorithm 584 octet would have been in the old data structure. This is then 585 followed immediately by a one-octet algorithm identifier, and then by 586 the S2K specifier as encoded above. 588 Therefore, preceding the secret data there will be one of these 589 possibilities: 591 0: secret data is unencrypted (no passphrase) 592 255, 254, or 253: followed by algorithm octet and S2K specifier 593 Cipher alg: use Simple S2K algorithm using MD5 hash 595 This last possibility, the cipher algorithm number with an implicit 596 use of MD5 and IDEA, is provided for backward compatibility; it MAY 597 be understood, but SHOULD NOT be generated, and is deprecated. 599 These are followed by an Initial Vector of the same length as the 600 block size of the cipher for the decryption of the secret values, if 601 they are encrypted, and then the secret-key values themselves. 603 3.7.2.2. {3.7.2.2} Symmetric-Key Message Encryption 605 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 606 at the front of a message. This is used to allow S2K specifiers to 607 be used for the passphrase conversion or to create messages with a 608 mix of symmetric-key ESKs and public-key ESKs. This allows a message 609 to be decrypted either with a passphrase or a public-key pair. 611 PGP 2.X always used IDEA with Simple string-to-key conversion when 612 encrypting a message with a symmetric algorithm. This is deprecated, 613 but MAY be used for backward-compatibility. 615 4. {4} Packet Syntax 617 This section describes the packets used by OpenPGP. 619 4.1. {4.1} Overview 621 An OpenPGP message is constructed from a number of records that are 622 traditionally called packets. A packet is a chunk of data that has a 623 tag specifying its meaning. An OpenPGP message, keyring, 624 certificate, and so forth consists of a number of packets. Some of 625 those packets may contain other OpenPGP packets (for example, a 626 compressed data packet, when uncompressed, contains OpenPGP packets). 628 Each packet consists of a packet header, followed by the packet body. 629 The packet header is of variable length. 631 4.2. {4.2} Packet Headers 633 The first octet of the packet header is called the "Packet Tag". It 634 determines the format of the header and denotes the packet contents. 635 The remainder of the packet header is the length of the packet. 637 Note that the most significant bit is the leftmost bit, called bit 7. 638 A mask for this bit is 0x80 in hexadecimal. 640 +---------------+ 641 PTag |7 6 5 4 3 2 1 0| 642 +---------------+ 643 Bit 7 -- Always one 644 Bit 6 -- New packet format if set 646 PGP 2.6.x only uses old format packets. Thus, software that 647 interoperates with those versions of PGP must only use old format 648 packets. If interoperability is not an issue, the new packet format 649 is RECOMMENDED. Note that old format packets have four bits of 650 packet tags, and new format packets have six; some features cannot be 651 used and still be backward-compatible. 653 Also note that packets with a tag greater than or equal to 16 MUST 654 use new format packets. The old format packets can only express tags 655 less than or equal to 15. 657 Old format packets contain: 659 Bits 5-2 -- packet tag 660 Bits 1-0 -- length-type 662 New format packets contain: 664 Bits 5-0 -- packet tag 666 4.2.1. {4.2.1} Old Format Packet Lengths 668 The meaning of the length-type in old format packets is: 670 0 The packet has a one-octet length. The header is 2 octets long. 672 1 The packet has a two-octet length. The header is 3 octets long. 674 2 The packet has a four-octet length. The header is 5 octets long. 676 3 The packet is of indeterminate length. The header is 1 octet 677 long, and the implementation must determine how long the packet 678 is. If the packet is in a file, this means that the packet 679 extends until the end of the file. In general, an implementation 680 SHOULD NOT use indeterminate-length packets except where the end 681 of the data will be clear from the context, and even then it is 682 better to use a definite length, or a new format header. The new 683 format headers described below have a mechanism for precisely 684 encoding data of indeterminate length. 686 4.2.2. {4.2.2} New Format Packet Lengths 688 New format packets have four possible ways of encoding length: 690 1. A one-octet Body Length header encodes packet lengths of up to 691 191 octets. 693 2. A two-octet Body Length header encodes packet lengths of 192 to 694 8383 octets. 696 3. A five-octet Body Length header encodes packet lengths of up to 697 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 698 encodes a four-octet scalar number.) 700 4. When the length of the packet body is not known in advance by the 701 issuer, Partial Body Length headers encode a packet of 702 indeterminate length, effectively making it a stream. 704 4.2.2.1. {4.2.2.1} One-Octet Lengths 706 A one-octet Body Length header encodes a length of 0 to 191 octets. 707 This type of length header is recognized because the one octet value 708 is less than 192. The body length is equal to: 710 bodyLen = 1st_octet; 712 4.2.2.2. {4.2.2.2} Two-Octet Lengths 714 A two-octet Body Length header encodes a length of 192 to 8383 715 octets. It is recognized because its first octet is in the range 192 716 to 223. The body length is equal to: 718 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 720 4.2.2.3. {4.2.2.3} Five-Octet Lengths 722 A five-octet Body Length header consists of a single octet holding 723 the value 255, followed by a four-octet scalar. The body length is 724 equal to: 726 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 727 (4th_octet << 8) | 5th_octet 729 This basic set of one, two, and five-octet lengths is also used 730 internally to some packets. 732 4.2.2.4. {4.2.2.4} Partial Body Lengths 734 A Partial Body Length header is one octet long and encodes the length 735 of only part of the data packet. This length is a power of 2, from 1 736 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 737 octet value that is greater than or equal to 224, and less than 255. 738 The Partial Body Length is equal to: 740 partialBodyLen = 1 << (1st_octet & 0x1F); 742 Each Partial Body Length header is followed by a portion of the 743 packet body data. The Partial Body Length header specifies this 744 portion's length. Another length header (one octet, two-octet, five- 745 octet, or partial) follows that portion. The last length header in 746 the packet MUST NOT be a Partial Body Length header. Partial Body 747 Length headers may only be used for the non-final parts of the 748 packet. 750 Note also that the last Body Length header can be a zero-length 751 header. 753 An implementation MAY use Partial Body Lengths for data packets, be 754 they literal, compressed, or encrypted. The first partial length 755 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 756 used for any other packet types. 758 4.2.3. {4.2.3} Packet Length Examples 760 These examples show ways that new format packets might encode the 761 packet lengths. 763 A packet with length 100 may have its length encoded in one octet: 764 0x64. This is followed by 100 octets of data. 766 A packet with length 1723 may have its length encoded in two octets: 767 0xC5, 0xFB. This header is followed by the 1723 octets of data. 769 A packet with length 100000 may have its length encoded in five 770 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 772 It might also be encoded in the following octet stream: 0xEF, first 773 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 774 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 775 octets of data. This is just one possible encoding, and many 776 variations are possible on the size of the Partial Body Length 777 headers, as long as a regular Body Length header encodes the last 778 portion of the data. 780 Please note that in all of these explanations, the total length of 781 the packet is the length of the header(s) plus the length of the 782 body. 784 4.3. {4.3} Packet Tags 786 The packet tag denotes what type of packet the body holds. Note that 787 old format headers can only have tags less than 16, whereas new 788 format headers can have tags as great as 63. The defined tags (in 789 decimal) are as follows: 791 +-----------+-----------------------------------------------------+ 792 | Tag | Packet Type | 793 +-----------+-----------------------------------------------------+ 794 | 0 | Reserved - a packet tag MUST NOT have this value | 795 | 1 | Public-Key Encrypted Session Key Packet | 796 | 2 | Signature Packet | 797 | 3 | Symmetric-Key Encrypted Session Key Packet | 798 | 4 | One-Pass Signature Packet | 799 | 5 | Secret-Key Packet | 800 | 6 | Public-Key Packet | 801 | 7 | Secret-Subkey Packet | 802 | 8 | Compressed Data Packet | 803 | 9 | Symmetrically Encrypted Data Packet | 804 | 10 | Marker Packet | 805 | 11 | Literal Data Packet | 806 | 12 | Trust Packet | 807 | 13 | User ID Packet | 808 | 14 | Public-Subkey Packet | 809 | 17 | User Attribute Packet | 810 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 811 | 19 | Modification Detection Code Packet | 812 | 20 | AEAD Encrypted Data Packet | 813 | 60 to 63 | Private or Experimental Values | 814 +-----------+-----------------------------------------------------+ 816 5. {5} Packet Types 818 5.1. {5.1} Public-Key Encrypted Session Key Packets (Tag 1) 820 A Public-Key Encrypted Session Key packet holds the session key used 821 to encrypt a message. Zero or more Public-Key Encrypted Session Key 822 packets and/or Symmetric-Key Encrypted Session Key packets may 823 precede a Symmetrically Encrypted Data Packet, which holds an 824 encrypted message. The message is encrypted with the session key, 825 and the session key is itself encrypted and stored in the Encrypted 826 Session Key packet(s). The Symmetrically Encrypted Data Packet is 827 preceded by one Public-Key Encrypted Session Key packet for each 828 OpenPGP key to which the message is encrypted. The recipient of the 829 message finds a session key that is encrypted to their public key, 830 decrypts the session key, and then uses the session key to decrypt 831 the message. 833 The body of this packet consists of: 835 o A one-octet number giving the version number of the packet type. 836 The currently defined value for packet version is 3. 838 o An eight-octet number that gives the Key ID of the public key to 839 which the session key is encrypted. If the session key is 840 encrypted to a subkey, then the Key ID of this subkey is used here 841 instead of the Key ID of the primary key. 843 o A one-octet number giving the public-key algorithm used. 845 o A string of octets that is the encrypted session key. This string 846 takes up the remainder of the packet, and its contents are 847 dependent on the public-key algorithm used. 849 Algorithm Specific Fields for RSA encryption: 851 * Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 853 Algorithm Specific Fields for Elgamal encryption: 855 * MPI of Elgamal (Diffie-Hellman) value g**k mod p. 857 * MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 859 Algorithm-Specific Fields for ECDH encryption: 861 * MPI of an EC point representing an ephemeral public key. 863 * a one-octet size, followed by a symmetric key encoded using the 864 method described in Section 13.5. 866 The value "m" in the above formulas is derived from the session key 867 as follows. First, the session key is prefixed with a one-octet 868 algorithm identifier that specifies the symmetric encryption 869 algorithm used to encrypt the following Symmetrically Encrypted Data 870 Packet. Then a two-octet checksum is appended, which is equal to the 871 sum of the preceding session key octets, not including the algorithm 872 identifier, modulo 65536. This value is then encoded as described in 873 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 874 form the "m" value used in the formulas above. See Section 13.1 of 875 this document for notes on OpenPGP's use of PKCS#1. 877 Note that when an implementation forms several PKESKs with one 878 session key, forming a message that can be decrypted by several keys, 879 the implementation MUST make a new PKCS#1 encoding for each key. 881 An implementation MAY accept or use a Key ID of zero as a "wild card" 882 or "speculative" Key ID. In this case, the receiving implementation 883 would try all available private keys, checking for a valid decrypted 884 session key. This format helps reduce traffic analysis of messages. 886 5.2. {5.2} Signature Packet (Tag 2) 888 A Signature packet describes a binding between some public key and 889 some data. The most common signatures are a signature of a file or a 890 block of text, and a signature that is a certification of a User ID. 892 Two versions of Signature packets are defined. Version 3 provides 893 basic signature information, while version 4 provides an expandable 894 format with subpackets that can specify more information about the 895 signature. PGP 2.6.x only accepts version 3 signatures. 897 Implementations SHOULD accept V3 signatures. Implementations SHOULD 898 generate V4 signatures. 900 Note that if an implementation is creating an encrypted and signed 901 message that is encrypted to a V3 key, it is reasonable to create a 902 V3 signature. 904 5.2.1. {5.2.1} Signature Types 906 There are a number of possible meanings for a signature, which are 907 indicated in a signature type octet in any given signature. Please 908 note that the vagueness of these meanings is not a flaw, but a 909 feature of the system. Because OpenPGP places final authority for 910 validity upon the receiver of a signature, it may be that one 911 signer's casual act might be more rigorous than some other 912 authority's positive act. See Section 5.2.4, "Computing Signatures", 913 for detailed information on how to compute and verify signatures of 914 each type. 916 These meanings are as follows: 918 0x00 Signature of a binary document. This means the signer owns it, 919 created it, or certifies that it has not been modified. 921 0x01 Signature of a canonical text document. This means the signer 922 owns it, created it, or certifies that it has not been modified. 923 The signature is calculated over the text data with its line 924 endings converted to . 926 0x02 Standalone signature. This signature is a signature of only 927 its own subpacket contents. It is calculated identically to a 928 signature over a zero-length binary document. Note that it 929 doesn't make sense to have a V3 standalone signature. 931 0x10 Generic certification of a User ID and Public-Key packet. The 932 issuer of this certification does not make any particular 933 assertion as to how well the certifier has checked that the owner 934 of the key is in fact the person described by the User ID. 936 0x11 Persona certification of a User ID and Public-Key packet. The 937 issuer of this certification has not done any verification of the 938 claim that the owner of this key is the User ID specified. 940 0x12 Casual certification of a User ID and Public-Key packet. The 941 issuer of this certification has done some casual verification of 942 the claim of identity. 944 0x13 Positive certification of a User ID and Public-Key packet. The 945 issuer of this certification has done substantial verification of 946 the claim of identity. 948 Most OpenPGP implementations make their "key signatures" as 0x10 949 certifications. Some implementations can issue 0x11-0x13 950 certifications, but few differentiate between the types. 952 0x18 Subkey Binding Signature This signature is a statement by the 953 top-level signing key that indicates that it owns the subkey. 954 This signature is calculated directly on the primary key and 955 subkey, and not on any User ID or other packets. A signature that 956 binds a signing subkey MUST have an Embedded Signature subpacket 957 in this binding signature that contains a 0x19 signature made by 958 the signing subkey on the primary key and subkey. 960 0x19 Primary Key Binding Signature This signature is a statement by 961 a signing subkey, indicating that it is owned by the primary key 962 and subkey. This signature is calculated the same way as a 0x18 963 signature: directly on the primary key and subkey, and not on any 964 User ID or other packets. 966 0x1F Signature directly on a key This signature is calculated 967 directly on a key. It binds the information in the Signature 968 subpackets to the key, and is appropriate to be used for 969 subpackets that provide information about the key, such as the 970 Revocation Key subpacket. It is also appropriate for statements 971 that non-self certifiers want to make about the key itself, rather 972 than the binding between a key and a name. 974 0x20 Key revocation signature The signature is calculated directly 975 on the key being revoked. A revoked key is not to be used. Only 976 revocation signatures by the key being revoked, or by an 977 authorized revocation key, should be considered valid revocation 978 signatures. 980 0x28 Subkey revocation signature The signature is calculated 981 directly on the subkey being revoked. A revoked subkey is not to 982 be used. Only revocation signatures by the top-level signature 983 key that is bound to this subkey, or by an authorized revocation 984 key, should be considered valid revocation signatures. 986 0x30 Certification revocation signature This signature revokes an 987 earlier User ID certification signature (signature class 0x10 988 through 0x13) or direct-key signature (0x1F). It should be issued 989 by the same key that issued the revoked signature or an authorized 990 revocation key. The signature is computed over the same data as 991 the certificate that it revokes, and should have a later creation 992 date than that certificate. 994 0x40 Timestamp signature. This signature is only meaningful for the 995 timestamp contained in it. 997 0x50 Third-Party Confirmation signature. This signature is a 998 signature over some other OpenPGP Signature packet(s). It is 999 analogous to a notary seal on the signed data. A third-party 1000 signature SHOULD include Signature Target subpacket(s) to give 1001 easy identification. Note that we really do mean SHOULD. There 1002 are plausible uses for this (such as a blind party that only sees 1003 the signature, not the key or source document) that cannot include 1004 a target subpacket. 1006 5.2.2. {5.2.2} Version 3 Signature Packet Format 1008 The body of a version 3 Signature Packet contains: 1010 o One-octet version number (3). 1012 o One-octet length of following hashed material. MUST be 5. 1014 o One-octet signature type. 1016 o Four-octet creation time. 1018 o Eight-octet Key ID of signer. 1020 o One-octet public-key algorithm. 1022 o One-octet hash algorithm. 1024 o Two-octet field holding left 16 bits of signed hash value. 1026 o One or more multiprecision integers comprising the signature. 1027 This portion is algorithm specific, as described below. 1029 The concatenation of the data to be signed, the signature type, 1030 and creation time from the Signature packet (5 additional octets) 1031 is hashed. The resulting hash value is used in the signature 1032 algorithm. The high 16 bits (first two octets) of the hash are 1033 included in the Signature packet to provide a quick test to reject 1034 some invalid signatures. 1036 Algorithm-Specific Fields for RSA signatures: 1038 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1040 Algorithm-Specific Fields for DSA and ECDSA signatures: 1042 * MPI of DSA or ECDSA value r. 1044 * MPI of DSA or ECDSA value s. 1046 The signature calculation is based on a hash of the signed data, as 1047 described above. The details of the calculation are different for 1048 DSA signatures than for RSA signatures. 1050 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1051 type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This 1052 requires inserting the hash value as an octet string into an ASN.1 1053 structure. The object identifier for the type of hash being used is 1054 included in the structure. The hexadecimal representations for the 1055 currently defined hash algorithms are as follows: 1057 - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 1059 - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 1061 - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A 1063 - SHA2-224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04 1065 - SHA2-256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 1067 - SHA2-384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 1069 - SHA2-512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 1071 The ASN.1 Object Identifiers (OIDs) are as follows: 1073 - MD5: 1.2.840.113549.2.5 1075 - RIPEMD-160: 1.3.36.3.2.1 1077 - SHA-1: 1.3.14.3.2.26 1079 - SHA2-224: 2.16.840.1.101.3.4.2.4 1081 - SHA2-256: 2.16.840.1.101.3.4.2.1 1083 - SHA2-384: 2.16.840.1.101.3.4.2.2 1085 - SHA2-512: 2.16.840.1.101.3.4.2.3 1087 The full hash prefixes for these are as follows: 1089 - MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 1090 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 1091 0x04, 0x10 1093 - RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 1094 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 1096 - SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, 1097 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 1099 - SHA2-224: 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1100 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 1101 0x00, 0x04, 0x1C 1103 - SHA2-256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1104 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 1105 0x00, 0x04, 0x20 1107 - SHA2-384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1108 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 1109 0x00, 0x04, 0x30 1111 - SHA2-512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 1112 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 1113 0x00, 0x04, 0x40 1115 DSA signatures MUST use hashes that are equal in size to the number 1116 of bits of q, the group generated by the DSA key's generator value. 1118 If the output size of the chosen hash is larger than the number of 1119 bits of q, the hash result is truncated to fit by taking the number 1120 of leftmost bits equal to the number of bits of q. This (possibly 1121 truncated) hash function result is treated as a number and used 1122 directly in the DSA signature algorithm. 1124 5.2.3. {5.2.3} Version 4 Signature Packet Format 1126 The body of a version 4 Signature packet contains: 1128 o One-octet version number (4). 1130 o One-octet signature type. 1132 o One-octet public-key algorithm. 1134 o One-octet hash algorithm. 1136 o Two-octet scalar octet count for following hashed subpacket data. 1137 Note that this is the length in octets of all of the hashed 1138 subpackets; a pointer incremented by this number will skip over 1139 the hashed subpackets. 1141 o Hashed subpacket data set (zero or more subpackets). 1143 o Two-octet scalar octet count for the following unhashed subpacket 1144 data. Note that this is the length in octets of all of the 1145 unhashed subpackets; a pointer incremented by this number will 1146 skip over the unhashed subpackets. 1148 o Unhashed subpacket data set (zero or more subpackets). 1150 o Two-octet field holding the left 16 bits of the signed hash value. 1152 o One or more multiprecision integers comprising the signature. 1153 This portion is algorithm specific: 1155 Algorithm-Specific Fields for RSA signatures: 1157 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1159 Algorithm-Specific Fields for DSA or ECDSA signatures: 1161 * MPI of DSA or ECDSA value r. 1163 * MPI of DSA or ECDSA value s. 1165 Algorithm-Specific Fields for EdDSA signatures: 1167 * MPI of EdDSA compressed value r. 1169 * MPI of EdDSA compressed value s. 1171 The compressed version of R and S for use with EdDSA is described in 1172 [I-D.irtf-cfrg-eddsa]. The version 3 signature format MUST NOT be 1173 used with EdDSA. 1175 The concatenation of the data being signed and the signature data 1176 from the version number through the hashed subpacket data (inclusive) 1177 is hashed. The resulting hash value is what is signed. The left 16 1178 bits of the hash are included in the Signature packet to provide a 1179 quick test to reject some invalid signatures. 1181 There are two fields consisting of Signature subpackets. The first 1182 field is hashed with the rest of the signature data, while the second 1183 is unhashed. The second set of subpackets is not cryptographically 1184 protected by the signature and should include only advisory 1185 information. 1187 The algorithms for converting the hash function result to a signature 1188 are described in a section below. 1190 5.2.3.1. {5.2.3.1} Signature Subpacket Specification 1192 A subpacket data set consists of zero or more Signature subpackets. 1193 In Signature packets, the subpacket data set is preceded by a two- 1194 octet scalar count of the length in octets of all the subpackets. A 1195 pointer incremented by this number will skip over the subpacket data 1196 set. 1198 Each subpacket consists of a subpacket header and a body. The header 1199 consists of: 1201 o the subpacket length (1, 2, or 5 octets), 1203 o the subpacket type (1 octet), 1205 and is followed by the subpacket-specific data. 1207 The length includes the type octet but not this length. Its format 1208 is similar to the "new" format packet header lengths, but cannot have 1209 Partial Body Lengths. That is: 1211 if the 1st octet < 192, then 1212 lengthOfLength = 1 1213 subpacketLen = 1st_octet 1215 if the 1st octet >= 192 and < 255, then 1216 lengthOfLength = 2 1217 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1219 if the 1st octet = 255, then 1220 lengthOfLength = 5 1221 subpacket length = [four-octet scalar starting at 2nd_octet] 1223 The value of the subpacket type octet may be: 1225 +-------------+-----------------------------------------+ 1226 | Type | Description | 1227 +-------------+-----------------------------------------+ 1228 | 0 | Reserved | 1229 | 1 | Reserved | 1230 | 2 | Signature Creation Time | 1231 | 3 | Signature Expiration Time | 1232 | 4 | Exportable Certification | 1233 | 5 | Trust Signature | 1234 | 6 | Regular Expression | 1235 | 7 | Revocable | 1236 | 8 | Reserved | 1237 | 9 | Key Expiration Time | 1238 | 10 | Placeholder for backward compatibility | 1239 | 11 | Preferred Symmetric Algorithms | 1240 | 12 | Revocation Key | 1241 | 13 to 15 | Reserved | 1242 | 16 | Issuer | 1243 | 17 to 19 | Reserved | 1244 | 20 | Notation Data | 1245 | 21 | Preferred Hash Algorithms | 1246 | 22 | Preferred Compression Algorithms | 1247 | 23 | Key Server Preferences | 1248 | 24 | Preferred Key Server | 1249 | 25 | Primary User ID | 1250 | 26 | Policy URI | 1251 | 27 | Key Flags | 1252 | 28 | Signer's User ID | 1253 | 29 | Reason for Revocation | 1254 | 30 | Features | 1255 | 31 | Signature Target | 1256 | 32 | Embedded Signature | 1257 | 33 | Issuer Fingerprint | 1258 | 34 | Preferred AEAD Algorithms | 1259 | 100 to 110 | Private or experimental | 1260 +-------------+-----------------------------------------+ 1262 An implementation SHOULD ignore any subpacket of a type that it does 1263 not recognize. 1265 Bit 7 of the subpacket type is the "critical" bit. If set, it 1266 denotes that the subpacket is one that is critical for the evaluator 1267 of the signature to recognize. If a subpacket is encountered that is 1268 marked critical but is unknown to the evaluating software, the 1269 evaluator SHOULD consider the signature to be in error. 1271 An evaluator may "recognize" a subpacket, but not implement it. The 1272 purpose of the critical bit is to allow the signer to tell an 1273 evaluator that it would prefer a new, unknown feature to generate an 1274 error than be ignored. 1276 Implementations SHOULD implement the four preferred algorithm 1277 subpackets (11, 21, 22, and 34), as well as the "Reason for 1278 Revocation" subpacket. Note, however, that if an implementation 1279 chooses not to implement some of the preferences, it is required to 1280 behave in a polite manner to respect the wishes of those users who do 1281 implement these preferences. 1283 5.2.3.2. {5.2.3.2} Signature Subpacket Types 1285 A number of subpackets are currently defined. Some subpackets apply 1286 to the signature itself and some are attributes of the key. 1287 Subpackets that are found on a self-signature are placed on a 1288 certification made by the key itself. Note that a key may have more 1289 than one User ID, and thus may have more than one self-signature, and 1290 differing subpackets. 1292 A subpacket may be found either in the hashed or unhashed subpacket 1293 sections of a signature. If a subpacket is not hashed, then the 1294 information in it cannot be considered definitive because it is not 1295 part of the signature proper. 1297 5.2.3.3. {5.2.3.3} Notes on Self-Signatures 1299 A self-signature is a binding signature made by the key to which the 1300 signature refers. There are three types of self-signatures, the 1301 certification signatures (types 0x10-0x13), the direct-key signature 1302 (type 0x1F), and the subkey binding signature (type 0x18). For 1303 certification self-signatures, each User ID may have a self- 1304 signature, and thus different subpackets in those self-signatures. 1305 For subkey binding signatures, each subkey in fact has a self- 1306 signature. Subpackets that appear in a certification self-signature 1307 apply to the user name, and subpackets that appear in the subkey 1308 self-signature apply to the subkey. Lastly, subpackets on the 1309 direct-key signature apply to the entire key. 1311 Implementing software should interpret a self-signature's preference 1312 subpackets as narrowly as possible. For example, suppose a key has 1313 two user names, Alice and Bob. Suppose that Alice prefers the 1314 symmetric algorithm AES-256, and Bob prefers Camellia-256 or AES-128. 1315 If the software locates this key via Alice's name, then the preferred 1316 algorithm is AES-256; if software locates the key via Bob's name, 1317 then the preferred algorithm is Camellia-256. If the key is located 1318 by Key ID, the algorithm of the primary User ID of the key provides 1319 the preferred symmetric algorithm. 1321 Revoking a self-signature or allowing it to expire has a semantic 1322 meaning that varies with the signature type. Revoking the self- 1323 signature on a User ID effectively retires that user name. The self- 1324 signature is a statement, "My name X is tied to my signing key K" and 1325 is corroborated by other users' certifications. If another user 1326 revokes their certification, they are effectively saying that they no 1327 longer believe that name and that key are tied together. Similarly, 1328 if the users themselves revoke their self-signature, then the users 1329 no longer go by that name, no longer have that email address, etc. 1330 Revoking a binding signature effectively retires that subkey. 1331 Revoking a direct-key signature cancels that signature. Please see 1332 the "Reason for Revocation" subpacket (Section 5.2.3.23) for more 1333 relevant detail. 1335 Since a self-signature contains important information about the key's 1336 use, an implementation SHOULD allow the user to rewrite the self- 1337 signature, and important information in it, such as preferences and 1338 key expiration. 1340 It is good practice to verify that a self-signature imported into an 1341 implementation doesn't advertise features that the implementation 1342 doesn't support, rewriting the signature as appropriate. 1344 An implementation that encounters multiple self-signatures on the 1345 same object may resolve the ambiguity in any way it sees fit, but it 1346 is RECOMMENDED that priority be given to the most recent self- 1347 signature. 1349 5.2.3.4. {5.2.3.4} Signature Creation Time 1351 (4-octet time field) 1353 The time the signature was made. 1355 MUST be present in the hashed area. 1357 5.2.3.5. {5.2.3.5} Issuer 1359 (8-octet Key ID) 1361 The OpenPGP Key ID of the key issuing the signature. If the version 1362 of that key is greater than 4, this subpacket MUST NOT be included in 1363 the signature. 1365 5.2.3.6. {5.2.3.6} Key Expiration Time 1367 (4-octet time field) 1369 The validity period of the key. This is the number of seconds after 1370 the key creation time that the key expires. If this is not present 1371 or has a value of zero, the key never expires. This is found only on 1372 a self-signature. 1374 5.2.3.7. {5.2.3.7} Preferred Symmetric Algorithms 1376 (array of one-octet values) 1378 Symmetric algorithm numbers that indicate which algorithms the key 1379 holder prefers to use. The subpacket body is an ordered list of 1380 octets with the most preferred listed first. It is assumed that only 1381 algorithms listed are supported by the recipient's software. 1382 Algorithm numbers are in Section 9. This is only found on a self- 1383 signature. 1385 5.2.3.8. Preferred AEAD Algorithms 1387 (array of one-octet values) 1389 AEAD algorithm numbers that indicate which AEAD algorithms the key 1390 holder prefers to use. The subpacket body is an ordered list of 1391 octets with the most preferred listed first. It is assumed that only 1392 algorithms listed are supported by the recipient's software. 1393 Algorithm numbers are in Section Section 9.6. This is only found on 1394 a self-signature. Note that support for the AEAD Encrypted Data 1395 packet in the general is indicated by a Feature Flag. 1397 5.2.3.9. {5.2.3.8} Preferred Hash Algorithms 1399 (array of one-octet values) 1401 Message digest algorithm numbers that indicate which algorithms the 1402 key holder prefers to receive. Like the preferred symmetric 1403 algorithms, the list is ordered. Algorithm numbers are in Section 9. 1404 This is only found on a self-signature. 1406 5.2.3.10. {5.2.3.9} Preferred Compression Algorithms 1408 (array of one-octet values) 1410 Compression algorithm numbers that indicate which algorithms the key 1411 holder prefers to use. Like the preferred symmetric algorithms, the 1412 list is ordered. Algorithm numbers are in Section 9. If this 1413 subpacket is not included, ZIP is preferred. A zero denotes that 1414 uncompressed data is preferred; the key holder's software might have 1415 no compression software in that implementation. This is only found 1416 on a self-signature. 1418 5.2.3.11. {5.2.3.10} Signature Expiration Time 1420 (4-octet time field) 1422 The validity period of the signature. This is the number of seconds 1423 after the signature creation time that the signature expires. If 1424 this is not present or has a value of zero, it never expires. 1426 5.2.3.12. {5.2.3.11} Exportable Certification 1428 (1 octet of exportability, 0 for not, 1 for exportable) 1430 This subpacket denotes whether a certification signature is 1431 "exportable", to be used by other users than the signature's issuer. 1432 The packet body contains a Boolean flag indicating whether the 1433 signature is exportable. If this packet is not present, the 1434 certification is exportable; it is equivalent to a flag containing a 1435 1. 1437 Non-exportable, or "local", certifications are signatures made by a 1438 user to mark a key as valid within that user's implementation only. 1440 Thus, when an implementation prepares a user's copy of a key for 1441 transport to another user (this is the process of "exporting" the 1442 key), any local certification signatures are deleted from the key. 1444 The receiver of a transported key "imports" it, and likewise trims 1445 any local certifications. In normal operation, there won't be any, 1446 assuming the import is performed on an exported key. However, there 1447 are instances where this can reasonably happen. For example, if an 1448 implementation allows keys to be imported from a key database in 1449 addition to an exported key, then this situation can arise. 1451 Some implementations do not represent the interest of a single user 1452 (for example, a key server). Such implementations always trim local 1453 certifications from any key they handle. 1455 5.2.3.13. {5.2.3.12} Revocable 1457 (1 octet of revocability, 0 for not, 1 for revocable) 1459 Signature's revocability status. The packet body contains a Boolean 1460 flag indicating whether the signature is revocable. Signatures that 1461 are not revocable have any later revocation signatures ignored. They 1462 represent a commitment by the signer that he cannot revoke his 1463 signature for the life of his key. If this packet is not present, 1464 the signature is revocable. 1466 5.2.3.14. {5.2.3.13} Trust Signature 1468 (1 octet "level" (depth), 1 octet of trust amount) 1470 Signer asserts that the key is not only valid but also trustworthy at 1471 the specified level. Level 0 has the same meaning as an ordinary 1472 validity signature. Level 1 means that the signed key is asserted to 1473 be a valid trusted introducer, with the 2nd octet of the body 1474 specifying the degree of trust. Level 2 means that the signed key is 1475 asserted to be trusted to issue level 1 trust signatures, i.e., that 1476 it is a "meta introducer". Generally, a level n trust signature 1477 asserts that a key is trusted to issue level n-1 trust signatures. 1478 The trust amount is in a range from 0-255, interpreted such that 1479 values less than 120 indicate partial trust and values of 120 or 1480 greater indicate complete trust. Implementations SHOULD emit values 1481 of 60 for partial trust and 120 for complete trust. 1483 5.2.3.15. {5.2.3.14} Regular Expression 1485 (null-terminated regular expression) 1487 Used in conjunction with trust Signature packets (of level > 0) to 1488 limit the scope of trust that is extended. Only signatures by the 1489 target key on User IDs that match the regular expression in the body 1490 of this packet have trust extended by the trust Signature subpacket. 1491 The regular expression uses the same syntax as the Henry Spencer's 1492 "almost public domain" regular expression [REGEX] package. A 1493 description of the syntax is found in Section 8 below. 1495 5.2.3.16. {5.2.3.15} Revocation Key 1497 (1 octet of class, 1 octet of public-key algorithm ID, 20 or 32 1498 octets of fingerprint) 1500 V4 keys use the full 20 octet fingerprint; V5 keys use the full 32 1501 octet fingerprint 1503 Authorizes the specified key to issue revocation signatures for this 1504 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1505 then this means that the revocation information is sensitive. Other 1506 bits are for future expansion to other kinds of authorizations. This 1507 is found on a self-signature. 1509 If the "sensitive" flag is set, the keyholder feels this subpacket 1510 contains private trust information that describes a real-world 1511 sensitive relationship. If this flag is set, implementations SHOULD 1512 NOT export this signature to other users except in cases where the 1513 data needs to be available: when the signature is being sent to the 1514 designated revoker, or when it is accompanied by a revocation 1515 signature from that revoker. Note that it may be appropriate to 1516 isolate this subpacket within a separate signature so that it is not 1517 combined with other subpackets that need to be exported. 1519 5.2.3.17. {5.2.3.16} Notation Data 1521 (4 octets of flags, 2 octets of name length (M), 1522 2 octets of value length (N), 1523 M octets of name data, 1524 N octets of value data) 1526 This subpacket describes a "notation" on the signature that the 1527 issuer wishes to make. The notation has a name and a value, each of 1528 which are strings of octets. There may be more than one notation in 1529 a signature. Notations can be used for any extension the issuer of 1530 the signature cares to make. The "flags" field holds four octets of 1531 flags. 1533 All undefined flags MUST be zero. Defined flags are as follows: 1535 First octet: 0x80 = human-readable. This note value is text. 1536 Other octets: none. 1538 Notation names are arbitrary strings encoded in UTF-8. They reside 1539 in two namespaces: The IETF namespace and the user namespace. 1541 The IETF namespace is registered with IANA. These names MUST NOT 1542 contain the "@" character (0x40). This is a tag for the user 1543 namespace. 1545 Names in the user namespace consist of a UTF-8 string tag followed by 1546 "@" followed by a DNS domain name. Note that the tag MUST NOT 1547 contain an "@" character. For example, the "sample" tag used by 1548 Example Corporation could be "sample@example.com". 1550 Names in a user space are owned and controlled by the owners of that 1551 domain. Obviously, it's bad form to create a new name in a DNS space 1552 that you don't own. 1554 Since the user namespace is in the form of an email address, 1555 implementers MAY wish to arrange for that address to reach a person 1556 who can be consulted about the use of the named tag. Note that due 1557 to UTF-8 encoding, not all valid user space name tags are valid email 1558 addresses. 1560 If there is a critical notation, the criticality applies to that 1561 specific notation and not to notations in general. 1563 The following subsections define a set of standard notations. 1565 5.2.3.17.1. The 'manu' Notation 1567 The "manu" notation is a string that declares the device 1568 manufacturer's name. The certifier key is asserting this string 1569 (which may or may not be related to the User ID of the certifier's 1570 key). 1572 5.2.3.17.2. The 'make' Notation 1574 This notation defines the product make. It is a free form string. 1576 5.2.3.17.3. The 'model' Notation 1578 This notation defines the product model name/number. It is a free 1579 form string. 1581 5.2.3.17.4. The 'prodid' Notation 1583 This notation contains the product identifier. It is a free form 1584 string. 1586 5.2.3.17.5. The 'pvers' Notation 1588 This notation defines the product version number (which could be a 1589 release number, year, or some other identifier to differentiate 1590 different versions of the same make/model). It is a free form 1591 string. 1593 5.2.3.17.6. The 'lot' Notation 1595 This notation defines the product lot number (which is an indicator 1596 of the batch of product). It is a free form string. 1598 5.2.3.17.7. The 'qty' Notation 1600 This notation defines the quantity of items in this package. It is a 1601 decimal integer representation with no punctuation, e.g. "10", 1602 "1000", "10000", etc. 1604 5.2.3.17.8. The 'loc' and 'dest' Notations 1606 The "loc" and 'dest' notations declare a GeoLocation as defined by 1607 RFC 5870 [RFC5870] but without the leading "geo:" header. For 1608 example, if you had a GeoLocation URI of "geo:13.4125,103.8667" you 1609 would encode that in these notations as "13.4125,103.8667". 1611 The 'loc' notation is meant to encode the geo location where the 1612 signature was made. The 'dest' notation is meant to encode the geo 1613 location where the device is "destined" (i.e., a "destination" for 1614 the device). 1616 5.2.3.17.9. The 'hash' Notation 1618 A 'hash' notation is a means to include external data in the contents 1619 of a signature without including the data itself. This is done by 1620 hashing the external data separately and then including the data's 1621 name and hash in the signature via this notation. This is useful, 1622 for example, to have an external "manifest," "image," or other data 1623 that might not be vital to the signature itself but still needs to be 1624 protected and authenticated without requiring a second signature. 1626 The 'hash' notation has the following structure: * A single byte 1627 specifying the length of the name of the hashed data * A UTF-8 string 1628 of the name of the hashed data * A single byte specifying the hash 1629 algorithm (see section 9.4) * The binary hash output of the hashed 1630 data using the specified algorithm. (The length of this data is 1631 implicit based on the algorithm specified). 1633 Due to its nature a 'hash' notation is not human readable and MUST 1634 NOT be marked as such when used. 1636 5.2.3.18. {5.2.3.17} Key Server Preferences 1638 (N octets of flags) 1640 This is a list of one-bit flags that indicate preferences that the 1641 key holder has about how the key is handled on a key server. All 1642 undefined flags MUST be zero. 1644 First octet: 0x80 = No-modify the key holder requests that this key 1645 only be modified or updated by the key holder or an administrator of 1646 the key server. 1648 This is found only on a self-signature. 1650 5.2.3.19. {5.2.3.18} Preferred Key Server 1652 (String) 1654 This is a URI of a key server that the key holder prefers be used for 1655 updates. Note that keys with multiple User IDs can have a preferred 1656 key server for each User ID. Note also that since this is a URI, the 1657 key server can actually be a copy of the key retrieved by ftp, http, 1658 finger, etc. 1660 5.2.3.20. {5.2.3.19} Primary User ID 1662 (1 octet, Boolean) 1664 This is a flag in a User ID's self-signature that states whether this 1665 User ID is the main User ID for this key. It is reasonable for an 1666 implementation to resolve ambiguities in preferences, etc. by 1667 referring to the primary User ID. If this flag is absent, its value 1668 is zero. If more than one User ID in a key is marked as primary, the 1669 implementation may resolve the ambiguity in any way it sees fit, but 1670 it is RECOMMENDED that priority be given to the User ID with the most 1671 recent self-signature. 1673 When appearing on a self-signature on a User ID packet, this 1674 subpacket applies only to User ID packets. When appearing on a self- 1675 signature on a User Attribute packet, this subpacket applies only to 1676 User Attribute packets. That is to say, there are two different and 1677 independent "primaries" -- one for User IDs, and one for User 1678 Attributes. 1680 5.2.3.21. {5.2.3.20} Policy URI 1682 (String) 1684 This subpacket contains a URI of a document that describes the policy 1685 under which the signature was issued. 1687 5.2.3.22. {5.2.3.21} Key Flags 1689 (N octets of flags) 1691 This subpacket contains a list of binary flags that hold information 1692 about a key. It is a string of octets, and an implementation MUST 1693 NOT assume a fixed size. This is so it can grow over time. If a 1694 list is shorter than an implementation expects, the unstated flags 1695 are considered to be zero. The defined flags are as follows: 1697 Defined features are as follows: 1699 First octet: 1701 0x01 - This key may be used to certify other keys. 1703 0x02 - This key may be used to sign data. 1705 0x04 - This key may be used to encrypt communications. 1707 0x08 - This key may be used to encrypt storage. 1709 0x10 - The private component of this key may have been split by a 1710 secret-sharing mechanism. 1712 0x20 - This key may be used for authentication. 1714 0x80 - The private component of this key may be in the possession 1715 of more than one person. 1717 Second octet: 1719 0x04 - This key may be used as an additional decryption subkey (ADSK). 1721 Usage notes: 1723 The flags in this packet may appear in self-signatures or in 1724 certification signatures. They mean different things depending on 1725 who is making the statement --- for example, a certification 1726 signature that has the "sign data" flag is stating that the 1727 certification is for that use. On the other hand, the 1728 "communications encryption" flag in a self-signature is stating a 1729 preference that a given key be used for communications. Note 1730 however, that it is a thorny issue to determine what is 1731 "communications" and what is "storage". This decision is left wholly 1732 up to the implementation; the authors of this document do not claim 1733 any special wisdom on the issue and realize that accepted opinion may 1734 change. 1736 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1737 self-signature only; they are meaningless on a certification 1738 signature. They SHOULD be placed only on a direct-key signature 1739 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1740 key the flag applies to. 1742 The ADSK flag helps to figure out an encryption subkey. 1744 5.2.3.23. {5.2.3.22} Signer's User ID 1746 (String) 1748 This subpacket allows a keyholder to state which User ID is 1749 responsible for the signing. Many keyholders use a single key for 1750 different purposes, such as business communications as well as 1751 personal communications. This subpacket allows such a keyholder to 1752 state which of their roles is making a signature. 1754 This subpacket is not appropriate to use to refer to a User Attribute 1755 packet. 1757 5.2.3.24. {5.2.3.23} Reason for Revocation 1759 (1 octet of revocation code, N octets of reason string) 1761 This subpacket is used only in key revocation and certification 1762 revocation signatures. It describes the reason why the key or 1763 certificate was revoked. 1765 The first octet contains a machine-readable code that denotes the 1766 reason for the revocation: 1768 +----------+--------------------------------------------------------+ 1769 | Code | Reason | 1770 +----------+--------------------------------------------------------+ 1771 | 0 | No reason specified (key revocations or cert | 1772 | | revocations) | 1773 | 1 | Key is superseded (key revocations) | 1774 | 2 | Key material has been compromised (key revocations) | 1775 | 3 | Key is retired and no longer used (key revocations) | 1776 | 32 | User ID information is no longer valid (cert | 1777 | | revocations) | 1778 | 100-110 | Private Use | 1779 +----------+--------------------------------------------------------+ 1781 Following the revocation code is a string of octets that gives 1782 information about the Reason for Revocation in human-readable form 1783 (UTF-8). The string may be null, that is, of zero length. The 1784 length of the subpacket is the length of the reason string plus one. 1785 An implementation SHOULD implement this subpacket, include it in all 1786 revocation signatures, and interpret revocations appropriately. 1787 There are important semantic differences between the reasons, and 1788 there are thus important reasons for revoking signatures. 1790 If a key has been revoked because of a compromise, all signatures 1791 created by that key are suspect. However, if it was merely 1792 superseded or retired, old signatures are still valid. If the 1793 revoked signature is the self-signature for certifying a User ID, a 1794 revocation denotes that that user name is no longer in use. Such a 1795 revocation SHOULD include a 0x20 code. 1797 Note that any signature may be revoked, including a certification on 1798 some other person's key. There are many good reasons for revoking a 1799 certification signature, such as the case where the keyholder leaves 1800 the employ of a business with an email address. A revoked 1801 certification is no longer a part of validity calculations. 1803 5.2.3.25. {5.2.3.24} Features 1805 (N octets of flags) 1807 The Features subpacket denotes which advanced OpenPGP features a 1808 user's implementation supports. This is so that as features are 1809 added to OpenPGP that cannot be backwards-compatible, a user can 1810 state that they can use that feature. The flags are single bits that 1811 indicate that a given feature is supported. 1813 This subpacket is similar to a preferences subpacket, and only 1814 appears in a self-signature. 1816 An implementation SHOULD NOT use a feature listed when sending to a 1817 user who does not state that they can use it. 1819 Defined features are as follows: 1821 First octet: 1823 0x01 - Modification Detection (packets 18 and 19) 1825 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5 1826 Symmetric-Key Encrypted Session Key Packets (packet 3) 1828 0x04 - Version 5 Public-Key Packet format and corresponding new 1829 fingerprint format 1831 If an implementation implements any of the defined features, it 1832 SHOULD implement the Features subpacket, too. 1834 An implementation may freely infer features from other suitable 1835 implementation-dependent mechanisms. 1837 5.2.3.26. {5.2.3.25} Signature Target 1839 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1841 This subpacket identifies a specific target signature to which a 1842 signature refers. For revocation signatures, this subpacket provides 1843 explicit designation of which signature is being revoked. For a 1844 third-party or timestamp signature, this designates what signature is 1845 signed. All arguments are an identifier of that target signature. 1847 The N octets of hash data MUST be the size of the hash of the 1848 signature. For example, a target signature with a SHA-1 hash MUST 1849 have 20 octets of hash data. 1851 5.2.3.27. {5.2.3.26} Embedded Signature 1853 (1 signature packet body) 1855 This subpacket contains a complete Signature packet body as specified 1856 in Section 5.2 above. It is useful when one signature needs to refer 1857 to, or be incorporated in, another signature. 1859 5.2.3.28. Issuer Fingerprint 1861 (1 octet key version number, N octets of fingerprint) 1863 The OpenPGP Key fingerprint of the key issuing the signature. This 1864 subpacket SHOULD be included in all signatures. If the version of 1865 the issuing key is 4 and an Issuer subpacket is also included in the 1866 signature, the key ID of the Issuer subpacket MUST match the low 64 1867 bits of the fingerprint. 1869 Note that the length N of the fingerprint for a version 4 key is 20 1870 octets; for a version 5 key N is 32. 1872 5.2.4. {5.2.4} Computing Signatures 1874 All signatures are formed by producing a hash over the signature 1875 data, and then using the resulting hash in the signature algorithm. 1877 For binary document signatures (type 0x00), the document data is 1878 hashed directly. For text document signatures (type 0x01), the 1879 document is canonicalized by converting line endings to , and 1880 the resulting data is hashed. 1882 When a signature is made over a key, the hash data starts with the 1883 octet 0x99, followed by a two-octet length of the key, and then body 1884 of the key packet. (Note that this is an old-style packet header for 1885 a key packet with two-octet length.) A subkey binding signature 1886 (type 0x18) or primary key binding signature (type 0x19) then hashes 1887 the subkey using the same format as the main key (also using 0x99 as 1888 the first octet). Primary key revocation signatures (type 0x20) hash 1889 only the key being revoked. Subkey revocation signature (type 0x28) 1890 hash first the primary key and then the subkey being revoked. 1892 A certification signature (type 0x10 through 0x13) hashes the User ID 1893 being bound to the key into the hash context after the above data. A 1894 V3 certification hashes the contents of the User ID or attribute 1895 packet packet, without any header. A V4 or V5 certification hashes 1896 the constant 0xB4 for User ID certifications or the constant 0xD1 for 1897 User Attribute certifications, followed by a four-octet number giving 1898 the length of the User ID or User Attribute data, and then the User 1899 ID or User Attribute data. 1901 When a signature is made over a Signature packet (type 0x50), the 1902 hash data starts with the octet 0x88, followed by the four-octet 1903 length of the signature, and then the body of the Signature packet. 1904 (Note that this is an old-style packet header for a Signature packet 1905 with the length-of-length set to zero.) The unhashed subpacket data 1906 of the Signature packet being hashed is not included in the hash, and 1907 the unhashed subpacket data length value is set to zero. 1909 Once the data body is hashed, then a trailer is hashed. A V3 1910 signature hashes five octets of the packet body, starting from the 1911 signature type field. This data is the signature type, followed by 1912 the four-octet signature time. A V4 or V5 signature hashes the 1913 packet body starting from its first field, the version number, 1914 through the end of the hashed subpacket data. Thus, the fields 1915 hashed are the signature version, the signature type, the public-key 1916 algorithm, the hash algorithm, the hashed subpacket length, and the 1917 hashed subpacket body. 1919 V4 signatures also hash in a final trailer of six octets: the version 1920 of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, big- 1921 endian number that is the length of the hashed data from the 1922 Signature packet (note that this number does not include these final 1923 six octets). {FIXME: truncated or wrap that number on overflow} 1925 V5 signatures instead hash in a ten-octet trailer: the version of the 1926 Signature packet, i.e., 0x05; 0xFF; and an eight-octet, big-endian 1927 number that is the length of the hashed data from the Signature 1928 packet (note that this number does not include these final ten 1929 octets). 1931 After all this has been hashed in a single hash context, the 1932 resulting hash field is used in the signature algorithm and placed at 1933 the end of the Signature packet. 1935 5.2.4.1. {5.2.4.1} Subpacket Hints 1937 It is certainly possible for a signature to contain conflicting 1938 information in subpackets. For example, a signature may contain 1939 multiple copies of a preference or multiple expiration times. In 1940 most cases, an implementation SHOULD use the last subpacket in the 1941 signature, but MAY use any conflict resolution scheme that makes more 1942 sense. Please note that we are intentionally leaving conflict 1943 resolution to the implementer; most conflicts are simply syntax 1944 errors, and the wishy-washy language here allows a receiver to be 1945 generous in what they accept, while putting pressure on a creator to 1946 be stingy in what they generate. 1948 Some apparent conflicts may actually make sense -- for example, 1949 suppose a keyholder has a V3 key and a V4 key that share the same RSA 1950 key material. Either of these keys can verify a signature created by 1951 the other, and it may be reasonable for a signature to contain an 1952 issuer subpacket for each key, as a way of explicitly tying those 1953 keys to the signature. 1955 5.3. {5.3} Symmetric-Key Encrypted Session Key Packets (Tag 3) 1957 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 1958 key encryption of a session key used to encrypt a message. Zero or 1959 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 1960 Encrypted Session Key packets may precede a Symmetrically Encrypted 1961 Data packet that holds an encrypted message. The message is 1962 encrypted with a session key, and the session key is itself encrypted 1963 and stored in the Encrypted Session Key packet or the Symmetric-Key 1964 Encrypted Session Key packet. 1966 If the Symmetrically Encrypted Data packet is preceded by one or more 1967 Symmetric-Key Encrypted Session Key packets, each specifies a 1968 passphrase that may be used to decrypt the message. This allows a 1969 message to be encrypted to a number of public keys, and also to one 1970 or more passphrases. This packet type is new and is not generated by 1971 PGP 2.x or PGP 5.0. 1973 A version 4 Symmetric-Key Encrypted Session Key packet consists of: 1975 o A one-octet version number with value 4. 1977 o A one-octet number describing the symmetric algorithm used. 1979 o A string-to-key (S2K) specifier, length as defined above. 1981 o Optionally, the encrypted session key itself, which is decrypted 1982 with the string-to-key object. 1984 If the encrypted session key is not present (which can be detected on 1985 the basis of packet length and S2K specifier size), then the S2K 1986 algorithm applied to the passphrase produces the session key for 1987 decrypting the file, using the symmetric cipher algorithm from the 1988 Symmetric-Key Encrypted Session Key packet. 1990 If the encrypted session key is present, the result of applying the 1991 S2K algorithm to the passphrase is used to decrypt just that 1992 encrypted session key field, using CFB mode with an IV of all zeros. 1993 The decryption result consists of a one-octet algorithm identifier 1994 that specifies the symmetric-key encryption algorithm used to encrypt 1995 the following Symmetrically Encrypted Data packet, followed by the 1996 session key octets themselves. 1998 Note: because an all-zero IV is used for this decryption, the S2K 1999 specifier MUST use a salt value, either a Salted S2K or an Iterated- 2000 Salted S2K. The salt value will ensure that the decryption key is 2001 not repeated even if the passphrase is reused. 2003 A version 5 Symmetric-Key Encrypted Session Key packet consists of: 2005 o A one-octet version number with value 5. 2007 o A one-octet cipher algorithm. 2009 o A one-octet AEAD algorithm. 2011 o A string-to-key (S2K) specifier, length as defined above. 2013 o A starting initialization vector of size specified by the AEAD 2014 algorithm. 2016 o The encrypted session key itself, which is decrypted with the 2017 string-to-key object using the given cipher and AEAD mode. 2019 o An authentication tag for the AEAD mode. 2021 The encrypted session key is encrypted using one of the AEAD 2022 algorithms specified for the AEAD Encrypted Packet. Note that no 2023 chunks are used and that there is only one authentication tag. The 2024 Packet Tag in new format encoding (bits 7 and 6 set, bits 5-0 carry 2025 the packet tag), the packet version number, the cipher algorithm 2026 octet, and the AEAD algorithm octet are given as additional data. 2028 For example, the additional data used with EAX and AES-128 consists 2029 of the octets 0xC3, 0x05, 0x07, and 0x01. 2031 5.4. {5.4} One-Pass Signature Packets (Tag 4) 2033 The One-Pass Signature packet precedes the signed data and contains 2034 enough information to allow the receiver to begin calculating any 2035 hashes needed to verify the signature. It allows the Signature 2036 packet to be placed at the end of the message, so that the signer can 2037 compute the entire signed message in one pass. 2039 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 2041 The body of this packet consists of: 2043 o A one-octet version number. The current version is 3. 2045 o A one-octet signature type. Signature types are described in 2046 Section 5.2.1. 2048 o A one-octet number describing the hash algorithm used. 2050 o A one-octet number describing the public-key algorithm used. 2052 o An eight-octet number holding the Key ID of the signing key. 2054 o A one-octet number holding a flag showing whether the signature is 2055 nested. A zero value indicates that the next packet is another 2056 One-Pass Signature packet that describes another signature to be 2057 applied to the same message data. 2059 Note that if a message contains more than one one-pass signature, 2060 then the Signature packets bracket the message; that is, the first 2061 Signature packet after the message corresponds to the last one-pass 2062 packet and the final Signature packet corresponds to the first one- 2063 pass packet. 2065 5.5. {5.5} Key Material Packet 2067 A key material packet contains all the information about a public or 2068 private key. There are four variants of this packet type, and two 2069 major versions. Consequently, this section is complex. 2071 5.5.1. {5.5.1} Key Packet Variants 2072 5.5.1.1. {5.5.1.1} Public-Key Packet (Tag 6) 2074 A Public-Key packet starts a series of packets that forms an OpenPGP 2075 key (sometimes called an OpenPGP certificate). 2077 5.5.1.2. {5.5.1.2} Public-Subkey Packet (Tag 14) 2079 A Public-Subkey packet (tag 14) has exactly the same format as a 2080 Public-Key packet, but denotes a subkey. One or more subkeys may be 2081 associated with a top-level key. By convention, the top-level key 2082 provides signature services, and the subkeys provide encryption 2083 services. 2085 Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet. 2086 This tag was selected for reuse because no previous version of PGP 2087 ever emitted comment packets but they did properly ignore them. 2088 Public-Subkey packets are ignored by PGP 2.6.x and do not cause it to 2089 fail, providing a limited degree of backward compatibility. 2091 5.5.1.3. {5.5.1.3} Secret-Key Packet (Tag 5) 2093 A Secret-Key packet contains all the information that is found in a 2094 Public-Key packet, including the public-key material, but also 2095 includes the secret-key material after all the public-key fields. 2097 5.5.1.4. {5.5.1.4} Secret-Subkey Packet (Tag 7) 2099 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2100 packet and has exactly the same format. 2102 5.5.2. {5.5.2} Public-Key Packet Formats 2104 There are three versions of key-material packets. Version 3 packets 2105 were first generated by PGP 2.6. Version 4 keys first appeared in 2106 PGP 5.0 and are the preferred key version for OpenPGP. 2108 OpenPGP implementations MUST create keys with version 4 format. V3 2109 keys are deprecated; an implementation MUST NOT generate a V3 key, 2110 but MAY accept it. 2112 A version 3 public key or public-subkey packet contains: 2114 o A one-octet version number (3). 2116 o A four-octet number denoting the time that the key was created. 2118 o A two-octet number denoting the time in days that this key is 2119 valid. If this number is zero, then it does not expire. 2121 o A one-octet number denoting the public-key algorithm of this key. 2123 o A series of multiprecision integers comprising the key material: 2125 * a multiprecision integer (MPI) of RSA public modulus n; 2127 * an MPI of RSA public encryption exponent e. 2129 V3 keys are deprecated. They contain three weaknesses. First, it is 2130 relatively easy to construct a V3 key that has the same Key ID as any 2131 other key because the Key ID is simply the low 64 bits of the public 2132 modulus. Secondly, because the fingerprint of a V3 key hashes the 2133 key material, but not its length, there is an increased opportunity 2134 for fingerprint collisions. Third, there are weaknesses in the MD5 2135 hash algorithm that make developers prefer other algorithms. See 2136 below for a fuller discussion of Key IDs and fingerprints. 2138 V2 keys are identical to the deprecated V3 keys except for the 2139 version number. An implementation MUST NOT generate them and MAY 2140 accept or reject them as it sees fit. 2142 The version 4 format is similar to the version 3 format except for 2143 the absence of a validity period. This has been moved to the 2144 Signature packet. In addition, fingerprints of version 4 keys are 2145 calculated differently from version 3 keys, as described in the 2146 section "Enhanced Key Formats". 2148 A version 4 packet contains: 2150 o A one-octet version number (4). 2152 o A four-octet number denoting the time that the key was created. 2154 o A one-octet number denoting the public-key algorithm of this key. 2156 o A series of values comprising the key material. This is 2157 algorithm-specific and described in section XXXX. 2159 The version 5 format is similar to the version 4 format except for 2160 the addition of a count for the key material. This count helps 2161 parsing secret key packets (which are an extension of the public key 2162 packet format) in the case of an unknown algoritm. In addition, 2163 fingerprints of version 5 keys are calculated differently from 2164 version 4 keys, as described in the section "Enhanced Key Formats". 2166 A version 5 packet contains: 2168 o A one-octet version number (5). 2170 o A four-octet number denoting the time that the key was created. 2172 o A one-octet number denoting the public-key algorithm of this key. 2174 o A four-octet scalar octet count for the following key material. 2176 o A series of values comprising the key material. This is 2177 algorithm-specific and described in section XXXX. 2179 5.5.3. {5.5.3} Secret-Key Packet Formats 2181 The Secret-Key and Secret-Subkey packets contain all the data of the 2182 Public-Key and Public-Subkey packets, with additional algorithm- 2183 specific secret-key data appended, usually in encrypted form. 2185 The packet contains: 2187 o A Public-Key or Public-Subkey packet, as described above. 2189 o One octet indicating string-to-key usage conventions. Zero 2190 indicates that the secret-key data is not encrypted. 255 or 254 2191 indicates that a string-to-key specifier is being given. Any 2192 other value is a symmetric-key encryption algorithm identifier. A 2193 version 5 packet MUST NOT use the value 255. 2195 o Only for a version 5 packet, a one-octet scalar octet count of the 2196 next 4 optional fields. 2198 o [Optional] If string-to-key usage octet was 255, 254, or 253, a 2199 one- octet symmetric encryption algorithm. 2201 o [Optional] If string-to-key usage octet was 253, a one-octet AEAD 2202 algorithm. 2204 o [Optional] If string-to-key usage octet was 255, 254, or 253, a 2205 string-to-key specifier. The length of the string-to-key 2206 specifier is implied by its type, as described above. 2208 o [Optional] If secret data is encrypted (string-to-key usage octet 2209 not zero), an Initial Vector (IV) of the same length as the 2210 cipher's block size. If string-to-key usage octet was 253 the IV 2211 is used as the nonce for the AEAD algorithm. If the AEAD 2212 algorithm requires a shorter nonce, the high-order bits of the IV 2213 are used and the remaining bits MUST be zero. 2215 o Only for a version 5 packet, a four-octet scalar octet count for 2216 the following key material. 2218 o Plain or encrypted series of values comprising the secret key 2219 material. This is algorithm-specific and described in section 2220 XXXX. 2222 o If the string-to-key usage octet is zero or 255, then a two-octet 2223 checksum of the plaintext of the algorithm-specific portion (sum 2224 of all octets, mod 65536). If the string-to-key usage octet was 2225 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2226 specific portion. This checksum or hash is encrypted together 2227 with the algorithm-specific fields (if string-to-key usage octet 2228 is not zero). If the string-to-key usage octet was 253, then an 2229 AEAD authentication tag is included here. Note that for all other 2230 values, a two-octet checksum is required. 2232 Note that the version 5 packet format adds two count values to help 2233 parsing packets with unknown S2K or public key algorithms. 2235 Secret MPI values can be encrypted using a passphrase. If a string- 2236 to-key specifier is given, that describes the algorithm for 2237 converting the passphrase to a key, else a simple MD5 hash of the 2238 passphrase is used. Implementations MUST use a string-to-key 2239 specifier; the simple hash is for backward compatibility and is 2240 deprecated, though implementations MAY continue to use existing 2241 private keys in the old format. The cipher for encrypting the MPIs 2242 is specified in the Secret-Key packet. 2244 Encryption/decryption of the secret data is done in CFB mode using 2245 the key created from the passphrase and the Initial Vector from the 2246 packet. A different mode is used with V3 keys (which are only RSA) 2247 than with other key formats. With V3 keys, the MPI bit count prefix 2248 (i.e., the first two octets) is not encrypted. Only the MPI non- 2249 prefix data is encrypted. Furthermore, the CFB state is 2250 resynchronized at the beginning of each new MPI value, so that the 2251 CFB block boundary is aligned with the start of the MPI data. 2253 With V4 and V5 keys, a simpler method is used. All secret MPI values 2254 are encrypted, including the MPI bitcount prefix. 2256 If the string-to-key usage octet is 253, the encrypted MPI values are 2257 encrypted as one combined plaintext using one of the AEAD algorithms 2258 specified for the AEAD Encrypted Packet. Note that no chunks are 2259 used and that there is only one authentication tag. The Packet Tag 2260 in new format encoding (bits 7 and 6 set, bits 5-0 carry the packet 2261 tag), the packet version number, the cipher algorithm octet, and the 2262 AEAD algorithm octet are given as additional data. For example, the 2263 additional data used with EAX and AES-128 in a Secret-Key Packet of 2264 version 4 consists of the octets 0xC5, 0x04, 0x07, and 0x01; in a 2265 Secret-Subkey Packet the first octet would be 0xC7. 2267 The two-octet checksum that follows the algorithm-specific portion is 2268 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2269 specific octets (including MPI prefix and data). With V3 keys, the 2270 checksum is stored in the clear. With V4 keys, the checksum is 2271 encrypted like the algorithm-specific data. This value is used to 2272 check that the passphrase was correct. However, this checksum is 2273 deprecated; an implementation SHOULD NOT use it, but should rather 2274 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2275 this is that there are some attacks that involve undetectably 2276 modifying the secret key. If the string-to-key usage octet is 253 no 2277 checksum or SHA-1 hash is used but the authentication tag of the AEAD 2278 algorithm follows. 2280 5.6. Algorithm-specific Parts of Keys 2282 The public and secret key format specifies algorithm-specific parts 2283 of a key. The following sections describe them in detail. 2285 5.6.1. Algorithm-Specific Part for RSA Keys 2287 The public key is this series of multiprecision integers: 2289 o MPI of RSA public modulus n; 2291 o MPI of RSA public encryption exponent e. 2293 The secret key is this series of multiprecision integers: 2295 o MPI of RSA secret exponent d; 2297 o MPI of RSA secret prime value p; 2299 o MPI of RSA secret prime value q (p < q); 2301 o MPI of u, the multiplicative inverse of p, mod q. 2303 5.6.2. Algorithm-Specific Part for DSA Keys 2305 The public key is this series of multiprecision integers: 2307 o MPI of DSA prime p; 2309 o MPI of DSA group order q (q is a prime divisor of p-1); 2311 o MPI of DSA group generator g; 2313 o MPI of DSA public-key value y (= g**x mod p where x is secret). 2315 The secret key is this single multiprecision integer: 2317 o MPI of DSA secret exponent x. 2319 5.6.3. Algorithm-Specific Part for Elgamal Keys 2321 The public key is this series of multiprecision integers: 2323 o MPI of Elgamal prime p; 2325 o MPI of Elgamal group generator g; 2327 o MPI of Elgamal public key value y (= g**x mod p where x is 2328 secret). 2330 The secret key is this single multiprecision integer: 2332 o MPI of Elgamal secret exponent x. 2334 5.6.4. Algorithm-Specific Part for ECDSA Keys 2336 The public key is this series of values: 2338 o a variable-length field containing a curve OID, formatted as 2339 follows: 2341 * a one-octet size of the following field; values 0 and 0xFF are 2342 reserved for future extensions, 2344 * the octets representing a curve OID, defined in section 2345 11{FIXME}; 2347 o a MPI of an EC point representing a public key. 2349 The secret key is this single multiprecision integer: 2351 o MPI of an integer representing the secret key, which is a scalar 2352 of the public EC point. 2354 5.6.5. Algorithm-Specific Part for EdDSA Keys 2356 The public key is this series of values: 2358 o a variable-length field containing a curve OID, formatted as 2359 follows: 2361 * a one-octet size of the following field; values 0 and 0xFF are 2362 reserved for future extensions, 2364 * the octets representing a curve OID, defined in section 2365 NN{FIXME}; 2367 o a MPI of an EC point representing a public key Q as described 2368 under EdDSA Point Format below. 2370 The secret key is this single multiprecision integer: 2372 o MPI of an integer representing the secret key, which is a scalar 2373 of the public EC point. 2375 5.6.6. Algorithm-Specific Part for ECDH Keys 2377 The public key is this series of values: 2379 o a variable-length field containing a curve OID, formatted as 2380 follows: 2382 * a one-octet size of the following field; values 0 and 0xFF are 2383 reserved for future extensions, 2385 * the octets representing a curve OID, defined in 2386 Section 11{FIXME}; 2388 o a MPI of an EC point representing a public key; 2390 o a variable-length field containing KDF parameters, formatted as 2391 follows: 2393 * a one-octet size of the following fields; values 0 and 0xff are 2394 reserved for future extensions; 2396 * a one-octet value 1, reserved for future extensions; 2398 * a one-octet hash function ID used with a KDF; 2400 * a one-octet algorithm ID for the symmetric algorithm used to 2401 wrap the symmetric key used for the message encryption; see 2402 Section 8 for details. 2404 Observe that an ECDH public key is composed of the same sequence of 2405 fields that define an ECDSA key, plus the KDF parameters field. 2407 The secret key is this single multiprecision integer: 2409 o MPI of an integer representing the secret key, which is a scalar 2410 of the public EC point. 2412 5.7. {5.6} Compressed Data Packet (Tag 8) 2414 The Compressed Data packet contains compressed data. Typically, this 2415 packet is found as the contents of an encrypted packet, or following 2416 a Signature or One-Pass Signature packet, and contains a literal data 2417 packet. 2419 The body of this packet consists of: 2421 o One octet that gives the algorithm used to compress the packet. 2423 o Compressed data, which makes up the remainder of the packet. 2425 A Compressed Data Packet's body contains an block that compresses 2426 some set of packets. See section "Packet Composition" for details on 2427 how messages are formed. 2429 ZIP-compressed packets are compressed with raw RFC 1951 [RFC1951] 2430 DEFLATE blocks. Note that PGP V2.6 uses 13 bits of compression. If 2431 an implementation uses more bits of compression, PGP V2.6 cannot 2432 decompress it. 2434 ZLIB-compressed packets are compressed with RFC 1950 [RFC1950] ZLIB- 2435 style blocks. 2437 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2438 algorithm. 2440 5.8. {5.7} Symmetrically Encrypted Data Packet (Tag 9) 2442 The Symmetrically Encrypted Data packet contains data encrypted with 2443 a symmetric-key algorithm. When it has been decrypted, it contains 2444 other packets (usually a literal data packet or compressed data 2445 packet, but in theory other Symmetrically Encrypted Data packets or 2446 sequences of packets that form whole OpenPGP messages). 2448 This packet is obsolete. An implementation MUST not create this 2449 packet. An implementation MAY process such a packet but it MUST 2450 return a clear diagnostic that a non-integrity protected packet has 2451 been processed. The implementation SHOULD also return an error in 2452 this case and stop processing. 2454 The body of this packet consists of: 2456 o Encrypted data, the output of the selected symmetric-key cipher 2457 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2459 The symmetric cipher used may be specified in a Public-Key or 2460 Symmetric-Key Encrypted Session Key packet that precedes the 2461 Symmetrically Encrypted Data packet. In that case, the cipher 2462 algorithm octet is prefixed to the session key before it is 2463 encrypted. If no packets of these types precede the encrypted data, 2464 the IDEA algorithm is used with the session key calculated as the MD5 2465 hash of the passphrase, though this use is deprecated. 2467 The data is encrypted in CFB mode, with a CFB shift size equal to the 2468 cipher's block size. The Initial Vector (IV) is specified as all 2469 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2470 equal to the block size of the cipher plus two to the data before it 2471 is encrypted. The first block-size octets (for example, 8 octets for 2472 a 64-bit block length) are random, and the following two octets are 2473 copies of the last two octets of the IV. For example, in an 8-octet 2474 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2475 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2476 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2477 in both these examples, we consider the first octet to be numbered 1. 2479 After encrypting the first block-size-plus-two octets, the CFB state 2480 is resynchronized. The last block-size octets of ciphertext are 2481 passed through the cipher and the block boundary is reset. 2483 The repetition of 16 bits in the random data prefixed to the message 2484 allows the receiver to immediately check whether the session key is 2485 incorrect. See the "Security Considerations" section for hints on 2486 the proper use of this "quick check". 2488 5.9. {5.8} Marker Packet (Obsolete Literal Packet) (Tag 10) 2490 An experimental version of PGP used this packet as the Literal 2491 packet, but no released version of PGP generated Literal packets with 2492 this tag. With PGP 5.x, this packet has been reassigned and is 2493 reserved for use as the Marker packet. 2495 The body of this packet consists of: 2497 o The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2499 Such a packet MUST be ignored when received. It may be placed at the 2500 beginning of a message that uses features not available in PGP 2.6.x 2501 in order to cause that version to report that newer software is 2502 necessary to process the message. 2504 5.10. {5.9} Literal Data Packet (Tag 11) 2506 A Literal Data packet contains the body of a message; data that is 2507 not to be further interpreted. 2509 The body of this packet consists of: 2511 o A one-octet field that describes how the data is formatted. 2513 If it is a 'b' (0x62), then the Literal packet contains binary 2514 data. If it is a 't' (0x74), then it contains text data, and thus 2515 may need line ends converted to local form, or other text-mode 2516 changes. The tag 'u' (0x75) means the same as 't', but also 2517 indicates that implementation believes that the literal data 2518 contains UTF-8 text. If it is a 'm' (0x6d), then it contains a 2519 MIME message body part [RFC2045]. 2521 Early versions of PGP also defined a value of 'l' as a 'local' 2522 mode for machine-local conversions. RFC 1991 [RFC1991] 2523 incorrectly stated this local mode flag as '1' (ASCII numeral 2524 one). Both of these local modes are deprecated. 2526 o File name as a string (one-octet length, followed by a file name). 2527 This may be a zero-length string. Commonly, if the source of the 2528 encrypted data is a file, this will be the name of the encrypted 2529 file. An implementation MAY consider the file name in the Literal 2530 packet to be a more authoritative name than the actual file name. 2532 If the special name "_CONSOLE" is used, the message is considered 2533 to be "for your eyes only". This advises that the message data is 2534 unusually sensitive, and the receiving program should process it 2535 more carefully, perhaps avoiding storing the received data to 2536 disk, for example. 2538 o A four-octet number that indicates a date associated with the 2539 literal data. Commonly, the date might be the modification date 2540 of a file, or the time the packet was created, or a zero that 2541 indicates no specific time. 2543 o The remainder of the packet is literal data. 2545 Text data is stored with text endings (i.e., network- 2546 normal line endings). These should be converted to native line 2547 endings by the receiving software. 2549 Note that the formatting octet, the file name, and the date field of 2550 the literal packet are not included in a signature hash and thus are 2551 not protected against tampering in a signed document. 2553 5.11. {5.10} Trust Packet (Tag 12) 2555 The Trust packet is used only within keyrings and is not normally 2556 exported. Trust packets contain data that record the user's 2557 specifications of which key holders are trustworthy introducers, 2558 along with other information that implementing software uses for 2559 trust information. The format of Trust packets is defined by a given 2560 implementation. 2562 Trust packets SHOULD NOT be emitted to output streams that are 2563 transferred to other users, and they SHOULD be ignored on any input 2564 other than local keyring files. 2566 5.12. {5.11} User ID Packet (Tag 13) 2568 A User ID packet consists of UTF-8 text that is intended to represent 2569 the name and email address of the key holder. By convention, it 2570 includes an RFC 2822 [RFC2822] mail name-addr, but there are no 2571 restrictions on its content. The packet length in the header 2572 specifies the length of the User ID. 2574 5.13. {5.12} User Attribute Packet (Tag 17) 2576 The User Attribute packet is a variation of the User ID packet. It 2577 is capable of storing more types of data than the User ID packet, 2578 which is limited to text. Like the User ID packet, a User Attribute 2579 packet may be certified by the key owner ("self-signed") or any other 2580 key owner who cares to certify it. Except as noted, a User Attribute 2581 packet may be used anywhere that a User ID packet may be used. 2583 While User Attribute packets are not a required part of the OpenPGP 2584 standard, implementations SHOULD provide at least enough 2585 compatibility to properly handle a certification signature on the 2586 User Attribute packet. A simple way to do this is by treating the 2587 User Attribute packet as a User ID packet with opaque contents, but 2588 an implementation may use any method desired. 2590 The User Attribute packet is made up of one or more attribute 2591 subpackets. Each subpacket consists of a subpacket header and a 2592 body. The header consists of: 2594 o the subpacket length (1, 2, or 5 octets) 2596 o the subpacket type (1 octet) 2598 and is followed by the subpacket specific data. 2600 The following table lists the currently known subpackets: 2602 +----------+------------------------------+ 2603 | Type | Attribute Subpacket | 2604 +----------+------------------------------+ 2605 | 1 | Image Attribute Subpacket | 2606 | [TBD1] | User ID Attribute Subpacket | 2607 | 100-110 | Private/Experimental Use | 2608 +----------+------------------------------+ 2610 An implementation SHOULD ignore any subpacket of a type that it does 2611 not recognize. 2613 5.13.1. {5.12.1} The Image Attribute Subpacket 2615 The Image Attribute subpacket is used to encode an image, presumably 2616 (but not required to be) that of the key owner. 2618 The Image Attribute subpacket begins with an image header. The first 2619 two octets of the image header contain the length of the image 2620 header. Note that unlike other multi-octet numerical values in this 2621 document, due to a historical accident this value is encoded as a 2622 little-endian number. The image header length is followed by a 2623 single octet for the image header version. The only currently 2624 defined version of the image header is 1, which is a 16-octet image 2625 header. The first three octets of a version 1 image header are thus 2626 0x10, 0x00, 0x01. 2628 The fourth octet of a version 1 image header designates the encoding 2629 format of the image. The only currently defined encoding format is 2630 the value 1 to indicate JPEG. Image format types 100 through 110 are 2631 reserved for private or experimental use. The rest of the version 1 2632 image header is made up of 12 reserved octets, all of which MUST be 2633 set to 0. 2635 The rest of the image subpacket contains the image itself. As the 2636 only currently defined image type is JPEG, the image is encoded in 2637 the JPEG File Interchange Format (JFIF), a standard file format for 2638 JPEG images [JFIF]. 2640 An implementation MAY try to determine the type of an image by 2641 examination of the image data if it is unable to handle a particular 2642 version of the image header or if a specified encoding format value 2643 is not recognized. 2645 5.13.2. User ID Attribute Subpacket 2647 A User ID Attribute subpacket has type #[IANA -- assignment TBD1]. 2649 A User ID Attribute subpacket, just like a User ID packet, consists 2650 of UTF-8 text that is intended to represent the name and email 2651 address of the key holder. By convention, it includes an RFC 2822 2652 [RFC2822] mail name-addr, but there are no restrictions on its 2653 content. For devices using OpenPGP for device certificates, it may 2654 just be the device identifier. The packet length in the header 2655 specifies the length of the User ID. 2657 Because User Attribute subpackets can be used anywhere a User ID 2658 packet can be used, implementations MAY choose to trust a signed User 2659 Attribute subpacket that includes a User ID Attribute subpacket. 2661 5.14. {5.13} Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2663 The Symmetrically Encrypted Integrity Protected Data packet is a 2664 variant of the Symmetrically Encrypted Data packet. It is a new 2665 feature created for OpenPGP that addresses the problem of detecting a 2666 modification to encrypted data. It is used in combination with a 2667 Modification Detection Code packet. 2669 There is a corresponding feature in the features Signature subpacket 2670 that denotes that an implementation can properly use this packet 2671 type. An implementation MUST support decrypting these packets and 2672 SHOULD prefer generating them to the older Symmetrically Encrypted 2673 Data packet when possible. Since this data packet protects against 2674 modification attacks, this standard encourages its proliferation. 2675 While blanket adoption of this data packet would create 2676 interoperability problems, rapid adoption is nevertheless important. 2677 An implementation SHOULD specifically denote support for this packet, 2678 but it MAY infer it from other mechanisms. 2680 For example, an implementation might infer from the use of a cipher 2681 such as Advanced Encryption Standard (AES) or Twofish that a user 2682 supports this feature. It might place in the unhashed portion of 2683 another user's key signature a Features subpacket. It might also 2684 present a user with an opportunity to regenerate their own self- 2685 signature with a Features subpacket. 2687 This packet contains data encrypted with a symmetric-key algorithm 2688 and protected against modification by the SHA-1 hash algorithm. When 2689 it has been decrypted, it will typically contain other packets (often 2690 a Literal Data packet or Compressed Data packet). The last decrypted 2691 packet in this packet's payload MUST be a Modification Detection Code 2692 packet. 2694 The body of this packet consists of: 2696 o A one-octet version number. The only defined value is 1. There 2697 won't be any future versions of this packet because the MDC system 2698 has been superseded by the AEAD Encrypted Data packet. 2700 o Encrypted data, the output of the selected symmetric-key cipher 2701 operating in Cipher Feedback mode with shift amount equal to the 2702 block size of the cipher (CFB-n where n is the block size). 2704 The symmetric cipher used MUST be specified in a Public-Key or 2705 Symmetric-Key Encrypted Session Key packet that precedes the 2706 Symmetrically Encrypted Data packet. In either case, the cipher 2707 algorithm octet is prefixed to the session key before it is 2708 encrypted. 2710 The data is encrypted in CFB mode, with a CFB shift size equal to the 2711 cipher's block size. The Initial Vector (IV) is specified as all 2712 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2713 the data before it is encrypted. The length of the octet string 2714 equals the block size of the cipher in octets, plus two. The first 2715 octets in the group, of length equal to the block size of the cipher, 2716 are random; the last two octets are each copies of their 2nd 2717 preceding octet. For example, with a cipher whose block size is 128 2718 bits or 16 octets, the prefix data will contain 16 random octets, 2719 then two more octets, which are copies of the 15th and 16th octets, 2720 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2721 special CFB resynchronization is done after encrypting this prefix 2722 data. See "OpenPGP CFB Mode" below for more details. 2724 The repetition of 16 bits in the random data prefixed to the message 2725 allows the receiver to immediately check whether the session key is 2726 incorrect. 2728 The plaintext of the data to be encrypted is passed through the SHA-1 2729 hash function, and the result of the hash is appended to the 2730 plaintext in a Modification Detection Code packet. The input to the 2731 hash function includes the prefix data described above; it includes 2732 all of the plaintext, and then also includes two octets of values 2733 0xD3, 0x14. These represent the encoding of a Modification Detection 2734 Code packet tag and length field of 20 octets. 2736 The resulting hash value is stored in a Modification Detection Code 2737 (MDC) packet, which MUST use the two octet encoding just given to 2738 represent its tag and length field. The body of the MDC packet is 2739 the 20-octet output of the SHA-1 hash. 2741 The Modification Detection Code packet is appended to the plaintext 2742 and encrypted along with the plaintext using the same CFB context. 2744 During decryption, the plaintext data should be hashed with SHA-1, 2745 including the prefix data as well as the packet tag and length field 2746 of the Modification Detection Code packet. The body of the MDC 2747 packet, upon decryption, is compared with the result of the SHA-1 2748 hash. 2750 Any failure of the MDC indicates that the message has been modified 2751 and MUST be treated as a security problem. Failures include a 2752 difference in the hash values, but also the absence of an MDC packet, 2753 or an MDC packet in any position other than the end of the plaintext. 2754 Any failure SHOULD be reported to the user. 2756 NON-NORMATIVE EXPLANATION 2758 The MDC system, as packets 18 and 19 are called, were created to 2759 provide an integrity mechanism that is less strong than a 2760 signature, yet stronger than bare CFB encryption. 2762 It is a limitation of CFB encryption that damage to the 2763 ciphertext will corrupt the affected cipher blocks and the block 2764 following. Additionally, if data is removed from the end of a 2765 CFB-encrypted block, that removal is undetectable. (Note also 2766 that CBC mode has a similar limitation, but data removed from 2767 the front of the block is undetectable.) 2769 The obvious way to protect or authenticate an encrypted block is 2770 to digitally sign it. However, many people do not wish to 2771 habitually sign data, for a large number of reasons beyond the 2772 scope of this document. Suffice it to say that many people 2773 consider properties such as deniability to be as valuable as 2774 integrity. 2776 OpenPGP addresses this desire to have more security than raw 2777 encryption and yet preserve deniability with the MDC system. An 2778 MDC is intentionally not a MAC. Its name was not selected by 2779 accident. It is analogous to a checksum. 2781 Despite the fact that it is a relatively modest system, it has 2782 proved itself in the real world. It is an effective defense to 2783 several attacks that have surfaced since it has been created. 2784 It has met its modest goals admirably. 2786 Consequently, because it is a modest security system, it has 2787 modest requirements on the hash function(s) it employs. It does 2788 not rely on a hash function being collision-free, it relies on a 2789 hash function being one-way. If a forger, Frank, wishes to send 2790 Alice a (digitally) unsigned message that says, "I've always 2791 secretly loved you, signed Bob", it is far easier for him to 2792 construct a new message than it is to modify anything 2793 intercepted from Bob. (Note also that if Bob wishes to 2794 communicate secretly with Alice, but without authentication or 2795 identification and with a threat model that includes forgers, he 2796 has a problem that transcends mere cryptography.) 2798 Note also that unlike nearly every other OpenPGP subsystem, 2799 there are no parameters in the MDC system. It hard-defines 2800 SHA-1 as its hash function. This is not an accident. It is an 2801 intentional choice to avoid downgrade and cross-grade attacks 2802 while making a simple, fast system. (A downgrade attack would 2803 be an attack that replaced SHA2-256 with SHA-1, for example. A 2804 cross-grade attack would replace SHA-1 with another 160-bit 2805 hash, such as RIPE-MD/160, for example.) 2807 However, given the present state of hash function cryptanalysis 2808 and cryptography, it may be desirable to upgrade the MDC system 2809 to a new hash function. See Section 13.11 in the "IANA 2810 Considerations" for guidance. 2812 5.15. {5.14} Modification Detection Code Packet (Tag 19) 2814 The Modification Detection Code packet contains a SHA-1 hash of 2815 plaintext data, which is used to detect message modification. It is 2816 only used with a Symmetrically Encrypted Integrity Protected Data 2817 packet. The Modification Detection Code packet MUST be the last 2818 packet in the plaintext data that is encrypted in the Symmetrically 2819 Encrypted Integrity Protected Data packet, and MUST appear in no 2820 other place. 2822 A Modification Detection Code packet MUST have a length of 20 octets. 2824 The body of this packet consists of: 2826 o A 20-octet SHA-1 hash of the preceding plaintext data of the 2827 Symmetrically Encrypted Integrity Protected Data packet, including 2828 prefix data, the tag octet, and length octet of the Modification 2829 Detection Code packet. 2831 Note that the Modification Detection Code packet MUST always use a 2832 new format encoding of the packet tag, and a one-octet encoding of 2833 the packet length. The reason for this is that the hashing rules for 2834 modification detection include a one-octet tag and one-octet length 2835 in the data hash. While this is a bit restrictive, it reduces 2836 complexity. 2838 5.16. AEAD Encrypted Data Packet (Tag 20) 2840 This packet contains data encrypted with an authenticated encryption 2841 and additional data (AEAD) construction. When it has been decrypted, 2842 it will typically contain other packets (often a Literal Data packet 2843 or Compressed Data packet). 2845 The body of this packet consists of: 2847 o A one-octet version number. The only currently defined value is 2848 1. 2850 o A one-octet cipher algorithm. 2852 o A one-octet AEAD algorithm. 2854 o A one-octet chunk size. 2856 o A starting initialization vector of size specified by the AEAD 2857 algorithm. 2859 o Encrypted data, the output of the selected symmetric-key cipher 2860 operating in the given AEAD mode. 2862 o A final, summary authentication tag for the AEAD mode. 2864 An AEAD encrypted data packet consists of one or more chunks of data. 2865 The plaintext of each chunk is of a size specified using the chunk 2866 size octet using the method specified below. 2868 The encrypted data consists of the encryption of each chunk of 2869 plaintext, followed immediately by the relevant authentication tag. 2870 If the last chunk of plaintext is smaller than the chunk size, the 2871 ciphertext for that data may be shorter; it is nevertheless followed 2872 by a full authentication tag. 2874 For each chunk, the AEAD construction is given the Packet Tag in new 2875 format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag), 2876 version number, cipher algorithm octet, AEAD algorithm octet, chunk 2877 size octet, and an eight-octet, big-endian chunk index as additional 2878 data. The index of the first chunk is zero. For example, the 2879 additional data of the first chunk using EAX and AES-128 with a chunk 2880 size of 64 kiByte consists of the octets 0xD4, 0x01, 0x07, 0x01, 2881 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, and 0x00. 2883 After the final chunk, the AEAD algorithm is used to produce a final 2884 authentication tag encrypting the empty string. This AEAD instance 2885 is given the additional data specified above, plus an eight-octet, 2886 big-endian value specifying the total number of plaintext octets 2887 encrypted. This allows detection of a truncated ciphertext. 2889 The chunk size octet specifies the size of chunks using the following 2890 formula (in C), where c is the chunk size octet: 2892 chunk_size = ((uint64_t)1 << (c + 6)) 2894 An implementation MUST support chunk size octets with values from 0 2895 to 56. Chunk size octets with other values are reserved for future 2896 extensions. Implementations SHOULD NOT create data with a chunk size 2897 octet value larger than 21 (128 MiB chunks) to facilitate buffering 2898 of not yet authenticated plaintext. 2900 A new random initialization vector MUST be used for each message. 2901 Failure to do so for each message will lead to a catastrophic failure 2902 depending on the used AEAD mode. 2904 5.16.1. EAX Mode 2906 The EAX algorithm can only use block ciphers with 16-octet blocks. 2907 The starting initialization vector and authentication tag are both 16 2908 octets long. 2910 The starting initialization vector for this mode MUST be unique and 2911 unpredictable. 2913 The nonce for EAX mode is computed by treating the starting 2914 initialization vector as a 16-octet, big-endian value and exclusive- 2915 oring the low eight octets of it with the chunk index. 2917 The security of EAX requires that the nonce is never reused, hence 2918 the requirement that the starting initialization vector be unique. 2920 5.16.2. OCB Mode 2922 The OCB Authenticated-Encryption Algorithm used in this document is 2923 defined in [RFC7253]. 2925 OCB usage requires specification of the following parameters: 2927 o a blockcipher that operate on 128-bit (16-octet) blocks 2929 o an authentication tag length of 16 octets 2931 o a nonce of 15 octets long (which is the longest nonce allowed 2932 specified by [RFC7253]) 2934 o an initialization vector of at least 15 octets long 2936 In the case that the initialization vector is longer than 15 octets 2937 (such as in Section {5.5.3} Secret-Key Packet Formats), only the 15 2938 leftmost octets are used in calculations; the remaining octets MUST 2939 be considered as zero. 2941 The nonce for OCB mode is computed by the exclusive-oring of the 2942 initialization vector as a 15-octet, big endian value, against the 2943 chunk index. 2945 Security of OCB mode depends on the non-repeated nature of nonces 2946 used for the same key on distinct plaintext [RFC7253]. Therefore the 2947 initialization vector per message MUST be distinct, and OCB mode 2948 SHOULD only be used in environments when there is certainty to 2949 fulfilling this requirement. 2951 6. {6} Radix-64 Conversions 2953 As stated in the introduction, OpenPGP's underlying native 2954 representation for objects is a stream of arbitrary octets, and some 2955 systems desire these objects to be immune to damage caused by 2956 character set translation, data conversions, etc. 2958 In principle, any printable encoding scheme that met the requirements 2959 of the unsafe channel would suffice, since it would not change the 2960 underlying binary bit streams of the native OpenPGP data structures. 2961 The OpenPGP standard specifies one such printable encoding scheme to 2962 ensure interoperability. 2964 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2965 encoding of the binary data and a checksum. The base64 encoding is 2966 identical to the MIME base64 content-transfer-encoding [RFC2045]. 2968 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 2969 four characters of radix-64 encoding by the same MIME base64 2970 transformation, preceded by an equal sign (=). The CRC is computed 2971 by using the generator 0x864CFB and an initialization of 0xB704CE. 2972 The accumulation is done on the data before it is converted to radix- 2973 64, rather than on the converted data. A sample implementation of 2974 this algorithm is in the next section. 2976 The checksum with its leading equal sign MAY appear on the first line 2977 after the base64 encoded data. 2979 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2980 base64. The nonzero initialization can detect more errors than a 2981 zero initialization. 2983 6.1. {6.1} An Implementation of the CRC-24 in "C" 2985 2986 #define CRC24_INIT 0xB704CEL 2987 #define CRC24_POLY 0x1864CFBL 2989 typedef long crc24; 2990 crc24 crc_octets(unsigned char *octets, size_t len) 2991 { 2992 crc24 crc = CRC24_INIT; 2993 int i; 2994 while (len--) { 2995 crc ^= (*octets++) << 16; 2996 for (i = 0; i < 8; i++) { 2997 crc <<= 1; 2998 if (crc & 0x1000000) 2999 crc ^= CRC24_POLY; 3000 } 3001 } 3002 return crc & 0xFFFFFFL; 3003 } 3004 3006 6.2. {6.2} Forming ASCII Armor 3008 When OpenPGP encodes data into ASCII Armor, it puts specific headers 3009 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 3010 later. An OpenPGP implementation MAY use ASCII armor to protect raw 3011 binary data. OpenPGP informs the user what kind of data is encoded 3012 in the ASCII armor through the use of the headers. 3014 Concatenating the following data creates ASCII Armor: 3016 o An Armor Header Line, appropriate for the type of data 3018 o Armor Headers 3020 o A blank line 3022 o The ASCII-Armored data 3024 o An Armor Checksum 3026 o The Armor Tail, which depends on the Armor Header Line 3028 An Armor Header Line consists of the appropriate header line text 3029 surrounded by five (5) dashes ('-', 0x2D) on either side of the 3030 header line text. The header line text is chosen based upon the type 3031 of data that is being encoded in Armor, and how it is being encoded. 3032 Header line texts include the following strings: 3034 BEGIN PGP MESSAGE Used for signed, encrypted, or compressed files. 3036 BEGIN PGP PUBLIC KEY BLOCK Used for armoring public keys. 3038 BEGIN PGP PRIVATE KEY BLOCK Used for armoring private keys. 3040 BEGIN PGP MESSAGE, PART X/Y Used for multi-part messages, where the 3041 armor is split amongst Y parts, and this is the Xth part out of Y. 3043 BEGIN PGP MESSAGE, PART X Used for multi-part messages, where this 3044 is the Xth part of an unspecified number of parts. Requires the 3045 MESSAGE-ID Armor Header to be used. 3047 BEGIN PGP SIGNATURE Used for detached signatures, OpenPGP/MIME 3048 signatures, and cleartext signatures. Note that PGP 2.x uses 3049 BEGIN PGP MESSAGE for detached signatures. 3051 Note that all these Armor Header Lines are to consist of a complete 3052 line. That is to say, there is always a line ending preceding the 3053 starting five dashes, and following the ending five dashes. The 3054 header lines, therefore, MUST start at the beginning of a line, and 3055 MUST NOT have text other than whitespace -- space (0x20), tab (0x09) 3056 or carriage return (0x0d) -- following them on the same line. These 3057 line endings are considered a part of the Armor Header Line for the 3058 purposes of determining the content they delimit. This is 3059 particularly important when computing a cleartext signature (see 3060 below). 3062 The Armor Headers are pairs of strings that can give the user or the 3063 receiving OpenPGP implementation some information about how to decode 3064 or use the message. The Armor Headers are a part of the armor, not a 3065 part of the message, and hence are not protected by any signatures 3066 applied to the message. 3068 The format of an Armor Header is that of a key-value pair. A colon 3069 (':' 0x38) and a single space (0x20) separate the key and value. 3070 OpenPGP should consider improperly formatted Armor Headers to be 3071 corruption of the ASCII Armor. Unknown keys should be reported to 3072 the user, but OpenPGP should continue to process the message. 3074 Note that some transport methods are sensitive to line length. While 3075 there is a limit of 76 characters for the Radix-64 data 3076 (Section 6.3), there is no limit to the length of Armor Headers. 3077 Care should be taken that the Armor Headers are short enough to 3078 survive transport. One way to do this is to repeat an Armor Header 3079 Key multiple times with different values for each so that no one line 3080 is overly long. 3082 Currently defined Armor Header Keys are as follows: 3084 o "Version", which states the OpenPGP implementation and version 3085 used to encode the message. 3087 o "Comment", a user-defined comment. OpenPGP defines all text to be 3088 in UTF-8. A comment may be any UTF-8 string. However, the whole 3089 point of armoring is to provide seven-bit-clean data. 3090 Consequently, if a comment has characters that are outside the US- 3091 ASCII range of UTF, they may very well not survive transport. 3093 o "Hash", a comma-separated list of hash algorithms used in this 3094 message. This is used only in cleartext signed messages. 3096 o "MessageID", a 32-character string of printable characters. The 3097 string must be the same for all parts of a multi-part message that 3098 uses the "PART X" Armor Header. MessageID strings should be 3099 unique enough that the recipient of the mail can associate all the 3100 parts of a message with each other. A good checksum or 3101 cryptographic hash function is sufficient. 3103 The MessageID SHOULD NOT appear unless it is in a multi-part 3104 message. If it appears at all, it MUST be computed from the 3105 finished (encrypted, signed, etc.) message in a deterministic 3106 fashion, rather than contain a purely random value. This is to 3107 allow the legitimate recipient to determine that the MessageID 3108 cannot serve as a covert means of leaking cryptographic key 3109 information. 3111 o "Charset", a description of the character set that the plaintext 3112 is in. Please note that OpenPGP defines text to be in UTF-8. An 3113 implementation will get best results by translating into and out 3114 of UTF-8. However, there are many instances where this is easier 3115 said than done. Also, there are communities of users who have no 3116 need for UTF-8 because they are all happy with a character set 3117 like ISO Latin-5 or a Japanese character set. In such instances, 3118 an implementation MAY override the UTF-8 default by using this 3119 header key. An implementation MAY implement this key and any 3120 translations it cares to; an implementation MAY ignore it and 3121 assume all text is UTF-8. 3123 The blank line can either be zero-length or contain only whitespace, 3124 that is spaces (0x20), tabs (0x09) or carriage returns (0x0d). 3126 The Armor Tail Line is composed in the same manner as the Armor 3127 Header Line, except the string "BEGIN" is replaced by the string 3128 "END". 3130 6.3. {6.3} Encoding Binary in Radix-64 3132 The encoding process represents 24-bit groups of input bits as output 3133 strings of 4 encoded characters. Proceeding from left to right, a 3134 24-bit input group is formed by concatenating three 8-bit input 3135 groups. These 24 bits are then treated as four concatenated 6-bit 3136 groups, each of which is translated into a single digit in the 3137 Radix-64 alphabet. When encoding a bit stream with the Radix-64 3138 encoding, the bit stream must be presumed to be ordered with the most 3139 significant bit first. That is, the first bit in the stream will be 3140 the high-order bit in the first 8-bit octet, and the eighth bit will 3141 be the low-order bit in the first 8-bit octet, and so on. 3143 +--first octet--+-second octet--+--third octet--+ 3144 |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| 3145 +-----------+---+-------+-------+---+-----------+ 3146 |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| 3147 +--1.index--+--2.index--+--3.index--+--4.index--+ 3149 Each 6-bit group is used as an index into an array of 64 printable 3150 characters from the table below. The character referenced by the 3151 index is placed in the output string. 3153 Value Encoding Value Encoding Value Encoding Value Encoding 3154 0 A 17 R 34 i 51 z 3155 1 B 18 S 35 j 52 0 3156 2 C 19 T 36 k 53 1 3157 3 D 20 U 37 l 54 2 3158 4 E 21 V 38 m 55 3 3159 5 F 22 W 39 n 56 4 3160 6 G 23 X 40 o 57 5 3161 7 H 24 Y 41 p 58 6 3162 8 I 25 Z 42 q 59 7 3163 9 J 26 a 43 r 60 8 3164 10 K 27 b 44 s 61 9 3165 11 L 28 c 45 t 62 + 3166 12 M 29 d 46 u 63 / 3167 13 N 30 e 47 v 3168 14 O 31 f 48 w (pad) = 3169 15 P 32 g 49 x 3170 16 Q 33 h 50 y 3172 The encoded output stream must be represented in lines of no more 3173 than 76 characters each. 3175 Special processing is performed if fewer than 24 bits are available 3176 at the end of the data being encoded. There are three possibilities: 3178 1. The last data group has 24 bits (3 octets). No special 3179 processing is needed. 3181 2. The last data group has 16 bits (2 octets). The first two 3182 6-bit groups are processed as above. The third (incomplete) 3183 data group has two zero-value bits added to it, and is 3184 processed as above. A pad character (=) is added to the 3185 output. 3187 3. The last data group has 8 bits (1 octet). The first 6-bit 3188 group is processed as above. The second (incomplete) data 3189 group has four zero-value bits added to it, and is processed 3190 as above. Two pad characters (=) are added to the output. 3192 6.4. {6.4} Decoding Radix-64 3194 In Radix-64 data, characters other than those in the table, line 3195 breaks, and other white space probably indicate a transmission error, 3196 about which a warning message or even a message rejection might be 3197 appropriate under some circumstances. Decoding software must ignore 3198 all white space. 3200 Because it is used only for padding at the end of the data, the 3201 occurrence of any "=" characters may be taken as evidence that the 3202 end of the data has been reached (without truncation in transit). No 3203 such assurance is possible, however, when the number of octets 3204 transmitted was a multiple of three and no "=" characters are 3205 present. 3207 6.5. {6.5} Examples of Radix-64 3208 Input data: 0x14FB9C03D97E 3209 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 3210 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 3211 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 3212 Decimal: 5 15 46 28 0 61 37 62 3213 Output: F P u c A 9 l + 3214 Input data: 0x14FB9C03D9 3215 Hex: 1 4 F B 9 C | 0 3 D 9 3216 8-bit: 00010100 11111011 10011100 | 00000011 11011001 3217 pad with 00 3218 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 3219 Decimal: 5 15 46 28 0 61 36 3220 pad with = 3221 Output: F P u c A 9 k = 3222 Input data: 0x14FB9C03 3223 Hex: 1 4 F B 9 C | 0 3 3224 8-bit: 00010100 11111011 10011100 | 00000011 3225 pad with 0000 3226 6-bit: 000101 001111 101110 011100 | 000000 110000 3227 Decimal: 5 15 46 28 0 48 3228 pad with = = 3229 Output: F P u c A w = = 3231 6.6. {6.6} Example of an ASCII Armored Message 3233 -----BEGIN PGP MESSAGE----- 3234 Version: OpenPrivacy 0.99 3236 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3237 vBSFjNSiVHsuAA== 3238 =njUN 3239 -----END PGP MESSAGE----- 3241 Note that this example has extra indenting; an actual armored message 3242 would have no leading whitespace. 3244 7. {7} Cleartext Signature Framework 3246 It is desirable to be able to sign a textual octet stream without 3247 ASCII armoring the stream itself, so the signed text is still 3248 readable without special software. In order to bind a signature to 3249 such a cleartext, this framework is used, which follows the same 3250 basic format and restrictions as the ASCII armoring described above 3251 in "Forming ASCII Armor" (Section 6.2). (Note that this framework is 3252 not intended to be reversible. RFC 3156 [RFC3156] defines another 3253 way to sign cleartext messages for environments that support MIME.) 3255 The cleartext signed message consists of: 3257 o The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a 3258 single line, 3260 o One or more "Hash" Armor Headers, 3262 o Exactly one blank line not included into the message digest, 3264 o The dash-escaped cleartext that is included into the message 3265 digest, 3267 o The ASCII armored signature(s) including the '-----BEGIN PGP 3268 SIGNATURE-----' Armor Header and Armor Tail Lines. 3270 If the "Hash" Armor Header is given, the specified message digest 3271 algorithm(s) are used for the signature. If there are no such 3272 headers, MD5 is used. If MD5 is the only hash used, then an 3273 implementation MAY omit this header for improved V2.x compatibility. 3274 If more than one message digest is used in the signature, the "Hash" 3275 armor header contains a comma-delimited list of used message digests. 3277 Current message digest names are described below with the algorithm 3278 IDs. 3280 An implementation SHOULD add a line break after the cleartext, but 3281 MAY omit it if the cleartext ends with a line break. This is for 3282 visual clarity. 3284 7.1. {7.1} Dash-Escaped Text 3286 The cleartext content of the message must also be dash-escaped. 3288 Dash-escaped cleartext is the ordinary cleartext where every line 3289 starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' 3290 (0x2D) and space ' ' (0x20). This prevents the parser from 3291 recognizing armor headers of the cleartext itself. An implementation 3292 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3293 followed by a space, and MUST dash-escape any line commencing in a 3294 dash. The message digest is computed using the cleartext itself, not 3295 the dash-escaped form. 3297 As with binary signatures on text documents, a cleartext signature is 3298 calculated on the text using canonical line endings. The 3299 line ending (i.e., the ) before the '-----BEGIN PGP 3300 SIGNATURE-----' line that terminates the signed text is not 3301 considered part of the signed text. 3303 When reversing dash-escaping, an implementation MUST strip the string 3304 "- " if it occurs at the beginning of a line, and SHOULD warn on "-" 3305 and any character other than a space at the beginning of a line. 3307 Also, any trailing whitespace -- spaces (0x20), tabs (0x09) or 3308 carriage returns (0x0d) -- at the end of any line is removed when the 3309 cleartext signature is generated and verified. 3311 8. {8} Regular Expressions 3313 A regular expression is zero or more branches, separated by '|'. It 3314 matches anything that matches one of the branches. 3316 A branch is zero or more pieces, concatenated. It matches a match 3317 for the first, followed by a match for the second, etc. 3319 A piece is an atom possibly followed by '_', '+', or '?'. An atom 3320 followed by '_' matches a sequence of 0 or more matches of the atom. 3321 An atom followed by '+' matches a sequence of 1 or more matches of 3322 the atom. An atom followed by '?' matches a match of the atom, or 3323 the null string. 3325 An atom is a regular expression in parentheses (matching a match for 3326 the regular expression), a range (see below), '.' (matching any 3327 single character), '^' (matching the null string at the beginning of 3328 the input string), '$' (matching the null string at the end of the 3329 input string), a '\' followed by a single character (matching that 3330 character), or a single character with no other significance 3331 (matching that character). 3333 A range is a sequence of characters enclosed in '[]'. It normally 3334 matches any single character from the sequence. If the sequence 3335 begins with '^', it matches any single character not from the rest of 3336 the sequence. If two characters in the sequence are separated by 3337 '-', this is shorthand for the full list of ASCII characters between 3338 them (e.g., '[0-9]' matches any decimal digit). To include a literal 3339 ']' in the sequence, make it the first character (following a 3340 possible '^'). To include a literal '-', make it the first or last 3341 character. 3343 9. {9} Constants 3345 This section describes the constants used in OpenPGP. 3347 Note that these tables are not exhaustive lists; an implementation 3348 MAY implement an algorithm not on these lists, so long as the 3349 algorithm numbers are chosen from the private or experimental 3350 algorithm range. 3352 See the section "Notes on Algorithms" below for more discussion of 3353 the algorithms. 3355 9.1. {9.1} Public-Key Algorithms 3357 +-----------+----------------------------------------------------+ 3358 | ID | Algorithm | 3359 +-----------+----------------------------------------------------+ 3360 | 1 | RSA (Encrypt or Sign) [HAC] | 3361 | 2 | RSA Encrypt-Only [HAC] | 3362 | 3 | RSA Sign-Only [HAC] | 3363 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3364 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3365 | 18 | ECDH public key algorithm | 3366 | 19 | ECDSA public key algorithm [FIPS186] | 3367 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3368 | 21 | Reserved for Diffie-Hellman | 3369 | | (X9.42, as defined for IETF-S/MIME) | 3370 | 22 | EdDSA [I-D.irtf-cfrg-eddsa] | 3371 | 23 | Reserved for AEDH | 3372 | 24 | Reserved for AEDSA | 3373 | 100--110 | Private/Experimental algorithm | 3374 +-----------+----------------------------------------------------+ 3376 Implementations MUST implement RSA (1) and ECDSA (19) for signatures, 3377 and RSA (1) and ECDH (18) for encryption. Implementations SHOULD 3378 implement EdDSA (22) keys. 3380 RSA Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD 3381 NOT be generated, but may be interpreted. See Section {FIXME 13.5}. 3382 See Section {FIXME 13.8} for notes on Elgamal Encrypt or Sign (20), 3383 and X9.42 (21). Implementations MAY implement any other algorithm. 3385 Note that implementations conforming to previous versions of this 3386 standard (RFC-4880) have DSA (17) and Elgamal (16) as its only MUST- 3387 implement algorithm. 3389 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3390 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this 3391 document. 3393 9.2. ECC Curve OID 3395 The parameter curve OID is an array of octets that define a named 3396 curve. The table below specifies the exact sequence of bytes for 3397 each named curve referenced in this document: 3399 +------------------------+-----+------------------+-----------------+ 3400 | ASN.1 Object | OID | Curve OID bytes | Curve name | 3401 | Identifier | len | in hexadecimal | | 3402 | | | representation | | 3403 +------------------------+-----+------------------+-----------------+ 3404 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | 3405 | | | 03 01 07 | | 3406 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | 3407 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | 3408 | 1.3.36.3.3.2.8.1.1.7 | 9 | 2B 24 03 03 02 | brainpoolP256r1 | 3409 | | | 08 01 01 07 | | 3410 | 1.3.36.3.3.2.8.1.1.13 | 9 | 2B 24 03 03 02 | brainpoolP512r1 | 3411 | | | 08 01 01 0D | | 3412 | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 | Ed25519 | 3413 | | | DA 47 0F 01 | | 3414 | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | 3415 | | | 97 55 01 05 01 | | 3416 +------------------------+-----+------------------+-----------------+ 3418 The sequence of octets in the third column is the result of applying 3419 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3420 with subsequent truncation. The truncation removes the two fields of 3421 encoded Object Identifier. The first omitted field is one octet 3422 representing the Object Identifier tag, and the second omitted field 3423 is the length of the Object Identifier body. For example, the 3424 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3425 86 48 CE 3D 03 01 07", from which the first entry in the table above 3426 is constructed by omitting the first two octets. Only the truncated 3427 sequence of octets is the valid representation of a curve OID. 3429 9.3. {9.2} Symmetric-Key Algorithms 3430 +-----------+-----------------------------------------------+ 3431 | ID | Algorithm | 3432 +-----------+-----------------------------------------------+ 3433 | 0 | Plaintext or unencrypted data | 3434 | 1 | IDEA [IDEA] | 3435 | 2 | TripleDES (DES-EDE, [SCHNEIER] [HAC] | 3436 | | - 168 bit key derived from 192) | 3437 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3438 | 4 | Blowfish (128 bit key, 16 rounds) [BLOWFISH] | 3439 | 5 | Reserved | 3440 | 6 | Reserved | 3441 | 7 | AES with 128-bit key [AES] | 3442 | 8 | AES with 192-bit key | 3443 | 9 | AES with 256-bit key | 3444 | 10 | Twofish with 256-bit key [TWOFISH] | 3445 | 11 | Camellia with 128-bit key [RFC3713] | 3446 | 12 | Camellia with 192-bit key | 3447 | 13 | Camellia with 256-bit key | 3448 | 100--110 | Private/Experimental algorithm | 3449 +-----------+-----------------------------------------------+ 3451 Implementations MUST implement AES-128. Implementations SHOULD 3452 implement AES-256. Implementations that interoperate with RFC-4880 3453 implementations need to support TripleDES and CAST5. Implementations 3454 that interoperate with PGP 2.6 or earlier need to support IDEA, as 3455 that is the only symmetric cipher those versions use. 3456 Implementations MAY implement any other algorithm. 3458 9.4. {9.3} Compression Algorithms 3460 +-----------+---------------------------------+ 3461 | ID | Algorithm | 3462 +-----------+---------------------------------+ 3463 | 0 | Uncompressed | 3464 | 1 | ZIP [RFC1951] | 3465 | 2 | ZLIB [RFC1950] | 3466 | 3 | BZip2 [BZ2] | 3467 | 100--110 | Private/Experimental algorithm | 3468 +-----------+---------------------------------+ 3470 Implementations MUST implement uncompressed data. Implementations 3471 SHOULD implement ZIP. Implementations MAY implement any other 3472 algorithm. 3474 9.5. {9.4} Hash Algorithms 3476 +-----------+---------------------------------+--------------+ 3477 | ID | Algorithm | Text Name | 3478 +-----------+---------------------------------+--------------+ 3479 | 1 | MD5 [HAC] | "MD5" | 3480 | 2 | SHA-1 [FIPS180] | "SHA1" | 3481 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3482 | 4 | Reserved | | 3483 | 5 | Reserved | | 3484 | 6 | Reserved | | 3485 | 7 | Reserved | | 3486 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3487 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3488 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3489 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3490 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3491 | 13 | Reserved | | 3492 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3493 | 100--110 | Private/Experimental algorithm | | 3494 +-----------+---------------------------------+--------------+ 3496 Implementations MUST implement SHA2-256. Implementations MAY 3497 implement other algorithms. Implementations SHOULD NOT create 3498 messages which require the use of SHA-1 with the exception of 3499 computing version 4 key fingerprints and for purposes of the MDC 3500 packet. Implementations SHOULD NOT use MD5 or RIPE-MD/160. 3502 9.6. AEAD Algorithms 3504 +-----------+---------------------------------+ 3505 | ID | Algorithm | 3506 +-----------+---------------------------------+ 3507 | 1 | EAX [EAX] | 3508 | 2 | OCB [RFC7253] | 3509 | 100--110 | Private/Experimental algorithm | 3510 +-----------+---------------------------------+ 3512 Implementations MUST implement EAX. Implementations MAY implement 3513 OCB and other algorithms. 3515 10. {10} IANA Considerations 3517 OpenPGP is highly parameterized, and consequently there are a number 3518 of considerations for allocating parameters for extensions. This 3519 section describes how IANA should look at extensions to the protocol 3520 as described in this document. 3522 10.1. {10.1} New String-to-Key Specifier Types 3524 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3525 a string into a key. This specification creates a registry of S2K 3526 specifier types. The registry includes the S2K type, the name of the 3527 S2K, and a reference to the defining specification. The initial 3528 values for this registry can be found in Section 3.7.1. Adding a new 3529 S2K specifier MUST be done through the IETF CONSENSUS method, as 3530 described in [RFC2434]. 3532 10.2. {10.2} New Packets 3534 Major new features of OpenPGP are defined through new packet types. 3535 This specification creates a registry of packet types. The registry 3536 includes the packet type, the name of the packet, and a reference to 3537 the defining specification. The initial values for this registry can 3538 be found in Section 4.3. Adding a new packet type MUST be done 3539 through the IETF CONSENSUS method, as described in [RFC2434]. 3541 10.2.1. {10.2.1} User Attribute Types 3543 The User Attribute packet permits an extensible mechanism for other 3544 types of certificate identification. This specification creates a 3545 registry of User Attribute types. The registry includes the User 3546 Attribute type, the name of the User Attribute, and a reference to 3547 the defining specification. The initial values for this registry can 3548 be found in Section 5.12. Adding a new User Attribute type MUST be 3549 done through the IETF CONSENSUS method, as described in [RFC2434]. 3551 This document requests that IANA register the User ID Attribute Type 3552 found in Section 5.12.2: 3554 +--------+------------+-----------------------------+ 3555 | Value | Attribute | Reference | 3556 +--------+------------+-----------------------------+ 3557 | TBD1 | User ID | This Document Section 5.12 | 3558 +--------+------------+-----------------------------+ 3560 10.2.2. {10.2.1.1} Image Format Subpacket Types 3562 Within User Attribute packets, there is an extensible mechanism for 3563 other types of image-based user attributes. This specification 3564 creates a registry of Image Attribute subpacket types. The registry 3565 includes the Image Attribute subpacket type, the name of the Image 3566 Attribute subpacket, and a reference to the defining specification. 3567 The initial values for this registry can be found in Section 5.12.1. 3568 Adding a new Image Attribute subpacket type MUST be done through the 3569 IETF CONSENSUS method, as described in [RFC2434]. 3571 10.2.3. {10.2.2} New Signature Subpackets 3573 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3574 to be added to them for a variety of purposes in the Signature 3575 subpackets as discussed in Section 5.2.3.1. This specification 3576 creates a registry of Signature subpacket types. The registry 3577 includes the Signature subpacket type, the name of the subpacket, and 3578 a reference to the defining specification. The initial values for 3579 this registry can be found in Section 5.2.3.1. Adding a new 3580 Signature subpacket MUST be done through the IETF CONSENSUS method, 3581 as described in [RFC2434]. 3583 10.2.3.1. {10.2.2.1} Signature Notation Data Subpackets 3585 OpenPGP signatures further contain a mechanism for extensions in 3586 signatures. These are the Notation Data subpackets, which contain a 3587 key/value pair. Notations contain a user space that is completely 3588 unmanaged and an IETF space. 3590 This specification creates a registry of Signature Notation Data 3591 types. The registry includes the Signature Notation Data type, the 3592 name of the Signature Notation Data, its allowed values, and a 3593 reference to the defining specification. The initial values for this 3594 registry can be found in Section 5.2.3.16. Adding a new Signature 3595 Notation Data subpacket MUST be done through the EXPERT REVIEW 3596 method, as described in [RFC2434]. 3598 This document requests IANA register the following Signature Notation 3599 Data types: 3601 +---------------+--------+--------------------+---------------------+ 3602 | Allowed | Name | Type | Reference | 3603 | Values | | | | 3604 +---------------+--------+--------------------+---------------------+ 3605 | Any String | manu | Manufacturer Name | This Doc Section | 3606 | | | | 5.2.3.16.1 | 3607 | Any String | make | Product Make | This Doc Section | 3608 | | | | 5.2.3.16.2 | 3609 | Any String | model | Product Model | This Doc Section | 3610 | | | | 5.2.3.16.3 | 3611 | Any String | prodid | Product ID | This Doc Section | 3612 | | | | 5.2.3.16.4 | 3613 | Any String | pvers | Product Version | This Doc Section | 3614 | | | | 5.2.3.16.5 | 3615 | Any String | lot | Product Lot Number | This Doc Section | 3616 | | | | 5.2.3.16.6 | 3617 | Decimal | qty | Package Quantity | This Doc Section | 3618 | Integer | | | 5.2.3.16.7 | 3619 | String | | | | 3620 | A geo: URI | loc | Current Geo- | This Doc Section | 3621 | | | | 5.2.3.16.8 | 3622 | without the | | location | | 3623 | "geo:" | | Latitude/Longitude | | 3624 | A geo: URI | dest | Destination Geo- | This Doc Section | 3625 | | | | 5.2.3.16.8 | 3626 | without the | | location | | 3627 | "geo:" | | Latitude/Longitude | | 3628 | Hash Notation | hash | The Hash of | This Doc Section | 3629 | | | | 5.2.3.16.9 | 3630 | data | | external data | | 3631 +---------------+--------+--------------------+---------------------+ 3633 10.2.3.2. {10.2.2.2} Key Server Preference Extensions 3635 OpenPGP signatures contain a mechanism for preferences to be 3636 specified about key servers. This specification creates a registry 3637 of key server preferences. The registry includes the key server 3638 preference, the name of the preference, and a reference to the 3639 defining specification. The initial values for this registry can be 3640 found in Section 5.2.3.17. Adding a new key server preference MUST 3641 be done through the IETF CONSENSUS method, as described in [RFC2434]. 3643 10.2.3.3. {10.2.2.3} Key Flags Extensions 3645 OpenPGP signatures contain a mechanism for flags to be specified 3646 about key usage. This specification creates a registry of key usage 3647 flags. The registry includes the key flags value, the name of the 3648 flag, and a reference to the defining specification. The initial 3649 values for this registry can be found in Section 5.2.3.21. Adding a 3650 new key usage flag MUST be done through the IETF CONSENSUS method, as 3651 described in [RFC2434]. 3653 10.2.3.4. {10.2.2.4} Reason for Revocation Extensions 3655 OpenPGP signatures contain a mechanism for flags to be specified 3656 about why a key was revoked. This specification creates a registry 3657 of "Reason for Revocation" flags. The registry includes the "Reason 3658 for Revocation" flags value, the name of the flag, and a reference to 3659 the defining specification. The initial values for this registry can 3660 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3661 through the IETF CONSENSUS method, as described in [RFC2434]. 3663 10.2.3.5. {10.2.2.5} Implementation Features 3665 OpenPGP signatures contain a mechanism for flags to be specified 3666 stating which optional features an implementation supports. This 3667 specification creates a registry of feature-implementation flags. 3668 The registry includes the feature-implementation flags value, the 3669 name of the flag, and a reference to the defining specification. The 3670 initial values for this registry can be found in Section 5.2.3.24. 3671 Adding a new feature-implementation flag MUST be done through the 3672 IETF CONSENSUS method, as described in [RFC2434]. 3674 Also see Section 13.12 for more information about when feature flags 3675 are needed. 3677 10.2.4. {10.2.3} New Packet Versions 3679 The core OpenPGP packets all have version numbers, and can be revised 3680 by introducing a new version of an existing packet. This 3681 specification creates a registry of packet types. The registry 3682 includes the packet type, the number of the version, and a reference 3683 to the defining specification. The initial values for this registry 3684 can be found in Section 5. Adding a new packet version MUST be done 3685 through the IETF CONSENSUS method, as described in [RFC2434]. 3687 10.3. {10.3} New Algorithms 3689 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3690 new algorithm is usually simple. For example, adding in a new 3691 symmetric cipher usually would not need anything more than allocating 3692 a constant for that cipher. If that cipher had other than a 64-bit 3693 or 128-bit block size, there might need to be additional 3694 documentation describing how OpenPGP-CFB mode would be adjusted. 3695 Similarly, when DSA was expanded from a maximum of 1024-bit public 3696 keys to 3072-bit public keys, the revision of FIPS 186 contained 3697 enough information itself to allow implementation. Changes to this 3698 document were made mainly for emphasis. 3700 10.3.1. {10.3.1} Public-Key Algorithms 3702 OpenPGP specifies a number of public-key algorithms. This 3703 specification creates a registry of public-key algorithm identifiers. 3704 The registry includes the algorithm name, its key sizes and 3705 parameters, and a reference to the defining specification. The 3706 initial values for this registry can be found in Section 9. Adding a 3707 new public-key algorithm MUST be done through the IETF CONSENSUS 3708 method, as described in [RFC2434]. 3710 This document requests IANA register the following public-key 3711 algorithm: 3713 +-----+-----------------------------+------------+ 3714 | ID | Algorithm | Reference | 3715 +-----+-----------------------------+------------+ 3716 | 22 | EdDSA public key algorithm | This doc | 3717 | 23 | Reserved for AEDH | This doc | 3718 | 24 | Reserved for AEDSA | This doc | 3719 +-----+-----------------------------+------------+ 3721 [Notes to RFC-Editor: Please remove the table above on publication. 3722 It is desirable not to reuse old or reserved algorithms because some 3723 existing tools might print a wrong description. A higher number is 3724 also an indication for a newer algorithm. As of now 22 is the next 3725 free number.] 3727 10.3.2. {10.3.2} Symmetric-Key Algorithms 3729 OpenPGP specifies a number of symmetric-key algorithms. This 3730 specification creates a registry of symmetric-key algorithm 3731 identifiers. The registry includes the algorithm name, its key sizes 3732 and block size, and a reference to the defining specification. The 3733 initial values for this registry can be found in Section 9. Adding a 3734 new symmetric-key algorithm MUST be done through the IETF CONSENSUS 3735 method, as described in [RFC2434]. 3737 10.3.3. {10.3.3} Hash Algorithms 3739 OpenPGP specifies a number of hash algorithms. This specification 3740 creates a registry of hash algorithm identifiers. The registry 3741 includes the algorithm name, a text representation of that name, its 3742 block size, an OID hash prefix, and a reference to the defining 3743 specification. The initial values for this registry can be found in 3744 Section 9 for the algorithm identifiers and text names, and 3745 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3746 new hash algorithm MUST be done through the IETF CONSENSUS method, as 3747 described in [RFC2434]. 3749 This document requests IANA register the following hash algorithms: 3751 +-----+------------+------------+ 3752 | ID | Algorithm | Reference | 3753 +-----+------------+------------+ 3754 | 12 | SHA3-256 | This doc | 3755 | 13 | Reserved | | 3756 | 14 | SHA3-512 | This doc | 3757 +-----+------------+------------+ 3759 [Notes to RFC-Editor: Please remove the table above on publication. 3760 It is desirable not to reuse old or reserved algorithms because some 3761 existing tools might print a wrong description. The ID 13 has been 3762 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 3763 counterparts.] 3765 10.3.4. {10.3.4} Compression Algorithms 3767 OpenPGP specifies a number of compression algorithms. This 3768 specification creates a registry of compression algorithm 3769 identifiers. The registry includes the algorithm name and a 3770 reference to the defining specification. The initial values for this 3771 registry can be found in Section 9.3. Adding a new compression key 3772 algorithm MUST be done through the IETF CONSENSUS method, as 3773 described in [RFC2434]. 3775 11. {11} Packet Composition 3777 OpenPGP packets are assembled into sequences in order to create 3778 messages and to transfer keys. Not all possible packet sequences are 3779 meaningful and correct. This section describes the rules for how 3780 packets should be placed into sequences. 3782 11.1. {11.1} Transferable Public Keys 3784 OpenPGP users may transfer public keys. The essential elements of a 3785 transferable public key are as follows: 3787 o One Public-Key packet 3789 o Zero or more revocation signatures 3791 o Zero or more User ID packets 3792 o After each User ID packet, zero or more Signature packets 3793 (certifications) 3795 o Zero or more User Attribute packets 3797 o After each User Attribute packet, zero or more Signature packets 3798 (certifications) 3800 o Zero or more Subkey packets 3802 o After each Subkey packet, one Signature packet, plus optionally a 3803 revocation 3805 The Public-Key packet occurs first. Each of the following User ID 3806 packets provides the identity of the owner of this public key. If 3807 there are multiple User ID packets, this corresponds to multiple 3808 means of identifying the same unique individual user; for example, a 3809 user may have more than one email address, and construct a User ID 3810 for each one. 3812 Immediately following each User ID packet, there are zero or more 3813 Signature packets. Each Signature packet is calculated on the 3814 immediately preceding User ID packet and the initial Public-Key 3815 packet. The signature serves to certify the corresponding public key 3816 and User ID. In effect, the signer is testifying to his or her 3817 belief that this public key belongs to the user identified by this 3818 User ID. 3820 Within the same section as the User ID packets, there are zero or 3821 more User Attribute packets. Like the User ID packets, a User 3822 Attribute packet is followed by zero or more Signature packets 3823 calculated on the immediately preceding User Attribute packet and the 3824 initial Public-Key packet. 3826 User Attribute packets and User ID packets may be freely intermixed 3827 in this section, so long as the signatures that follow them are 3828 maintained on the proper User Attribute or User ID packet. 3830 After the User ID packet or Attribute packet, there may be zero or 3831 more Subkey packets. In general, subkeys are provided in cases where 3832 the top-level public key is a signature-only key. However, any V4 3833 key may have subkeys, and the subkeys may be encryption-only keys, 3834 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3835 subkeys. 3837 Each Subkey packet MUST be followed by one Signature packet, which 3838 should be a subkey binding signature issued by the top-level key. 3839 For subkeys that can issue signatures, the subkey binding signature 3840 MUST contain an Embedded Signature subpacket with a primary key 3841 binding signature (0x19) issued by the subkey on the top-level key. 3843 Subkey and Key packets may each be followed by a revocation Signature 3844 packet to indicate that the key is revoked. Revocation signatures 3845 are only accepted if they are issued by the key itself, or by a key 3846 that is authorized to issue revocations via a Revocation Key 3847 subpacket in a self-signature by the top-level key. 3849 Transferable public-key packet sequences may be concatenated to allow 3850 transferring multiple public keys in one operation. 3852 11.2. {11.2} Transferable Secret Keys 3854 OpenPGP users may transfer secret keys. The format of a transferable 3855 secret key is the same as a transferable public key except that 3856 secret-key and secret-subkey packets are used instead of the public 3857 key and public-subkey packets. Implementations SHOULD include self- 3858 signatures on any user IDs and subkeys, as this allows for a complete 3859 public key to be automatically extracted from the transferable secret 3860 key. Implementations MAY choose to omit the self-signatures, 3861 especially if a transferable public key accompanies the transferable 3862 secret key. 3864 11.3. {11.3} OpenPGP Messages 3866 An OpenPGP message is a packet or sequence of packets that 3867 corresponds to the following grammatical rules (comma represents 3868 sequential composition, and vertical bar separates alternatives): 3870 OpenPGP Message :- Encrypted Message | Signed Message | 3871 Compressed Message | Literal Message. 3873 Compressed Message :- Compressed Data Packet. 3875 Literal Message :- Literal Data Packet. 3877 ESK :- Public-Key Encrypted Session Key Packet | 3878 Symmetric-Key Encrypted Session Key Packet. 3880 ESK Sequence :- ESK | ESK Sequence, ESK. 3882 Encrypted Data :- Symmetrically Encrypted Data Packet | 3883 Symmetrically Encrypted Integrity Protected Data Packet 3885 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3887 One-Pass Signed Message :- One-Pass Signature Packet, 3888 OpenPGP Message, Corresponding Signature Packet. 3890 Signed Message :- Signature Packet, OpenPGP Message | 3891 One-Pass Signed Message. 3893 In addition, decrypting a Symmetrically Encrypted Data packet or a 3894 Symmetrically Encrypted Integrity Protected Data packet as well as 3895 decompressing a Compressed Data packet must yield a valid OpenPGP 3896 Message. 3898 11.4. {11.4} Detached Signatures 3900 Some OpenPGP applications use so-called "detached signatures". For 3901 example, a program bundle may contain a file, and with it a second 3902 file that is a detached signature of the first file. These detached 3903 signatures are simply a Signature packet stored separately from the 3904 data for which they are a signature. 3906 12. {12} Enhanced Key Formats 3908 12.1. {12.1} Key Structures 3910 The format of an OpenPGP V3 key is as follows. Entries in square 3911 brackets are optional and ellipses indicate repetition. 3913 RSA Public Key 3914 [Revocation Self Signature] 3915 User ID [Signature ...] 3916 [User ID [Signature ...] ...] 3918 Each signature certifies the RSA public key and the preceding User 3919 ID. The RSA public key can have many User IDs and each User ID can 3920 have many signatures. V3 keys are deprecated. Implementations MUST 3921 NOT generate new V3 keys, but MAY continue to use existing ones. 3923 The format of an OpenPGP V4 key that uses multiple public keys is 3924 similar except that the other keys are added to the end as "subkeys" 3925 of the primary key. 3927 Primary-Key 3928 [Revocation Self Signature] 3929 [Direct Key Signature...] 3930 [User ID [Signature ...] ...] 3931 [User Attribute [Signature ...] ...] 3932 [[Subkey [Binding-Signature-Revocation] 3933 Primary-Key-Binding-Signature] ...] 3935 A subkey always has a single signature after it that is issued using 3936 the primary key to tie the two keys together. This binding signature 3937 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3938 issue signatures MUST have a V4 binding signature due to the REQUIRED 3939 embedded primary key binding signature. 3941 In the above diagram, if the binding signature of a subkey has been 3942 revoked, the revoked key may be removed, leaving only one key. 3944 In a V4 key, the primary key SHOULD be a key capable of 3945 certification. There are cases, such as device certificates, where 3946 the primary key may not be capable of certification. A primary key 3947 capable of making signatures SHOULD be accompanied by either a 3948 certification signature (on a User ID or User Attribute) or a 3949 signature directly on the key. 3951 Implementations SHOULD accept encryption-only primary keys without a 3952 signature. It also SHOULD allow importing any key accompanied either 3953 by a certification signature or a signature on itself. It MAY accept 3954 signature-capable primary keys without an accompanying signature. 3956 The subkeys may be keys of any other type. There may be other 3957 constructions of V4 keys, too. For example, there may be a single- 3958 key RSA key in V4 format, a DSA primary key with an RSA encryption 3959 key, or RSA primary key with an Elgamal subkey, etc. 3961 It is also possible to have a signature-only subkey. This permits a 3962 primary key that collects certifications (key signatures), but is 3963 used only for certifying subkeys that are used for encryption and 3964 signatures. 3966 12.2. {12.2} Key IDs and Fingerprints 3968 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3969 the public modulus of the RSA key. 3971 The fingerprint of a V3 key is formed by hashing the body (but not 3972 the two-octet length) of the MPIs that form the key material (public 3973 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3974 and MD5 are deprecated. 3976 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3977 followed by the two-octet packet length, followed by the entire 3978 Public-Key packet starting with the version field. The Key ID is the 3979 low-order 64 bits of the fingerprint. Here are the fields of the 3980 hash material, with the example of a DSA key: 3982 a.1) 0x99 (1 octet) 3984 a.2) two-octet scalar octet count of (b)-(e) 3986 b) version number = 4 (1 octet); 3988 c) timestamp of key creation (4 octets); 3990 d) algorithm (1 octet): 17 = DSA (example); 3992 e) Algorithm-specific fields. 3994 Algorithm-Specific Fields for DSA keys (example): 3996 e.1) MPI of DSA prime p; 3998 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 4000 e.3) MPI of DSA group generator g; 4002 e.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 4004 A V5 fingerprint is the 256-bit SHA2-256 hash of the octet 0x9A, 4005 followed by the four-octet packet length, followed by the entire 4006 Public-Key packet starting with the version field. The Key ID is the 4007 high-order 64 bits of the fingerprint. Here are the fields of the 4008 hash material, with the example of a DSA key: 4010 a.1) 0x9A (1 octet) 4012 a.2) four-octet scalar octet count of (b)-(f) 4014 b) version number = 5 (1 octet); 4016 c) timestamp of key creation (4 octets); 4018 d) algorithm (1 octet): 17 = DSA (example); 4020 e) four-octet scalar octet count for the following key material; 4022 f) algorithm-specific fields. 4024 Algorithm-Specific Fields for DSA keys (example): 4026 f.1) MPI of DSA prime p; 4028 f.2) MPI of DSA group order q (q is a prime divisor of p-1); 4030 f.3) MPI of DSA group generator g; 4032 f.4) MPI of DSA public-key value y (= g\*\*x mod p where x is secret). 4034 Note that it is possible for there to be collisions of Key IDs -- two 4035 different keys with the same Key ID. Note that there is a much 4036 smaller, but still non-zero, probability that two different keys have 4037 the same fingerprint. 4039 Also note that if V3, V4, and V5 format keys share the same RSA key 4040 material, they will have different Key IDs as well as different 4041 fingerprints. 4043 Finally, the Key ID and fingerprint of a subkey are calculated in the 4044 same way as for a primary key, including the 0x99 (V3 and V4 key) or 4045 0x9A (V5 key) as the first octet (even though this is not a valid 4046 packet ID for a public subkey). 4048 13. Elliptic Curve Cryptography 4050 This section descripes algorithms and parameters used with Elliptic 4051 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 4052 found in [KOBLITZ]. 4054 13.1. Supported ECC Curves 4056 This document references five named prime field curves, defined in 4057 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521"; and 4058 defined in [RFC5639] as "brainpoolP256r1", and "brainpoolP512r1". 4059 Further curve "Curve25519", defined in [RFC7748] is referenced for 4060 use with Ed25519 (EdDSA signing) and X25519 (encryption). 4062 The named curves are referenced as a sequence of bytes in this 4063 document, called throughout, curve OID. Section 9.2 describes in 4064 detail how this sequence of bytes is formed. 4066 13.2. ECDSA and ECDH Conversion Primitives 4068 This document defines the uncompressed point format for ECDSA and 4069 ECDH and a custom compression format for certain curves. The point 4070 is encoded in the Multiprecision Integer (MPI) format. 4072 For an uncompressed point the content of the MPI is: 4074 B = 04 || x || y 4076 where x and y are coordinates of the point P = (x, y), each encoded 4077 in the big-endian format and zero-padded to the adjusted underlying 4078 field size. The adjusted underlying field size is the underlying 4079 field size that is rounded up to the nearest 8-bit boundary. This 4080 encoding is compatible with the definition given in [SEC1]. 4082 For a custom compressed point the content of the MPI is: 4084 B = 40 || x 4086 where x is the x coordinate of the point P encoded to the rules 4087 defined for the specified curve. This format is used for ECDH keys 4088 based on curves expressed in Montgomery form. 4090 Therefore, the exact size of the MPI payload is 515 bits for "Curve 4091 P-256", 771 for "Curve P-384", 1059 for "Curve P-521", and 263 for 4092 Curve25519. 4094 Even though the zero point, also called the point at infinity, may 4095 occur as a result of arithmetic operations on points of an elliptic 4096 curve, it SHALL NOT appear in data structures defined in this 4097 document. 4099 If other conversion methods are defined in the future, a compliant 4100 application MUST NOT use a new format when in doubt that any 4101 recipient can support it. Consider, for example, that while both the 4102 public key and the per-recipient ECDH data structure, respectively 4103 defined in Sections 9{FIXME} and 10{FIXME}, contain an encoded point 4104 field, the format changes to the field in Section 10{FIXME} only 4105 affect a given recipient of a given message. 4107 13.3. EdDSA Point Format 4109 The EdDSA algorithm defines a specific point compression format. To 4110 indicate the use of this compression format and to make sure that the 4111 key can be represented in the Multiprecision Integer (MPI) format the 4112 octet string specifying the point is prefixed with the octet 0x40. 4113 This encoding is an extension of the encoding given in [SEC1] which 4114 uses 0x04 to indicate an uncompressed point. 4116 For example, the length of a public key for the curve Ed25519 is 263 4117 bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the 4118 native value of the public key. 4120 13.4. Key Derivation Function 4122 A key derivation function (KDF) is necessary to implement the EC 4123 encryption. The Concatenation Key Derivation Function (Approved 4124 Alternative 1) [SP800-56A] with the KDF hash function that is 4125 SHA2-256 [FIPS180] or stronger is REQUIRED. See Section 12{FIXME} 4126 for the details regarding the choice of the hash function. 4128 For convenience, the synopsis of the encoding method is given below 4129 with significant simplifications attributable to the restricted 4130 choice of hash functions in this document. However, [SP800-56A] is 4131 the normative source of the definition. 4133 // Implements KDF( X, oBits, Param ); 4134 // Input: point X = (x,y) 4135 // oBits - the desired size of output 4136 // hBits - the size of output of hash function Hash 4137 // Param - octets representing the parameters 4138 // Assumes that oBits <= hBits 4139 // Convert the point X to the octet string, see section 6{FIXME}: 4140 // ZB' = 04 || x || y 4141 // and extract the x portion from ZB' 4142 ZB = x; 4143 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 4144 return oBits leftmost bits of MB. 4146 Note that ZB in the KDF description above is the compact 4147 representation of X, defined in Section 4.2 of [RFC6090]. 4149 13.5. EC DH Algorithm (ECDH) 4151 The method is a combination of an ECC Diffie-Hellman method to 4152 establish a shared secret, a key derivation method to process the 4153 shared secret into a derived key, and a key wrapping method that uses 4154 the derived key to protect a session key used to encrypt a message. 4156 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 4157 be implemented with the following restrictions: the ECC CDH primitive 4158 employed by this method is modified to always assume the cofactor as 4159 1, the KDF specified in Section 7 is used, and the KDF parameters 4160 specified below are used. 4162 The KDF parameters are encoded as a concatenation of the following 5 4163 variable-length and fixed-length fields, compatible with the 4164 definition of the OtherInfo bitstring [SP800-56A]: 4166 o a variable-length field containing a curve OID, formatted as 4167 follows: 4169 * a one-octet size of the following field 4171 * the octets representing a curve OID, defined in Section 11 4173 o a one-octet public key algorithm ID defined in Section 5 4175 o a variable-length field containing KDF parameters, identical to 4176 the corresponding field in the ECDH public key, formatted as 4177 follows: 4179 * a one-octet size of the following fields; values 0 and 0xff are 4180 reserved for future extensions 4182 * a one-octet value 01, reserved for future extensions 4184 * a one-octet hash function ID used with the KDF 4186 * a one-octet algorithm ID for the symmetric algorithm used to 4187 wrap the symmetric key for message encryption; see Section 8 4188 for details 4190 o 20 octets representing the UTF-8 encoding of the string "Anonymous 4191 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 73 4192 20 53 65 6E 64 65 72 20 20 20 20 4194 o 20 octets representing a recipient encryption subkey or a master 4195 key fingerprint, identifying the key material that is needed for 4196 the decryption. For version 5 keys the 20 leftmost octets of the 4197 fingerprint are used. 4199 The size of the KDF parameters sequence, defined above, is either 54 4200 for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 4201 for Curve25519. 4203 The key wrapping method is described in [RFC3394]. KDF produces a 4204 symmetric key that is used as a key-encryption key (KEK) as specified 4205 in [RFC3394]. Refer to Section 13{FIXME} for the details regarding 4206 the choice of the KEK algorithm, which SHOULD be one of three AES 4207 algorithms. Key wrapping and unwrapping is performed with the 4208 default initial value of [RFC3394]. 4210 The input to the key wrapping method is the value "m" derived from 4211 the session key, as described in Section 5.1{FIXME}, "Public-Key 4212 Encrypted Session Key Packets (Tag 1)", except that the PKCS #1.5 4213 padding step is omitted. The result is padded using the method 4214 described in [PKCS5] to the 8-byte granularity. For example, the 4215 following AES-256 session key, in which 32 octets are denoted from k0 4216 to k31, is composed to form the following 40 octet sequence: 4218 09 k0 k1 ... k31 c0 c1 05 05 05 05 05 4220 The octets c0 and c1 above denote the checksum. This encoding allows 4221 the sender to obfuscate the size of the symmetric encryption key used 4222 to encrypt the data. For example, assuming that an AES algorithm is 4223 used for the session key, the sender MAY use 21, 13, and 5 bytes of 4224 padding for AES-128, AES-192, and AES-256, respectively, to provide 4225 the same number of octets, 40 total, as an input to the key wrapping 4226 method. 4228 The output of the method consists of two fields. The first field is 4229 the MPI containing the ephemeral key used to establish the shared 4230 secret. The second field is composed of the following two fields: 4232 o a one-octet encoding the size in octets of the result of the key 4233 wrapping method; the value 255 is reserved for future extensions; 4235 o up to 254 octets representing the result of the key wrapping 4236 method, applied to the 8-byte padded session key, as described 4237 above. 4239 Note that for session key sizes 128, 192, and 256 bits, the size of 4240 the result of the key wrapping method is, respectively, 32, 40, and 4241 48 octets, unless the size obfuscation is used. 4243 For convenience, the synopsis of the encoding method is given below; 4244 however, this section, [SP800-56A], and [RFC3394] are the normative 4245 sources of the definition. 4247 Obtain the authenticated recipient public key R 4248 Generate an ephemeral key pair {v, V=vG} 4249 Compute the shared point S = vR; 4250 m = symm_alg_ID || session key || checksum || pkcs5_padding; 4251 curve_OID_len = (byte)len(curve_OID); 4252 Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 4253 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 4254 Sender " || recipient_fingerprint; 4255 Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 4256 Compute Z = KDF( S, Z_len, Param ); 4257 Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4258 VB = convert point V to the octet string 4259 Output (MPI(VB) || len(C) || C). 4261 The decryption is the inverse of the method given. Note that the 4262 recipient obtains the shared secret by calculating 4264 S = rV = rvG, where (r,R) is the recipient's key pair. 4266 Consistent with Section 5.13{FIXME}, "Sym. Encrypted Integrity 4267 Protected Data Packet (Tag 18)", a Modification Detection Code (MDC) 4268 MUST be used anytime the symmetric key is protected by ECDH. 4270 14. {13} Notes on Algorithms 4272 14.1. {13.1} PKCS#1 Encoding in OpenPGP 4274 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4275 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4276 has changed in the past. To avoid potential confusion and 4277 interoperability problems, we are including local copies in this 4278 document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447 4279 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4280 Nonetheless, we believe that there is value in having a self- 4281 contained document that avoids problems in the future with needed 4282 changes in the conventions. 4284 14.1.1. {13.1.1} EME-PKCS1-v1_5-ENCODE 4285 Input: 4287 k = the length in octets of the key modulus 4289 M = message to be encoded, an octet string of length mLen, where mLen 4290 \<= k - 11 4292 Output: 4294 EM = encoded message, an octet string of length k 4296 Error: "message too long" 4298 1. Length checking: If mLen > k - 11, output "message too long" 4299 and stop. 4301 2. Generate an octet string PS of length k - mLen - 3 consisting 4302 of pseudo-randomly generated nonzero octets. The length of PS 4303 will be at least eight octets. 4305 3. Concatenate PS, the message M, and other padding to form an 4306 encoded message EM of length k octets as 4308 EM = 0x00 || 0x02 || PS || 0x00 || M. 4310 4. Output EM. 4312 14.1.2. {13.1.2} EME-PKCS1-v1_5-DECODE 4314 Input: 4316 EM = encoded message, an octet string 4318 Output: 4320 M = message, an octet string 4322 Error: "decryption error" 4324 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4325 into an octet string PS consisting of nonzero octets and a message M 4326 as follows 4328 EM = 0x00 || 0x02 || PS || 0x00 || M. 4330 If the first octet of EM does not have hexadecimal value 0x00, if the 4331 second octet of EM does not have hexadecimal value 0x02, if there is 4332 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4333 length of PS is less than 8 octets, output "decryption error" and 4334 stop. See also the security note in Section 14 regarding differences 4335 in reporting between a decryption error and a padding error. 4337 14.1.3. {13.1.3} EMSA-PKCS1-v1_5 4339 This encoding method is deterministic and only has an encoding 4340 operation. 4342 Option: 4344 Hash - a hash function in which hLen denotes the length in octets 4345 of the hash function output 4347 Input: 4349 M = message to be encoded 4351 emLen = intended length in octets of the encoded message, at least 4352 tLen + 11, where tLen is the octet length of the DER encoding 4353 T of a certain value computed during the encoding operation 4355 Output: 4357 EM = encoded message, an octet string of length emLen 4359 Errors: "message too long"; 4360 "intended encoded message length too short" 4362 Steps: 4364 1. Apply the hash function to the message M to produce a hash 4365 value H: 4367 H = Hash(M). 4369 If the hash function outputs "message too long," output 4370 "message too long" and stop. 4372 2. Using the list in Section 5.2.2, produce an ASN.1 DER value 4373 for the hash function used. Let T be the full hash prefix 4374 from Section 5.2.2, and let tLen be the length in octets of T. 4376 3. If emLen < tLen + 11, output "intended encoded message length 4377 too short" and stop. 4379 4. Generate an octet string PS consisting of emLen - tLen - 3 4380 octets with hexadecimal value 0xFF. The length of PS will be 4381 at least 8 octets. 4383 5. Concatenate PS, the hash prefix T, and other padding to form 4384 the encoded message EM as 4386 EM = 0x00 || 0x01 || PS || 0x00 || T. 4388 6. Output EM. 4390 14.2. {13.2} Symmetric Algorithm Preferences 4392 The symmetric algorithm preference is an ordered list of algorithms 4393 that the keyholder accepts. Since it is found on a self-signature, 4394 it is possible that a keyholder may have multiple, different 4395 preferences. For example, Alice may have AES-128 only specified for 4396 "alice@work.com" but Camellia-256, Twofish, and AES-128 specified for 4397 "alice@home.org". Note that it is also possible for preferences to 4398 be in a subkey's binding signature. 4400 Since AES-128 is the MUST-implement algorithm, if it is not 4401 explicitly in the list, it is tacitly at the end. However, it is 4402 good form to place it there explicitly. Note also that if an 4403 implementation does not implement the preference, then it is 4404 implicitly an AES-128-only implementation. Note further that 4405 implementations conforming to previous versions of this standard 4406 (RFC-4880) have TripleDES as its only MUST-implement algorithm. 4408 An implementation MUST NOT use a symmetric algorithm that is not in 4409 the recipient's preference list. When encrypting to more than one 4410 recipient, the implementation finds a suitable algorithm by taking 4411 the intersection of the preferences of the recipients. Note that the 4412 MUST-implement algorithm, AES-128, ensures that the intersection is 4413 not null. The implementation may use any mechanism to pick an 4414 algorithm in the intersection. 4416 If an implementation can decrypt a message that a keyholder doesn't 4417 have in their preferences, the implementation SHOULD decrypt the 4418 message anyway, but MUST warn the keyholder that the protocol has 4419 been violated. For example, suppose that Alice, above, has software 4420 that implements all algorithms in this specification. Nonetheless, 4421 she prefers subsets for work or home. If she is sent a message 4422 encrypted with IDEA, which is not in her preferences, the software 4423 warns her that someone sent her an IDEA-encrypted message, but it 4424 would ideally decrypt it anyway. 4426 14.3. {13.3} Other Algorithm Preferences 4428 Other algorithm preferences work similarly to the symmetric algorithm 4429 preference, in that they specify which algorithms the keyholder 4430 accepts. There are two interesting cases that other comments need to 4431 be made about, though, the compression preferences and the hash 4432 preferences. 4434 14.3.1. {13.3.1} Compression Preferences 4436 Compression has been an integral part of PGP since its first days. 4437 OpenPGP and all previous versions of PGP have offered compression. 4438 In this specification, the default is for messages to be compressed, 4439 although an implementation is not required to do so. Consequently, 4440 the compression preference gives a way for a keyholder to request 4441 that messages not be compressed, presumably because they are using a 4442 minimal implementation that does not include compression. 4443 Additionally, this gives a keyholder a way to state that it can 4444 support alternate algorithms. 4446 Like the algorithm preferences, an implementation MUST NOT use an 4447 algorithm that is not in the preference vector. If the preferences 4448 are not present, then they are assumed to be [ZIP(1), 4449 Uncompressed(0)]. 4451 Additionally, an implementation MUST implement this preference to the 4452 degree of recognizing when to send an uncompressed message. A robust 4453 implementation would satisfy this requirement by looking at the 4454 recipient's preference and acting accordingly. A minimal 4455 implementation can satisfy this requirement by never generating a 4456 compressed message, since all implementations can handle messages 4457 that have not been compressed. 4459 14.3.2. {13.3.2} Hash Algorithm Preferences 4461 Typically, the choice of a hash algorithm is something the signer 4462 does, rather than the verifier, because a signer rarely knows who is 4463 going to be verifying the signature. This preference, though, allows 4464 a protocol based upon digital signatures ease in negotiation. 4466 Thus, if Alice is authenticating herself to Bob with a signature, it 4467 makes sense for her to use a hash algorithm that Bob's software uses. 4468 This preference allows Bob to state in his key which algorithms Alice 4469 may use. 4471 Since SHA2-256 is the MUST-implement hash algorithm, if it is not 4472 explicitly in the list, it is tacitly at the end. However, it is 4473 good form to place it there explicitly. 4475 14.4. {13.4} Plaintext 4477 Algorithm 0, "plaintext", may only be used to denote secret keys that 4478 are stored in the clear. Implementations MUST NOT use plaintext in 4479 Symmetrically Encrypted Data packets; they must use Literal Data 4480 packets to encode unencrypted or literal data. 4482 14.5. {13.5} RSA 4484 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4485 keys. These types are deprecated. The "key flags" subpacket in a 4486 signature is a much better way to express the same idea, and 4487 generalizes it to all algorithms. An implementation SHOULD NOT 4488 create such a key, but MAY interpret it. 4490 An implementation SHOULD NOT implement RSA keys of size less than 4491 1024 bits. 4493 14.6. {13.6} DSA 4495 An implementation SHOULD NOT implement DSA keys of size less than 4496 1024 bits. It MUST NOT implement a DSA key with a q size of less 4497 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4498 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4499 (DSS) [FIPS186] specifies that DSA be used in one of the following 4500 ways: 4502 o 1024-bit key, 160-bit q, SHA-1, SHA2--224, SHA2-256, SHA2-384, or 4503 SHA2-512 hash 4505 o 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 4506 hash 4508 o 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4510 o 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4512 The above key and q size pairs were chosen to best balance the 4513 strength of the key with the strength of the hash. Implementations 4514 SHOULD use one of the above key and q size pairs when generating DSA 4515 keys. If DSS compliance is desired, one of the specified SHA hashes 4516 must be used as well. [FIPS186] is the ultimate authority on DSS, 4517 and should be consulted for all questions of DSS compliance. 4519 Note that earlier versions of this standard only allowed a 160-bit q 4520 with no truncation allowed, so earlier implementations may not be 4521 able to handle signatures with a different q size or a truncated 4522 hash. 4524 14.7. {13.7} Elgamal 4526 An implementation SHOULD NOT implement Elgamal keys of size less than 4527 1024 bits. 4529 14.8. EdDSA 4531 Although the EdDSA algorithm allows arbitrary data as input, its use 4532 with OpenPGP requires that a digest of the message is used as input 4533 (pre-hashed). See section XXXXX, "Computing Signatures" for details. 4534 Truncation of the resulting digest is never applied; the resulting 4535 digest value is used verbatim as input to the EdDSA algorithm. 4537 14.9. {13.8} Reserved Algorithm Numbers 4539 A number of algorithm IDs have been reserved for algorithms that 4540 would be useful to use in an OpenPGP implementation, yet there are 4541 issues that prevent an implementer from actually implementing the 4542 algorithm. These are marked in Section 9.1, "Public-Key Algorithms", 4543 as "reserved for". 4545 The reserved public-key algorithm X9.42 (21) does not have the 4546 necessary parameters, parameter order, or semantics defined. The 4547 same is currently true for reserved public-key algorithms AEDH (23) 4548 and AEDSA (24). 4550 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4551 with a public-key identifier of 20. These are no longer permitted. 4552 An implementation MUST NOT generate such keys. An implementation 4553 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4555 14.10. {13.9} OpenPGP CFB Mode 4557 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4558 mode (CFB mode). This section describes the procedure it uses in 4559 detail. This mode is what is used for Symmetrically Encrypted Data 4560 Packets; the mechanism used for encrypting secret-key material is 4561 similar, and is described in the sections above. 4563 In the description below, the value BS is the block size in octets of 4564 the cipher. Most ciphers have a block size of 8 octets. The AES and 4565 Twofish have a block size of 16 octets. Also note that the 4566 description below assumes that the IV and CFB arrays start with an 4567 index of 1 (unlike the C language, which assumes arrays start with a 4568 zero index). 4570 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4571 prefixes the plaintext with BS+2 octets of random data, such that 4572 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4573 resynchronization after encrypting those BS+2 octets. 4575 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4576 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4577 octets 9 and 10. For an algorithm with a block size of 16 octets 4578 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4579 octets 15 and 16. Those extra two octets are an easy check for a 4580 correct key. 4582 Step by step, here is the procedure: 4584 1. The feedback register (FR) is set to the IV, which is all zeros. 4586 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4587 encryption of an all-zero value. 4589 3. FRE is xored with the first BS octets of random data prefixed to 4590 the plaintext to produce C[1] through C[BS], the first BS octets 4591 of ciphertext. 4593 4. FR is loaded with C[1] through C[BS]. 4595 5. FR is encrypted to produce FRE, the encryption of the first BS 4596 octets of ciphertext. 4598 6. The left two octets of FRE get xored with the next two octets of 4599 data that were prefixed to the plaintext. This produces C[BS+1] 4600 and C[BS+2], the next two octets of ciphertext. 4602 7. (The resynchronization step) FR is loaded with C[3] through 4603 C[BS+2]. 4605 8. FRE is xored with the first BS octets of the given plaintext, 4606 now that we have finished encrypting the BS+2 octets of prefixed 4607 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4608 octets of ciphertext. 4610 9. FR is encrypted to produce FRE. 4612 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4613 for an 8-octet block). 4615 11. FR is encrypted to produce FRE. 4617 12. FRE is xored with the next BS octets of plaintext, to produce 4618 the next BS octets of ciphertext. These are loaded into FR, and 4619 the process is repeated until the plaintext is used up. 4621 14.11. {13.10} Private or Experimental Parameters 4623 S2K specifiers, Signature subpacket types, user attribute types, 4624 image format types, and algorithms described in Section 9 all reserve 4625 the range 100 to 110 for private and experimental use. Packet types 4626 reserve the range 60 to 63 for private and experimental use. These 4627 are intentionally managed with the PRIVATE USE method, as described 4628 in [RFC2434]. 4630 However, implementations need to be careful with these and promote 4631 them to full IANA-managed parameters when they grow beyond the 4632 original, limited system. 4634 14.12. {13.12} Meta-Considerations for Expansion 4636 If OpenPGP is extended in a way that is not backwards-compatible, 4637 meaning that old implementations will not gracefully handle their 4638 absence of a new feature, the extension proposal can be declared in 4639 the key holder's self-signature as part of the Features signature 4640 subpacket. 4642 We cannot state definitively what extensions will not be upwards- 4643 compatible, but typically new algorithms are upwards-compatible, 4644 whereas new packets are not. 4646 If an extension proposal does not update the Features system, it 4647 SHOULD include an explanation of why this is unnecessary. If the 4648 proposal contains neither an extension to the Features system nor an 4649 explanation of why such an extension is unnecessary, the proposal 4650 SHOULD be rejected. 4652 15. {14} Security Considerations 4654 o As with any technology involving cryptography, you should check 4655 the current literature to determine if any algorithms used here 4656 have been found to be vulnerable to attack. 4658 o This specification uses Public-Key Cryptography technologies. It 4659 is assumed that the private key portion of a public-private key 4660 pair is controlled and secured by the proper party or parties. 4662 o Certain operations in this specification involve the use of random 4663 numbers. An appropriate entropy source should be used to generate 4664 these numbers (see [RFC4086]). 4666 o The MD5 hash algorithm has been found to have weaknesses, with 4667 collisions found in a number of cases. MD5 is deprecated for use 4668 in OpenPGP. Implementations MUST NOT generate new signatures 4669 using MD5 as a hash function. They MAY continue to consider old 4670 signatures that used MD5 as valid. 4672 o SHA2-224 and SHA2-384 require the same work as SHA2-256 and 4673 SHA2-512, respectively. In general, there are few reasons to use 4674 them outside of DSS compatibility. You need a situation where one 4675 needs more security than smaller hashes, but does not want to have 4676 the full 256-bit or 512-bit data length. 4678 o Many security protocol designers think that it is a bad idea to 4679 use a single key for both privacy (encryption) and integrity 4680 (signatures). In fact, this was one of the motivating forces 4681 behind the V4 key format with separate signature and encryption 4682 keys. If you as an implementer promote dual-use keys, you should 4683 at least be aware of this controversy. 4685 o The DSA algorithm will work with any hash, but is sensitive to the 4686 quality of the hash algorithm. Verifiers should be aware that 4687 even if the signer used a strong hash, an attacker could have 4688 modified the signature to use a weak one. Only signatures using 4689 acceptably strong hash algorithms should be accepted as valid. 4691 o As OpenPGP combines many different asymmetric, symmetric, and hash 4692 algorithms, each with different measures of strength, care should 4693 be taken that the weakest element of an OpenPGP message is still 4694 sufficiently strong for the purpose at hand. While consensus 4695 about the strength of a given algorithm may evolve, NIST Special 4696 Publication 800-57 [SP800-57] recommends the following list of 4697 equivalent strengths: 4699 Asymmetric | Hash | Symmetric 4700 key size | size | key size 4701 ------------+--------+----------- 4702 1024 160 80 4703 2048 224 112 4704 3072 256 128 4705 7680 384 192 4706 15360 512 256 4708 o There is a somewhat-related potential security problem in 4709 signatures. If an attacker can find a message that hashes to the 4710 same hash with a different algorithm, a bogus signature structure 4711 can be constructed that evaluates correctly. 4713 For example, suppose Alice DSA signs message M using hash 4714 algorithm H. Suppose that Mallet finds a message M' that has the 4715 same hash value as M with H'. Mallet can then construct a 4716 signature block that verifies as Alice's signature of M' with H'. 4717 However, this would also constitute a weakness in either H or H' 4718 or both. Should this ever occur, a revision will have to be made 4719 to this document to revise the allowed hash algorithms. 4721 o If you are building an authentication system, the recipient may 4722 specify a preferred signing algorithm. However, the signer would 4723 be foolish to use a weak algorithm simply because the recipient 4724 requests it. 4726 o Some of the encryption algorithms mentioned in this document have 4727 been analyzed less than others. For example, although CAST5 is 4728 presently considered strong, it has been analyzed less than 4729 TripleDES. Other algorithms may have other controversies 4730 surrounding them. 4732 o In late summer 2002, Jallad, Katz, and Schneier published an 4733 interesting attack on the OpenPGP protocol and some of its 4734 implementations [JKS02]. In this attack, the attacker modifies a 4735 message and sends it to a user who then returns the erroneously 4736 decrypted message to the attacker. The attacker is thus using the 4737 user as a random oracle, and can often decrypt the message. 4739 Compressing data can ameliorate this attack. The incorrectly 4740 decrypted data nearly always decompresses in ways that defeat the 4741 attack. However, this is not a rigorous fix, and leaves open some 4742 small vulnerabilities. For example, if an implementation does not 4743 compress a message before encryption (perhaps because it knows it 4744 was already compressed), then that message is vulnerable. Because 4745 of this happenstance -- that modification attacks can be thwarted 4746 by decompression errors -- an implementation SHOULD treat a 4747 decompression error as a security problem, not merely a data 4748 problem. 4750 This attack can be defeated by the use of modification detection, 4751 provided that the implementation does not let the user naively 4752 return the data to the attacker. The modification detection is 4753 prefereabble implemented by using the AEAD Encrypted Data Packet 4754 and only if the recipients don't supports this by use of the 4755 Symmmetric Encrypted and Integrity Protected Data Packet. An 4756 implementation MUST treat an authentication or MDC failure as a 4757 security problem, not merely a data problem. 4759 In either case, the implementation SHOULD NOT allow the user 4760 access to the erroneous data, and MUST warn the user as to 4761 potential security problems should that data be returned to the 4762 sender. 4764 While this attack is somewhat obscure, requiring a special set of 4765 circumstances to create it, it is nonetheless quite serious as it 4766 permits someone to trick a user to decrypt a message. 4767 Consequently, it is important that: 4769 1. Implementers treat authentication errors, MDC errors, 4770 decompression failures or no use of MDC or AEAD as security 4771 problems. 4773 2. Implementers implement AEAD with all due speed and encourage 4774 its spread. 4776 3. Users migrate to implementations that support AEAD encryption 4777 with all due speed. 4779 o PKCS#1 has been found to be vulnerable to attacks in which a 4780 system that reports errors in padding differently from errors in 4781 decryption becomes a random oracle that can leak the private key 4782 in mere millions of queries. Implementations must be aware of 4783 this attack and prevent it from happening. The simplest solution 4784 is to report a single error code for all variants of decryption 4785 errors so as not to leak information to an attacker. 4787 o Some technologies mentioned here may be subject to government 4788 control in some countries. 4790 o In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4791 released a paper describing a way that the "quick check" in 4792 OpenPGP CFB mode can be used with a random oracle to decrypt two 4793 octets of every cipher block [MZ05]. They recommend as prevention 4794 not using the quick check at all. 4796 Many implementers have taken this advice to heart for any data 4797 that is symmetrically encrypted and for which the session key is 4798 public-key encrypted. In this case, the quick check is not needed 4799 as the public-key encryption of the session key should guarantee 4800 that it is the right session key. In other cases, the 4801 implementation should use the quick check with care. 4803 On the one hand, there is a danger to using it if there is a 4804 random oracle that can leak information to an attacker. In 4805 plainer language, there is a danger to using the quick check if 4806 timing information about the check can be exposed to an attacker, 4807 particularly via an automated service that allows rapidly repeated 4808 queries. 4810 On the other hand, it is inconvenient to the user to be informed 4811 that they typed in the wrong passphrase only after a petabyte of 4812 data is decrypted. There are many cases in cryptographic 4813 engineering where the implementer must use care and wisdom, and 4814 this is one. 4816 o Refer to [FIPS186], B.4.1, for the method to generate a uniformly 4817 distributed ECC private key. 4819 o The curves proposed in this document correspond to the symmetric 4820 key sizes 128 bits, 192 bits, and 256 bits, as described in the 4821 table below. This allows a compliant application to offer 4822 balanced public key security, which is compatible with the 4823 symmetric key strength for each AES algorithm defined here. 4825 The following table defines the hash and the symmetric encryption 4826 algorithm that SHOULD be used with a given curve for ECDSA or 4827 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 4828 be used for a given ECC curve. However, note that the increase in 4829 the strength of the hash algorithm or the symmetric key algorithm 4830 may not increase the overall security offered by the given ECC 4831 key. 4833 Curve name | ECC | RSA | Hash size | Symmetric 4834 | strength | strength, | | key size 4835 | | informative | | 4836 -----------+----------+-------------+-----------+----------- 4837 NIST P-256 256 3072 256 128 4838 NIST P-384 384 7680 384 192 4839 NIST P-521 521 15360 512 256 4841 Requirement levels indicated elsewhere in this document lead to 4842 the following combinations of algorithms in the OpenPGP profile: 4843 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 4844 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 4845 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 4846 combinations. 4848 Consistent with the table above, the following table defines the 4849 KDF hash algorithm and the AES KEK encryption algorithm that 4850 SHOULD be used with a given curve for ECDH. A stronger KDF hash 4851 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 4853 Curve name | Recommended KDF | Recommended KEK 4854 | hash algorithm | encryption algorithm 4855 -----------+-----------------+----------------------- 4856 NIST P-256 SHA2-256 AES-128 4857 NIST P-384 SHA2-384 AES-192 4858 NIST P-521 SHA2-512 AES-256 4860 This document explicitly discourages the use of algorithms other 4861 than AES as a KEK algorithm because backward compatibility of the 4862 ECDH format is not a concern. The KEK algorithm is only used 4863 within the scope of a Public-Key Encrypted Session Key Packet, 4864 which represents an ECDH key recipient of a message. Compare this 4865 with the algorithm used for the session key of the message, which 4866 MAY be different from a KEK algorithm. 4868 Compliant applications SHOULD implement, advertise through key 4869 preferences, and use the strongest algorithms specified in this 4870 document. 4872 Note that the symmetric algorithm preference list may make it 4873 impossible to use the balanced strength of symmetric key 4874 algorithms for a corresponding public key. For example, the 4875 presence of the symmetric key algorithm IDs and their order in the 4876 key preference list affects the algorithm choices available to the 4877 encoding side, which in turn may make the adherence to the table 4878 above infeasible. Therefore, compliance with this specification 4879 is a concern throughout the life of the key, starting immediately 4880 after the key generation when the key preferences are first added 4881 to a key. It is generally advisable to position a symmetric 4882 algorithm ID of strength matching the public key at the head of 4883 the key preference list. 4885 Encryption to multiple recipients often results in an unordered 4886 intersection subset. For example, if the first recipient's set is 4887 {A, B} and the second's is {B, A}, the intersection is an 4888 unordered set of two algorithms, A and B. In this case, a 4889 compliant application SHOULD choose the stronger encryption 4890 algorithm. 4892 Resource constraints, such as limited computational power, is a 4893 likely reason why an application might prefer to use the weakest 4894 algorithm. On the other side of the spectrum are applications 4895 that can implement every algorithm defined in this document. Most 4896 applications are expected to fall into either of two categories. 4897 A compliant application in the second, or strongest, category 4898 SHOULD prefer AES-256 to AES-192. 4900 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 4901 method. 4903 MDC MUST be used when a symmetric encryption key is protected by 4904 ECDH. None of the ECC methods described in this document are 4905 allowed with deprecated V3 keys. A compliant application MUST 4906 only use iterated and salted S2K to protect private keys, as 4907 defined in Section 3.7.1.3{FIXME}, "Iterated and Salted S2K". 4909 Side channel attacks are a concern when a compliant application's 4910 use of the OpenPGP format can be modeled by a decryption or 4911 signing oracle model, for example, when an application is a 4912 network service performing decryption to unauthenticated remote 4913 users. ECC scalar multiplication operations used in ECDSA and 4914 ECDH are vulnerable to side channel attacks. Countermeasures can 4915 often be taken at the higher protocol level, such as limiting the 4916 number of allowed failures or time-blinding of the operations 4917 associated with each network interface. Mitigations at the scalar 4918 multiplication level seek to eliminate any measurable distinction 4919 between the ECC point addition and doubling operations. 4921 o Although technically possible, the EdDSA algorithm MUST NOT be 4922 used with a digest algorithms weaker than SHA2-256. 4924 OpenPGP was designed with security in mind, with many smart, 4925 intelligent people spending a lot of time thinking about the 4926 ramifications of their decisions. Removing the requirement for self- 4927 certifying User ID (and User Attribute) packets on a key means that 4928 someone could surreptitiously add an unwanted ID to a key and sign 4929 it. If enough "trusted" people sign that surreptitious identity then 4930 other people might believe it. The attack could wind up sending 4931 encrypted mail destined for alice to some other target, bob, because 4932 someone added "alice" to bob's key without bob's consent. 4934 In the case of device certificates the device itself does not have 4935 any consent. It is given an identity by the device manufacturer and 4936 the manufacturer can insert that ID on the device certificate, 4937 signing it with the manufacturer's key. If another people wants to 4938 label the device by another name, they can do so. There is no harm 4939 in multiple IDs, because the verification is all done based on who 4940 has signed those IDs. 4942 When a key can self-sign, it is still suggested to self-certify IDs, 4943 even if it no longer required by this modification to OpenPGP. This 4944 at least signals to recipients of keys that yes, the owner of this 4945 key asserts that this identity belongs to herself. Note, however, 4946 that mallet could still assert that he is 'alice' and could even 4947 self-certify that. So the attack is not truly different. Moreover, 4948 in the case of device certificates, it's more the manufacturer than 4949 the device that wants to assert an identity (even if the device could 4950 self-certify). 4952 There is no signaling whether a key is using this looser-requirement 4953 key format. An attacker could therefore just remove the self- 4954 signature off a published key. However one would hope that wide 4955 publication would result in another copy still having that signature 4956 and it being returned quickly. However, the lack of signaling also 4957 means that a user with an application following RFC 4880 directly 4958 would see a key following this specification as "broken" and may not 4959 accept it. 4961 On a different note, including the "geo" notation could leak 4962 information about where a signer is located. However it is just an 4963 assertion (albeit a signed assertion) so there is no verifiable truth 4964 to the location information released. Similarly, all the rest of the 4965 signature notations are pure assertions, so they should be taken with 4966 the trustworthiness of the signer. 4968 Combining the User ID with the User Attribute means that an ID and 4969 image would not be separable. For a person this is probably not 4970 good, but for a device it's unlikely the image will change so it 4971 makes sense to combine the ID and image into a single signed packet 4972 with a single signature. 4974 16. Compatibility Profiles 4976 16.1. OpenPGP ECC Profile 4978 A compliant application MUST implement NIST curve P-256, SHOULD 4979 implement NIST curve P-521, SHOULD implemend Ed25519, SHOULD 4980 implement Curve25519, MAY implement NIST curve P-384, MAY implement 4981 brainpoolP256r1, and MAY implement brainpoolP512r1, as defined in 4982 Section 11. A compliant application MUST implement SHA2-256 and 4983 SHOULD implement SHA2-384 and SHA2-512. A compliant application MUST 4984 implement AES-128 and SHOULD implement AES-256. 4986 A compliant application SHOULD follow Section 13{FIXME} regarding the 4987 choice of the following algorithms for each curve: 4989 o the KDF hash algorithm, 4991 o the KEK algorithm, 4993 o the message digest algorithm and the hash algorithm used in the 4994 key certifications, 4996 o the symmetric algorithm used for message encryption. 4998 It is recommended that the chosen symmetric algorithm for message 4999 encryption be no less secure than the KEK algorithm. 5001 16.2. Suite-B Profile 5003 A subset of algorithms allowed by this document can be used to 5004 achieve [SuiteB] compatibility. The references to [SuiteB] in this 5005 document are informative. This document is primarily concerned with 5006 format specification, leaving additional security restrictions 5007 unspecified, such as matching the assigned security level of 5008 information to authorized recipients or interoperability concerns 5009 arising from fewer allowed algorithms in [SuiteB] than allowed by 5010 this document. 5012 16.3. Security Strength at 192 Bits 5014 To achieve the security strength of 192 bits, [SuiteB] requires NIST 5015 curve P-384, AES-256, and SHA2-384. The symmetric algorithm 5016 restriction means that the algorithm of KEK used for key wrapping in 5017 Section 8 and an OpenPGP session key used for message encryption must 5018 be AES-256. The hash algorithm restriction means that the hash 5019 algorithms of KDF and the OpenPGP message digest calculation must be 5020 SHA2-384. 5022 16.4. Security Strength at 128 Bits 5024 The set of algorithms in Section 12.2.1{FIXME} is extended to allow 5025 NIST curve P-256, AES-128, and SHA2-256. 5027 17. {15} Implementation Nits 5029 This section is a collection of comments to help an implementer, 5030 particularly with an eye to backward compatibility. Previous 5031 implementations of PGP are not OpenPGP compliant. Often the 5032 differences are small, but small differences are frequently more 5033 vexing than large differences. Thus, this is a non-comprehensive 5034 list of potential problems and gotchas for a developer who is trying 5035 to be backward-compatible. 5037 o The IDEA algorithm is patented, and yet it is required for PGP 2.x 5038 interoperability. It is also the de-facto preferred algorithm for 5039 a V3 key with a V3 self-signature (or no self- signature). 5041 o When exporting a private key, PGP 2.x generates the header "BEGIN 5042 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 5043 All previous versions ignore the implied data type, and look 5044 directly at the packet data type. 5046 o PGP 2.0 through 2.5 generated V2 Public-Key packets. These are 5047 identical to the deprecated V3 keys except for the version number. 5048 An implementation MUST NOT generate them and may accept or reject 5049 them as it sees fit. Some older PGP versions generated V2 PKESK 5050 packets (Tag 1) as well. An implementation may accept or reject 5051 V2 PKESK packets as it sees fit, and MUST NOT generate them. 5053 o PGP 2.6.x will not accept key-material packets with versions 5054 greater than 3. 5056 o There are many ways possible for two keys to have the same key 5057 material, but different fingerprints (and thus Key IDs). Perhaps 5058 the most interesting is an RSA key that has been "upgraded" to V4 5059 format, but since a V4 fingerprint is constructed by hashing the 5060 key creation time along with other things, two V4 keys created at 5061 different times, yet with the same key material will have 5062 different fingerprints. 5064 o If an implementation is using zlib to interoperate with PGP 2.x, 5065 then the "windowBits" parameter should be set to -13. 5067 o The 0x19 back signatures were not required for signing subkeys 5068 until relatively recently. Consequently, there may be keys in the 5069 wild that do not have these back signatures. Implementing 5070 software may handle these keys as it sees fit. 5072 o OpenPGP does not put limits on the size of public keys. However, 5073 larger keys are not necessarily better keys. Larger keys take 5074 more computation time to use, and this can quickly become 5075 impractical. Different OpenPGP implementations may also use 5076 different upper bounds for public key sizes, and so care should be 5077 taken when choosing sizes to maintain interoperability. As of 5078 2007 most implementations have an upper bound of 4096 bits. 5080 o ASCII armor is an optional feature of OpenPGP. The OpenPGP 5081 working group strives for a minimal set of mandatory-to-implement 5082 features, and since there could be useful implementations that 5083 only use binary object formats, this is not a "MUST" feature for 5084 an implementation. For example, an implementation that is using 5085 OpenPGP as a mechanism for file signatures may find ASCII armor 5086 unnecessary. OpenPGP permits an implementation to declare what 5087 features it does and does not support, but ASCII armor is not one 5088 of these. Since most implementations allow binary and armored 5089 objects to be used indiscriminately, an implementation that does 5090 not implement ASCII armor may find itself with compatibility 5091 issues with general-purpose implementations. Moreover, 5092 implementations of OpenPGP-MIME [RFC3156] already have a 5093 requirement for ASCII armor so those implementations will 5094 necessarily have support. 5096 o The OCB mode is patented and a debate is still underway on whether 5097 it can be included in RFC4880bis or needs to be moved to a 5098 separate document. For the sole purpose of experimenting with the 5099 Preferred AEAD Algorithms signature subpacket it is has been 5100 included in this I-D. 5102 18. References 5104 18.1. Normative References 5106 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 5107 November 2001, 5108 . 5111 [BLOWFISH] 5112 Schneier, B., "Description of a New Variable-Length Key, 5113 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 5114 Cambridge Security Workshop Proceedings, Springer-Verlag, 5115 1994, pp191-204, December 1993, 5116 . 5118 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 5119 . 5121 [EAX] Bellare, M., Rogaway, P., and D. Wagner, "A Conventional 5122 Authenticated-Encryption Mode", April 2003. 5124 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 5125 Scheme Based on Discrete Logarithms,", IEEE Transactions 5126 on Information Theory v. IT-31, n. 4, 1985, pp. 469-472, . 5128 [FIPS180] National Institute of Standards and Technology, U.S. 5129 Department of Commerce, "Secure Hash Standard (SHS), FIPS 5130 180-4", August 2015, 5131 . 5133 [FIPS186] National Institute of Standards and Technology, U.S. 5134 Department of Commerce, "Digital Signature Standard (DSS), 5135 FIPS 186-4", July 2013, 5136 . 5138 [FIPS202] National Institute of Standards and Technology, U.S. 5139 Department of Commerce, "SHA-3 Standard: Permutation-Based 5140 Hash and Extendable-Output Functions, FIPS 202", August 5141 2015, . 5143 [HAC] Menezes, A., Oorschot, P., and S. Vanstone, "Handbook of 5144 Applied Cryptography", 1996. 5146 [I-D.irtf-cfrg-eddsa] 5147 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 5148 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-02 5149 (work in progress), January 2016. 5151 [IDEA] Lai, X., "On the design and security of block ciphers", 5152 ETH Series in Information Processing, J.L. Massey 5153 (editor), Vol. 1, Hartung-Gorre Verlag Konstanz, 5154 Technische Hochschule (Zurich), 1992. 5156 [ISO10646] 5157 International Organization for Standardization, 5158 "Information Technology - Universal Multiple-octet coded 5159 Character Set (UCS) - Part 1: Architecture and Basic 5160 Multilingual Plane", ISO Standard 10646-1, May 1993. 5162 [JFIF] Eric Hamilton, C-Cube Microsystems, Milpitas, CA, "JPEG 5163 File Interchange Format (Version 1.02).", September 1996. 5165 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 5166 Cryptography Standard", March 1999. 5168 [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format 5169 Specification version 3.3", RFC 1950, May 1996. 5171 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 5172 version 1.3", RFC 1951, May 1996. 5174 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5175 Extensions (MIME) Part One: Format of Internet Message 5176 Bodies", RFC 2045, November 1996. 5178 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5179 Requirement Levels", BCP 14, RFC 2119, March 1997. 5181 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 5182 May 1997. 5184 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an 5185 IANA Considerations Section in RFCs", BCP 26, RFC 2434, 5186 October 1998. 5188 [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, April 5189 2001. 5191 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 5192 "MIME Security with OpenPGP", RFC 3156, August 2001. 5194 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 5195 (AES) Key Wrap Algorithm", RFC 3394, September 2002. 5197 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 5198 Standards (PKCS) #1: RSA Cryptography Specifications 5199 Version 2.1", RFC 3447, February 2003. 5201 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5202 10646", STD 63, RFC 3629, November 2003. 5204 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 5205 the Camellia Encryption Algorithm", RFC 3713, April 2004. 5207 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 5208 Requirements for Security", BCP 106, RFC 4086, June 2005. 5210 [RFC5639] Lochter, M. and J. Merkle, "Elliptic Curve Cryptography 5211 (ECC) Brainpool Standard Curves and Curve Generation", RFC 5212 5639, DOI 10.17487/RFC5639, March 2010, 5213 . 5215 [RFC5870] Mayrhofer, A. and C. Spanring, "A Uniform Resource 5216 Identifier for Geographic Locations ('geo' URI)", RFC 5217 5870, DOI 10.17487/RFC5870, June 2010, 5218 . 5220 [RFC7253] Krovetz, T. and P. Rogaway, "The OCB Authenticated- 5221 Encryption Algorithm", RFC 7253, DOI 10.17487/RFC7253, May 5222 2014, . 5224 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 5225 for Security", RFC 7748, DOI 10.17487/RFC7748, January 5226 2016, . 5228 [SCHNEIER] 5229 Schneier, B., "Applied Cryptography Second Edition: 5230 protocols, algorithms, and source code in C", 1996. 5232 [SP800-56A] 5233 Barker, E., Johnson, D., and M. Smid, "Recommendation for 5234 Pair-Wise Key Establishment Schemes Using Discrete 5235 Logarithm Cryptography", NIST Special Publication 800-56A 5236 Revision 1, March 2007. 5238 [SuiteB] National Security Agency, "NSA Suite B Cryptography", 5239 March 2010, 5240 . 5242 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 5243 C., and N. Ferguson, "The Twofish Encryption Algorithm", 5244 1999. 5246 18.2. Informative References 5248 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 5249 Chapter VI. Elliptic Curves, ISBN: 0-387-96576-9, 5250 Springer-Verlag", 1997. 5252 [RFC1423] Balenson, D., "Privacy Enhancement for Internet Electronic 5253 Mail: Part III: Algorithms, Modes, and Identifiers", RFC 5254 1423, February 1993. 5256 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5257 Exchange Formats", RFC 1991, August 1996. 5259 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5260 "OpenPGP Message Format", RFC 2440, November 1998. 5262 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5263 Curve Cryptography Algorithms", RFC 6090, February 2011. 5265 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5266 Elliptic Curve Cryptography", September 2000. 5268 [SP800-57] 5269 NIST, "Recommendation on Key Management", NIST Special 5270 Publication 800-57, March 2007, 5271 . 5274 Appendix A. Test vectors 5276 To help implementing this specification a non-normative example for 5277 the EdDSA algorithm is given. 5279 A.1. Sample EdDSA key 5281 The secret key used for this example is: 5283 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 5285 Note that this is the raw secret key used as input to the EdDSA 5286 signing operation. The key was created on 2014-08-19 14:28:27 and 5287 thus the fingerprint of the OpenPGP key is: 5289 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 5291 The algorithm specific input parameters without the MPI length 5292 headers are: 5294 oid: 2b06010401da470f01 5296 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 5298 The entire public key packet is thus: 5300 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 5301 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 5302 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 5303 43 ee 3b 24 06 5305 A.2. Sample EdDSA signature 5307 The signature is created using the sample key over the input data 5308 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 5309 function is: 5311 m: 4f70656e504750040016080006050255f95f9504ff0000000c 5313 Using the SHA2-256 hash algorithm yields the digest: 5315 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 5316 Which is fed into the EdDSA signature function and yields this 5317 signature: 5319 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 5321 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 5323 The entire signature packet is thus: 5325 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 5326 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 5327 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 5328 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 5329 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 5330 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 5332 A.3. Sample AEAD-EAX encryption and decryption 5334 Encryption is performed with the string 'Hello, world!' and password 5335 'password', using AES-128 with AEAD-EAX encryption. 5337 A.3.1. Sample Parameters 5339 S2K: 5341 type 3 5343 Iterations: 5345 524288 (144), SHA-256 5347 Salt: 5349 cd5a9f70fbe0bc65 5351 A.3.2. Sample symmetric-key encrypted session key packet (v5) 5353 Packet header: 5355 c3 3e 5357 Version, algorithms, S2K fields: 5359 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5361 AEAD IV: 5363 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5365 AEAD encrypted CEK: 5367 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 5369 Authentication tag: 5371 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 5373 A.3.3. Starting AEAD-EAX decryption of CEK 5375 The derived key is: 5377 b2 55 69 b9 54 32 45 66 45 27 c4 97 6e 7a 5d 6e 5379 Authenticated Data: 5381 c3 05 07 01 5383 Nonce: 5385 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5387 Decrypted CEK: 5389 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d 5391 A.3.4. Sample AEAD encrypted data packet 5393 Packet header: 5395 d4 4a 5397 Version, EAX, AES-128, Chunk bits (14): 5399 01 07 01 0e 5401 IV: 5403 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5405 AEAD-EAX Encrypted data chunk #0: 5407 5d c1 1a 81 dc 0c b8 a2 f6 f3 d9 00 16 38 4a 56 5408 fc 82 1a e1 1a e8 5410 Chunk #0 authentication tag: 5412 db cb 49 86 26 55 de a8 8d 06 a8 14 86 80 1b 0f 5414 Final (zero-size chunk #1) authentication tag: 5416 f3 87 bd 2e ab 01 3d e1 25 95 86 90 6e ab 24 76 5418 A.3.5. Decryption of data 5420 Starting AEAD-EAX decryption of data, using the CEK. 5422 Chunk #0: 5424 Authenticated data: 5426 d4 01 07 01 0e 00 00 00 00 00 00 00 00 5428 Nonce: 5430 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5432 Decrypted chunk #0. 5434 Literal data packet with the string contents 'Hello, world!'. 5436 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 5437 6f 72 6c 64 21 0a 5439 Authenticating final tag: 5441 Authenticated data: 5443 d4 01 07 01 0e 00 00 00 00 00 00 00 01 00 00 00 5444 00 00 00 00 16 5446 Nonce: 5448 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 11 5450 A.3.6. Complete AEAD-EAX encrypted packet sequence 5452 Symmetric-key encrypted session key packet (v5): 5454 c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5455 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5456 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 5457 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 5459 AEAD encrypted data packet: 5461 d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f 5462 ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3 5463 d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86 5464 26 55 de a8 8d 06 a8 14 86 80 1b 0f f3 87 bd 2e 5465 ab 01 3d e1 25 95 86 90 6e ab 24 76 5467 A.4. Sample AEAD-OCB encryption and decryption 5469 Encryption is performed with the string 'Hello, world!' and password 5470 'password', using AES-128 with AEAD-OCB encryption. 5472 A.4.1. Sample Parameters 5474 S2K: 5476 type 3 5478 Iterations: 5480 524288 (144), SHA-256 5482 Salt: 5484 9f0b7da3e5ea6477 5486 A.4.2. Sample symmetric-key encrypted session key packet (v5) 5488 Packet header: 5490 c3 3d 5492 Version, algorithms, S2K fields: 5494 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 5496 AEAD IV: 5498 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 5500 AEAD encrypted CEK: 5502 67 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da 5504 Authentication tag: 5506 c5 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 5508 A.4.3. Starting AEAD-EAX decryption of CEK 5510 The derived key is: 5512 eb 9d a7 8a 9d 5d f8 0e c7 02 05 96 39 9b 65 08 5514 Authenticated Data: 5516 c3 05 07 02 5518 Nonce: 5520 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 5522 Decrypted CEK: 5524 d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 5526 A.4.4. Sample AEAD encrypted data packet 5528 Packet header: 5530 d4 49 5532 Version, EAX, AES-128, Chunk bits (14): 5534 01 07 02 0e 5536 IV: 5538 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 5540 AEAD-EAX Encrypted data chunk #0: 5542 7b 0f 77 01 19 66 11 a1 54 ba 9c 25 74 cd 05 62 5543 84 a8 ef 68 03 5c 5545 Chunk #0 authentication tag: 5547 62 3d 93 cc 70 8a 43 21 1b b6 ea f2 b2 7f 7c 18 5549 Final (zero-size chunk #1) authentication tag: 5551 d5 71 bc d8 3b 20 ad d3 a0 8b 73 af 15 b9 a0 98 5553 A.4.5. Decryption of data 5555 Starting AEAD-OCB decryption of data, using the CEK. 5557 Chunk #0: 5559 Authenticated data: 5561 r4 01 07 02 0e 00 00 00 00 00 00 00 00 5563 Nonce: 5565 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 5567 Decrypted chunk #0. 5569 Literal data packet with the string contents 'Hello, world!'. 5571 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 5572 6f 72 6c 64 21 0a 5574 Authenticating final tag: 5576 Authenticated data: 5578 d4 01 07 02 0e 00 00 00 00 00 00 00 01 00 00 00 5579 00 00 00 00 16 5581 Nonce: 5583 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 57 5585 A.4.6. Complete AEAD-OCB encrypted packet sequence 5587 Symmetric-key encrypted session key packet (v5): 5589 c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 5590 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67 5591 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5 5592 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 5594 AEAD encrypted data packet: 5596 d4 49 01 07 02 0e 5e d2 bc 1e 47 0a be 8f 1d 64 5597 4c 7a 6c 8a 56 7b 0f 77 01 19 66 11 a1 54 ba 9c 5598 25 74 cd 05 62 84 a8 ef 68 03 5c 62 3d 93 cc 70 5599 8a 43 21 1b b6 ea f2 b2 7f 7c 18 d5 71 bc d8 3b 5600 20 ad d3 a0 8b 73 af 15 b9 a0 98 5602 Appendix B. ECC Point compression flag bytes 5604 This specification introduces the new flag byte 0x40 to indicate the 5605 point compression format. The value has been chosen so that the high 5606 bit is not cleared and thus to avoid accidental sign extension. Two 5607 other values might also be interesting for other ECC specifications: 5609 Flag Description 5610 ---- ----------- 5611 0x04 Standard flag for uncompressed format 5612 0x40 Native point format of the curve follows 5613 0x41 Only X coordinate follows. 5614 0x42 Only Y coordinate follows. 5616 Appendix C. Changes since RFC-4880 5618 o Applied errata 2270, 2271, 2242, 3298. 5620 o Added Camellia cipher from RFC 5581. 5622 o Incorporated RFC 6637 (ECC for OpenPGP) 5624 o Added draft-atkins-openpgp-device-certificates 5626 o Added draft-koch-eddsa-for-openpgp-04 5628 o Added Issuer Fingerprint signature subpacket. 5630 o Added a v5 key and fingerprint format. 5632 o Added OIDs for brainpool curves and Curve25519. 5634 o Marked SHA2-256 as MUST implement. 5636 o Marked Curve25519 and Ed25519 as SHOULD implement. 5638 o Marked SHA-1 as SHOULD NOT be used to create messages. 5640 o Marked MD5 as SHOULD NOT implement. 5642 o Changed v5 key fingerprint format to full 32 octets. 5644 o Added Literal Data Packet format octet 'm'. 5646 o Added Feature Flag for v5 key support. 5648 o Added AEAD Encrypted Data Packet. 5650 o Removed notes on extending the MDC packet. 5652 o Added v5 Symmetric-Key Encrypted Session Key packet. 5654 o Added AEAD encryption of secret keys. 5656 o Added test vectors for AEAD. 5658 o Added the Additional Encryption Subkey key flag. 5660 o Deprecated the Symmetrically Encrypted Data Packet. 5662 o Suggest limitation of the AEAD chunksize to 128 MiB. 5664 { Informational rfcs: [RFC1423] } 5666 Appendix D. The principal authors of RFC-4880 are as follows: 5668 Jon Callas 5669 EMail: jon@callas.org 5671 Lutz Donnerhacke 5672 EMail: lutz@iks-jena.de 5674 Hal Finney 5676 David Shaw 5677 EMail: dshaw@jabberwocky.com 5679 Rodney Thayer 5680 EMail: rodney@canola-jones.com 5682 Author's Address 5684 Werner Koch 5686 Email: wk@gnupg.org