idnits 2.17.00 (12 Aug 2021) /tmp/idnits64304/draft-ietf-openpgp-crypto-refresh-02.txt: -(2946): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2948): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2950): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding 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: ---------------------------------------------------------------------------- == There are 8 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document obsoletes RFC6637, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC4880, but the abstract doesn't seem to directly say this. It does mention RFC4880 though, so this could be OK. -- The draft header indicates that this document obsoletes RFC5581, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (22 February 2021) is 453 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 414 -- Looks like a reference, but probably isn't: '1' on line 4343 -- Looks like a reference, but probably isn't: '2' on line 414 -- Looks like a reference, but probably isn't: '3' on line 4352 == Missing Reference: 'Optional' is mentioned on line 2189, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3741, but not defined == Missing Reference: 'BS' is mentioned on line 4343, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. 'BLOWFISH' -- Possible downref: Non-RFC (?) normative reference: ref. 'BZ2' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS202' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' -- Possible downref: Non-RFC (?) normative reference: ref. 'IDEA' -- Possible downref: Non-RFC (?) normative reference: ref. 'ISO10646' -- Possible downref: Non-RFC (?) normative reference: ref. 'JFIF' -- Possible downref: Non-RFC (?) normative reference: ref. 'PKCS5' ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Downref: Normative reference to an Informational RFC: RFC 1951 ** Downref: Normative reference to an Informational RFC: RFC 2144 ** Obsolete normative reference: RFC 2822 (Obsoleted by RFC 5322) ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Downref: Normative reference to an Informational RFC: RFC 3713 ** Downref: Normative reference to an Informational RFC: RFC 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: 8 errors (**), 0 flaws (~~), 5 warnings (==), 27 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group W. Koch, Ed. 3 Internet-Draft GnuPG e.V. 4 Obsoletes: 4880, 5581, 6637 (if approved) P. Wouters, Ed. 5 Intended status: Standards Track 22 February 2021 6 Expires: 26 August 2021 8 OpenPGP Message Format 9 draft-ietf-openpgp-crypto-refresh-02 11 Abstract 13 { Work in progress to update the OpenPGP specification from RFC4880 } 15 This document specifies the message formats used in OpenPGP. OpenPGP 16 provides encryption with public-key or symmetric cryptographic 17 algorithms, digital signatures, compression and key management. 19 This document is maintained in order to publish all necessary 20 information needed to develop interoperable applications based on the 21 OpenPGP format. It is not a step-by-step cookbook for writing an 22 application. It describes only the format and methods needed to 23 read, check, generate, and write conforming packets crossing any 24 network. It does not deal with storage and implementation questions. 25 It does, however, discuss implementation issues necessary to avoid 26 security flaws. 28 Status of This Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at https://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on 26 August 2021. 45 Copyright Notice 47 Copyright (c) 2021 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 52 license-info) in effect on the date of publication of this document. 53 Please review these documents carefully, as they describe your rights 54 and restrictions with respect to this document. Code Components 55 extracted from this document must include Simplified BSD License text 56 as described in Section 4.e of the Trust Legal Provisions and are 57 provided without warranty as described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 5 62 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 6 63 2. General functions . . . . . . . . . . . . . . . . . . . . . . 7 64 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 7 65 2.2. Authentication via Digital Signature . . . . . . . . . . 8 66 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 8 67 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 9 68 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 9 69 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 9 70 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 9 71 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 9 72 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 10 73 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 10 74 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 10 75 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 11 76 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 11 77 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 11 78 3.7.1.1. Simple S2K . . . . . . . . . . . . . . . . . . . 11 79 3.7.1.2. Salted S2K . . . . . . . . . . . . . . . . . . . 12 80 3.7.1.3. Iterated and Salted S2K . . . . . . . . . . . . . 12 81 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 13 82 3.7.2.1. Secret-Key Encryption . . . . . . . . . . . . . . 13 83 3.7.2.2. Symmetric-Key Message Encryption . . . . . . . . 14 84 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 14 85 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 14 86 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 14 87 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 15 88 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 16 89 4.2.2.1. One-Octet Lengths . . . . . . . . . . . . . . . . 16 90 4.2.2.2. Two-Octet Lengths . . . . . . . . . . . . . . . . 16 91 4.2.2.3. Five-Octet Lengths . . . . . . . . . . . . . . . 16 92 4.2.2.4. Partial Body Lengths . . . . . . . . . . . . . . 17 93 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 17 94 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 18 95 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 19 96 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 20 97 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 21 98 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 21 99 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 24 100 5.2.3. Version 4 Signature Packet Format . . . . . . . . . . 27 101 5.2.3.1. Signature Subpacket Specification . . . . . . . . 29 102 5.2.3.2. Signature Subpacket Types . . . . . . . . . . . . 31 103 5.2.3.3. Notes on Self-Signatures . . . . . . . . . . . . 32 104 5.2.3.4. Signature Creation Time . . . . . . . . . . . . . 33 105 5.2.3.5. Issuer . . . . . . . . . . . . . . . . . . . . . 33 106 5.2.3.6. Key Expiration Time . . . . . . . . . . . . . . . 33 107 5.2.3.7. Preferred Symmetric Algorithms . . . . . . . . . 33 108 5.2.3.8. Preferred Hash Algorithms . . . . . . . . . . . . 33 109 5.2.3.9. Preferred Compression Algorithms . . . . . . . . 34 110 5.2.3.10. Signature Expiration Time . . . . . . . . . . . . 34 111 5.2.3.11. Exportable Certification . . . . . . . . . . . . 34 112 5.2.3.12. Revocable . . . . . . . . . . . . . . . . . . . . 35 113 5.2.3.13. Trust Signature . . . . . . . . . . . . . . . . . 35 114 5.2.3.14. Regular Expression . . . . . . . . . . . . . . . 35 115 5.2.3.15. Revocation Key . . . . . . . . . . . . . . . . . 36 116 5.2.3.16. Notation Data . . . . . . . . . . . . . . . . . . 36 117 5.2.3.17. Key Server Preferences . . . . . . . . . . . . . 37 118 5.2.3.18. Preferred Key Server . . . . . . . . . . . . . . 38 119 5.2.3.19. Primary User ID . . . . . . . . . . . . . . . . . 38 120 5.2.3.20. Policy URI . . . . . . . . . . . . . . . . . . . 38 121 5.2.3.21. Key Flags . . . . . . . . . . . . . . . . . . . . 39 122 5.2.3.22. Signer's User ID . . . . . . . . . . . . . . . . 40 123 5.2.3.23. Reason for Revocation . . . . . . . . . . . . . . 40 124 5.2.3.24. Features . . . . . . . . . . . . . . . . . . . . 42 125 5.2.3.25. Signature Target . . . . . . . . . . . . . . . . 42 126 5.2.3.26. Embedded Signature . . . . . . . . . . . . . . . 43 127 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 43 128 5.2.4.1. Subpacket Hints . . . . . . . . . . . . . . . . . 45 129 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 45 130 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 46 131 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 47 132 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 47 133 5.5.1.1. Public-Key Packet (Tag 6) . . . . . . . . . . . . 47 134 5.5.1.2. Public-Subkey Packet (Tag 14) . . . . . . . . . . 47 135 5.5.1.3. Secret-Key Packet (Tag 5) . . . . . . . . . . . . 47 136 5.5.1.4. Secret-Subkey Packet (Tag 7) . . . . . . . . . . 48 137 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 48 138 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 49 139 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 50 140 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 51 141 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 51 142 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 51 143 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 52 144 5.6.5. Algorithm-Specific Part for ECDH Keys . . . . . . . . 52 145 5.7. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 53 146 5.8. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 53 147 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 54 148 5.10. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 55 149 5.11. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 56 150 5.12. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 56 151 5.13. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 56 152 5.13.1. The Image Attribute Subpacket . . . . . . . . . . . 57 153 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 154 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 58 155 5.15. Modification Detection Code Packet (Tag 19) . . . . . . . 61 156 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 61 157 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 62 158 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 63 159 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 65 160 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 68 161 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 68 162 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 69 163 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 69 164 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 70 165 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 71 166 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 71 167 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 72 168 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 73 169 9.3. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 73 170 9.4. Compression Algorithms . . . . . . . . . . . . . . . . . 74 171 9.5. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 75 172 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 76 173 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 76 174 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 76 175 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 76 176 10.2.1.1. Image Format Subpacket Types . . . . . . . . . . 76 177 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 77 178 10.2.2.1. Signature Notation Data Subpackets . . . . . . . 77 179 10.2.2.2. Signature Notation Data Subpacket Notation 180 Flags . . . . . . . . . . . . . . . . . . . . . . . 77 181 10.2.2.3. Key Server Preference Extensions . . . . . . . . 77 182 10.2.2.4. Key Flags Extensions . . . . . . . . . . . . . . 78 183 10.2.2.5. Reason for Revocation Extensions . . . . . . . . 78 184 10.2.2.6. Implementation Features . . . . . . . . . . . . 78 185 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 78 186 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 79 187 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 79 188 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 79 189 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 79 190 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 80 191 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 80 192 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 80 193 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 82 194 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 82 195 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 83 196 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 83 197 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 83 198 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 84 199 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 85 200 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 85 201 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 86 202 13.3. Key Derivation Function . . . . . . . . . . . . . . . . 86 203 13.4. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 87 204 14. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 90 205 14.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 90 206 14.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 90 207 14.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 91 208 14.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 91 209 14.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 92 210 14.3. Other Algorithm Preferences . . . . . . . . . . . . . . 93 211 14.3.1. Compression Preferences . . . . . . . . . . . . . . 93 212 14.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 94 213 14.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 94 214 14.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 94 215 14.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 95 216 14.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 95 217 14.8. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 95 218 14.9. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 96 219 14.10. Private or Experimental Parameters . . . . . . . . . . . 97 220 14.11. Extension of the MDC System . . . . . . . . . . . . . . 97 221 14.12. Meta-Considerations for Expansion . . . . . . . . . . . 98 222 15. Security Considerations . . . . . . . . . . . . . . . . . . . 99 223 16. Compatibility Profiles . . . . . . . . . . . . . . . . . . . 105 224 16.1. OpenPGP ECC Profile . . . . . . . . . . . . . . . . . . 105 225 16.2. Suite-B Profile . . . . . . . . . . . . . . . . . . . . 105 226 16.2.1. Security Strength at 192 Bits . . . . . . . . . . . 106 227 16.2.2. Security Strength at 128 Bits . . . . . . . . . . . 106 228 17. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 106 229 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 107 230 18.1. Normative References . . . . . . . . . . . . . . . . . . 107 231 18.2. Informative References . . . . . . . . . . . . . . . . . 110 232 Appendix A. Document Workflow . . . . . . . . . . . . . . . . . 111 233 Appendix B. ECC Point compression flag bytes . . . . . . . . . . 112 234 Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 112 235 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 112 237 1. Introduction 239 { This is work in progress to update OpenPGP. Editorial notes are 240 enclosed in curly braces. } 241 This document provides information on the message-exchange packet 242 formats used by OpenPGP to provide encryption, decryption, signing, 243 and key management functions. It is a revision of RFC 4880, "OpenPGP 244 Message Format", which is a revision of RFC 2440, which itself 245 replaces RFC 1991, "PGP Message Exchange Formats" [RFC1991] [RFC2440] 246 [RFC4880]. 248 This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia 249 cipher) and RFC 6637 (ECC for OpenPGP). 251 1.1. Terms 253 * OpenPGP - This is a term for security software that uses PGP 5 as 254 a basis, formalized in this document. 256 * PGP - Pretty Good Privacy. PGP is a family of software systems 257 developed by Philip R. Zimmermann from which OpenPGP is based. 259 * PGP 2 - This version of PGP has many variants; where necessary a 260 more detailed version number is used here. PGP 2 uses only RSA, 261 MD5, and IDEA for its cryptographic transforms. An informational 262 RFC, RFC 1991, was written describing this version of PGP. 264 * PGP 5 - This version of PGP is formerly known as "PGP 3" in the 265 community. It has new formats and corrects a number of problems 266 in the PGP 2 design. It is referred to here as PGP 5 because that 267 software was the first release of the "PGP 3" code base. 269 * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 270 implementation that avoids all encumbered algorithms. 271 Consequently, early versions of GnuPG did not include RSA public 272 keys. 274 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 275 Corporation and are used with permission. The term "OpenPGP" refers 276 to the protocol described in this and related documents. 278 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 279 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 280 document are to be interpreted as described in [RFC2119]. 282 The key words "PRIVATE USE", "SPECIFICATION REQUIRED", and "RFC 283 REQUIRED" that appear in this document when used to describe 284 namespace allocation are to be interpreted as described in [RFC8126]. 286 2. General functions 288 OpenPGP provides data integrity services for messages and data files 289 by using these core technologies: 291 * digital signatures 293 * encryption 295 * compression 297 * Radix-64 conversion 299 In addition, OpenPGP provides key management and certificate 300 services, but many of these are beyond the scope of this document. 302 2.1. Confidentiality via Encryption 304 OpenPGP combines symmetric-key encryption and public-key encryption 305 to provide confidentiality. When made confidential, first the object 306 is encrypted using a symmetric encryption algorithm. Each symmetric 307 key is used only once, for a single object. A new "session key" is 308 generated as a random number for each object (sometimes referred to 309 as a session). Since it is used only once, the session key is bound 310 to the message and transmitted with it. To protect the key, it is 311 encrypted with the receiver's public key. The sequence is as 312 follows: 314 1. The sender creates a message. 316 2. The sending OpenPGP generates a random number to be used as a 317 session key for this message only. 319 3. The session key is encrypted using each recipient's public key. 320 These "encrypted session keys" start the message. 322 4. The sending OpenPGP encrypts the message using the session key, 323 which forms the remainder of the message. Note that the message 324 is also usually compressed. 326 5. The receiving OpenPGP decrypts the session key using the 327 recipient's private key. 329 6. The receiving OpenPGP decrypts the message using the session key. 330 If the message was compressed, it will be decompressed. 332 With symmetric-key encryption, an object may be encrypted with a 333 symmetric key derived from a passphrase (or other shared secret), or 334 a two-stage mechanism similar to the public-key method described 335 above in which a session key is itself encrypted with a symmetric 336 algorithm keyed from a shared secret. 338 Both digital signature and confidentiality services may be applied to 339 the same message. First, a signature is generated for the message 340 and attached to the message. Then the message plus signature is 341 encrypted using a symmetric session key. Finally, the session key is 342 encrypted using public-key encryption and prefixed to the encrypted 343 block. 345 2.2. Authentication via Digital Signature 347 The digital signature uses a hash code or message digest algorithm, 348 and a public-key signature algorithm. The sequence is as follows: 350 1. The sender creates a message. 352 2. The sending software generates a hash code of the message. 354 3. The sending software generates a signature from the hash code 355 using the sender's private key. 357 4. The binary signature is attached to the message. 359 5. The receiving software keeps a copy of the message signature. 361 6. The receiving software generates a new hash code for the received 362 message and verifies it using the message's signature. If the 363 verification is successful, the message is accepted as authentic. 365 2.3. Compression 367 OpenPGP implementations SHOULD compress the message after applying 368 the signature but before encryption. 370 If an implementation does not implement compression, its authors 371 should be aware that most OpenPGP messages in the world are 372 compressed. Thus, it may even be wise for a space-constrained 373 implementation to implement decompression, but not compression. 375 Furthermore, compression has the added side effect that some types of 376 attacks can be thwarted by the fact that slightly altered, compressed 377 data rarely uncompresses without severe errors. This is hardly 378 rigorous, but it is operationally useful. These attacks can be 379 rigorously prevented by implementing and using Modification Detection 380 Codes as described in sections following. 382 2.4. Conversion to Radix-64 384 OpenPGP's underlying native representation for encrypted messages, 385 signature certificates, and keys is a stream of arbitrary octets. 386 Some systems only permit the use of blocks consisting of seven-bit, 387 printable text. For transporting OpenPGP's native raw binary octets 388 through channels that are not safe to raw binary data, a printable 389 encoding of these binary octets is needed. OpenPGP provides the 390 service of converting the raw 8-bit binary octet stream to a stream 391 of printable ASCII characters, called Radix-64 encoding or ASCII 392 Armor. 394 Implementations SHOULD provide Radix-64 conversions. 396 2.5. Signature-Only Applications 398 OpenPGP is designed for applications that use both encryption and 399 signatures, but there are a number of problems that are solved by a 400 signature-only implementation. Although this specification requires 401 both encryption and signatures, it is reasonable for there to be 402 subset implementations that are non-conformant only in that they omit 403 encryption. 405 3. Data Element Formats 407 This section describes the data elements used by OpenPGP. 409 3.1. Scalar Numbers 411 Scalar numbers are unsigned and are always stored in big-endian 412 format. Using n[k] to refer to the kth octet being interpreted, the 413 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 414 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 415 n[3]). 417 3.2. Multiprecision Integers 419 Multiprecision integers (also called MPIs) are unsigned integers used 420 to hold large integers such as the ones used in cryptographic 421 calculations. 423 An MPI consists of two pieces: a two-octet scalar that is the length 424 of the MPI in bits followed by a string of octets that contain the 425 actual integer. 427 These octets form a big-endian number; a big-endian number can be 428 made into an MPI by prefixing it with the appropriate length. 430 Examples: 432 (all numbers are in hexadecimal) 434 The string of octets [00 01 01] forms an MPI with the value 1. The 435 string [00 09 01 FF] forms an MPI with the value of 511. 437 Additional rules: 439 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 441 The length field of an MPI describes the length starting from its 442 most significant non-zero bit. Thus, the MPI [00 02 01] is not 443 formed correctly. It should be [00 01 01]. 445 Unused bits of an MPI MUST be zero. 447 Also note that when an MPI is encrypted, the length refers to the 448 plaintext MPI. It may be ill-formed in its ciphertext. 450 3.3. Key IDs 452 A Key ID is an eight-octet scalar that identifies a key. 453 Implementations SHOULD NOT assume that Key IDs are unique. 454 Section 12 describes how Key IDs are formed. 456 3.4. Text 458 Unless otherwise specified, the character set for text is the UTF-8 459 [RFC3629] encoding of Unicode [ISO10646]. 461 3.5. Time Fields 463 A time field is an unsigned four-octet number containing the number 464 of seconds elapsed since midnight, 1 January 1970 UTC. 466 3.6. Keyrings 468 A keyring is a collection of one or more keys in a file or database. 469 Traditionally, a keyring is simply a sequential list of keys, but may 470 be any suitable database. It is beyond the scope of this standard to 471 discuss the details of keyrings or other databases. 473 3.7. String-to-Key (S2K) Specifiers 475 String-to-key (S2K) specifiers are used to convert passphrase strings 476 into symmetric-key encryption/decryption keys. They are used in two 477 places, currently: to encrypt the secret part of private keys in the 478 private keyring, and to convert passphrases to encryption keys for 479 symmetrically encrypted messages. 481 3.7.1. String-to-Key (S2K) Specifier Types 483 There are three types of S2K specifiers currently supported, and some 484 reserved values: 486 +============+==========================+ 487 | ID | S2K Type | 488 +============+==========================+ 489 | 0 | Simple S2K | 490 +------------+--------------------------+ 491 | 1 | Salted S2K | 492 +------------+--------------------------+ 493 | 2 | Reserved value | 494 +------------+--------------------------+ 495 | 3 | Iterated and Salted S2K | 496 +------------+--------------------------+ 497 | 100 to 110 | Private/Experimental S2K | 498 +------------+--------------------------+ 500 Table 1: S2K type registry 502 These are described in the subsections below. 504 3.7.1.1. Simple S2K 506 This directly hashes the string to produce the key data. See below 507 for how this hashing is done. 509 Octet 0: 0x00 510 Octet 1: hash algorithm 512 Simple S2K hashes the passphrase to produce the session key. The 513 manner in which this is done depends on the size of the session key 514 (which will depend on the cipher used) and the size of the hash 515 algorithm's output. If the hash size is greater than the session key 516 size, the high-order (leftmost) octets of the hash are used as the 517 key. 519 If the hash size is less than the key size, multiple instances of the 520 hash context are created -- enough to produce the required key data. 521 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 522 is to say, the first instance has no preloading, the second gets 523 preloaded with 1 octet of zero, the third is preloaded with two 524 octets of zeros, and so forth). 526 As the data is hashed, it is given independently to each hash 527 context. Since the contexts have been initialized differently, they 528 will each produce different hash output. Once the passphrase is 529 hashed, the output data from the multiple hashes is concatenated, 530 first hash leftmost, to produce the key data, with any excess octets 531 on the right discarded. 533 3.7.1.2. Salted S2K 535 This includes a "salt" value in the S2K specifier -- some arbitrary 536 data -- that gets hashed along with the passphrase string, to help 537 prevent dictionary attacks. 539 Octet 0: 0x01 540 Octet 1: hash algorithm 541 Octets 2-9: 8-octet salt value 543 Salted S2K is exactly like Simple S2K, except that the input to the 544 hash function(s) consists of the 8 octets of salt from the S2K 545 specifier, followed by the passphrase. 547 3.7.1.3. Iterated and Salted S2K 549 This includes both a salt and an octet count. The salt is combined 550 with the passphrase and the resulting value is hashed repeatedly. 551 This further increases the amount of work an attacker must do to try 552 dictionary attacks. 554 Octet 0: 0x03 555 Octet 1: hash algorithm 556 Octets 2-9: 8-octet salt value 557 Octet 10: count, a one-octet, coded value 559 The count is coded into a one-octet number using the following 560 formula: 562 #define EXPBIAS 6 563 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 565 The above formula is in C, where "Int32" is a type for a 32-bit 566 integer, and the variable "c" is the coded count, Octet 10. 568 Iterated-Salted S2K hashes the passphrase and salt data multiple 569 times. The total number of octets to be hashed is specified in the 570 encoded count in the S2K specifier. Note that the resulting count 571 value is an octet count of how many octets will be hashed, not an 572 iteration count. 574 Initially, one or more hash contexts are set up as with the other S2K 575 algorithms, depending on how many octets of key data are needed. 576 Then the salt, followed by the passphrase data, is repeatedly hashed 577 until the number of octets specified by the octet count has been 578 hashed. The one exception is that if the octet count is less than 579 the size of the salt plus passphrase, the full salt plus passphrase 580 will be hashed even though that is greater than the octet count. 581 After the hashing is done, the data is unloaded from the hash 582 context(s) as with the other S2K algorithms. 584 3.7.2. String-to-Key Usage 586 Implementations SHOULD use salted or iterated-and-salted S2K 587 specifiers, as simple S2K specifiers are more vulnerable to 588 dictionary attacks. 590 3.7.2.1. Secret-Key Encryption 592 An S2K specifier can be stored in the secret keyring to specify how 593 to convert the passphrase to a key that unlocks the secret data. 594 Older versions of PGP just stored a cipher algorithm octet preceding 595 the secret data or a zero to indicate that the secret data was 596 unencrypted. The MD5 hash function was always used to convert the 597 passphrase to a key for the specified cipher algorithm. 599 For compatibility, when an S2K specifier is used, the special value 600 254 or 255 is stored in the position where the hash algorithm octet 601 would have been in the old data structure. This is then followed 602 immediately by a one-octet algorithm identifier, and then by the S2K 603 specifier as encoded above. 605 Therefore, preceding the secret data there will be one of these 606 possibilities: 608 0: secret data is unencrypted (no passphrase) 609 255 or 254: followed by algorithm octet and S2K specifier 610 Cipher alg: use Simple S2K algorithm using MD5 hash 612 This last possibility, the cipher algorithm number with an implicit 613 use of MD5 and IDEA, is provided for backward compatibility; it MAY 614 be understood, but SHOULD NOT be generated, and is deprecated. 616 These are followed by an Initial Vector of the same length as the 617 block size of the cipher for the decryption of the secret values, if 618 they are encrypted, and then the secret-key values themselves. 620 3.7.2.2. Symmetric-Key Message Encryption 622 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 623 at the front of a message. This is used to allow S2K specifiers to 624 be used for the passphrase conversion or to create messages with a 625 mix of symmetric-key ESKs and public-key ESKs. This allows a message 626 to be decrypted either with a passphrase or a public-key pair. 628 PGP 2 always used IDEA with Simple string-to-key conversion when 629 encrypting a message with a symmetric algorithm. This is deprecated, 630 but MAY be used for backward-compatibility. 632 4. Packet Syntax 634 This section describes the packets used by OpenPGP. 636 4.1. Overview 638 An OpenPGP message is constructed from a number of records that are 639 traditionally called packets. A packet is a chunk of data that has a 640 tag specifying its meaning. An OpenPGP message, keyring, 641 certificate, and so forth consists of a number of packets. Some of 642 those packets may contain other OpenPGP packets (for example, a 643 compressed data packet, when uncompressed, contains OpenPGP packets). 645 Each packet consists of a packet header, followed by the packet body. 646 The packet header is of variable length. 648 4.2. Packet Headers 650 The first octet of the packet header is called the "Packet Tag". It 651 determines the format of the header and denotes the packet contents. 652 The remainder of the packet header is the length of the packet. 654 Note that the most significant bit is the leftmost bit, called bit 7. 655 A mask for this bit is 0x80 in hexadecimal. 657 ┌───────────────┐ 658 PTag │7 6 5 4 3 2 1 0│ 659 └───────────────┘ 660 Bit 7 -- Always one 661 Bit 6 -- New packet format if set 663 PGP 2.6.x only uses old format packets. Thus, software that 664 interoperates with those versions of PGP must only use old format 665 packets. If interoperability is not an issue, the new packet format 666 is RECOMMENDED. Note that old format packets have four bits of 667 packet tags, and new format packets have six; some features cannot be 668 used and still be backward-compatible. 670 Also note that packets with a tag greater than or equal to 16 MUST 671 use new format packets. The old format packets can only express tags 672 less than or equal to 15. 674 Old format packets contain: 676 Bits 5-2 -- packet tag 677 Bits 1-0 -- length-type 679 New format packets contain: 681 Bits 5-0 -- packet tag 683 4.2.1. Old Format Packet Lengths 685 The meaning of the length-type in old format packets is: 687 0 The packet has a one-octet length. The header is 2 octets long. 689 1 The packet has a two-octet length. The header is 3 octets long. 691 2 The packet has a four-octet length. The header is 5 octets long. 693 3 The packet is of indeterminate length. The header is 1 octet 694 long, and the implementation must determine how long the packet 695 is. If the packet is in a file, this means that the packet 696 extends until the end of the file. In general, an implementation 697 SHOULD NOT use indeterminate-length packets except where the end 698 of the data will be clear from the context, and even then it is 699 better to use a definite length, or a new format header. The new 700 format headers described below have a mechanism for precisely 701 encoding data of indeterminate length. 703 4.2.2. New Format Packet Lengths 705 New format packets have four possible ways of encoding length: 707 1. A one-octet Body Length header encodes packet lengths of up to 708 191 octets. 710 2. A two-octet Body Length header encodes packet lengths of 192 to 711 8383 octets. 713 3. A five-octet Body Length header encodes packet lengths of up to 714 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 715 encodes a four-octet scalar number.) 717 4. When the length of the packet body is not known in advance by the 718 issuer, Partial Body Length headers encode a packet of 719 indeterminate length, effectively making it a stream. 721 4.2.2.1. One-Octet Lengths 723 A one-octet Body Length header encodes a length of 0 to 191 octets. 724 This type of length header is recognized because the one octet value 725 is less than 192. The body length is equal to: 727 bodyLen = 1st_octet; 729 4.2.2.2. Two-Octet Lengths 731 A two-octet Body Length header encodes a length of 192 to 8383 732 octets. It is recognized because its first octet is in the range 192 733 to 223. The body length is equal to: 735 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 737 4.2.2.3. Five-Octet Lengths 739 A five-octet Body Length header consists of a single octet holding 740 the value 255, followed by a four-octet scalar. The body length is 741 equal to: 743 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 744 (4th_octet << 8) | 5th_octet 746 This basic set of one, two, and five-octet lengths is also used 747 internally to some packets. 749 4.2.2.4. Partial Body Lengths 751 A Partial Body Length header is one octet long and encodes the length 752 of only part of the data packet. This length is a power of 2, from 1 753 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 754 octet value that is greater than or equal to 224, and less than 255. 755 The Partial Body Length is equal to: 757 partialBodyLen = 1 << (1st_octet & 0x1F); 759 Each Partial Body Length header is followed by a portion of the 760 packet body data. The Partial Body Length header specifies this 761 portion's length. Another length header (one octet, two-octet, five- 762 octet, or partial) follows that portion. The last length header in 763 the packet MUST NOT be a Partial Body Length header. Partial Body 764 Length headers may only be used for the non-final parts of the 765 packet. 767 Note also that the last Body Length header can be a zero-length 768 header. 770 An implementation MAY use Partial Body Lengths for data packets, be 771 they literal, compressed, or encrypted. The first partial length 772 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 773 used for any other packet types. 775 4.2.3. Packet Length Examples 777 These examples show ways that new format packets might encode the 778 packet lengths. 780 A packet with length 100 may have its length encoded in one octet: 781 0x64. This is followed by 100 octets of data. 783 A packet with length 1723 may have its length encoded in two octets: 784 0xC5, 0xFB. This header is followed by the 1723 octets of data. 786 A packet with length 100000 may have its length encoded in five 787 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 789 It might also be encoded in the following octet stream: 0xEF, first 790 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 791 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 792 octets of data. This is just one possible encoding, and many 793 variations are possible on the size of the Partial Body Length 794 headers, as long as a regular Body Length header encodes the last 795 portion of the data. 797 Please note that in all of these explanations, the total length of 798 the packet is the length of the header(s) plus the length of the 799 body. 801 4.3. Packet Tags 803 The packet tag denotes what type of packet the body holds. Note that 804 old format headers can only have tags less than 16, whereas new 805 format headers can have tags as great as 63. The defined tags (in 806 decimal) are as follows: 808 +==========+====================================================+ 809 | Tag | Packet Type | 810 +==========+====================================================+ 811 | 0 | Reserved - a packet tag MUST NOT have this value | 812 +----------+----------------------------------------------------+ 813 | 1 | Public-Key Encrypted Session Key Packet | 814 +----------+----------------------------------------------------+ 815 | 2 | Signature Packet | 816 +----------+----------------------------------------------------+ 817 | 3 | Symmetric-Key Encrypted Session Key Packet | 818 +----------+----------------------------------------------------+ 819 | 4 | One-Pass Signature Packet | 820 +----------+----------------------------------------------------+ 821 | 5 | Secret-Key Packet | 822 +----------+----------------------------------------------------+ 823 | 6 | Public-Key Packet | 824 +----------+----------------------------------------------------+ 825 | 7 | Secret-Subkey Packet | 826 +----------+----------------------------------------------------+ 827 | 8 | Compressed Data Packet | 828 +----------+----------------------------------------------------+ 829 | 9 | Symmetrically Encrypted Data Packet | 830 +----------+----------------------------------------------------+ 831 | 10 | Marker Packet | 832 +----------+----------------------------------------------------+ 833 | 11 | Literal Data Packet | 834 +----------+----------------------------------------------------+ 835 | 12 | Trust Packet | 836 +----------+----------------------------------------------------+ 837 | 13 | User ID Packet | 838 +----------+----------------------------------------------------+ 839 | 14 | Public-Subkey Packet | 840 +----------+----------------------------------------------------+ 841 | 17 | User Attribute Packet | 842 +----------+----------------------------------------------------+ 843 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 844 +----------+----------------------------------------------------+ 845 | 19 | Modification Detection Code Packet | 846 +----------+----------------------------------------------------+ 847 | 20 | Reserved (AEAD Encrypted Data) | 848 +----------+----------------------------------------------------+ 849 | 60 to 63 | Private or Experimental Values | 850 +----------+----------------------------------------------------+ 852 Table 2: Packet type registry 854 5. Packet Types 855 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 857 A Public-Key Encrypted Session Key packet holds the session key used 858 to encrypt a message. Zero or more Public-Key Encrypted Session Key 859 packets and/or Symmetric-Key Encrypted Session Key packets may 860 precede a Symmetrically Encrypted Data Packet, which holds an 861 encrypted message. The message is encrypted with the session key, 862 and the session key is itself encrypted and stored in the Encrypted 863 Session Key packet(s). The Symmetrically Encrypted Data Packet is 864 preceded by one Public-Key Encrypted Session Key packet for each 865 OpenPGP key to which the message is encrypted. The recipient of the 866 message finds a session key that is encrypted to their public key, 867 decrypts the session key, and then uses the session key to decrypt 868 the message. 870 The body of this packet consists of: 872 * A one-octet number giving the version number of the packet type. 873 The currently defined value for packet version is 3. 875 * An eight-octet number that gives the Key ID of the public key to 876 which the session key is encrypted. If the session key is 877 encrypted to a subkey, then the Key ID of this subkey is used here 878 instead of the Key ID of the primary key. 880 * A one-octet number giving the public-key algorithm used. 882 * A string of octets that is the encrypted session key. This string 883 takes up the remainder of the packet, and its contents are 884 dependent on the public-key algorithm used. 886 Algorithm Specific Fields for RSA encryption: 888 - Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 890 Algorithm Specific Fields for Elgamal encryption: 892 - MPI of Elgamal (Diffie-Hellman) value g**k mod p. 894 - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 896 Algorithm-Specific Fields for ECDH encryption: 898 - MPI of an EC point representing an ephemeral public key. 900 - a one-octet size, followed by a symmetric key encoded using the 901 method described in Section 13.4. 903 The value "m" in the above formulas is derived from the session key 904 as follows. First, the session key is prefixed with a one-octet 905 algorithm identifier that specifies the symmetric encryption 906 algorithm used to encrypt the following Symmetrically Encrypted Data 907 Packet. Then a two-octet checksum is appended, which is equal to the 908 sum of the preceding session key octets, not including the algorithm 909 identifier, modulo 65536. This value is then encoded as described in 910 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 911 form the "m" value used in the formulas above. See Section 14.1 in 912 this document for notes on OpenPGP's use of PKCS#1. 914 Note that when an implementation forms several PKESKs with one 915 session key, forming a message that can be decrypted by several keys, 916 the implementation MUST make a new PKCS#1 encoding for each key. 918 An implementation MAY accept or use a Key ID of zero as a "wild card" 919 or "speculative" Key ID. In this case, the receiving implementation 920 would try all available private keys, checking for a valid decrypted 921 session key. This format helps reduce traffic analysis of messages. 923 5.2. Signature Packet (Tag 2) 925 A Signature packet describes a binding between some public key and 926 some data. The most common signatures are a signature of a file or a 927 block of text, and a signature that is a certification of a User ID. 929 Two versions of Signature packets are defined. Version 3 provides 930 basic signature information, while version 4 provides an expandable 931 format with subpackets that can specify more information about the 932 signature. PGP 2.6.x only accepts version 3 signatures. 934 Implementations SHOULD generate V4 signatures. Implementations MUST 935 NOT create version 3 signatures; they MAY accept version 3 936 signatures. 938 5.2.1. Signature Types 940 There are a number of possible meanings for a signature, which are 941 indicated in a signature type octet in any given signature. Please 942 note that the vagueness of these meanings is not a flaw, but a 943 feature of the system. Because OpenPGP places final authority for 944 validity upon the receiver of a signature, it may be that one 945 signer's casual act might be more rigorous than some other 946 authority's positive act. See Section 5.2.4 for detailed information 947 on how to compute and verify signatures of each type. 949 These meanings are as follows: 951 0x00: Signature of a binary document. 952 This means the signer owns it, created it, or certifies that it 953 has not been modified. 955 0x01: Signature of a canonical text document. 956 This means the signer owns it, created it, or certifies that it 957 has not been modified. The signature is calculated over the text 958 data with its line endings converted to . 960 0x02: Standalone signature. 961 This signature is a signature of only its own subpacket contents. 962 It is calculated identically to a signature over a zero-length 963 binary document. Note that it doesn't make sense to have a V3 964 standalone signature. 966 0x10: Generic certification of a User ID and Public-Key packet. 967 The issuer of this certification does not make any particular 968 assertion as to how well the certifier has checked that the owner 969 of the key is in fact the person described by the User ID. 971 0x11: Persona certification of a User ID and Public-Key packet. 972 The issuer of this certification has not done any verification of 973 the claim that the owner of this key is the User ID specified. 975 0x12: Casual certification of a User ID and Public-Key packet. 976 The issuer of this certification has done some casual verification 977 of the claim of identity. 979 0x13: Positive certification of a User ID and Public-Key packet. 980 The issuer of this certification has done substantial verification 981 of the claim of identity. Most OpenPGP implementations make their 982 "key signatures" as 0x10 certifications. Some implementations can 983 issue 0x11-0x13 certifications, but few differentiate between the 984 types. 986 0x18: Subkey Binding Signature. 987 This signature is a statement by the top-level signing key that 988 indicates that it owns the subkey. This signature is calculated 989 directly on the primary key and subkey, and not on any User ID or 990 other packets. A signature that binds a signing subkey MUST have 991 an Embedded Signature subpacket in this binding signature that 992 contains a 0x19 signature made by the signing subkey on the 993 primary key and subkey. 995 0x19: Primary Key Binding Signature. 996 This signature is a statement by a signing subkey, indicating that 997 it is owned by the primary key and subkey. This signature is 998 calculated the same way as a 0x18 signature: directly on the 999 primary key and subkey, and not on any User ID or other packets. 1001 0x1F: Signature directly on a key. 1002 This signature is calculated directly on a key. It binds the 1003 information in the Signature subpackets to the key, and is 1004 appropriate to be used for subpackets that provide information 1005 about the key, such as the Revocation Key subpacket. It is also 1006 appropriate for statements that non-self certifiers want to make 1007 about the key itself, rather than the binding between a key and a 1008 name. 1010 0x20: Key revocation signature. 1011 The signature is calculated directly on the key being revoked. A 1012 revoked key is not to be used. Only revocation signatures by the 1013 key being revoked, or by an authorized revocation key, should be 1014 considered valid revocation signatures. 1016 0x28: Subkey revocation signature. 1017 The signature is calculated directly on the subkey being revoked. 1018 A revoked subkey is not to be used. Only revocation signatures by 1019 the top-level signature key that is bound to this subkey, or by an 1020 authorized revocation key, should be considered valid revocation 1021 signatures. 1023 0x30: Certification revocation signature. 1024 This signature revokes an earlier User ID certification signature 1025 (signature class 0x10 through 0x13) or direct-key signature 1026 (0x1F). It should be issued by the same key that issued the 1027 revoked signature or an authorized revocation key. The signature 1028 is computed over the same data as the certificate that it revokes, 1029 and should have a later creation date than that certificate. 1031 0x40: Timestamp signature. 1032 This signature is only meaningful for the timestamp contained in 1033 it. 1035 0x50: Third-Party Confirmation signature. 1036 This signature is a signature over some other OpenPGP Signature 1037 packet(s). It is analogous to a notary seal on the signed data. 1038 A third-party signature SHOULD include Signature Target 1039 subpacket(s) to give easy identification. Note that we really do 1040 mean SHOULD. There are plausible uses for this (such as a blind 1041 party that only sees the signature, not the key or source 1042 document) that cannot include a target subpacket. 1044 5.2.2. Version 3 Signature Packet Format 1046 The body of a version 3 Signature Packet contains: 1048 * One-octet version number (3). 1050 * One-octet length of following hashed material. MUST be 5. 1052 - One-octet signature type. 1054 - Four-octet creation time. 1056 * Eight-octet Key ID of signer. 1058 * One-octet public-key algorithm. 1060 * One-octet hash algorithm. 1062 * Two-octet field holding left 16 bits of signed hash value. 1064 * One or more multiprecision integers comprising the signature. 1065 This portion is algorithm specific, as described below. 1067 The concatenation of the data to be signed, the signature type, and 1068 creation time from the Signature packet (5 additional octets) is 1069 hashed. The resulting hash value is used in the signature algorithm. 1070 The high 16 bits (first two octets) of the hash are included in the 1071 Signature packet to provide a way to reject some invalid signatures 1072 without performing a signature verification. 1074 Algorithm-Specific Fields for RSA signatures: 1076 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1078 Algorithm-Specific Fields for DSA and ECDSA signatures: 1080 * MPI of DSA or ECDSA value r. 1082 * MPI of DSA or ECDSA value s. 1084 The signature calculation is based on a hash of the signed data, as 1085 described above. The details of the calculation are different for 1086 DSA signatures than for RSA signatures. 1088 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1089 type EMSA-PKCS1-v1_5 as described in Section 9.2 of [RFC3447]. This 1090 requires inserting the hash value as an octet string into an ASN.1 1091 structure. The object identifier for the type of hash being used is 1092 included in the structure. The hexadecimal representations for the 1093 currently defined hash algorithms are as follows: 1095 +============+======================================================+ 1096 | algorithm | hexadecimal represenatation | 1097 +============+======================================================+ 1098 | MD5 | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 | 1099 +------------+------------------------------------------------------+ 1100 | RIPEMD-160 | 0x2B, 0x24, 0x03, 0x02, 0x01 | 1101 +------------+------------------------------------------------------+ 1102 | SHA-1 | 0x2B, 0x0E, 0x03, 0x02, 0x1A | 1103 +------------+------------------------------------------------------+ 1104 | SHA224 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1105 | | 0x02, 0x04 | 1106 +------------+------------------------------------------------------+ 1107 | SHA256 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1108 | | 0x02, 0x01 | 1109 +------------+------------------------------------------------------+ 1110 | SHA384 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1111 | | 0x02, 0x02 | 1112 +------------+------------------------------------------------------+ 1113 | SHA512 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1114 | | 0x02, 0x03 | 1115 +------------+------------------------------------------------------+ 1117 Table 3: Hash hexadecimal representations 1119 The ASN.1 Object Identifiers (OIDs) are as follows: 1121 +============+========================+ 1122 | algorithm | OID | 1123 +============+========================+ 1124 | MD5 | 1.2.840.113549.2.5 | 1125 +------------+------------------------+ 1126 | RIPEMD-160 | 1.3.36.3.2.1 | 1127 +------------+------------------------+ 1128 | SHA-1 | 1.3.14.3.2.26 | 1129 +------------+------------------------+ 1130 | SHA224 | 2.16.840.1.101.3.4.2.4 | 1131 +------------+------------------------+ 1132 | SHA256 | 2.16.840.1.101.3.4.2.1 | 1133 +------------+------------------------+ 1134 | SHA384 | 2.16.840.1.101.3.4.2.2 | 1135 +------------+------------------------+ 1136 | SHA512 | 2.16.840.1.101.3.4.2.3 | 1137 +------------+------------------------+ 1139 Table 4: Hash OIDs 1141 The full hash prefixes for these are as follows: 1143 +============+==========================================+ 1144 | algorithm | full hash prefix | 1145 +============+==========================================+ 1146 | MD5 | 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, | 1147 | | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, | 1148 | | 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 | 1149 +------------+------------------------------------------+ 1150 | RIPEMD-160 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1151 | | 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, | 1152 | | 0x00, 0x04, 0x14 | 1153 +------------+------------------------------------------+ 1154 | SHA-1 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1155 | | 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, | 1156 | | 0x00, 0x04, 0x14 | 1157 +------------+------------------------------------------+ 1158 | SHA224 | 0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, | 1159 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1160 | | 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C | 1161 +------------+------------------------------------------+ 1162 | SHA256 | 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, | 1163 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1164 | | 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 | 1165 +------------+------------------------------------------+ 1166 | SHA384 | 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, | 1167 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1168 | | 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 | 1169 +------------+------------------------------------------+ 1170 | SHA512 | 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, | 1171 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1172 | | 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 | 1173 +------------+------------------------------------------+ 1175 Table 5: Hash hexadecimal prefixes 1177 DSA signatures MUST use hashes that are equal in size to the number 1178 of bits of q, the group generated by the DSA key's generator value. 1180 If the output size of the chosen hash is larger than the number of 1181 bits of q, the hash result is truncated to fit by taking the number 1182 of leftmost bits equal to the number of bits of q. This (possibly 1183 truncated) hash function result is treated as a number and used 1184 directly in the DSA signature algorithm. 1186 5.2.3. Version 4 Signature Packet Format 1188 The body of a version 4 Signature packet contains: 1190 * One-octet version number (4). 1192 * One-octet signature type. 1194 * One-octet public-key algorithm. 1196 * One-octet hash algorithm. 1198 * Two-octet scalar octet count for following hashed subpacket data. 1199 Note that this is the length in octets of all of the hashed 1200 subpackets; a pointer incremented by this number will skip over 1201 the hashed subpackets. 1203 * Hashed subpacket data set (zero or more subpackets). 1205 * Two-octet scalar octet count for the following unhashed subpacket 1206 data. Note that this is the length in octets of all of the 1207 unhashed subpackets; a pointer incremented by this number will 1208 skip over the unhashed subpackets. 1210 * Unhashed subpacket data set (zero or more subpackets). 1212 * Two-octet field holding the left 16 bits of the signed hash value. 1214 * One or more multiprecision integers comprising the signature. 1215 This portion is algorithm specific: 1217 Algorithm-Specific Fields for RSA signatures: 1219 - Multiprecision integer (MPI) of RSA signature value m**d mod n. 1221 Algorithm-Specific Fields for DSA or ECDSA signatures: 1223 - MPI of DSA or ECDSA value r. 1225 - MPI of DSA or ECDSA value s. 1227 The concatenation of the data being signed and the signature data 1228 from the version number through the hashed subpacket data (inclusive) 1229 is hashed. The resulting hash value is what is signed. The high 16 1230 bits (first two octets) of the hash are included in the Signature 1231 packet to provide a way to reject some invalid signatures without 1232 performing a signature verification. 1234 There are two fields consisting of Signature subpackets. The first 1235 field is hashed with the rest of the signature data, while the second 1236 is unhashed. The second set of subpackets is not cryptographically 1237 protected by the signature and should include only advisory 1238 information. 1240 The algorithms for converting the hash function result to a signature 1241 are described in a section below. 1243 5.2.3.1. Signature Subpacket Specification 1245 A subpacket data set consists of zero or more Signature subpackets. 1246 In Signature packets, the subpacket data set is preceded by a two- 1247 octet scalar count of the length in octets of all the subpackets. A 1248 pointer incremented by this number will skip over the subpacket data 1249 set. 1251 Each subpacket consists of a subpacket header and a body. The header 1252 consists of: 1254 * the subpacket length (1, 2, or 5 octets), 1256 * the subpacket type (1 octet), 1258 and is followed by the subpacket-specific data. 1260 The length includes the type octet but not this length. Its format 1261 is similar to the "new" format packet header lengths, but cannot have 1262 Partial Body Lengths. That is: 1264 if the 1st octet < 192, then 1265 lengthOfLength = 1 1266 subpacketLen = 1st_octet 1268 if the 1st octet >= 192 and < 255, then 1269 lengthOfLength = 2 1270 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1272 if the 1st octet = 255, then 1273 lengthOfLength = 5 1274 subpacket length = [four-octet scalar starting at 2nd_octet] 1276 The value of the subpacket type octet may be: 1278 +============+===========================================+ 1279 | Type | Description | 1280 +============+===========================================+ 1281 | 0 | Reserved | 1282 +------------+-------------------------------------------+ 1283 | 1 | Reserved | 1284 +------------+-------------------------------------------+ 1285 | 2 | Signature Creation Time | 1286 +------------+-------------------------------------------+ 1287 | 3 | Signature Expiration Time | 1288 +------------+-------------------------------------------+ 1289 | 4 | Exportable Certification | 1290 +------------+-------------------------------------------+ 1291 | 5 | Trust Signature | 1292 +------------+-------------------------------------------+ 1293 | 6 | Regular Expression | 1294 +------------+-------------------------------------------+ 1295 | 7 | Revocable | 1296 +------------+-------------------------------------------+ 1297 | 8 | Reserved | 1298 +------------+-------------------------------------------+ 1299 | 9 | Key Expiration Time | 1300 +------------+-------------------------------------------+ 1301 | 10 | Placeholder for backward compatibility | 1302 +------------+-------------------------------------------+ 1303 | 11 | Preferred Symmetric Algorithms | 1304 +------------+-------------------------------------------+ 1305 | 12 | Revocation Key | 1306 +------------+-------------------------------------------+ 1307 | 13 to 15 | Reserved | 1308 +------------+-------------------------------------------+ 1309 | 16 | Issuer | 1310 +------------+-------------------------------------------+ 1311 | 17 to 19 | Reserved | 1312 +------------+-------------------------------------------+ 1313 | 20 | Notation Data | 1314 +------------+-------------------------------------------+ 1315 | 21 | Preferred Hash Algorithms | 1316 +------------+-------------------------------------------+ 1317 | 22 | Preferred Compression Algorithms | 1318 +------------+-------------------------------------------+ 1319 | 23 | Key Server Preferences | 1320 +------------+-------------------------------------------+ 1321 | 24 | Preferred Key Server | 1322 +------------+-------------------------------------------+ 1323 | 25 | Primary User ID | 1324 +------------+-------------------------------------------+ 1325 | 26 | Policy URI | 1326 +------------+-------------------------------------------+ 1327 | 27 | Key Flags | 1328 +------------+-------------------------------------------+ 1329 | 28 | Signer's User ID | 1330 +------------+-------------------------------------------+ 1331 | 29 | Reason for Revocation | 1332 +------------+-------------------------------------------+ 1333 | 30 | Features | 1334 +------------+-------------------------------------------+ 1335 | 31 | Signature Target | 1336 +------------+-------------------------------------------+ 1337 | 32 | Embedded Signature | 1338 +------------+-------------------------------------------+ 1339 | 33 | Reserved (Issuer Fingerprint) | 1340 +------------+-------------------------------------------+ 1341 | 34 | Reserved (Preferred AEAD Algorithms) | 1342 +------------+-------------------------------------------+ 1343 | 35 | Reserved (Intended Recipient Fingerprint) | 1344 +------------+-------------------------------------------+ 1345 | 37 | Reserved (Attested Certifications) | 1346 +------------+-------------------------------------------+ 1347 | 38 | Reserved (Key Block) | 1348 +------------+-------------------------------------------+ 1349 | 100 to 110 | Private or experimental | 1350 +------------+-------------------------------------------+ 1352 Table 6: Subpacket type registry 1354 An implementation SHOULD ignore any subpacket of a type that it does 1355 not recognize. 1357 Bit 7 of the subpacket type is the "critical" bit. If set, it 1358 denotes that the subpacket is one that is critical for the evaluator 1359 of the signature to recognize. If a subpacket is encountered that is 1360 marked critical but is unknown to the evaluating software, the 1361 evaluator SHOULD consider the signature to be in error. 1363 An evaluator may "recognize" a subpacket, but not implement it. The 1364 purpose of the critical bit is to allow the signer to tell an 1365 evaluator that it would prefer a new, unknown feature to generate an 1366 error than be ignored. 1368 Implementations SHOULD implement the three preferred algorithm 1369 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1370 subpacket. Note, however, that if an implementation chooses not to 1371 implement some of the preferences, it is required to behave in a 1372 polite manner to respect the wishes of those users who do implement 1373 these preferences. 1375 5.2.3.2. Signature Subpacket Types 1377 A number of subpackets are currently defined. Some subpackets apply 1378 to the signature itself and some are attributes of the key. 1379 Subpackets that are found on a self-signature are placed on a 1380 certification made by the key itself. Note that a key may have more 1381 than one User ID, and thus may have more than one self-signature, and 1382 differing subpackets. 1384 A subpacket may be found either in the hashed or unhashed subpacket 1385 sections of a signature. If a subpacket is not hashed, then the 1386 information in it cannot be considered definitive because it is not 1387 part of the signature proper. 1389 5.2.3.3. Notes on Self-Signatures 1391 A self-signature is a binding signature made by the key to which the 1392 signature refers. There are three types of self-signatures, the 1393 certification signatures (types 0x10-0x13), the direct-key signature 1394 (type 0x1F), and the subkey binding signature (type 0x18). For 1395 certification self-signatures, each User ID may have a self- 1396 signature, and thus different subpackets in those self-signatures. 1397 For subkey binding signatures, each subkey in fact has a self- 1398 signature. Subpackets that appear in a certification self-signature 1399 apply to the user name, and subpackets that appear in the subkey 1400 self-signature apply to the subkey. Lastly, subpackets on the 1401 direct-key signature apply to the entire key. 1403 Implementing software should interpret a self-signature's preference 1404 subpackets as narrowly as possible. For example, suppose a key has 1405 two user names, Alice and Bob. Suppose that Alice prefers the 1406 symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the 1407 software locates this key via Alice's name, then the preferred 1408 algorithm is CAST5; if software locates the key via Bob's name, then 1409 the preferred algorithm is IDEA. If the key is located by Key ID, 1410 the algorithm of the primary User ID of the key provides the 1411 preferred symmetric algorithm. 1413 Revoking a self-signature or allowing it to expire has a semantic 1414 meaning that varies with the signature type. Revoking the self- 1415 signature on a User ID effectively retires that user name. The self- 1416 signature is a statement, "My name X is tied to my signing key K" and 1417 is corroborated by other users' certifications. If another user 1418 revokes their certification, they are effectively saying that they no 1419 longer believe that name and that key are tied together. Similarly, 1420 if the users themselves revoke their self-signature, then the users 1421 no longer go by that name, no longer have that email address, etc. 1422 Revoking a binding signature effectively retires that subkey. 1423 Revoking a direct-key signature cancels that signature. Please see 1424 Section 5.2.3.23 for more relevant detail. 1426 Since a self-signature contains important information about the key's 1427 use, an implementation SHOULD allow the user to rewrite the self- 1428 signature, and important information in it, such as preferences and 1429 key expiration. 1431 It is good practice to verify that a self-signature imported into an 1432 implementation doesn't advertise features that the implementation 1433 doesn't support, rewriting the signature as appropriate. 1435 An implementation that encounters multiple self-signatures on the 1436 same object may resolve the ambiguity in any way it sees fit, but it 1437 is RECOMMENDED that priority be given to the most recent self- 1438 signature. 1440 5.2.3.4. Signature Creation Time 1442 (4-octet time field) 1444 The time the signature was made. 1446 MUST be present in the hashed area. 1448 5.2.3.5. Issuer 1450 (8-octet Key ID) 1452 The OpenPGP Key ID of the key issuing the signature. 1454 5.2.3.6. Key Expiration Time 1456 (4-octet time field) 1458 The validity period of the key. This is the number of seconds after 1459 the key creation time that the key expires. If this is not present 1460 or has a value of zero, the key never expires. This is found only on 1461 a self-signature. 1463 5.2.3.7. Preferred Symmetric Algorithms 1465 (array of one-octet values) 1467 Symmetric algorithm numbers that indicate which algorithms the key 1468 holder prefers to use. The subpacket body is an ordered list of 1469 octets with the most preferred listed first. It is assumed that only 1470 algorithms listed are supported by the recipient's software. 1471 Algorithm numbers are in Section 9.3. This is only found on a self- 1472 signature. 1474 5.2.3.8. Preferred Hash Algorithms 1476 (array of one-octet values) 1477 Message digest algorithm numbers that indicate which algorithms the 1478 key holder prefers to receive. Like the preferred symmetric 1479 algorithms, the list is ordered. Algorithm numbers are in 1480 Section 9.5. This is only found on a self-signature. 1482 5.2.3.9. Preferred Compression Algorithms 1484 (array of one-octet values) 1486 Compression algorithm numbers that indicate which algorithms the key 1487 holder prefers to use. Like the preferred symmetric algorithms, the 1488 list is ordered. Algorithm numbers are in Section 9.4. If this 1489 subpacket is not included, ZIP is preferred. A zero denotes that 1490 uncompressed data is preferred; the key holder's software might have 1491 no compression software in that implementation. This is only found 1492 on a self-signature. 1494 5.2.3.10. Signature Expiration Time 1496 (4-octet time field) 1498 The validity period of the signature. This is the number of seconds 1499 after the signature creation time that the signature expires. If 1500 this is not present or has a value of zero, it never expires. 1502 5.2.3.11. Exportable Certification 1504 (1 octet of exportability, 0 for not, 1 for exportable) 1506 This subpacket denotes whether a certification signature is 1507 "exportable", to be used by other users than the signature's issuer. 1508 The packet body contains a Boolean flag indicating whether the 1509 signature is exportable. If this packet is not present, the 1510 certification is exportable; it is equivalent to a flag containing a 1511 1. 1513 Non-exportable, or "local", certifications are signatures made by a 1514 user to mark a key as valid within that user's implementation only. 1516 Thus, when an implementation prepares a user's copy of a key for 1517 transport to another user (this is the process of "exporting" the 1518 key), any local certification signatures are deleted from the key. 1520 The receiver of a transported key "imports" it, and likewise trims 1521 any local certifications. In normal operation, there won't be any, 1522 assuming the import is performed on an exported key. However, there 1523 are instances where this can reasonably happen. For example, if an 1524 implementation allows keys to be imported from a key database in 1525 addition to an exported key, then this situation can arise. 1527 Some implementations do not represent the interest of a single user 1528 (for example, a key server). Such implementations always trim local 1529 certifications from any key they handle. 1531 5.2.3.12. Revocable 1533 (1 octet of revocability, 0 for not, 1 for revocable) 1535 Signature's revocability status. The packet body contains a Boolean 1536 flag indicating whether the signature is revocable. Signatures that 1537 are not revocable have any later revocation signatures ignored. They 1538 represent a commitment by the signer that he cannot revoke his 1539 signature for the life of his key. If this packet is not present, 1540 the signature is revocable. 1542 5.2.3.13. Trust Signature 1544 (1 octet "level" (depth), 1 octet of trust amount) 1546 Signer asserts that the key is not only valid but also trustworthy at 1547 the specified level. Level 0 has the same meaning as an ordinary 1548 validity signature. Level 1 means that the signed key is asserted to 1549 be a valid trusted introducer, with the 2nd octet of the body 1550 specifying the degree of trust. Level 2 means that the signed key is 1551 asserted to be trusted to issue level 1 trust signatures, i.e., that 1552 it is a "meta introducer". Generally, a level n trust signature 1553 asserts that a key is trusted to issue level n-1 trust signatures. 1554 The trust amount is in a range from 0-255, interpreted such that 1555 values less than 120 indicate partial trust and values of 120 or 1556 greater indicate complete trust. Implementations SHOULD emit values 1557 of 60 for partial trust and 120 for complete trust. 1559 5.2.3.14. Regular Expression 1561 (null-terminated regular expression) 1562 Used in conjunction with trust Signature packets (of level > 0) to 1563 limit the scope of trust that is extended. Only signatures by the 1564 target key on User IDs that match the regular expression in the body 1565 of this packet have trust extended by the trust Signature subpacket. 1566 The regular expression uses the same syntax as the Henry Spencer's 1567 "almost public domain" regular expression [REGEX] package. A 1568 description of the syntax is found in Section 8. 1570 5.2.3.15. Revocation Key 1572 (1 octet of class, 1 octet of public-key algorithm ID, 20 octets of 1573 fingerprint) 1575 Authorizes the specified key to issue revocation signatures for this 1576 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1577 then this means that the revocation information is sensitive. Other 1578 bits are for future expansion to other kinds of authorizations. This 1579 is found on a self-signature. 1581 If the "sensitive" flag is set, the keyholder feels this subpacket 1582 contains private trust information that describes a real-world 1583 sensitive relationship. If this flag is set, implementations SHOULD 1584 NOT export this signature to other users except in cases where the 1585 data needs to be available: when the signature is being sent to the 1586 designated revoker, or when it is accompanied by a revocation 1587 signature from that revoker. Note that it may be appropriate to 1588 isolate this subpacket within a separate signature so that it is not 1589 combined with other subpackets that need to be exported. 1591 5.2.3.16. Notation Data 1593 (4 octets of flags, 2 octets of name length (M), 2 octets of value 1594 length (N), M octets of name data, N octets of value data) 1596 This subpacket describes a "notation" on the signature that the 1597 issuer wishes to make. The notation has a name and a value, each of 1598 which are strings of octets. There may be more than one notation in 1599 a signature. Notations can be used for any extension the issuer of 1600 the signature cares to make. The "flags" field holds four octets of 1601 flags. 1603 All undefined flags MUST be zero. Defined flags are as follows: 1605 First octet: 1607 +======+================+==========================+ 1608 | flag | shorthand | definition | 1609 +======+================+==========================+ 1610 | 0x80 | human-readable | This note value is text. | 1611 +------+----------------+--------------------------+ 1613 Table 7: Notation flag registry (first octet) 1615 Other octets: none. 1617 Notation names are arbitrary strings encoded in UTF-8. They reside 1618 in two namespaces: The IETF namespace and the user namespace. 1620 The IETF namespace is registered with IANA. These names MUST NOT 1621 contain the "@" character (0x40). This is a tag for the user 1622 namespace. 1624 Names in the user namespace consist of a UTF-8 string tag followed by 1625 "@" followed by a DNS domain name. Note that the tag MUST NOT 1626 contain an "@" character. For example, the "sample" tag used by 1627 Example Corporation could be "sample@example.com". 1629 Names in a user space are owned and controlled by the owners of that 1630 domain. Obviously, it's bad form to create a new name in a DNS space 1631 that you don't own. 1633 Since the user namespace is in the form of an email address, 1634 implementers MAY wish to arrange for that address to reach a person 1635 who can be consulted about the use of the named tag. Note that due 1636 to UTF-8 encoding, not all valid user space name tags are valid email 1637 addresses. 1639 If there is a critical notation, the criticality applies to that 1640 specific notation and not to notations in general. 1642 5.2.3.17. Key Server Preferences 1644 (N octets of flags) 1646 This is a list of one-bit flags that indicate preferences that the 1647 key holder has about how the key is handled on a key server. All 1648 undefined flags MUST be zero. 1650 First octet: 1652 +======+===========+============================================+ 1653 | flag | shorthand | definition | 1654 +======+===========+============================================+ 1655 | 0x80 | No-modify | The key holder requests that this key only | 1656 | | | be modified or updated by the key holder | 1657 | | | or an administrator of the key server. | 1658 +------+-----------+--------------------------------------------+ 1660 Table 8: Key server preferences flag registry (first octet) 1662 This is found only on a self-signature. 1664 5.2.3.18. Preferred Key Server 1666 (String) 1668 This is a URI of a key server that the key holder prefers be used for 1669 updates. Note that keys with multiple User IDs can have a preferred 1670 key server for each User ID. Note also that since this is a URI, the 1671 key server can actually be a copy of the key retrieved by ftp, http, 1672 finger, etc. 1674 5.2.3.19. Primary User ID 1676 (1 octet, Boolean) 1678 This is a flag in a User ID's self-signature that states whether this 1679 User ID is the main User ID for this key. It is reasonable for an 1680 implementation to resolve ambiguities in preferences, etc. by 1681 referring to the primary User ID. If this flag is absent, its value 1682 is zero. If more than one User ID in a key is marked as primary, the 1683 implementation may resolve the ambiguity in any way it sees fit, but 1684 it is RECOMMENDED that priority be given to the User ID with the most 1685 recent self-signature. 1687 When appearing on a self-signature on a User ID packet, this 1688 subpacket applies only to User ID packets. When appearing on a self- 1689 signature on a User Attribute packet, this subpacket applies only to 1690 User Attribute packets. That is to say, there are two different and 1691 independent "primaries" -- one for User IDs, and one for User 1692 Attributes. 1694 5.2.3.20. Policy URI 1696 (String) 1698 This subpacket contains a URI of a document that describes the policy 1699 under which the signature was issued. 1701 5.2.3.21. Key Flags 1703 (N octets of flags) 1705 This subpacket contains a list of binary flags that hold information 1706 about a key. It is a string of octets, and an implementation MUST 1707 NOT assume a fixed size. This is so it can grow over time. If a 1708 list is shorter than an implementation expects, the unstated flags 1709 are considered to be zero. The defined flags are as follows: 1711 First octet: 1713 +======+=================================================+ 1714 | flag | definition | 1715 +======+=================================================+ 1716 | 0x01 | This key may be used to certify other keys. | 1717 +------+-------------------------------------------------+ 1718 | 0x02 | This key may be used to sign data. | 1719 +------+-------------------------------------------------+ 1720 | 0x04 | This key may be used to encrypt communications. | 1721 +------+-------------------------------------------------+ 1722 | 0x08 | This key may be used to encrypt storage. | 1723 +------+-------------------------------------------------+ 1724 | 0x10 | The private component of this key may have been | 1725 | | split by a secret-sharing mechanism. | 1726 +------+-------------------------------------------------+ 1727 | 0x20 | This key may be used for authentication. | 1728 +------+-------------------------------------------------+ 1729 | 0x80 | The private component of this key may be in the | 1730 | | possession of more than one person. | 1731 +------+-------------------------------------------------+ 1733 Table 9: Key flags registry (first octet) 1735 Second octet: 1737 +======+==========================+ 1738 | flag | definition | 1739 +======+==========================+ 1740 | 0x04 | Reserved (ADSK). | 1741 +------+--------------------------+ 1742 | 0x08 | Reserved (timestamping). | 1743 +------+--------------------------+ 1745 Table 10: Key flags registry 1746 (second octet) 1748 Usage notes: 1750 The flags in this packet may appear in self-signatures or in 1751 certification signatures. They mean different things depending on 1752 who is making the statement -- for example, a certification signature 1753 that has the "sign data" flag is stating that the certification is 1754 for that use. On the other hand, the "communications encryption" 1755 flag in a self-signature is stating a preference that a given key be 1756 used for communications. Note however, that it is a thorny issue to 1757 determine what is "communications" and what is "storage". This 1758 decision is left wholly up to the implementation; the authors of this 1759 document do not claim any special wisdom on the issue and realize 1760 that accepted opinion may change. 1762 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1763 self-signature only; they are meaningless on a certification 1764 signature. They SHOULD be placed only on a direct-key signature 1765 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1766 key the flag applies to. 1768 5.2.3.22. Signer's User ID 1770 (String) 1772 This subpacket allows a keyholder to state which User ID is 1773 responsible for the signing. Many keyholders use a single key for 1774 different purposes, such as business communications as well as 1775 personal communications. This subpacket allows such a keyholder to 1776 state which of their roles is making a signature. 1778 This subpacket is not appropriate to use to refer to a User Attribute 1779 packet. 1781 5.2.3.23. Reason for Revocation 1783 (1 octet of revocation code, N octets of reason string) 1785 This subpacket is used only in key revocation and certification 1786 revocation signatures. It describes the reason why the key or 1787 certificate was revoked. 1789 The first octet contains a machine-readable code that denotes the 1790 reason for the revocation: 1792 +=========+==================================+ 1793 | Code | Reason | 1794 +=========+==================================+ 1795 | 0 | No reason specified (key | 1796 | | revocations or cert revocations) | 1797 +---------+----------------------------------+ 1798 | 1 | Key is superseded (key | 1799 | | revocations) | 1800 +---------+----------------------------------+ 1801 | 2 | Key material has been | 1802 | | compromised (key revocations) | 1803 +---------+----------------------------------+ 1804 | 3 | Key is retired and no longer | 1805 | | used (key revocations) | 1806 +---------+----------------------------------+ 1807 | 32 | User ID information is no longer | 1808 | | valid (cert revocations) | 1809 +---------+----------------------------------+ 1810 | 100-110 | Private Use | 1811 +---------+----------------------------------+ 1813 Table 11: Reasons for revocation 1815 Following the revocation code is a string of octets that gives 1816 information about the Reason for Revocation in human-readable form 1817 (UTF-8). The string may be null, that is, of zero length. The 1818 length of the subpacket is the length of the reason string plus one. 1819 An implementation SHOULD implement this subpacket, include it in all 1820 revocation signatures, and interpret revocations appropriately. 1821 There are important semantic differences between the reasons, and 1822 there are thus important reasons for revoking signatures. 1824 If a key has been revoked because of a compromise, all signatures 1825 created by that key are suspect. However, if it was merely 1826 superseded or retired, old signatures are still valid. If the 1827 revoked signature is the self-signature for certifying a User ID, a 1828 revocation denotes that that user name is no longer in use. Such a 1829 revocation SHOULD include a 0x20 code. 1831 Note that any signature may be revoked, including a certification on 1832 some other person's key. There are many good reasons for revoking a 1833 certification signature, such as the case where the keyholder leaves 1834 the employ of a business with an email address. A revoked 1835 certification is no longer a part of validity calculations. 1837 5.2.3.24. Features 1839 (N octets of flags) 1841 The Features subpacket denotes which advanced OpenPGP features a 1842 user's implementation supports. This is so that as features are 1843 added to OpenPGP that cannot be backwards-compatible, a user can 1844 state that they can use that feature. The flags are single bits that 1845 indicate that a given feature is supported. 1847 This subpacket is similar to a preferences subpacket, and only 1848 appears in a self-signature. 1850 An implementation SHOULD NOT use a feature listed when sending to a 1851 user who does not state that they can use it. 1853 Defined features are as follows: 1855 First octet: 1857 +=========+============================================+ 1858 | feature | definition | 1859 +=========+============================================+ 1860 | 0x01 | Modification Detection (packets 18 and 19) | 1861 +---------+--------------------------------------------+ 1862 | 0x02 | Reserved (AEAD Data & v5 SKESK) | 1863 +---------+--------------------------------------------+ 1864 | 0x04 | Reserved (v5 pubkey & fingerprint) | 1865 +---------+--------------------------------------------+ 1867 Table 12: Features registry 1869 If an implementation implements any of the defined features, it 1870 SHOULD implement the Features subpacket, too. 1872 An implementation may freely infer features from other suitable 1873 implementation-dependent mechanisms. 1875 5.2.3.25. Signature Target 1877 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1879 This subpacket identifies a specific target signature to which a 1880 signature refers. For revocation signatures, this subpacket provides 1881 explicit designation of which signature is being revoked. For a 1882 third-party or timestamp signature, this designates what signature is 1883 signed. All arguments are an identifier of that target signature. 1885 The N octets of hash data MUST be the size of the hash of the 1886 signature. For example, a target signature with a SHA-1 hash MUST 1887 have 20 octets of hash data. 1889 5.2.3.26. Embedded Signature 1891 (1 signature packet body) 1893 This subpacket contains a complete Signature packet body as specified 1894 in Section 5.2. It is useful when one signature needs to refer to, 1895 or be incorporated in, another signature. 1897 5.2.4. Computing Signatures 1899 All signatures are formed by producing a hash over the signature 1900 data, and then using the resulting hash in the signature algorithm. 1902 For binary document signatures (type 0x00), the document data is 1903 hashed directly. For text document signatures (type 0x01), the 1904 document is canonicalized by converting line endings to , and 1905 the resulting data is hashed. 1907 When a signature is made over a key, the hash data starts with the 1908 octet 0x99, followed by a two-octet length of the key, and then body 1909 of the key packet. (Note that this is an old-style packet header for 1910 a key packet with two-octet length.) A subkey binding signature 1911 (type 0x18) or primary key binding signature (type 0x19) then hashes 1912 the subkey using the same format as the main key (also using 0x99 as 1913 the first octet). Primary key revocation signatures (type 0x20) hash 1914 only the key being revoked. Subkey revocation signature (type 0x28) 1915 hash first the primary key and then the subkey being revoked. 1917 A certification signature (type 0x10 through 0x13) hashes the User ID 1918 being bound to the key into the hash context after the above data. A 1919 V3 certification hashes the contents of the User ID or attribute 1920 packet packet, without any header. A V4 certification hashes the 1921 constant 0xB4 for User ID certifications or the constant 0xD1 for 1922 User Attribute certifications, followed by a four-octet number giving 1923 the length of the User ID or User Attribute data, and then the User 1924 ID or User Attribute data. 1926 When a signature is made over a Signature packet (type 0x50, "Third- 1927 Party Confirmation signature"), the hash data starts with the octet 1928 0x88, followed by the four-octet length of the signature, and then 1929 the body of the Signature packet. (Note that this is an old-style 1930 packet header for a Signature packet with the length-of-length field 1931 set to zero.) The unhashed subpacket data of the Signature packet 1932 being hashed is not included in the hash, and the unhashed subpacket 1933 data length value is set to zero. 1935 Once the data body is hashed, then a trailer is hashed. This trailer 1936 depends on the version of the signature. 1938 * A V3 signature hashes five octets of the packet body, starting 1939 from the signature type field. This data is the signature type, 1940 followed by the four-octet signature time. 1942 * A V4 signature hashes the packet body starting from its first 1943 field, the version number, through the end of the hashed subpacket 1944 data and a final extra trailer. Thus, the hashed fields are: 1946 - the signature version (0x04), 1948 - the signature type, 1950 - the public-key algorithm, 1952 - the hash algorithm, 1954 - the hashed subpacket length, 1956 - the hashed subpacket body, 1958 - the two octets 0x04 and 0xFF, 1960 - a four-octet big-endian number that is the length of the hashed 1961 data from the Signature packet stopping right before the 0x04, 1962 0xff octets. 1964 After all this has been hashed in a single hash context, the 1965 resulting hash field is used in the signature algorithm and placed at 1966 the end of the Signature packet. 1968 5.2.4.1. Subpacket Hints 1970 It is certainly possible for a signature to contain conflicting 1971 information in subpackets. For example, a signature may contain 1972 multiple copies of a preference or multiple expiration times. In 1973 most cases, an implementation SHOULD use the last subpacket in the 1974 signature, but MAY use any conflict resolution scheme that makes more 1975 sense. Please note that we are intentionally leaving conflict 1976 resolution to the implementer; most conflicts are simply syntax 1977 errors, and the wishy-washy language here allows a receiver to be 1978 generous in what they accept, while putting pressure on a creator to 1979 be stingy in what they generate. 1981 Some apparent conflicts may actually make sense -- for example, 1982 suppose a keyholder has a V3 key and a V4 key that share the same RSA 1983 key material. Either of these keys can verify a signature created by 1984 the other, and it may be reasonable for a signature to contain an 1985 issuer subpacket for each key, as a way of explicitly tying those 1986 keys to the signature. 1988 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 1990 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 1991 key encryption of a session key used to encrypt a message. Zero or 1992 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 1993 Encrypted Session Key packets may precede a Symmetrically Encrypted 1994 Data packet that holds an encrypted message. The message is 1995 encrypted with a session key, and the session key is itself encrypted 1996 and stored in the Encrypted Session Key packet or the Symmetric-Key 1997 Encrypted Session Key packet. 1999 If the Symmetrically Encrypted Data packet is preceded by one or more 2000 Symmetric-Key Encrypted Session Key packets, each specifies a 2001 passphrase that may be used to decrypt the message. This allows a 2002 message to be encrypted to a number of public keys, and also to one 2003 or more passphrases. This packet type is new and is not generated by 2004 PGP 2 or PGP version 5.0. 2006 The body of this packet consists of: 2008 * A one-octet version number. The only currently defined version is 2009 4. 2011 * A one-octet number describing the symmetric algorithm used. 2013 * A string-to-key (S2K) specifier, length as defined above. 2015 * Optionally, the encrypted session key itself, which is decrypted 2016 with the string-to-key object. 2018 If the encrypted session key is not present (which can be detected on 2019 the basis of packet length and S2K specifier size), then the S2K 2020 algorithm applied to the passphrase produces the session key for 2021 decrypting the message, using the symmetric cipher algorithm from the 2022 Symmetric-Key Encrypted Session Key packet. 2024 If the encrypted session key is present, the result of applying the 2025 S2K algorithm to the passphrase is used to decrypt just that 2026 encrypted session key field, using CFB mode with an IV of all zeros. 2027 The decryption result consists of a one-octet algorithm identifier 2028 that specifies the symmetric-key encryption algorithm used to encrypt 2029 the following Symmetrically Encrypted Data packet, followed by the 2030 session key octets themselves. 2032 Note: because an all-zero IV is used for this decryption, the S2K 2033 specifier MUST use a salt value, either a Salted S2K or an Iterated- 2034 Salted S2K. The salt value will ensure that the decryption key is 2035 not repeated even if the passphrase is reused. 2037 5.4. One-Pass Signature Packets (Tag 4) 2039 The One-Pass Signature packet precedes the signed data and contains 2040 enough information to allow the receiver to begin calculating any 2041 hashes needed to verify the signature. It allows the Signature 2042 packet to be placed at the end of the message, so that the signer can 2043 compute the entire signed message in one pass. 2045 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 2047 The body of this packet consists of: 2049 * A one-octet version number. The current version is 3. 2051 * A one-octet signature type. Signature types are described in 2052 Section 5.2.1. 2054 * A one-octet number describing the hash algorithm used. 2056 * A one-octet number describing the public-key algorithm used. 2058 * An eight-octet number holding the Key ID of the signing key. 2060 * A one-octet number holding a flag showing whether the signature is 2061 nested. A zero value indicates that the next packet is another 2062 One-Pass Signature packet that describes another signature to be 2063 applied to the same message data. 2065 Note that if a message contains more than one one-pass signature, 2066 then the Signature packets bracket the message; that is, the first 2067 Signature packet after the message corresponds to the last one-pass 2068 packet and the final Signature packet corresponds to the first one- 2069 pass packet. 2071 5.5. Key Material Packet 2073 A key material packet contains all the information about a public or 2074 private key. There are four variants of this packet type, and two 2075 major versions. Consequently, this section is complex. 2077 5.5.1. Key Packet Variants 2079 5.5.1.1. Public-Key Packet (Tag 6) 2081 A Public-Key packet starts a series of packets that forms an OpenPGP 2082 key (sometimes called an OpenPGP certificate). 2084 5.5.1.2. Public-Subkey Packet (Tag 14) 2086 A Public-Subkey packet (tag 14) has exactly the same format as a 2087 Public-Key packet, but denotes a subkey. One or more subkeys may be 2088 associated with a top-level key. By convention, the top-level key 2089 provides signature services, and the subkeys provide encryption 2090 services. 2092 Note: in PGP version 2.6, tag 14 was intended to indicate a comment 2093 packet. This tag was selected for reuse because no previous version 2094 of PGP ever emitted comment packets but they did properly ignore 2095 them. Public-Subkey packets are ignored by PGP version 2.6 and do 2096 not cause it to fail, providing a limited degree of backward 2097 compatibility. 2099 5.5.1.3. Secret-Key Packet (Tag 5) 2101 A Secret-Key packet contains all the information that is found in a 2102 Public-Key packet, including the public-key material, but also 2103 includes the secret-key material after all the public-key fields. 2105 5.5.1.4. Secret-Subkey Packet (Tag 7) 2107 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2108 packet and has exactly the same format. 2110 5.5.2. Public-Key Packet Formats 2112 There are two versions of key-material packets. Version 3 packets 2113 were first generated by PGP version 2.6. Version 4 keys first 2114 appeared in PGP 5 and are the preferred key version for OpenPGP. 2116 OpenPGP implementations MUST create keys with version 4 format. V3 2117 keys are deprecated; an implementation MUST NOT generate a V3 key, 2118 but MAY accept it. 2120 A version 3 public key or public-subkey packet contains: 2122 * A one-octet version number (3). 2124 * A four-octet number denoting the time that the key was created. 2126 * A two-octet number denoting the time in days that this key is 2127 valid. If this number is zero, then it does not expire. 2129 * A one-octet number denoting the public-key algorithm of this key. 2131 * A series of multiprecision integers comprising the key material: 2133 - a multiprecision integer (MPI) of RSA public modulus n; 2135 - an MPI of RSA public encryption exponent e. 2137 V3 keys are deprecated. They contain three weaknesses. First, it is 2138 relatively easy to construct a V3 key that has the same Key ID as any 2139 other key because the Key ID is simply the low 64 bits of the public 2140 modulus. Secondly, because the fingerprint of a V3 key hashes the 2141 key material, but not its length, there is an increased opportunity 2142 for fingerprint collisions. Third, there are weaknesses in the MD5 2143 hash algorithm that make developers prefer other algorithms. See 2144 below for a fuller discussion of Key IDs and fingerprints. 2146 V2 keys are identical to the deprecated V3 keys except for the 2147 version number. An implementation MUST NOT generate them and MAY 2148 accept or reject them as it sees fit. 2150 The version 4 format is similar to the version 3 format except for 2151 the absence of a validity period. This has been moved to the 2152 Signature packet. In addition, fingerprints of version 4 keys are 2153 calculated differently from version 3 keys, as described in 2154 Section 12. 2156 A version 4 packet contains: 2158 * A one-octet version number (4). 2160 * A four-octet number denoting the time that the key was created. 2162 * A one-octet number denoting the public-key algorithm of this key. 2164 * A series of multiprecision integers comprising the key material. 2165 This is algorithm-specific and described in Section 5.6. 2167 5.5.3. Secret-Key Packet Formats 2169 The Secret-Key and Secret-Subkey packets contain all the data of the 2170 Public-Key and Public-Subkey packets, with additional algorithm- 2171 specific secret-key data appended, usually in encrypted form. 2173 The packet contains: 2175 * A Public-Key or Public-Subkey packet, as described above. 2177 * One octet indicating string-to-key usage conventions. Zero 2178 indicates that the secret-key data is not encrypted. 255 or 254 2179 indicates that a string-to-key specifier is being given. Any 2180 other value is a symmetric-key encryption algorithm identifier. 2182 * [Optional] If string-to-key usage octet was 255 or 254, a one- 2183 octet symmetric encryption algorithm. 2185 * [Optional] If string-to-key usage octet was 255 or 254, a string- 2186 to-key specifier. The length of the string-to-key specifier is 2187 implied by its type, as described above. 2189 * [Optional] If secret data is encrypted (string-to-key usage octet 2190 not zero), an Initial Vector (IV) of the same length as the 2191 cipher's block size. 2193 * Plain or encrypted multiprecision integers comprising the secret 2194 key data. This is algorithm-specific and described in section 2195 Section 5.6. 2197 * If the string-to-key usage octet is zero or 255, then a two-octet 2198 checksum of the plaintext of the algorithm-specific portion (sum 2199 of all octets, mod 65536). If the string-to-key usage octet was 2200 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2201 specific portion. This checksum or hash is encrypted together 2202 with the algorithm-specific fields (if string-to-key usage octet 2203 is not zero). Note that for all other values, a two-octet 2204 checksum is required. 2206 Secret MPI values can be encrypted using a passphrase. If a string- 2207 to-key specifier is given, that describes the algorithm for 2208 converting the passphrase to a key, else a simple MD5 hash of the 2209 passphrase is used. Implementations MUST use a string-to-key 2210 specifier; the simple hash is for backward compatibility and is 2211 deprecated, though implementations MAY continue to use existing 2212 private keys in the old format. The cipher for encrypting the MPIs 2213 is specified in the Secret-Key packet. 2215 Encryption/decryption of the secret data is done in CFB mode using 2216 the key created from the passphrase and the Initial Vector from the 2217 packet. A different mode is used with V3 keys (which are only RSA) 2218 than with other key formats. With V3 keys, the MPI bit count prefix 2219 (i.e., the first two octets) is not encrypted. Only the MPI non- 2220 prefix data is encrypted. Furthermore, the CFB state is 2221 resynchronized at the beginning of each new MPI value, so that the 2222 CFB block boundary is aligned with the start of the MPI data. 2224 With V4 keys, a simpler method is used. All secret MPI values are 2225 encrypted in CFB mode, including the MPI bitcount prefix. 2227 The two-octet checksum that follows the algorithm-specific portion is 2228 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2229 specific octets (including MPI prefix and data). With V3 keys, the 2230 checksum is stored in the clear. With V4 keys, the checksum is 2231 encrypted like the algorithm-specific data. This value is used to 2232 check that the passphrase was correct. However, this checksum is 2233 deprecated; an implementation SHOULD NOT use it, but should rather 2234 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2235 this is that there are some attacks that involve undetectably 2236 modifying the secret key. 2238 5.6. Algorithm-specific Parts of Keys 2240 The public and secret key format specifies algorithm-specific parts 2241 of a key. The following sections describe them in detail. 2243 5.6.1. Algorithm-Specific Part for RSA Keys 2245 The public key is this series of multiprecision integers: 2247 * MPI of RSA public modulus n; 2249 * MPI of RSA public encryption exponent e. 2251 The secret key is this series of multiprecision integers: 2253 * MPI of RSA secret exponent d; 2255 * MPI of RSA secret prime value p; 2257 * MPI of RSA secret prime value q (p < q); 2259 * MPI of u, the multiplicative inverse of p, mod q. 2261 5.6.2. Algorithm-Specific Part for DSA Keys 2263 The public key is this series of multiprecision integers: 2265 * MPI of DSA prime p; 2267 * MPI of DSA group order q (q is a prime divisor of p-1); 2269 * MPI of DSA group generator g; 2271 * MPI of DSA public-key value y (= g**x mod p where x is secret). 2273 The secret key is this single multiprecision integer: 2275 * MPI of DSA secret exponent x. 2277 5.6.3. Algorithm-Specific Part for Elgamal Keys 2279 The public key is this series of multiprecision integers: 2281 * MPI of Elgamal prime p; 2283 * MPI of Elgamal group generator g; 2285 * MPI of Elgamal public key value y (= g**x mod p where x is 2286 secret). 2288 The secret key is this single multiprecision integer: 2290 * MPI of Elgamal secret exponent x. 2292 5.6.4. Algorithm-Specific Part for ECDSA Keys 2294 The public key is this series of values: 2296 * a variable-length field containing a curve OID, formatted as 2297 follows: 2299 - a one-octet size of the following field; values 0 and 0xFF are 2300 reserved for future extensions, 2302 - the octets representing a curve OID, defined in Section 9.2; 2304 * a MPI of an EC point representing a public key. 2306 The secret key is this single multiprecision integer: 2308 * MPI of an integer representing the secret key, which is a scalar 2309 of the public EC point. 2311 5.6.5. Algorithm-Specific Part for ECDH Keys 2313 The public key is this series of values: 2315 * a variable-length field containing a curve OID, formatted as 2316 follows: 2318 - a one-octet size of the following field; values 0 and 0xFF are 2319 reserved for future extensions, 2321 - the octets representing a curve OID, defined in Section 9.2; 2323 * a MPI of an EC point representing a public key; 2325 * a variable-length field containing KDF parameters, formatted as 2326 follows: 2328 - a one-octet size of the following fields; values 0 and 0xff are 2329 reserved for future extensions; 2331 - a one-octet value 1, reserved for future extensions; 2333 - a one-octet hash function ID used with a KDF; 2335 - a one-octet algorithm ID for the symmetric algorithm used to 2336 wrap the symmetric key used for the message encryption; see 2337 Section 13.4 for details. 2339 Observe that an ECDH public key is composed of the same sequence of 2340 fields that define an ECDSA key, plus the KDF parameters field. 2342 The secret key is this single multiprecision integer: 2344 * MPI of an integer representing the secret key, which is a scalar 2345 of the public EC point. 2347 5.7. Compressed Data Packet (Tag 8) 2349 The Compressed Data packet contains compressed data. Typically, this 2350 packet is found as the contents of an encrypted packet, or following 2351 a Signature or One-Pass Signature packet, and contains a literal data 2352 packet. 2354 The body of this packet consists of: 2356 * One octet that gives the algorithm used to compress the packet. 2358 * Compressed data, which makes up the remainder of the packet. 2360 A Compressed Data Packet's body contains an block that compresses 2361 some set of packets. See Section 11 for details on how messages are 2362 formed. 2364 ZIP-compressed packets are compressed with raw [RFC1951] DEFLATE 2365 blocks. Note that PGP V2.6 uses 13 bits of compression. If an 2366 implementation uses more bits of compression, PGP V2.6 cannot 2367 decompress it. 2369 ZLIB-compressed packets are compressed with [RFC1950] ZLIB-style 2370 blocks. 2372 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2373 algorithm. 2375 5.8. Symmetrically Encrypted Data Packet (Tag 9) 2377 The Symmetrically Encrypted Data packet contains data encrypted with 2378 a symmetric-key algorithm. When it has been decrypted, it contains 2379 other packets (usually a literal data packet or compressed data 2380 packet, but in theory other Symmetrically Encrypted Data packets or 2381 sequences of packets that form whole OpenPGP messages). 2383 This packet is obsolete. An implementation MUST NOT create this 2384 packet. An implementation MAY process such a packet but it MUST 2385 return a clear diagnostic that a non-integrity protected packet has 2386 been processed. The implementation SHOULD also return an error in 2387 this case and stop processing. 2389 The body of this packet consists of: 2391 * Encrypted data, the output of the selected symmetric-key cipher 2392 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2394 The symmetric cipher used may be specified in a Public-Key or 2395 Symmetric-Key Encrypted Session Key packet that precedes the 2396 Symmetrically Encrypted Data packet. In that case, the cipher 2397 algorithm octet is prefixed to the session key before it is 2398 encrypted. If no packets of these types precede the encrypted data, 2399 the IDEA algorithm is used with the session key calculated as the MD5 2400 hash of the passphrase, though this use is deprecated. 2402 The data is encrypted in CFB mode, with a CFB shift size equal to the 2403 cipher's block size. The Initial Vector (IV) is specified as all 2404 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2405 equal to the block size of the cipher plus two to the data before it 2406 is encrypted. The first block-size octets (for example, 8 octets for 2407 a 64-bit block length) are random, and the following two octets are 2408 copies of the last two octets of the IV. For example, in an 8-octet 2409 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2410 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2411 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2412 in both these examples, we consider the first octet to be numbered 1. 2414 After encrypting the first block-size-plus-two octets, the CFB state 2415 is resynchronized. The last block-size octets of ciphertext are 2416 passed through the cipher and the block boundary is reset. 2418 The repetition of 16 bits in the random data prefixed to the message 2419 allows the receiver to immediately check whether the session key is 2420 incorrect. See Section 15 for hints on the proper use of this "quick 2421 check". 2423 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) 2425 An experimental version of PGP used this packet as the Literal 2426 packet, but no released version of PGP generated Literal packets with 2427 this tag. With PGP 5, this packet has been reassigned and is 2428 reserved for use as the Marker packet. 2430 The body of this packet consists of: 2432 * The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2434 Such a packet MUST be ignored when received. It may be placed at the 2435 beginning of a message that uses features not available in PGP 2436 version 2.6 in order to cause that version to report that newer 2437 software is necessary to process the message. 2439 5.10. Literal Data Packet (Tag 11) 2441 A Literal Data packet contains the body of a message; data that is 2442 not to be further interpreted. 2444 The body of this packet consists of: 2446 * A one-octet field that describes how the data is formatted. 2448 If it is a "b" (0x62), then the Literal packet contains binary 2449 data. If it is a "t" (0x74), then it contains text data, and thus 2450 may need line ends converted to local form, or other text-mode 2451 changes. The tag "u" (0x75) means the same as "t", but also 2452 indicates that implementation believes that the literal data 2453 contains UTF-8 text. 2455 Early versions of PGP also defined a value of "l" as a 'local' 2456 mode for machine-local conversions. [RFC1991] incorrectly stated 2457 this local mode flag as "1" (ASCII numeral one). Both of these 2458 local modes are deprecated. 2460 * File name as a string (one-octet length, followed by a file name). 2461 This may be a zero-length string. Commonly, if the source of the 2462 encrypted data is a file, this will be the name of the encrypted 2463 file. An implementation MAY consider the file name in the Literal 2464 packet to be a more authoritative name than the actual file name. 2466 If the special name "_CONSOLE" is used, the message is considered 2467 to be "for your eyes only". This advises that the message data is 2468 unusually sensitive, and the receiving program should process it 2469 more carefully, perhaps avoiding storing the received data to 2470 disk, for example. 2472 * A four-octet number that indicates a date associated with the 2473 literal data. Commonly, the date might be the modification date 2474 of a file, or the time the packet was created, or a zero that 2475 indicates no specific time. 2477 * The remainder of the packet is literal data. 2479 Text data is stored with text endings (i.e., network- 2480 normal line endings). These should be converted to native line 2481 endings by the receiving software. 2483 5.11. Trust Packet (Tag 12) 2485 The Trust packet is used only within keyrings and is not normally 2486 exported. Trust packets contain data that record the user's 2487 specifications of which key holders are trustworthy introducers, 2488 along with other information that implementing software uses for 2489 trust information. The format of Trust packets is defined by a given 2490 implementation. 2492 Trust packets SHOULD NOT be emitted to output streams that are 2493 transferred to other users, and they SHOULD be ignored on any input 2494 other than local keyring files. 2496 5.12. User ID Packet (Tag 13) 2498 A User ID packet consists of UTF-8 text that is intended to represent 2499 the name and email address of the key holder. By convention, it 2500 includes an [RFC2822] mail name-addr, but there are no restrictions 2501 on its content. The packet length in the header specifies the length 2502 of the User ID. 2504 5.13. User Attribute Packet (Tag 17) 2506 The User Attribute packet is a variation of the User ID packet. It 2507 is capable of storing more types of data than the User ID packet, 2508 which is limited to text. Like the User ID packet, a User Attribute 2509 packet may be certified by the key owner ("self-signed") or any other 2510 key owner who cares to certify it. Except as noted, a User Attribute 2511 packet may be used anywhere that a User ID packet may be used. 2513 While User Attribute packets are not a required part of the OpenPGP 2514 standard, implementations SHOULD provide at least enough 2515 compatibility to properly handle a certification signature on the 2516 User Attribute packet. A simple way to do this is by treating the 2517 User Attribute packet as a User ID packet with opaque contents, but 2518 an implementation may use any method desired. 2520 The User Attribute packet is made up of one or more attribute 2521 subpackets. Each subpacket consists of a subpacket header and a 2522 body. The header consists of: 2524 * the subpacket length (1, 2, or 5 octets) 2526 * the subpacket type (1 octet) 2527 and is followed by the subpacket specific data. 2529 The following table lists the currently known subpackets: 2531 +=========+===========================+ 2532 | Type | Attribute Subpacket | 2533 +=========+===========================+ 2534 | 1 | Image Attribute Subpacket | 2535 +---------+---------------------------+ 2536 | 100-110 | Private/Experimental Use | 2537 +---------+---------------------------+ 2539 Table 13: User Attribute type registry 2541 An implementation SHOULD ignore any subpacket of a type that it does 2542 not recognize. 2544 5.13.1. The Image Attribute Subpacket 2546 The Image Attribute subpacket is used to encode an image, presumably 2547 (but not required to be) that of the key owner. 2549 The Image Attribute subpacket begins with an image header. The first 2550 two octets of the image header contain the length of the image 2551 header. Note that unlike other multi-octet numerical values in this 2552 document, due to a historical accident this value is encoded as a 2553 little-endian number. The image header length is followed by a 2554 single octet for the image header version. The only currently 2555 defined version of the image header is 1, which is a 16-octet image 2556 header. The first three octets of a version 1 image header are thus 2557 0x10, 0x00, 0x01. 2559 The fourth octet of a version 1 image header designates the encoding 2560 format of the image. The only currently defined encoding format is 2561 the value 1 to indicate JPEG. Image format types 100 through 110 are 2562 reserved for private or experimental use. The rest of the version 1 2563 image header is made up of 12 reserved octets, all of which MUST be 2564 set to 0. 2566 The rest of the image subpacket contains the image itself. As the 2567 only currently defined image type is JPEG, the image is encoded in 2568 the JPEG File Interchange Format (JFIF), a standard file format for 2569 JPEG images [JFIF]. 2571 An implementation MAY try to determine the type of an image by 2572 examination of the image data if it is unable to handle a particular 2573 version of the image header or if a specified encoding format value 2574 is not recognized. 2576 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2578 The Symmetrically Encrypted Integrity Protected Data packet is a 2579 variant of the Symmetrically Encrypted Data packet. It is a new 2580 feature created for OpenPGP that addresses the problem of detecting a 2581 modification to encrypted data. It is used in combination with a 2582 Modification Detection Code packet. 2584 There is a corresponding feature in the features Signature subpacket 2585 that denotes that an implementation can properly use this packet 2586 type. An implementation MUST support decrypting these packets and 2587 SHOULD prefer generating them to the older Symmetrically Encrypted 2588 Data packet when possible. Since this data packet protects against 2589 modification attacks, this standard encourages its proliferation. 2590 While blanket adoption of this data packet would create 2591 interoperability problems, rapid adoption is nevertheless important. 2592 An implementation SHOULD specifically denote support for this packet, 2593 but it MAY infer it from other mechanisms. 2595 For example, an implementation might infer from the use of a cipher 2596 such as Advanced Encryption Standard (AES) or Twofish that a user 2597 supports this feature. It might place in the unhashed portion of 2598 another user's key signature a Features subpacket. It might also 2599 present a user with an opportunity to regenerate their own self- 2600 signature with a Features subpacket. 2602 This packet contains data encrypted with a symmetric-key algorithm 2603 and protected against modification by the SHA-1 hash algorithm. When 2604 it has been decrypted, it will typically contain other packets (often 2605 a Literal Data packet or Compressed Data packet). The last decrypted 2606 packet in this packet's payload MUST be a Modification Detection Code 2607 packet. 2609 The body of this packet consists of: 2611 * A one-octet version number. The only currently defined value is 2612 1. 2614 * Encrypted data, the output of the selected symmetric-key cipher 2615 operating in Cipher Feedback mode with shift amount equal to the 2616 block size of the cipher (CFB-n where n is the block size). 2618 The symmetric cipher used MUST be specified in a Public-Key or 2619 Symmetric-Key Encrypted Session Key packet that precedes the 2620 Symmetrically Encrypted Data packet. In either case, the cipher 2621 algorithm octet is prefixed to the session key before it is 2622 encrypted. 2624 The data is encrypted in CFB mode, with a CFB shift size equal to the 2625 cipher's block size. The Initial Vector (IV) is specified as all 2626 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2627 the data before it is encrypted. The length of the octet string 2628 equals the block size of the cipher in octets, plus two. The first 2629 octets in the group, of length equal to the block size of the cipher, 2630 are random; the last two octets are each copies of their 2nd 2631 preceding octet. For example, with a cipher whose block size is 128 2632 bits or 16 octets, the prefix data will contain 16 random octets, 2633 then two more octets, which are copies of the 15th and 16th octets, 2634 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2635 special CFB resynchronization is done after encrypting this prefix 2636 data. See Section 14.9 for more details. 2638 The repetition of 16 bits in the random data prefixed to the message 2639 allows the receiver to immediately check whether the session key is 2640 incorrect. 2642 The plaintext of the data to be encrypted is passed through the SHA-1 2643 hash function, and the result of the hash is appended to the 2644 plaintext in a Modification Detection Code packet. The input to the 2645 hash function includes the prefix data described above; it includes 2646 all of the plaintext, and then also includes two octets of values 2647 0xD3, 0x14. These represent the encoding of a Modification Detection 2648 Code packet tag and length field of 20 octets. 2650 The resulting hash value is stored in a Modification Detection Code 2651 (MDC) packet, which MUST use the two octet encoding just given to 2652 represent its tag and length field. The body of the MDC packet is 2653 the 20-octet output of the SHA-1 hash. 2655 The Modification Detection Code packet is appended to the plaintext 2656 and encrypted along with the plaintext using the same CFB context. 2658 During decryption, the plaintext data should be hashed with SHA-1, 2659 including the prefix data as well as the packet tag and length field 2660 of the Modification Detection Code packet. The body of the MDC 2661 packet, upon decryption, is compared with the result of the SHA-1 2662 hash. 2664 Any failure of the MDC indicates that the message has been modified 2665 and MUST be treated as a security problem. Failures include a 2666 difference in the hash values, but also the absence of an MDC packet, 2667 or an MDC packet in any position other than the end of the plaintext. 2668 Any failure SHOULD be reported to the user. 2670 Note: future designs of new versions of this packet should consider 2671 rollback attacks since it will be possible for an attacker to change 2672 the version back to 1. 2674 NON-NORMATIVE EXPLANATION 2676 The MDC system, as packets 18 and 19 are called, were created to 2677 provide an integrity mechanism that is less strong than a 2678 signature, yet stronger than bare CFB encryption. 2680 It is a limitation of CFB encryption that damage to the ciphertext 2681 will corrupt the affected cipher blocks and the block following. 2682 Additionally, if data is removed from the end of a CFB-encrypted 2683 block, that removal is undetectable. (Note also that CBC mode has 2684 a similar limitation, but data removed from the front of the block 2685 is undetectable.) 2687 The obvious way to protect or authenticate an encrypted block is 2688 to digitally sign it. However, many people do not wish to 2689 habitually sign data, for a large number of reasons beyond the 2690 scope of this document. Suffice it to say that many people 2691 consider properties such as deniability to be as valuable as 2692 integrity. 2694 OpenPGP addresses this desire to have more security than raw 2695 encryption and yet preserve deniability with the MDC system. An 2696 MDC is intentionally not a MAC. Its name was not selected by 2697 accident. It is analogous to a checksum. 2699 Despite the fact that it is a relatively modest system, it has 2700 proved itself in the real world. It is an effective defense to 2701 several attacks that have surfaced since it has been created. It 2702 has met its modest goals admirably. 2704 Consequently, because it is a modest security system, it has 2705 modest requirements on the hash function(s) it employs. It does 2706 not rely on a hash function being collision-free, it relies on a 2707 hash function being one-way. If a forger, Frank, wishes to send 2708 Alice a (digitally) unsigned message that says, "I've always 2709 secretly loved you, signed Bob", it is far easier for him to 2710 construct a new message than it is to modify anything intercepted 2711 from Bob. (Note also that if Bob wishes to communicate secretly 2712 with Alice, but without authentication or identification and with 2713 a threat model that includes forgers, he has a problem that 2714 transcends mere cryptography.) 2715 Note also that unlike nearly every other OpenPGP subsystem, there 2716 are no parameters in the MDC system. It hard-defines SHA-1 as its 2717 hash function. This is not an accident. It is an intentional 2718 choice to avoid downgrade and cross-grade attacks while making a 2719 simple, fast system. (A downgrade attack would be an attack that 2720 replaced SHA2-256 with SHA-1, for example. A cross-grade attack 2721 would replace SHA-1 with another 160-bit hash, such as RIPE- 2722 MD/160, for example.) 2724 However, given the present state of hash function cryptanalysis 2725 and cryptography, it may be desirable to upgrade the MDC system to 2726 a new hash function. See Section 14.11 for guidance. 2728 5.15. Modification Detection Code Packet (Tag 19) 2730 The Modification Detection Code packet contains a SHA-1 hash of 2731 plaintext data, which is used to detect message modification. It is 2732 only used with a Symmetrically Encrypted Integrity Protected Data 2733 packet. The Modification Detection Code packet MUST be the last 2734 packet in the plaintext data that is encrypted in the Symmetrically 2735 Encrypted Integrity Protected Data packet, and MUST appear in no 2736 other place. 2738 A Modification Detection Code packet MUST have a length of 20 octets. 2740 The body of this packet consists of: 2742 * A 20-octet SHA-1 hash of the preceding plaintext data of the 2743 Symmetrically Encrypted Integrity Protected Data packet, including 2744 prefix data, the tag octet, and length octet of the Modification 2745 Detection Code packet. 2747 Note that the Modification Detection Code packet MUST always use a 2748 new format encoding of the packet tag, and a one-octet encoding of 2749 the packet length. The reason for this is that the hashing rules for 2750 modification detection include a one-octet tag and one-octet length 2751 in the data hash. While this is a bit restrictive, it reduces 2752 complexity. 2754 6. Radix-64 Conversions 2756 As stated in the introduction, OpenPGP's underlying native 2757 representation for objects is a stream of arbitrary octets, and some 2758 systems desire these objects to be immune to damage caused by 2759 character set translation, data conversions, etc. 2761 In principle, any printable encoding scheme that met the requirements 2762 of the unsafe channel would suffice, since it would not change the 2763 underlying binary bit streams of the native OpenPGP data structures. 2764 The OpenPGP standard specifies one such printable encoding scheme to 2765 ensure interoperability. 2767 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2768 encoding of the binary data and a checksum. The base64 encoding is 2769 identical to the MIME base64 content-transfer-encoding [RFC2045]. 2771 The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to 2772 four characters of radix-64 encoding by the same MIME base64 2773 transformation, preceded by an equal sign (=). The CRC is computed 2774 by using the generator 0x864CFB and an initialization of 0xB704CE. 2775 The accumulation is done on the data before it is converted to radix- 2776 64, rather than on the converted data. A sample implementation of 2777 this algorithm is in the next section. 2779 The checksum with its leading equal sign MAY appear on the first line 2780 after the base64 encoded data. 2782 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2783 base64. The nonzero initialization can detect more errors than a 2784 zero initialization. 2786 6.1. An Implementation of the CRC-24 in "C" 2788 #define CRC24_INIT 0xB704CEL 2789 #define CRC24_POLY 0x1864CFBL 2791 typedef long crc24; 2792 crc24 crc_octets(unsigned char *octets, size_t len) 2793 { 2794 crc24 crc = CRC24_INIT; 2795 int i; 2796 while (len--) { 2797 crc ^= (*octets++) << 16; 2798 for (i = 0; i < 8; i++) { 2799 crc <<= 1; 2800 if (crc & 0x1000000) 2801 crc ^= CRC24_POLY; 2802 } 2803 } 2804 return crc & 0xFFFFFFL; 2805 } 2807 6.2. Forming ASCII Armor 2809 When OpenPGP encodes data into ASCII Armor, it puts specific headers 2810 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 2811 later. An OpenPGP implementation MAY use ASCII armor to protect raw 2812 binary data. OpenPGP informs the user what kind of data is encoded 2813 in the ASCII armor through the use of the headers. 2815 Concatenating the following data creates ASCII Armor: 2817 * An Armor Header Line, appropriate for the type of data 2819 * Armor Headers 2821 * A blank (zero-length, or containing only whitespace) line 2823 * The ASCII-Armored data 2825 * An Armor Checksum 2827 * The Armor Tail, which depends on the Armor Header Line 2829 An Armor Header Line consists of the appropriate header line text 2830 surrounded by five (5) dashes ("-", 0x2D) on either side of the 2831 header line text. The header line text is chosen based upon the type 2832 of data that is being encoded in Armor, and how it is being encoded. 2833 Header line texts include the following strings: 2835 BEGIN PGP MESSAGE 2836 Used for signed, encrypted, or compressed files. 2838 BEGIN PGP PUBLIC KEY BLOCK 2839 Used for armoring public keys. 2841 BEGIN PGP PRIVATE KEY BLOCK 2842 Used for armoring private keys. 2844 BEGIN PGP MESSAGE, PART X/Y 2845 Used for multi-part messages, where the armor is split amongst Y 2846 parts, and this is the Xth part out of Y. 2848 BEGIN PGP MESSAGE, PART X 2849 Used for multi-part messages, where this is the Xth part of an 2850 unspecified number of parts. Requires the MESSAGE-ID Armor Header 2851 to be used. 2853 BEGIN PGP SIGNATURE 2854 Used for detached signatures, OpenPGP/MIME signatures, and 2855 cleartext signatures. Note that PGP 2 uses BEGIN PGP MESSAGE for 2856 detached signatures. 2858 Note that all these Armor Header Lines are to consist of a complete 2859 line. That is to say, there is always a line ending preceding the 2860 starting five dashes, and following the ending five dashes. The 2861 header lines, therefore, MUST start at the beginning of a line, and 2862 MUST NOT have text other than whitespace following them on the same 2863 line. These line endings are considered a part of the Armor Header 2864 Line for the purposes of determining the content they delimit. This 2865 is particularly important when computing a cleartext signature (see 2866 below). 2868 The Armor Headers are pairs of strings that can give the user or the 2869 receiving OpenPGP implementation some information about how to decode 2870 or use the message. The Armor Headers are a part of the armor, not a 2871 part of the message, and hence are not protected by any signatures 2872 applied to the message. 2874 The format of an Armor Header is that of a key-value pair. A colon 2875 (":" 0x38) and a single space (0x20) separate the key and value. 2876 OpenPGP should consider improperly formatted Armor Headers to be 2877 corruption of the ASCII Armor. Unknown keys should be reported to 2878 the user, but OpenPGP should continue to process the message. 2880 Note that some transport methods are sensitive to line length. While 2881 there is a limit of 76 characters for the Radix-64 data 2882 (Section 6.3), there is no limit to the length of Armor Headers. 2883 Care should be taken that the Armor Headers are short enough to 2884 survive transport. One way to do this is to repeat an Armor Header 2885 Key multiple times with different values for each so that no one line 2886 is overly long. 2888 Currently defined Armor Header Keys are as follows: 2890 * "Version", which states the OpenPGP implementation and version 2891 used to encode the message. 2893 * "Comment", a user-defined comment. OpenPGP defines all text to be 2894 in UTF-8. A comment may be any UTF-8 string. However, the whole 2895 point of armoring is to provide seven-bit-clean data. 2896 Consequently, if a comment has characters that are outside the US- 2897 ASCII range of UTF, they may very well not survive transport. 2899 * "MessageID", a 32-character string of printable characters. The 2900 string must be the same for all parts of a multi-part message that 2901 uses the "PART X" Armor Header. MessageID strings should be 2902 unique enough that the recipient of the mail can associate all the 2903 parts of a message with each other. A good checksum or 2904 cryptographic hash function is sufficient. 2906 The MessageID SHOULD NOT appear unless it is in a multi-part 2907 message. If it appears at all, it MUST be computed from the 2908 finished (encrypted, signed, etc.) message in a deterministic 2909 fashion, rather than contain a purely random value. This is to 2910 allow the legitimate recipient to determine that the MessageID 2911 cannot serve as a covert means of leaking cryptographic key 2912 information. 2914 * "Hash", a comma-separated list of hash algorithms used in this 2915 message. This is used only in cleartext signed messages. 2917 * "Charset", a description of the character set that the plaintext 2918 is in. Please note that OpenPGP defines text to be in UTF-8. An 2919 implementation will get best results by translating into and out 2920 of UTF-8. However, there are many instances where this is easier 2921 said than done. Also, there are communities of users who have no 2922 need for UTF-8 because they are all happy with a character set 2923 like ISO Latin-5 or a Japanese character set. In such instances, 2924 an implementation MAY override the UTF-8 default by using this 2925 header key. An implementation MAY implement this key and any 2926 translations it cares to; an implementation MAY ignore it and 2927 assume all text is UTF-8. 2929 The Armor Tail Line is composed in the same manner as the Armor 2930 Header Line, except the string "BEGIN" is replaced by the string 2931 "END". 2933 6.3. Encoding Binary in Radix-64 2935 The encoding process represents 24-bit groups of input bits as output 2936 strings of 4 encoded characters. Proceeding from left to right, a 2937 24-bit input group is formed by concatenating three 8-bit input 2938 groups. These 24 bits are then treated as four concatenated 6-bit 2939 groups, each of which is translated into a single digit in the 2940 Radix-64 alphabet. When encoding a bit stream with the Radix-64 2941 encoding, the bit stream must be presumed to be ordered with the most 2942 significant bit first. That is, the first bit in the stream will be 2943 the high-order bit in the first 8-bit octet, and the eighth bit will 2944 be the low-order bit in the first 8-bit octet, and so on. 2946 ┌──first octet──┬─second octet──┬──third octet──┐ 2947 │7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│ 2948 ├───────────┬───┴───────┬───────┴───┬───────────┤ 2949 │5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│ 2950 └──1.index──┴──2.index──┴──3.index──┴──4.index──┘ 2952 Each 6-bit group is used as an index into an array of 64 printable 2953 characters from the table below. The character referenced by the 2954 index is placed in the output string. 2956 +=====+========++=====+=========++=====+==========++=====+==========+ 2957 |Value|Encoding||Value|Encoding ||Value| Encoding ||Value| Encoding | 2958 +=====+========++=====+=========++=====+==========++=====+==========+ 2959 | 0|A || 17|R || 34| i || 51| z | 2960 +-----+--------++-----+---------++-----+----------++-----+----------+ 2961 | 1|B || 18|S || 35| j || 52| 0 | 2962 +-----+--------++-----+---------++-----+----------++-----+----------+ 2963 | 2|C || 19|T || 36| k || 53| 1 | 2964 +-----+--------++-----+---------++-----+----------++-----+----------+ 2965 | 3|D || 20|U || 37| l || 54| 2 | 2966 +-----+--------++-----+---------++-----+----------++-----+----------+ 2967 | 4|E || 21|V || 38| m || 55| 3 | 2968 +-----+--------++-----+---------++-----+----------++-----+----------+ 2969 | 5|F || 22|W || 39| n || 56| 4 | 2970 +-----+--------++-----+---------++-----+----------++-----+----------+ 2971 | 6|G || 23|X || 40| o || 57| 5 | 2972 +-----+--------++-----+---------++-----+----------++-----+----------+ 2973 | 7|H || 24|Y || 41| p || 58| 6 | 2974 +-----+--------++-----+---------++-----+----------++-----+----------+ 2975 | 8|I || 25|Z || 42| q || 59| 7 | 2976 +-----+--------++-----+---------++-----+----------++-----+----------+ 2977 | 9|J || 26|a || 43| r || 60| 8 | 2978 +-----+--------++-----+---------++-----+----------++-----+----------+ 2979 | 10|K || 27|b || 44| s || 61| 9 | 2980 +-----+--------++-----+---------++-----+----------++-----+----------+ 2981 | 11|L || 28|c || 45| t || 62| + | 2982 +-----+--------++-----+---------++-----+----------++-----+----------+ 2983 | 12|M || 29|d || 46| u || 63| / | 2984 +-----+--------++-----+---------++-----+----------++-----+----------+ 2985 | 13|N || 30|e || 47| v || | | 2986 +-----+--------++-----+---------++-----+----------++-----+----------+ 2987 | 14|O || 31|f || 48| w ||(pad)| = | 2988 +-----+--------++-----+---------++-----+----------++-----+----------+ 2989 | 15|P || 32|g || 49| x || | | 2990 +-----+--------++-----+---------++-----+----------++-----+----------+ 2991 | 16|Q || 33|h || 50| y || | | 2992 +-----+--------++-----+---------++-----+----------++-----+----------+ 2994 Table 14: Encoding for Radix-64 2996 The encoded output stream must be represented in lines of no more 2997 than 76 characters each. 2999 Special processing is performed if fewer than 24 bits are available 3000 at the end of the data being encoded. There are three possibilities: 3002 1. The last data group has 24 bits (3 octets). No special 3003 processing is needed. 3005 2. The last data group has 16 bits (2 octets). The first two 6-bit 3006 groups are processed as above. The third (incomplete) data group 3007 has two zero-value bits added to it, and is processed as above. 3008 A pad character (=) is added to the output. 3010 3. The last data group has 8 bits (1 octet). The first 6-bit group 3011 is processed as above. The second (incomplete) data group has 3012 four zero-value bits added to it, and is processed as above. Two 3013 pad characters (=) are added to the output. 3015 6.4. Decoding Radix-64 3017 In Radix-64 data, characters other than those in the table, line 3018 breaks, and other white space probably indicate a transmission error, 3019 about which a warning message or even a message rejection might be 3020 appropriate under some circumstances. Decoding software must ignore 3021 all white space. 3023 Because it is used only for padding at the end of the data, the 3024 occurrence of any "=" characters may be taken as evidence that the 3025 end of the data has been reached (without truncation in transit). No 3026 such assurance is possible, however, when the number of octets 3027 transmitted was a multiple of three and no "=" characters are 3028 present. 3030 6.5. Examples of Radix-64 3031 Input data: 0x14FB9C03D97E 3032 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 3033 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 3034 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 3035 Decimal: 5 15 46 28 0 61 37 62 3036 Output: F P u c A 9 l + 3037 Input data: 0x14FB9C03D9 3038 Hex: 1 4 F B 9 C | 0 3 D 9 3039 8-bit: 00010100 11111011 10011100 | 00000011 11011001 3040 pad with 00 3041 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 3042 Decimal: 5 15 46 28 0 61 36 3043 pad with = 3044 Output: F P u c A 9 k = 3045 Input data: 0x14FB9C03 3046 Hex: 1 4 F B 9 C | 0 3 3047 8-bit: 00010100 11111011 10011100 | 00000011 3048 pad with 0000 3049 6-bit: 000101 001111 101110 011100 | 000000 110000 3050 Decimal: 5 15 46 28 0 48 3051 pad with = = 3052 Output: F P u c A w = = 3054 6.6. Example of an ASCII Armored Message 3056 -----BEGIN PGP MESSAGE----- 3057 Version: OpenPrivacy 0.99 3059 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3060 vBSFjNSiVHsuAA== 3061 =njUN 3062 -----END PGP MESSAGE----- 3064 Note that this example has extra indenting; an actual armored message 3065 would have no leading whitespace. 3067 7. Cleartext Signature Framework 3069 It is desirable to be able to sign a textual octet stream without 3070 ASCII armoring the stream itself, so the signed text is still 3071 readable without special software. In order to bind a signature to 3072 such a cleartext, this framework is used, which follows the same 3073 basic format and restrictions as the ASCII armoring described in 3074 Section 6.2. (Note that this framework is not intended to be 3075 reversible. [RFC3156] defines another way to sign cleartext messages 3076 for environments that support MIME.) 3078 The cleartext signed message consists of: 3080 * The cleartext header "-----BEGIN PGP SIGNED MESSAGE-----" on a 3081 single line, 3083 * One or more "Hash" Armor Headers, 3085 * Exactly one empty line not included into the message digest, 3087 * The dash-escaped cleartext that is included into the message 3088 digest, 3090 * The ASCII armored signature(s) including the "-----BEGIN PGP 3091 SIGNATURE-----" Armor Header and Armor Tail Lines. 3093 If the "Hash" Armor Header is given, the specified message digest 3094 algorithm(s) are used for the signature. If there are no such 3095 headers, MD5 is used. If MD5 is the only hash used, then an 3096 implementation MAY omit this header for improved V2.x compatibility. 3097 If more than one message digest is used in the signature, the "Hash" 3098 armor header contains a comma-delimited list of used message digests. 3100 Current message digest names are described below with the algorithm 3101 IDs. 3103 An implementation SHOULD add a line break after the cleartext, but 3104 MAY omit it if the cleartext ends with a line break. This is for 3105 visual clarity. 3107 7.1. Dash-Escaped Text 3109 The cleartext content of the message must also be dash-escaped. 3111 Dash-escaped cleartext is the ordinary cleartext where every line 3112 starting with a dash "-" (0x2D) is prefixed by the sequence dash "-" 3113 (0x2D) and space ` ` (0x20). This prevents the parser from 3114 recognizing armor headers of the cleartext itself. An implementation 3115 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3116 followed by a space, and MUST dash-escape any line commencing in a 3117 dash. The message digest is computed using the cleartext itself, not 3118 the dash-escaped form. 3120 As with binary signatures on text documents, a cleartext signature is 3121 calculated on the text using canonical line endings. The 3122 line ending (i.e., the ) before the "-----BEGIN PGP 3123 SIGNATURE-----" line that terminates the signed text is not 3124 considered part of the signed text. 3126 When reversing dash-escaping, an implementation MUST strip the string 3127 "-" if it occurs at the beginning of a line, and SHOULD warn on "-" 3128 and any character other than a space at the beginning of a line. 3130 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 3131 the end of any line is removed when the cleartext signature is 3132 generated. 3134 8. Regular Expressions 3136 A regular expression is zero or more branches, separated by "|". It 3137 matches anything that matches one of the branches. 3139 A branch is zero or more pieces, concatenated. It matches a match 3140 for the first, followed by a match for the second, etc. 3142 A piece is an atom possibly followed by "*", "+", or "?". An atom 3143 followed by "*" matches a sequence of 0 or more matches of the atom. 3144 An atom followed by "+" matches a sequence of 1 or more matches of 3145 the atom. An atom followed by "?" matches a match of the atom, or 3146 the null string. 3148 An atom is a regular expression in parentheses (matching a match for 3149 the regular expression), a range (see below), "." (matching any 3150 single character), "^" (matching the null string at the beginning of 3151 the input string), "$" (matching the null string at the end of the 3152 input string), a "\" followed by a single character (matching that 3153 character), or a single character with no other significance 3154 (matching that character). 3156 A range is a sequence of characters enclosed in "[]". It normally 3157 matches any single character from the sequence. If the sequence 3158 begins with "^", it matches any single character not from the rest of 3159 the sequence. If two characters in the sequence are separated by 3160 "-", this is shorthand for the full list of ASCII characters between 3161 them (e.g., "[0-9]" matches any decimal digit). To include a literal 3162 "]" in the sequence, make it the first character (following a 3163 possible "^"). To include a literal "-", make it the first or last 3164 character. 3166 9. Constants 3168 This section describes the constants used in OpenPGP. 3170 Note that these tables are not exhaustive lists; an implementation 3171 MAY implement an algorithm not on these lists, so long as the 3172 algorithm numbers are chosen from the private or experimental 3173 algorithm range. 3175 See Section 14 for more discussion of the algorithms. 3177 9.1. Public-Key Algorithms 3179 +========+===================================================+ 3180 | ID | Algorithm | 3181 +========+===================================================+ 3182 | 1 | RSA (Encrypt or Sign) [HAC] | 3183 +--------+---------------------------------------------------+ 3184 | 2 | RSA Encrypt-Only [HAC] | 3185 +--------+---------------------------------------------------+ 3186 | 3 | RSA Sign-Only [HAC] | 3187 +--------+---------------------------------------------------+ 3188 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3189 +--------+---------------------------------------------------+ 3190 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3191 +--------+---------------------------------------------------+ 3192 | 18 | ECDH public key algorithm | 3193 +--------+---------------------------------------------------+ 3194 | 19 | ECDSA public key algorithm [FIPS186] | 3195 +--------+---------------------------------------------------+ 3196 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3197 +--------+---------------------------------------------------+ 3198 | 21 | Reserved for Diffie-Hellman (X9.42, as defined | 3199 | | for IETF-S/MIME) | 3200 +--------+---------------------------------------------------+ 3201 | 22 | Reserved (EdDSA) | 3202 +--------+---------------------------------------------------+ 3203 | 23 | Reserved (AEDH) | 3204 +--------+---------------------------------------------------+ 3205 | 24 | Reserved (AEDSA) | 3206 +--------+---------------------------------------------------+ 3207 | 100 to | Private/Experimental algorithm | 3208 | 110 | | 3209 +--------+---------------------------------------------------+ 3211 Table 15: Public-key algorithm registry 3213 Implementations MUST implement DSA for signatures, and Elgamal for 3214 encryption. Implementations SHOULD implement RSA keys (1). RSA 3215 Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD NOT 3216 be generated, but may be interpreted. See Section 14.5. See 3217 Section 14.8 for notes on Elgamal Encrypt or Sign (20), and X9.42 3218 (21). Implementations MAY implement any other algorithm. 3220 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3221 Signatures" and in [SEC1]; ECDH is defined in Section 13.4 this 3222 document. 3224 9.2. ECC Curve OID 3226 The parameter curve OID is an array of octets that define a named 3227 curve. The table below specifies the exact sequence of bytes for 3228 each named curve referenced in this document: 3230 +========================+=====+=================+============+ 3231 | ASN.1 Object | OID | Curve OID bytes | Curve name | 3232 | Identifier | len | in hexadecimal | | 3233 | | | representation | | 3234 +========================+=====+=================+============+ 3235 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | 3236 | | | 03 01 07 | | 3237 +------------------------+-----+-----------------+------------+ 3238 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | 3239 +------------------------+-----+-----------------+------------+ 3240 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | 3241 +------------------------+-----+-----------------+------------+ 3242 | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | 3243 | | | 97 55 01 05 01 | | 3244 +------------------------+-----+-----------------+------------+ 3246 Table 16: ECC Curve OID registry 3248 The sequence of octets in the third column is the result of applying 3249 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3250 with subsequent truncation. The truncation removes the two fields of 3251 encoded Object Identifier. The first omitted field is one octet 3252 representing the Object Identifier tag, and the second omitted field 3253 is the length of the Object Identifier body. For example, the 3254 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3255 86 48 CE 3D 03 01 07", from which the first entry in the table above 3256 is constructed by omitting the first two octets. Only the truncated 3257 sequence of octets is the valid representation of a curve OID. 3259 9.3. Symmetric-Key Algorithms 3261 +========+=======================================+ 3262 | ID | Algorithm | 3263 +========+=======================================+ 3264 | 0 | Plaintext or unencrypted data | 3265 +--------+---------------------------------------+ 3266 | 1 | IDEA [IDEA] | 3267 +--------+---------------------------------------+ 3268 | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] | 3269 | | - 168 bit key derived from 192) | 3270 +--------+---------------------------------------+ 3271 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3272 +--------+---------------------------------------+ 3273 | 4 | Blowfish (128 bit key, 16 rounds) | 3274 | | [BLOWFISH] | 3275 +--------+---------------------------------------+ 3276 | 5 | Reserved | 3277 +--------+---------------------------------------+ 3278 | 6 | Reserved | 3279 +--------+---------------------------------------+ 3280 | 7 | AES with 128-bit key [AES] | 3281 +--------+---------------------------------------+ 3282 | 8 | AES with 192-bit key | 3283 +--------+---------------------------------------+ 3284 | 9 | AES with 256-bit key | 3285 +--------+---------------------------------------+ 3286 | 10 | Twofish with 256-bit key [TWOFISH] | 3287 +--------+---------------------------------------+ 3288 | 11 | Camellia with 128-bit key [RFC3713] | 3289 +--------+---------------------------------------+ 3290 | 12 | Camellia with 192-bit key | 3291 +--------+---------------------------------------+ 3292 | 13 | Camellia with 256-bit key | 3293 +--------+---------------------------------------+ 3294 | 100 to | Private/Experimental algorithm | 3295 | 110 | | 3296 +--------+---------------------------------------+ 3298 Table 17: Symmetric-key algorithm registry 3300 Implementations MUST implement TripleDES. Implementations SHOULD 3301 implement AES-128 and CAST5. Implementations that interoperate with 3302 PGP 2.6 or earlier need to support IDEA, as that is the only 3303 symmetric cipher those versions use. Implementations MAY implement 3304 any other algorithm. 3306 9.4. Compression Algorithms 3308 +============+================================+ 3309 | ID | Algorithm | 3310 +============+================================+ 3311 | 0 | Uncompressed | 3312 +------------+--------------------------------+ 3313 | 1 | ZIP [RFC1951] | 3314 +------------+--------------------------------+ 3315 | 2 | ZLIB [RFC1950] | 3316 +------------+--------------------------------+ 3317 | 3 | BZip2 [BZ2] | 3318 +------------+--------------------------------+ 3319 | 100 to 110 | Private/Experimental algorithm | 3320 +------------+--------------------------------+ 3322 Table 18: Compression algorithm registry 3324 Implementations MUST implement uncompressed data. Implementations 3325 SHOULD implement ZIP. Implementations MAY implement any other 3326 algorithm. 3328 9.5. Hash Algorithms 3330 +============+================================+=============+ 3331 | ID | Algorithm | Text Name | 3332 +============+================================+=============+ 3333 | 1 | MD5 [HAC] | "MD5" | 3334 +------------+--------------------------------+-------------+ 3335 | 2 | SHA-1 [FIPS180] | "SHA1" | 3336 +------------+--------------------------------+-------------+ 3337 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3338 +------------+--------------------------------+-------------+ 3339 | 4 | Reserved | | 3340 +------------+--------------------------------+-------------+ 3341 | 5 | Reserved | | 3342 +------------+--------------------------------+-------------+ 3343 | 6 | Reserved | | 3344 +------------+--------------------------------+-------------+ 3345 | 7 | Reserved | | 3346 +------------+--------------------------------+-------------+ 3347 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3348 +------------+--------------------------------+-------------+ 3349 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3350 +------------+--------------------------------+-------------+ 3351 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3352 +------------+--------------------------------+-------------+ 3353 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3354 +------------+--------------------------------+-------------+ 3355 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3356 +------------+--------------------------------+-------------+ 3357 | 13 | Reserved | | 3358 +------------+--------------------------------+-------------+ 3359 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3360 +------------+--------------------------------+-------------+ 3361 | 100 to 110 | Private/Experimental algorithm | | 3362 +------------+--------------------------------+-------------+ 3364 Table 19: Hash algorithm registry 3366 Implementations MUST implement SHA-1. Implementations MAY implement 3367 other algorithms. MD5 is deprecated. 3369 10. IANA Considerations 3371 OpenPGP is highly parameterized, and consequently there are a number 3372 of considerations for allocating parameters for extensions. This 3373 section describes how IANA should look at extensions to the protocol 3374 as described in this document. 3376 10.1. New String-to-Key Specifier Types 3378 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3379 a string into a key. This specification creates a registry of S2K 3380 specifier types. The registry includes the S2K type, the name of the 3381 S2K, and a reference to the defining specification. The initial 3382 values for this registry can be found in Section 3.7.1. Adding a new 3383 S2K specifier MUST be done through the SPECIFICATION REQUIRED method, 3384 as described in [RFC8126]. 3386 10.2. New Packets 3388 Major new features of OpenPGP are defined through new packet types. 3389 This specification creates a registry of packet types. The registry 3390 includes the packet type, the name of the packet, and a reference to 3391 the defining specification. The initial values for this registry can 3392 be found in Section 4.3. Adding a new packet type MUST be done 3393 through the RFC REQUIRED method, as described in [RFC8126]. 3395 10.2.1. User Attribute Types 3397 The User Attribute packet permits an extensible mechanism for other 3398 types of certificate identification. This specification creates a 3399 registry of User Attribute types. The registry includes the User 3400 Attribute type, the name of the User Attribute, and a reference to 3401 the defining specification. The initial values for this registry can 3402 be found in Section 5.13. Adding a new User Attribute type MUST be 3403 done through the SPECIFICATION REQUIRED method, as described in 3404 [RFC8126]. 3406 10.2.1.1. Image Format Subpacket Types 3408 Within User Attribute packets, there is an extensible mechanism for 3409 other types of image-based User Attributes. This specification 3410 creates a registry of Image Attribute subpacket types. The registry 3411 includes the Image Attribute subpacket type, the name of the Image 3412 Attribute subpacket, and a reference to the defining specification. 3413 The initial values for this registry can be found in Section 5.13.1. 3414 Adding a new Image Attribute subpacket type MUST be done through the 3415 SPECIFICATION REQUIRED method, as described in [RFC8126]. 3417 10.2.2. New Signature Subpackets 3419 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3420 to be added to them for a variety of purposes in the Signature 3421 subpackets as discussed in Section 5.2.3.1. This specification 3422 creates a registry of Signature subpacket types. The registry 3423 includes the Signature subpacket type, the name of the subpacket, and 3424 a reference to the defining specification. The initial values for 3425 this registry can be found in Section 5.2.3.1. Adding a new 3426 Signature subpacket MUST be done through the SPECIFICATION REQUIRED 3427 method, as described in [RFC8126]. 3429 10.2.2.1. Signature Notation Data Subpackets 3431 OpenPGP signatures further contain a mechanism for extensions in 3432 signatures. These are the Notation Data subpackets, which contain a 3433 key/value pair. Notations contain a user space that is completely 3434 unmanaged and an IETF space. 3436 This specification creates a registry of Signature Notation Data 3437 types. The registry includes the Signature Notation Data type, the 3438 name of the Signature Notation Data, its allowed values, and a 3439 reference to the defining specification. The initial values for this 3440 registry can be found in Section 5.2.3.16. Adding a new Signature 3441 Notation Data subpacket MUST be done through the SPECIFICATION 3442 REQUIRED method, as described in [RFC8126]. 3444 10.2.2.2. Signature Notation Data Subpacket Notation Flags 3446 This specification creates a new registry of Signature Notation Data 3447 Subpacket Notation Flags. The registry includes the columns "Flag", 3448 "Description", "Security Recommended", "Interoperability 3449 Recommended", and "Reference". Adding a new item MUST be done 3450 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 3452 10.2.2.3. Key Server Preference Extensions 3454 OpenPGP signatures contain a mechanism for preferences to be 3455 specified about key servers. This specification creates a registry 3456 of key server preferences. The registry includes the key server 3457 preference, the name of the preference, and a reference to the 3458 defining specification. The initial values for this registry can be 3459 found in Section 5.2.3.17. Adding a new key server preference MUST 3460 be done through the SPECIFICATION REQUIRED method, as described in 3461 [RFC8126]. 3463 10.2.2.4. Key Flags Extensions 3465 OpenPGP signatures contain a mechanism for flags to be specified 3466 about key usage. This specification creates a registry of key usage 3467 flags. The registry includes the key flags value, the name of the 3468 flag, and a reference to the defining specification. The initial 3469 values for this registry can be found in Section 5.2.3.21. Adding a 3470 new key usage flag MUST be done through the SPECIFICATION REQUIRED 3471 method, as described in [RFC8126]. 3473 10.2.2.5. Reason for Revocation Extensions 3475 OpenPGP signatures contain a mechanism for flags to be specified 3476 about why a key was revoked. This specification creates a registry 3477 of "Reason for Revocation" flags. The registry includes the "Reason 3478 for Revocation" flags value, the name of the flag, and a reference to 3479 the defining specification. The initial values for this registry can 3480 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3481 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 3483 10.2.2.6. Implementation Features 3485 OpenPGP signatures contain a mechanism for flags to be specified 3486 stating which optional features an implementation supports. This 3487 specification creates a registry of feature-implementation flags. 3488 The registry includes the feature-implementation flags value, the 3489 name of the flag, and a reference to the defining specification. The 3490 initial values for this registry can be found in Section 5.2.3.24. 3491 Adding a new feature-implementation flag MUST be done through the 3492 SPECIFICATION REQUIRED method, as described in [RFC8126]. 3494 Also see Section 14.12 for more information about when feature flags 3495 are needed. 3497 10.2.3. New Packet Versions 3499 The core OpenPGP packets all have version numbers, and can be revised 3500 by introducing a new version of an existing packet. This 3501 specification creates a registry of packet types. The registry 3502 includes the packet type, the number of the version, and a reference 3503 to the defining specification. The initial values for this registry 3504 can be found in Section 5. Adding a new packet version MUST be done 3505 through the RFC REQUIRED method, as described in [RFC8126]. 3507 10.3. New Algorithms 3509 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3510 new algorithm is usually simple. For example, adding in a new 3511 symmetric cipher usually would not need anything more than allocating 3512 a constant for that cipher. If that cipher had other than a 64-bit 3513 or 128-bit block size, there might need to be additional 3514 documentation describing how OpenPGP-CFB mode would be adjusted. 3515 Similarly, when DSA was expanded from a maximum of 1024-bit public 3516 keys to 3072-bit public keys, the revision of FIPS 186 contained 3517 enough information itself to allow implementation. Changes to this 3518 document were made mainly for emphasis. 3520 10.3.1. Public-Key Algorithms 3522 OpenPGP specifies a number of public-key algorithms. This 3523 specification creates a registry of public-key algorithm identifiers. 3524 The registry includes the algorithm name, its key sizes and 3525 parameters, and a reference to the defining specification. The 3526 initial values for this registry can be found in Section 9.1. Adding 3527 a new public-key algorithm MUST be done through the SPECIFICATION 3528 REQUIRED method, as described in [RFC8126]. 3530 10.3.2. Symmetric-Key Algorithms 3532 OpenPGP specifies a number of symmetric-key algorithms. This 3533 specification creates a registry of symmetric-key algorithm 3534 identifiers. The registry includes the algorithm name, its key sizes 3535 and block size, and a reference to the defining specification. The 3536 initial values for this registry can be found in Section 9.3. Adding 3537 a new symmetric-key algorithm MUST be done through the SPECIFICATION 3538 REQUIRED method, as described in [RFC8126]. 3540 10.3.3. Hash Algorithms 3542 OpenPGP specifies a number of hash algorithms. This specification 3543 creates a registry of hash algorithm identifiers. The registry 3544 includes the algorithm name, a text representation of that name, its 3545 block size, an OID hash prefix, and a reference to the defining 3546 specification. The initial values for this registry can be found in 3547 Section 9.5 for the algorithm identifiers and text names, and 3548 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3549 new hash algorithm MUST be done through the SPECIFICATION REQUIRED 3550 method, as described in [RFC8126]. 3552 This document requests IANA register the following hash algorithms: 3554 +====+===========+===========+ 3555 | ID | Algorithm | Reference | 3556 +====+===========+===========+ 3557 | 12 | SHA3-256 | This doc | 3558 +----+-----------+-----------+ 3559 | 13 | Reserved | | 3560 +----+-----------+-----------+ 3561 | 14 | SHA3-512 | This doc | 3562 +----+-----------+-----------+ 3564 Table 20: New hash 3565 algorithms registered 3567 [Notes to RFC-Editor: Please remove the table above on publication. 3568 It is desirable not to reuse old or reserved algorithms because some 3569 existing tools might print a wrong description. The ID 13 has been 3570 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 3571 counterparts.] 3573 10.3.4. Compression Algorithms 3575 OpenPGP specifies a number of compression algorithms. This 3576 specification creates a registry of compression algorithm 3577 identifiers. The registry includes the algorithm name and a 3578 reference to the defining specification. The initial values for this 3579 registry can be found in Section 9.4. Adding a new compression key 3580 algorithm MUST be done through the SPECIFICATION REQUIRED method, as 3581 described in [RFC8126]. 3583 11. Packet Composition 3585 OpenPGP packets are assembled into sequences in order to create 3586 messages and to transfer keys. Not all possible packet sequences are 3587 meaningful and correct. This section describes the rules for how 3588 packets should be placed into sequences. 3590 11.1. Transferable Public Keys 3592 OpenPGP users may transfer public keys. The essential elements of a 3593 transferable public key are as follows: 3595 * One Public-Key packet 3597 * Zero or more revocation signatures 3599 * One or more User ID packets 3600 * After each User ID packet, zero or more Signature packets 3601 (certifications) 3603 * Zero or more User Attribute packets 3605 * After each User Attribute packet, zero or more Signature packets 3606 (certifications) 3608 * Zero or more Subkey packets 3610 * After each Subkey packet, one Signature packet, plus optionally a 3611 revocation 3613 The Public-Key packet occurs first. Each of the following User ID 3614 packets provides the identity of the owner of this public key. If 3615 there are multiple User ID packets, this corresponds to multiple 3616 means of identifying the same unique individual user; for example, a 3617 user may have more than one email address, and construct a User ID 3618 for each one. 3620 Immediately following each User ID packet, there are zero or more 3621 Signature packets. Each Signature packet is calculated on the 3622 immediately preceding User ID packet and the initial Public-Key 3623 packet. The signature serves to certify the corresponding public key 3624 and User ID. In effect, the signer is testifying to his or her 3625 belief that this public key belongs to the user identified by this 3626 User ID. 3628 Within the same section as the User ID packets, there are zero or 3629 more User Attribute packets. Like the User ID packets, a User 3630 Attribute packet is followed by zero or more Signature packets 3631 calculated on the immediately preceding User Attribute packet and the 3632 initial Public-Key packet. 3634 User Attribute packets and User ID packets may be freely intermixed 3635 in this section, so long as the signatures that follow them are 3636 maintained on the proper User Attribute or User ID packet. 3638 After the User ID packet or Attribute packet, there may be zero or 3639 more Subkey packets. In general, subkeys are provided in cases where 3640 the top-level public key is a signature-only key. However, any V4 3641 key may have subkeys, and the subkeys may be encryption-only keys, 3642 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3643 subkeys. 3645 Each Subkey packet MUST be followed by one Signature packet, which 3646 should be a subkey binding signature issued by the top-level key. 3647 For subkeys that can issue signatures, the subkey binding signature 3648 MUST contain an Embedded Signature subpacket with a primary key 3649 binding signature (0x19) issued by the subkey on the top-level key. 3651 Subkey and Key packets may each be followed by a revocation Signature 3652 packet to indicate that the key is revoked. Revocation signatures 3653 are only accepted if they are issued by the key itself, or by a key 3654 that is authorized to issue revocations via a Revocation Key 3655 subpacket in a self-signature by the top-level key. 3657 Transferable public-key packet sequences may be concatenated to allow 3658 transferring multiple public keys in one operation. 3660 11.2. Transferable Secret Keys 3662 OpenPGP users may transfer secret keys. The format of a transferable 3663 secret key is the same as a transferable public key except that 3664 secret-key and secret-subkey packets are used instead of the public 3665 key and public-subkey packets. Implementations SHOULD include self- 3666 signatures on any User IDs and subkeys, as this allows for a complete 3667 public key to be automatically extracted from the transferable secret 3668 key. Implementations MAY choose to omit the self-signatures, 3669 especially if a transferable public key accompanies the transferable 3670 secret key. 3672 11.3. OpenPGP Messages 3674 An OpenPGP message is a packet or sequence of packets that 3675 corresponds to the following grammatical rules (comma represents 3676 sequential composition, and vertical bar separates alternatives): 3678 OpenPGP Message :- Encrypted Message | Signed Message | Compressed 3679 Message | Literal Message. 3681 Compressed Message :- Compressed Data Packet. 3683 Literal Message :- Literal Data Packet. 3685 ESK :- Public-Key Encrypted Session Key Packet | Symmetric-Key 3686 Encrypted Session Key Packet. 3688 ESK Sequence :- ESK | ESK Sequence, ESK. 3690 Encrypted Data :- Symmetrically Encrypted Data Packet | 3691 Symmetrically Encrypted Integrity Protected Data Packet 3693 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3695 One-Pass Signed Message :- One-Pass Signature Packet, OpenPGP 3696 Message, Corresponding Signature Packet. 3698 Signed Message :- Signature Packet, OpenPGP Message | One-Pass 3699 Signed Message. 3701 In addition, decrypting a Symmetrically Encrypted Data packet or a 3702 Symmetrically Encrypted Integrity Protected Data packet as well as 3703 decompressing a Compressed Data packet must yield a valid OpenPGP 3704 Message. 3706 11.4. Detached Signatures 3708 Some OpenPGP applications use so-called "detached signatures". For 3709 example, a program bundle may contain a file, and with it a second 3710 file that is a detached signature of the first file. These detached 3711 signatures are simply a Signature packet stored separately from the 3712 data for which they are a signature. 3714 12. Enhanced Key Formats 3716 12.1. Key Structures 3718 The format of an OpenPGP V3 key is as follows. Entries in square 3719 brackets are optional and ellipses indicate repetition. 3721 RSA Public Key 3722 [Revocation Self Signature] 3723 User ID [Signature ...] 3724 [User ID [Signature ...] ...] 3726 Each signature certifies the RSA public key and the preceding User 3727 ID. The RSA public key can have many User IDs and each User ID can 3728 have many signatures. V3 keys are deprecated. Implementations MUST 3729 NOT generate new V3 keys, but MAY continue to use existing ones. 3731 The format of an OpenPGP V4 key that uses multiple public keys is 3732 similar except that the other keys are added to the end as "subkeys" 3733 of the primary key. 3735 Primary-Key 3736 [Revocation Self Signature] 3737 [Direct Key Signature...] 3738 User ID [Signature ...] 3739 [User ID [Signature ...] ...] 3740 [User Attribute [Signature ...] ...] 3741 [[Subkey [Binding-Signature-Revocation] 3742 Primary-Key-Binding-Signature] ...] 3744 A subkey always has a single signature after it that is issued using 3745 the primary key to tie the two keys together. This binding signature 3746 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3747 issue signatures MUST have a V4 binding signature due to the REQUIRED 3748 embedded primary key binding signature. 3750 In the above diagram, if the binding signature of a subkey has been 3751 revoked, the revoked key may be removed, leaving only one key. 3753 In a V4 key, the primary key MUST be a key capable of certification. 3754 The subkeys may be keys of any other type. There may be other 3755 constructions of V4 keys, too. For example, there may be a single- 3756 key RSA key in V4 format, a DSA primary key with an RSA encryption 3757 key, or RSA primary key with an Elgamal subkey, etc. 3759 It is also possible to have a signature-only subkey. This permits a 3760 primary key that collects certifications (key signatures), but is 3761 used only for certifying subkeys that are used for encryption and 3762 signatures. 3764 12.2. Key IDs and Fingerprints 3766 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3767 the public modulus of the RSA key. 3769 The fingerprint of a V3 key is formed by hashing the body (but not 3770 the two-octet length) of the MPIs that form the key material (public 3771 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3772 and MD5 are deprecated. 3774 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3775 followed by the two-octet packet length, followed by the entire 3776 Public-Key packet starting with the version field. The Key ID is the 3777 low-order 64 bits of the fingerprint. Here are the fields of the 3778 hash material, with the example of a DSA key: 3780 a.1) 0x99 (1 octet) 3782 a.2) two-octet scalar octet count of (b)-(e) 3783 b) version number = 4 (1 octet); 3785 c) timestamp of key creation (4 octets); 3787 d) algorithm (1 octet): 17 = DSA (example); 3789 e) Algorithm-specific fields. 3791 Algorithm-Specific Fields for DSA keys (example): 3793 e.1) MPI of DSA prime p; 3795 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 3797 e.3) MPI of DSA group generator g; 3799 e.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 3801 Note that it is possible for there to be collisions of Key IDs -- two 3802 different keys with the same Key ID. Note that there is a much 3803 smaller, but still non-zero, probability that two different keys have 3804 the same fingerprint. 3806 Also note that if V3 and V4 format keys share the same RSA key 3807 material, they will have different Key IDs as well as different 3808 fingerprints. 3810 Finally, the Key ID and fingerprint of a subkey are calculated in the 3811 same way as for a primary key, including the 0x99 as the first octet 3812 (even though this is not a valid packet ID for a public subkey). 3814 13. Elliptic Curve Cryptography 3816 This section descripes algorithms and parameters used with Elliptic 3817 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 3818 found in [KOBLITZ]. 3820 13.1. Supported ECC Curves 3822 This document references three named prime field curves, defined in 3823 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521". 3824 Further curve "Curve25519", defined in [RFC7748] is referenced for 3825 use with X25519 (ECDH encryption). 3827 The named curves are referenced as a sequence of bytes in this 3828 document, called throughout, curve OID. Section 9.2 describes in 3829 detail how this sequence of bytes is formed. 3831 13.2. ECDSA and ECDH Conversion Primitives 3833 This document defines the uncompressed point format for ECDSA and 3834 ECDH and a custom compression format for certain curves. The point 3835 is encoded in the Multiprecision Integer (MPI) format. 3837 For an uncompressed point the content of the MPI is: 3839 B = 04 || x || y 3841 where x and y are coordinates of the point P = (x, y), each encoded 3842 in the big-endian format and zero-padded to the adjusted underlying 3843 field size. The adjusted underlying field size is the underlying 3844 field size that is rounded up to the nearest 8-bit boundary. This 3845 encoding is compatible with the definition given in [SEC1]. 3847 For a custom compressed point the content of the MPI is: 3849 B = 40 || x 3851 where x is the x coordinate of the point P encoded to the rules 3852 defined for the specified curve. This format is used for ECDH keys 3853 based on curves expressed in Montgomery form. 3855 Therefore, the exact size of the MPI payload is 515 bits for "Curve 3856 P-256", 771 for "Curve P-384", 1059 for "Curve P-521", and 263 for 3857 Curve25519. 3859 Even though the zero point, also called the point at infinity, may 3860 occur as a result of arithmetic operations on points of an elliptic 3861 curve, it SHALL NOT appear in data structures defined in this 3862 document. 3864 If other conversion methods are defined in the future, a compliant 3865 application MUST NOT use a new format when in doubt that any 3866 recipient can support it. Consider, for example, that while both the 3867 public key and the per-recipient ECDH data structure, respectively 3868 defined in Section 5.6.5 and Section 5.1, contain an encoded point 3869 field, the format changes to the field in Section 5.1 only affect a 3870 given recipient of a given message. 3872 13.3. Key Derivation Function 3874 A key derivation function (KDF) is necessary to implement the EC 3875 encryption. The Concatenation Key Derivation Function (Approved 3876 Alternative 1) [SP800-56A] with the KDF hash function that is 3877 SHA2-256 [FIPS180] or stronger is REQUIRED. See Section 16 for the 3878 details regarding the choice of the hash function. 3880 For convenience, the synopsis of the encoding method is given below 3881 with significant simplifications attributable to the restricted 3882 choice of hash functions in this document. However, [SP800-56A] is 3883 the normative source of the definition. 3885 // Implements KDF( X, oBits, Param ); 3886 // Input: point X = (x,y) 3887 // oBits - the desired size of output 3888 // hBits - the size of output of hash function Hash 3889 // Param - octets representing the parameters 3890 // Assumes that oBits <= hBits 3891 // Convert the point X to the octet string: 3892 // ZB' = 04 || x || y 3893 // and extract the x portion from ZB' 3894 ZB = x; 3895 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 3896 return oBits leftmost bits of MB. 3898 Note that ZB in the KDF description above is the compact 3899 representation of X, defined in Section 4.2 of [RFC6090]. 3901 13.4. EC DH Algorithm (ECDH) 3903 The method is a combination of an ECC Diffie-Hellman method to 3904 establish a shared secret, a key derivation method to process the 3905 shared secret into a derived key, and a key wrapping method that uses 3906 the derived key to protect a session key used to encrypt a message. 3908 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 3909 be implemented with the following restrictions: the ECC CDH primitive 3910 employed by this method is modified to always assume the cofactor as 3911 1, the KDF specified in Section 13.3 is used, and the KDF parameters 3912 specified below are used. 3914 The KDF parameters are encoded as a concatenation of the following 5 3915 variable-length and fixed-length fields, compatible with the 3916 definition of the OtherInfo bitstring [SP800-56A]: 3918 * a variable-length field containing a curve OID, formatted as 3919 follows: 3921 - a one-octet size of the following field 3923 - the octets representing a curve OID, defined in Section 9.2 3925 * a one-octet public key algorithm ID defined in Section 9.1 3926 * a variable-length field containing KDF parameters, identical to 3927 the corresponding field in the ECDH public key, formatted as 3928 follows: 3930 - a one-octet size of the following fields; values 0 and 0xff are 3931 reserved for future extensions 3933 - a one-octet value 01, reserved for future extensions 3935 - a one-octet hash function ID used with the KDF 3937 - a one-octet algorithm ID for the symmetric algorithm used to 3938 wrap the symmetric key for message encryption; see Section 13.4 3939 for details 3941 * 20 octets representing the UTF-8 encoding of the string "Anonymous 3942 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 3943 73 20 53 65 6E 64 65 72 20 20 20 20 3945 * 20 octets representing a recipient encryption subkey or a master 3946 key fingerprint, identifying the key material that is needed for 3947 the decryption. For version 5 keys the 20 leftmost octets of the 3948 fingerprint are used. 3950 The size of the KDF parameters sequence, defined above, is either 54 3951 for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 3952 for Curve25519. 3954 The key wrapping method is described in [RFC3394]. KDF produces a 3955 symmetric key that is used as a key-encryption key (KEK) as specified 3956 in [RFC3394]. Refer to Section 15 for the details regarding the 3957 choice of the KEK algorithm, which SHOULD be one of three AES 3958 algorithms. Key wrapping and unwrapping is performed with the 3959 default initial value of [RFC3394]. 3961 The input to the key wrapping method is the value "m" derived from 3962 the session key, as described in Section 5.1, "Public-Key Encrypted 3963 Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step 3964 is omitted. The result is padded using the method described in 3965 [PKCS5] to the 8-byte granularity. For example, the following 3966 AES-256 session key, in which 32 octets are denoted from k0 to k31, 3967 is composed to form the following 40 octet sequence: 3969 09 k0 k1 ... k31 c0 c1 05 05 05 05 05 3971 The octets c0 and c1 above denote the checksum. This encoding allows 3972 the sender to obfuscate the size of the symmetric encryption key used 3973 to encrypt the data. For example, assuming that an AES algorithm is 3974 used for the session key, the sender MAY use 21, 13, and 5 bytes of 3975 padding for AES-128, AES-192, and AES-256, respectively, to provide 3976 the same number of octets, 40 total, as an input to the key wrapping 3977 method. 3979 The output of the method consists of two fields. The first field is 3980 the MPI containing the ephemeral key used to establish the shared 3981 secret. The second field is composed of the following two fields: 3983 * a one-octet encoding the size in octets of the result of the key 3984 wrapping method; the value 255 is reserved for future extensions; 3986 * up to 254 octets representing the result of the key wrapping 3987 method, applied to the 8-byte padded session key, as described 3988 above. 3990 Note that for session key sizes 128, 192, and 256 bits, the size of 3991 the result of the key wrapping method is, respectively, 32, 40, and 3992 48 octets, unless the size obfuscation is used. 3994 For convenience, the synopsis of the encoding method is given below; 3995 however, this section, [SP800-56A], and [RFC3394] are the normative 3996 sources of the definition. 3998 * Obtain the authenticated recipient public key R 4000 * Generate an ephemeral key pair {v, V=vG} 4002 * Compute the shared point S = vR; 4004 * m = symm_alg_ID || session key || checksum || pkcs5_padding; 4006 * curve_OID_len = (byte)len(curve_OID); 4008 * Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 4009 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 4010 Sender " || recipient_fingerprint; 4012 * Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 4014 * Compute Z = KDF( S, Z_len, Param ); 4016 * Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4018 * VB = convert point V to the octet string 4020 * Output (MPI(VB) || len(C) || C). 4022 The decryption is the inverse of the method given. Note that the 4023 recipient obtains the shared secret by calculating 4025 S = rV = rvG, where (r,R) is the recipient's key pair. 4027 Consistent with Section 5.14, Modification Detection Code (MDC) MUST 4028 be used anytime the symmetric key is protected by ECDH. 4030 14. Notes on Algorithms 4032 14.1. PKCS#1 Encoding in OpenPGP 4034 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4035 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4036 has changed in the past. To avoid potential confusion and 4037 interoperability problems, we are including local copies in this 4038 document, adapted from those in PKCS#1 v2.1 [RFC3447]. [RFC3447] 4039 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4040 Nonetheless, we believe that there is value in having a self- 4041 contained document that avoids problems in the future with needed 4042 changes in the conventions. 4044 14.1.1. EME-PKCS1-v1_5-ENCODE 4046 Input: 4048 k = the length in octets of the key modulus. 4050 M = message to be encoded, an octet string of length mLen, where 4051 mLen <= k - 11. 4053 Output: 4055 EM = encoded message, an octet string of length k. 4057 Error: "message too long". 4059 1. Length checking: If mLen > k - 11, output "message too long" and 4060 stop. 4062 2. Generate an octet string PS of length k - mLen - 3 consisting of 4063 pseudo-randomly generated nonzero octets. The length of PS will 4064 be at least eight octets. 4066 3. Concatenate PS, the message M, and other padding to form an 4067 encoded message EM of length k octets as 4069 EM = 0x00 || 0x02 || PS || 0x00 || M. 4071 4. Output EM. 4073 14.1.2. EME-PKCS1-v1_5-DECODE 4075 Input: 4077 EM = encoded message, an octet string 4079 Output: 4081 M = message, an octet string. 4083 Error: "decryption error". 4085 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4086 into an octet string PS consisting of nonzero octets and a message M 4087 as follows 4089 EM = 0x00 || 0x02 || PS || 0x00 || M. 4091 If the first octet of EM does not have hexadecimal value 0x00, if the 4092 second octet of EM does not have hexadecimal value 0x02, if there is 4093 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4094 length of PS is less than 8 octets, output "decryption error" and 4095 stop. See also the security note in Section 15 regarding differences 4096 in reporting between a decryption error and a padding error. 4098 14.1.3. EMSA-PKCS1-v1_5 4100 This encoding method is deterministic and only has an encoding 4101 operation. 4103 Option: 4105 Hash - a hash function in which hLen denotes the length in octets of 4106 the hash function output. 4108 Input: 4110 M = message to be encoded. 4112 emLen = intended length in octets of the encoded message, at least 4113 tLen + 11, where tLen is the octet length of the DER encoding T of 4114 a certain value computed during the encoding operation. 4116 Output: 4118 EM = encoded message, an octet string of length emLen. 4120 Errors: "message too long"; "intended encoded message length too 4121 short". 4123 Steps: 4125 1. Apply the hash function to the message M to produce a hash value 4126 H: 4128 H = Hash(M). 4130 If the hash function outputs "message too long," output "message 4131 too long" and stop. 4133 2. Using the list in Section 5.2.2, produce an ASN.1 DER value for 4134 the hash function used. Let T be the full hash prefix from the 4135 list, and let tLen be the length in octets of T. 4137 3. If emLen < tLen + 11, output "intended encoded message length too 4138 short" and stop. 4140 4. Generate an octet string PS consisting of emLen - tLen - 3 octets 4141 with hexadecimal value 0xFF. The length of PS will be at least 8 4142 octets. 4144 5. Concatenate PS, the hash prefix T, and other padding to form the 4145 encoded message EM as 4147 EM = 0x00 || 0x01 || PS || 0x00 || T. 4149 6. Output EM. 4151 14.2. Symmetric Algorithm Preferences 4153 The symmetric algorithm preference is an ordered list of algorithms 4154 that the keyholder accepts. Since it is found on a self-signature, 4155 it is possible that a keyholder may have multiple, different 4156 preferences. For example, Alice may have TripleDES only specified 4157 for "alice@work.com" but CAST5, Blowfish, and TripleDES specified for 4158 "alice@home.org". Note that it is also possible for preferences to 4159 be in a subkey's binding signature. 4161 Since TripleDES is the MUST-implement algorithm, if it is not 4162 explicitly in the list, it is tacitly at the end. However, it is 4163 good form to place it there explicitly. Note also that if an 4164 implementation does not implement the preference, then it is 4165 implicitly a TripleDES-only implementation. 4167 An implementation MUST NOT use a symmetric algorithm that is not in 4168 the recipient's preference list. When encrypting to more than one 4169 recipient, the implementation finds a suitable algorithm by taking 4170 the intersection of the preferences of the recipients. Note that the 4171 MUST-implement algorithm, TripleDES, ensures that the intersection is 4172 not null. The implementation may use any mechanism to pick an 4173 algorithm in the intersection. 4175 If an implementation can decrypt a message that a keyholder doesn't 4176 have in their preferences, the implementation SHOULD decrypt the 4177 message anyway, but MUST warn the keyholder that the protocol has 4178 been violated. For example, suppose that Alice, above, has software 4179 that implements all algorithms in this specification. Nonetheless, 4180 she prefers subsets for work or home. If she is sent a message 4181 encrypted with IDEA, which is not in her preferences, the software 4182 warns her that someone sent her an IDEA-encrypted message, but it 4183 would ideally decrypt it anyway. 4185 14.3. Other Algorithm Preferences 4187 Other algorithm preferences work similarly to the symmetric algorithm 4188 preference, in that they specify which algorithms the keyholder 4189 accepts. There are two interesting cases that other comments need to 4190 be made about, though, the compression preferences and the hash 4191 preferences. 4193 14.3.1. Compression Preferences 4195 Compression has been an integral part of PGP since its first days. 4196 OpenPGP and all previous versions of PGP have offered compression. 4197 In this specification, the default is for messages to be compressed, 4198 although an implementation is not required to do so. Consequently, 4199 the compression preference gives a way for a keyholder to request 4200 that messages not be compressed, presumably because they are using a 4201 minimal implementation that does not include compression. 4202 Additionally, this gives a keyholder a way to state that it can 4203 support alternate algorithms. 4205 Like the algorithm preferences, an implementation MUST NOT use an 4206 algorithm that is not in the preference vector. If the preferences 4207 are not present, then they are assumed to be [ZIP(1), 4208 Uncompressed(0)]. 4210 Additionally, an implementation MUST implement this preference to the 4211 degree of recognizing when to send an uncompressed message. A robust 4212 implementation would satisfy this requirement by looking at the 4213 recipient's preference and acting accordingly. A minimal 4214 implementation can satisfy this requirement by never generating a 4215 compressed message, since all implementations can handle messages 4216 that have not been compressed. 4218 14.3.2. Hash Algorithm Preferences 4220 Typically, the choice of a hash algorithm is something the signer 4221 does, rather than the verifier, because a signer rarely knows who is 4222 going to be verifying the signature. This preference, though, allows 4223 a protocol based upon digital signatures ease in negotiation. 4225 Thus, if Alice is authenticating herself to Bob with a signature, it 4226 makes sense for her to use a hash algorithm that Bob's software uses. 4227 This preference allows Bob to state in his key which algorithms Alice 4228 may use. 4230 Since SHA1 is the MUST-implement hash algorithm, if it is not 4231 explicitly in the list, it is tacitly at the end. However, it is 4232 good form to place it there explicitly. 4234 14.4. Plaintext 4236 Algorithm 0, "plaintext", may only be used to denote secret keys that 4237 are stored in the clear. Implementations MUST NOT use plaintext in 4238 Symmetrically Encrypted Data packets; they must use Literal Data 4239 packets to encode unencrypted or literal data. 4241 14.5. RSA 4243 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4244 keys. These types are deprecated. The "key flags" subpacket in a 4245 signature is a much better way to express the same idea, and 4246 generalizes it to all algorithms. An implementation SHOULD NOT 4247 create such a key, but MAY interpret it. 4249 An implementation SHOULD NOT implement RSA keys of size less than 4250 1024 bits. 4252 14.6. DSA 4254 An implementation SHOULD NOT implement DSA keys of size less than 4255 1024 bits. It MUST NOT implement a DSA key with a q size of less 4256 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4257 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4258 (DSS) [FIPS186] specifies that DSA be used in one of the following 4259 ways: 4261 * 1024-bit key, 160-bit q, SHA-1, SHA2-224, SHA2-256, SHA2-384, or 4262 SHA2-512 hash 4264 * 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 4265 hash 4267 * 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4269 * 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4271 The above key and q size pairs were chosen to best balance the 4272 strength of the key with the strength of the hash. Implementations 4273 SHOULD use one of the above key and q size pairs when generating DSA 4274 keys. If DSS compliance is desired, one of the specified SHA hashes 4275 must be used as well. [FIPS186] is the ultimate authority on DSS, 4276 and should be consulted for all questions of DSS compliance. 4278 Note that earlier versions of this standard only allowed a 160-bit q 4279 with no truncation allowed, so earlier implementations may not be 4280 able to handle signatures with a different q size or a truncated 4281 hash. 4283 14.7. Elgamal 4285 An implementation SHOULD NOT implement Elgamal keys of size less than 4286 1024 bits. 4288 14.8. Reserved Algorithm Numbers 4290 A number of algorithm IDs have been reserved for algorithms that 4291 would be useful to use in an OpenPGP implementation, yet there are 4292 issues that prevent an implementer from actually implementing the 4293 algorithm. These are marked in Section 9.1 as "reserved for". 4295 The reserved public-key algorithm X9.42 (21) does not have the 4296 necessary parameters, parameter order, or semantics defined. The 4297 same is currently true for reserved public-key algorithms AEDH (23) 4298 and AEDSA (24). 4300 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4301 with a public-key identifier of 20. These are no longer permitted. 4302 An implementation MUST NOT generate such keys. An implementation 4303 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4305 14.9. OpenPGP CFB Mode 4307 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4308 mode (CFB mode). This section describes the procedure it uses in 4309 detail. This mode is what is used for Symmetrically Encrypted Data 4310 Packets; the mechanism used for encrypting secret-key material is 4311 similar, and is described in the sections above. 4313 In the description below, the value BS is the block size in octets of 4314 the cipher. Most ciphers have a block size of 8 octets. The AES and 4315 Twofish have a block size of 16 octets. Also note that the 4316 description below assumes that the IV and CFB arrays start with an 4317 index of 1 (unlike the C language, which assumes arrays start with a 4318 zero index). 4320 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4321 prefixes the plaintext with BS+2 octets of random data, such that 4322 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4323 resynchronization after encrypting those BS+2 octets. 4325 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4326 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4327 octets 9 and 10. For an algorithm with a block size of 16 octets 4328 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4329 octets 15 and 16. Those extra two octets are an easy check for a 4330 correct key. 4332 Step by step, here is the procedure: 4334 1. The feedback register (FR) is set to the IV, which is all zeros. 4336 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4337 encryption of an all-zero value. 4339 3. FRE is xored with the first BS octets of random data prefixed to 4340 the plaintext to produce C[1] through C[BS], the first BS octets 4341 of ciphertext. 4343 4. FR is loaded with C[1] through C[BS]. 4345 5. FR is encrypted to produce FRE, the encryption of the first BS 4346 octets of ciphertext. 4348 6. The left two octets of FRE get xored with the next two octets of 4349 data that were prefixed to the plaintext. This produces C[BS+1] 4350 and C[BS+2], the next two octets of ciphertext. 4352 7. (The resynchronization step) FR is loaded with C[3] through 4353 C[BS+2]. 4355 8. FR is encrypted to produce FRE. 4357 9. FRE is xored with the first BS octets of the given plaintext, 4358 now that we have finished encrypting the BS+2 octets of prefixed 4359 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4360 octets of ciphertext. 4362 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4363 for an 8-octet block). 4365 11. FR is encrypted to produce FRE. 4367 12. FRE is xored with the next BS octets of plaintext, to produce 4368 the next BS octets of ciphertext. These are loaded into FR, and 4369 the process is repeated until the plaintext is used up. 4371 14.10. Private or Experimental Parameters 4373 S2K specifiers, Signature subpacket types, User Attribute types, 4374 image format types, and algorithms described in Section 9 all reserve 4375 the range 100 to 110 for private and experimental use. Packet types 4376 reserve the range 60 to 63 for private and experimental use. These 4377 are intentionally managed with the PRIVATE USE method, as described 4378 in [RFC8126]. 4380 However, implementations need to be careful with these and promote 4381 them to full IANA-managed parameters when they grow beyond the 4382 original, limited system. 4384 14.11. Extension of the MDC System 4386 As described in the non-normative explanation in Section 5.14, the 4387 MDC system is uniquely unparameterized in OpenPGP. This was an 4388 intentional decision to avoid cross-grade attacks. If the MDC system 4389 is extended to a stronger hash function, care must be taken to avoid 4390 downgrade and cross-grade attacks. 4392 One simple way to do this is to create new packets for a new MDC. 4393 For example, instead of the MDC system using packets 18 and 19, a new 4394 MDC could use 20 and 21. This has obvious drawbacks (it uses two 4395 packet numbers for each new hash function in a space that is limited 4396 to a maximum of 60). 4398 Another simple way to extend the MDC system is to create new versions 4399 of packet 18, and reflect this in packet 19. For example, suppose 4400 that V2 of packet 18 implicitly used SHA-256. This would require 4401 packet 19 to have a length of 32 octets. The change in the version 4402 in packet 18 and the size of packet 19 prevent a downgrade attack. 4404 There are two drawbacks to this latter approach. The first is that 4405 using the version number of a packet to carry algorithm information 4406 is not tidy from a protocol-design standpoint. It is possible that 4407 there might be several versions of the MDC system in common use, but 4408 this untidiness would reflect untidiness in cryptographic consensus 4409 about hash function security. The second is that different versions 4410 of packet 19 would have to have unique sizes. If there were two 4411 versions each with 256-bit hashes, they could not both have 32-octet 4412 packet 19s without admitting the chance of a cross-grade attack. 4414 Yet another, complex approach to extend the MDC system would be a 4415 hybrid of the two above -- create a new pair of MDC packets that are 4416 fully parameterized, and yet protected from downgrade and cross- 4417 grade. 4419 Any change to the MDC system MUST be done through the IETF CONSENSUS 4420 method, as described in [RFC8126]. 4422 14.12. Meta-Considerations for Expansion 4424 If OpenPGP is extended in a way that is not backwards-compatible, 4425 meaning that old implementations will not gracefully handle their 4426 absence of a new feature, the extension proposal can be declared in 4427 the key holder's self-signature as part of the Features signature 4428 subpacket. 4430 We cannot state definitively what extensions will not be upwards- 4431 compatible, but typically new algorithms are upwards-compatible, 4432 whereas new packets are not. 4434 If an extension proposal does not update the Features system, it 4435 SHOULD include an explanation of why this is unnecessary. If the 4436 proposal contains neither an extension to the Features system nor an 4437 explanation of why such an extension is unnecessary, the proposal 4438 SHOULD be rejected. 4440 15. Security Considerations 4442 * As with any technology involving cryptography, you should check 4443 the current literature to determine if any algorithms used here 4444 have been found to be vulnerable to attack. 4446 * This specification uses Public-Key Cryptography technologies. It 4447 is assumed that the private key portion of a public-private key 4448 pair is controlled and secured by the proper party or parties. 4450 * Certain operations in this specification involve the use of random 4451 numbers. An appropriate entropy source should be used to generate 4452 these numbers (see [RFC4086]). 4454 * The MD5 hash algorithm has been found to have weaknesses, with 4455 collisions found in a number of cases. MD5 is deprecated for use 4456 in OpenPGP. Implementations MUST NOT generate new signatures 4457 using MD5 as a hash function. They MAY continue to consider old 4458 signatures that used MD5 as valid. 4460 * SHA2-224 and SHA2-384 require the same work as SHA2-256 and 4461 SHA2-512, respectively. In general, there are few reasons to use 4462 them outside of DSS compatibility. You need a situation where one 4463 needs more security than smaller hashes, but does not want to have 4464 the full 256-bit or 512-bit data length. 4466 * Many security protocol designers think that it is a bad idea to 4467 use a single key for both privacy (encryption) and integrity 4468 (signatures). In fact, this was one of the motivating forces 4469 behind the V4 key format with separate signature and encryption 4470 keys. If you as an implementer promote dual-use keys, you should 4471 at least be aware of this controversy. 4473 * The DSA algorithm will work with any hash, but is sensitive to the 4474 quality of the hash algorithm. Verifiers should be aware that 4475 even if the signer used a strong hash, an attacker could have 4476 modified the signature to use a weak one. Only signatures using 4477 acceptably strong hash algorithms should be accepted as valid. 4479 * As OpenPGP combines many different asymmetric, symmetric, and hash 4480 algorithms, each with different measures of strength, care should 4481 be taken that the weakest element of an OpenPGP message is still 4482 sufficiently strong for the purpose at hand. While consensus 4483 about the strength of a given algorithm may evolve, NIST Special 4484 Publication 800-57 [SP800-57] recommends the following list of 4485 equivalent strengths: 4487 +=====================+===========+====================+ 4488 | Asymmetric key size | Hash size | Symmetric key size | 4489 +=====================+===========+====================+ 4490 | 1024 | 160 | 80 | 4491 +---------------------+-----------+--------------------+ 4492 | 2048 | 224 | 112 | 4493 +---------------------+-----------+--------------------+ 4494 | 3072 | 256 | 128 | 4495 +---------------------+-----------+--------------------+ 4496 | 7680 | 384 | 192 | 4497 +---------------------+-----------+--------------------+ 4498 | 15360 | 512 | 256 | 4499 +---------------------+-----------+--------------------+ 4501 Table 21: Key length equivalences 4503 * There is a somewhat-related potential security problem in 4504 signatures. If an attacker can find a message that hashes to the 4505 same hash with a different algorithm, a bogus signature structure 4506 can be constructed that evaluates correctly. 4508 For example, suppose Alice DSA signs message M using hash 4509 algorithm H. Suppose that Mallet finds a message M' that has the 4510 same hash value as M with H'. Mallet can then construct a 4511 signature block that verifies as Alice's signature of M' with H'. 4512 However, this would also constitute a weakness in either H or H' 4513 or both. Should this ever occur, a revision will have to be made 4514 to this document to revise the allowed hash algorithms. 4516 * If you are building an authentication system, the recipient may 4517 specify a preferred signing algorithm. However, the signer would 4518 be foolish to use a weak algorithm simply because the recipient 4519 requests it. 4521 * Some of the encryption algorithms mentioned in this document have 4522 been analyzed less than others. For example, although CAST5 is 4523 presently considered strong, it has been analyzed less than 4524 TripleDES. Other algorithms may have other controversies 4525 surrounding them. 4527 * In late summer 2002, Jallad, Katz, and Schneier published an 4528 interesting attack on the OpenPGP protocol and some of its 4529 implementations [JKS02]. In this attack, the attacker modifies a 4530 message and sends it to a user who then returns the erroneously 4531 decrypted message to the attacker. The attacker is thus using the 4532 user as a random oracle, and can often decrypt the message. 4534 Compressing data can ameliorate this attack. The incorrectly 4535 decrypted data nearly always decompresses in ways that defeat the 4536 attack. However, this is not a rigorous fix, and leaves open some 4537 small vulnerabilities. For example, if an implementation does not 4538 compress a message before encryption (perhaps because it knows it 4539 was already compressed), then that message is vulnerable. Because 4540 of this happenstance -- that modification attacks can be thwarted 4541 by decompression errors -- an implementation SHOULD treat a 4542 decompression error as a security problem, not merely a data 4543 problem. 4545 This attack can be defeated by the use of Modification Detection, 4546 provided that the implementation does not let the user naively 4547 return the data to the attacker. An implementation MUST treat an 4548 MDC failure as a security problem, not merely a data problem. 4550 In either case, the implementation MAY allow the user access to 4551 the erroneous data, but MUST warn the user as to potential 4552 security problems should that data be returned to the sender. 4554 While this attack is somewhat obscure, requiring a special set of 4555 circumstances to create it, it is nonetheless quite serious as it 4556 permits someone to trick a user to decrypt a message. 4557 Consequently, it is important that: 4559 1. Implementers treat MDC errors and decompression failures as 4560 security problems. 4562 2. Implementers implement Modification Detection with all due 4563 speed and encourage its spread. 4565 3. Users migrate to implementations that support Modification 4566 Detection with all due speed. 4568 * PKCS#1 has been found to be vulnerable to attacks in which a 4569 system that reports errors in padding differently from errors in 4570 decryption becomes a random oracle that can leak the private key 4571 in mere millions of queries. Implementations must be aware of 4572 this attack and prevent it from happening. The simplest solution 4573 is to report a single error code for all variants of decryption 4574 errors so as not to leak information to an attacker. 4576 * Some technologies mentioned here may be subject to government 4577 control in some countries. 4579 * In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4580 released a paper describing a way that the "quick check" in 4581 OpenPGP CFB mode can be used with a random oracle to decrypt two 4582 octets of every cipher block [MZ05]. They recommend as prevention 4583 not using the quick check at all. 4585 Many implementers have taken this advice to heart for any data 4586 that is symmetrically encrypted and for which the session key is 4587 public-key encrypted. In this case, the quick check is not needed 4588 as the public-key encryption of the session key should guarantee 4589 that it is the right session key. In other cases, the 4590 implementation should use the quick check with care. 4592 On the one hand, there is a danger to using it if there is a 4593 random oracle that can leak information to an attacker. In 4594 plainer language, there is a danger to using the quick check if 4595 timing information about the check can be exposed to an attacker, 4596 particularly via an automated service that allows rapidly repeated 4597 queries. 4599 On the other hand, it is inconvenient to the user to be informed 4600 that they typed in the wrong passphrase only after a petabyte of 4601 data is decrypted. There are many cases in cryptographic 4602 engineering where the implementer must use care and wisdom, and 4603 this is one. 4605 * Refer to [FIPS186], B.4.1, for the method to generate a uniformly 4606 distributed ECC private key. 4608 * The curves proposed in this document correspond to the symmetric 4609 key sizes 128 bits, 192 bits, and 256 bits, as described in the 4610 table below. This allows a compliant application to offer 4611 balanced public key security, which is compatible with the 4612 symmetric key strength for each AES algorithm defined here. 4614 The following table defines the hash and the symmetric encryption 4615 algorithm that SHOULD be used with a given curve for ECDSA or 4616 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 4617 be used for a given ECC curve. However, note that the increase in 4618 the strength of the hash algorithm or the symmetric key algorithm 4619 may not increase the overall security offered by the given ECC 4620 key. 4622 +============+=====+==============+=====================+===========+ 4623 | Curve name | ECC | RSA | Hash size strength, | Symmetric | 4624 | | | strength | informative | key size | 4625 +============+=====+==============+=====================+===========+ 4626 | NIST P-256 | 256 | 3072 | 256 | 128 | 4627 +------------+-----+--------------+---------------------+-----------+ 4628 | NIST P-384 | 384 | 7680 | 384 | 192 | 4629 +------------+-----+--------------+---------------------+-----------+ 4630 | NIST P-521 | 521 | 15360 | 512 | 256 | 4631 +------------+-----+--------------+---------------------+-----------+ 4633 Table 22: Elliptic Curve cryptographic guidance 4635 * Requirement levels indicated elsewhere in this document lead to 4636 the following combinations of algorithms in the OpenPGP profile: 4637 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 4638 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 4639 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 4640 combinations. 4642 Consistent with the table above, the following table defines the 4643 KDF hash algorithm and the AES KEK encryption algorithm that 4644 SHOULD be used with a given curve for ECDH. A stronger KDF hash 4645 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 4647 +============+=================+======================+ 4648 | Curve name | Recommended KDF | Recommended KEK | 4649 | | hash algorithm | encryption algorithm | 4650 +============+=================+======================+ 4651 | NIST P-256 | SHA2-256 | AES-128 | 4652 +------------+-----------------+----------------------+ 4653 | NIST P-384 | SHA2-384 | AES-192 | 4654 +------------+-----------------+----------------------+ 4655 | NIST P-521 | SHA2-512 | AES-256 | 4656 +------------+-----------------+----------------------+ 4658 Table 23: Elliptic Curve KDF and KEK recommendations 4660 * This document explicitly discourages the use of algorithms other 4661 than AES as a KEK algorithm because backward compatibility of the 4662 ECDH format is not a concern. The KEK algorithm is only used 4663 within the scope of a Public-Key Encrypted Session Key Packet, 4664 which represents an ECDH key recipient of a message. Compare this 4665 with the algorithm used for the session key of the message, which 4666 MAY be different from a KEK algorithm. 4668 Compliant applications SHOULD implement, advertise through key 4669 preferences, and use the strongest algorithms specified in this 4670 document. 4672 Note that the symmetric algorithm preference list may make it 4673 impossible to use the balanced strength of symmetric key 4674 algorithms for a corresponding public key. For example, the 4675 presence of the symmetric key algorithm IDs and their order in the 4676 key preference list affects the algorithm choices available to the 4677 encoding side, which in turn may make the adherence to the table 4678 above infeasible. Therefore, compliance with this specification 4679 is a concern throughout the life of the key, starting immediately 4680 after the key generation when the key preferences are first added 4681 to a key. It is generally advisable to position a symmetric 4682 algorithm ID of strength matching the public key at the head of 4683 the key preference list. 4685 Encryption to multiple recipients often results in an unordered 4686 intersection subset. For example, if the first recipient's set is 4687 {A, B} and the second's is {B, A}, the intersection is an 4688 unordered set of two algorithms, A and B. In this case, a 4689 compliant application SHOULD choose the stronger encryption 4690 algorithm. 4692 Resource constraints, such as limited computational power, is a 4693 likely reason why an application might prefer to use the weakest 4694 algorithm. On the other side of the spectrum are applications 4695 that can implement every algorithm defined in this document. Most 4696 applications are expected to fall into either of two categories. 4697 A compliant application in the second, or strongest, category 4698 SHOULD prefer AES-256 to AES-192. 4700 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 4701 method. 4703 MDC MUST be used when a symmetric encryption key is protected by 4704 ECDH. None of the ECC methods described in this document are 4705 allowed with deprecated V3 keys. A compliant application MUST 4706 only use iterated and salted S2K to protect private keys, as 4707 defined in Section 3.7.1.3, "Iterated and Salted S2K". 4709 Side channel attacks are a concern when a compliant application's 4710 use of the OpenPGP format can be modeled by a decryption or 4711 signing oracle model, for example, when an application is a 4712 network service performing decryption to unauthenticated remote 4713 users. ECC scalar multiplication operations used in ECDSA and 4714 ECDH are vulnerable to side channel attacks. Countermeasures can 4715 often be taken at the higher protocol level, such as limiting the 4716 number of allowed failures or time-blinding of the operations 4717 associated with each network interface. Mitigations at the scalar 4718 multiplication level seek to eliminate any measurable distinction 4719 between the ECC point addition and doubling operations. 4721 16. Compatibility Profiles 4723 16.1. OpenPGP ECC Profile 4725 A compliant application MUST implement NIST curve P-256, SHOULD 4726 implement NIST curve P-521, and SHOULD implement Curve25519 as 4727 defined in Section 9.2. A compliant application MUST implement 4728 SHA2-256 and SHOULD implement SHA2-384 and SHA2-512. A compliant 4729 application MUST implement AES-128 and SHOULD implement AES-256. 4731 A compliant application SHOULD follow Section 15 regarding the choice 4732 of the following algorithms for each curve: 4734 * the KDF hash algorithm, 4736 * the KEK algorithm, 4738 * the message digest algorithm and the hash algorithm used in the 4739 key certifications, 4741 * the symmetric algorithm used for message encryption. 4743 It is recommended that the chosen symmetric algorithm for message 4744 encryption be no less secure than the KEK algorithm. 4746 16.2. Suite-B Profile 4748 A subset of algorithms allowed by this document can be used to 4749 achieve [SuiteB] compatibility. The references to [SuiteB] in this 4750 document are informative. This document is primarily concerned with 4751 format specification, leaving additional security restrictions 4752 unspecified, such as matching the assigned security level of 4753 information to authorized recipients or interoperability concerns 4754 arising from fewer allowed algorithms in [SuiteB] than allowed by 4755 this document. 4757 16.2.1. Security Strength at 192 Bits 4759 To achieve the security strength of 192 bits, [SuiteB] requires NIST 4760 curve P-384, AES-256, and SHA2-384. The symmetric algorithm 4761 restriction means that the algorithm of KEK used for key wrapping in 4762 Section 13.4 and an OpenPGP session key used for message encryption 4763 must be AES-256. The hash algorithm restriction means that the hash 4764 algorithms of KDF and the OpenPGP message digest calculation must be 4765 SHA2-384. 4767 16.2.2. Security Strength at 128 Bits 4769 The set of algorithms in Section 16.2.1 is extended to allow NIST 4770 curve P-256, AES-128, and SHA2-256. 4772 17. Implementation Nits 4774 This section is a collection of comments to help an implementer, 4775 particularly with an eye to backward compatibility. Previous 4776 implementations of PGP are not OpenPGP compliant. Often the 4777 differences are small, but small differences are frequently more 4778 vexing than large differences. Thus, this is a non-comprehensive 4779 list of potential problems and gotchas for a developer who is trying 4780 to be backward-compatible. 4782 * The IDEA algorithm is patented, and yet it is required for PGP 2 4783 interoperability. It is also the de-facto preferred algorithm for 4784 a V3 key with a V3 self-signature (or no self-signature). 4786 * When exporting a private key, PGP 2 generates the header "BEGIN 4787 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 4788 All previous versions ignore the implied data type, and look 4789 directly at the packet data type. 4791 * PGP versions 2.0 through 2.5 generated V2 Public-Key packets. 4792 These are identical to the deprecated V3 keys except for the 4793 version number. An implementation MUST NOT generate them and may 4794 accept or reject them as it sees fit. Some older PGP versions 4795 generated V2 PKESK packets (Tag 1) as well. An implementation may 4796 accept or reject V2 PKESK packets as it sees fit, and MUST NOT 4797 generate them. 4799 * PGP version 2.6 will not accept key-material packets with versions 4800 greater than 3. 4802 * There are many ways possible for two keys to have the same key 4803 material, but different fingerprints (and thus Key IDs). Perhaps 4804 the most interesting is an RSA key that has been "upgraded" to V4 4805 format, but since a V4 fingerprint is constructed by hashing the 4806 key creation time along with other things, two V4 keys created at 4807 different times, yet with the same key material will have 4808 different fingerprints. 4810 * If an implementation is using zlib to interoperate with PGP 2, 4811 then the "windowBits" parameter should be set to -13. 4813 * The 0x19 back signatures were not required for signing subkeys 4814 until relatively recently. Consequently, there may be keys in the 4815 wild that do not have these back signatures. Implementing 4816 software may handle these keys as it sees fit. 4818 * OpenPGP does not put limits on the size of public keys. However, 4819 larger keys are not necessarily better keys. Larger keys take 4820 more computation time to use, and this can quickly become 4821 impractical. Different OpenPGP implementations may also use 4822 different upper bounds for public key sizes, and so care should be 4823 taken when choosing sizes to maintain interoperability. As of 4824 2007 most implementations have an upper bound of 4096 bits. 4826 * ASCII armor is an optional feature of OpenPGP. The OpenPGP 4827 working group strives for a minimal set of mandatory-to-implement 4828 features, and since there could be useful implementations that 4829 only use binary object formats, this is not a "MUST" feature for 4830 an implementation. For example, an implementation that is using 4831 OpenPGP as a mechanism for file signatures may find ASCII armor 4832 unnecessary. OpenPGP permits an implementation to declare what 4833 features it does and does not support, but ASCII armor is not one 4834 of these. Since most implementations allow binary and armored 4835 objects to be used indiscriminately, an implementation that does 4836 not implement ASCII armor may find itself with compatibility 4837 issues with general-purpose implementations. Moreover, 4838 implementations of OpenPGP-MIME [RFC3156] already have a 4839 requirement for ASCII armor so those implementations will 4840 necessarily have support. 4842 18. References 4844 18.1. Normative References 4846 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 4847 November 2001, 4848 . 4851 [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 4852 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 4853 Cambridge Security Workshop Proceedings Springer-Verlag, 4854 1994, pp191-204, December 1993, 4855 . 4857 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, 4858 . 4860 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 4861 Scheme Based on Discrete Logarithms", IEEE Transactions on 4862 Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 4863 1985. 4865 [FIPS180] National Institute of Standards and Technology, U.S. 4866 Department of Commerce, "Secure Hash Standard (SHS), FIPS 4867 180-4", August 2015, 4868 . 4870 [FIPS186] National Institute of Standards and Technology, U.S. 4871 Department of Commerce, "Digital Signature Standard (DSS), 4872 FIPS 186-4", July 2013, 4873 . 4875 [FIPS202] National Institute of Standards and Technology, U.S. 4876 Department of Commerce, "SHA-3 Standard: Permutation-Based 4877 Hash and Extendable-Output Functions, FIPS 202", August 4878 2015, . 4880 [HAC] Menezes, A.J., Oorschot, P.v., and S. Vanstone, "Handbook 4881 of Applied Cryptography", 1996. 4883 [IDEA] Lai, X., "On the design and security of block ciphers", 4884 ETH Series in Information Processing, J.L. Massey 4885 (editor) Vol. 1, Hartung-Gorre Verlag Konstanz, Technische 4886 Hochschule (Zurich), 1992. 4888 [ISO10646] International Organization for Standardization, 4889 "Information Technology - Universal Multiple-octet coded 4890 Character Set (UCS) - Part 1: Architecture and Basic 4891 Multilingual Plane", ISO Standard 10646-1, May 1993. 4893 [JFIF] CA, E.H.M., "JPEG File Interchange Format (Version 4894 1.02).", September 1996. 4896 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 4897 Cryptography Standard", 25 March 1999. 4899 [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format 4900 Specification version 3.3", RFC 1950, 4901 DOI 10.17487/RFC1950, May 1996, 4902 . 4904 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 4905 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 4906 . 4908 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4909 Extensions (MIME) Part One: Format of Internet Message 4910 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 4911 . 4913 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4914 Requirement Levels", BCP 14, RFC 2119, 4915 DOI 10.17487/RFC2119, March 1997, 4916 . 4918 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 4919 DOI 10.17487/RFC2144, May 1997, 4920 . 4922 [RFC2822] Resnick, P., Ed., "Internet Message Format", RFC 2822, 4923 DOI 10.17487/RFC2822, April 2001, 4924 . 4926 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 4927 "MIME Security with OpenPGP", RFC 3156, 4928 DOI 10.17487/RFC3156, August 2001, 4929 . 4931 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4932 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 4933 September 2002, . 4935 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4936 Standards (PKCS) #1: RSA Cryptography Specifications 4937 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 4938 2003, . 4940 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 4941 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 4942 2003, . 4944 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 4945 the Camellia Encryption Algorithm", RFC 3713, 4946 DOI 10.17487/RFC3713, April 2004, 4947 . 4949 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 4950 "Randomness Requirements for Security", BCP 106, RFC 4086, 4951 DOI 10.17487/RFC4086, June 2005, 4952 . 4954 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 4955 for Security", RFC 7748, DOI 10.17487/RFC7748, January 4956 2016, . 4958 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 4959 Writing an IANA Considerations Section in RFCs", BCP 26, 4960 RFC 8126, DOI 10.17487/RFC8126, June 2017, 4961 . 4963 [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: 4964 protocols, algorithms, and source code in C", 1996. 4966 [SP800-56A] 4967 Barker, E., Johnson, D., and M. Smid, "Recommendation for 4968 Pair-Wise Key Establishment Schemes Using Discrete 4969 Logarithm Cryptography", NIST Special Publication 800-56A 4970 Revision 1, March 2007. 4972 [SuiteB] National Security Agency, "NSA Suite B Cryptography", 11 4973 March 2010, 4974 . 4976 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 4977 C., and N. Ferguson, "The Twofish Encryption Algorithm", 4978 1999. 4980 18.2. Informative References 4982 [BLEICHENBACHER] 4983 Bleichenbacher, D., "Generating ElGamal Signatures Without 4984 Knowing the Secret Key", Lecture Notes in Computer 4985 Science Volume 1070, pp. 10-18, 1996. 4987 [JKS02] Jallad, K., Katz, J., and B. Schneier, "Implementation of 4988 Chosen-Ciphertext Attacks against PGP and GnuPG", 2002, 4989 . 4991 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 4992 Chapter VI. Elliptic Curves", ISBN 0-387-96576-9, 1997. 4994 [MZ05] Mister, S. and R. Zuccherato, "An Attack on CFB Mode 4995 Encryption As Used By OpenPGP", IACR ePrint Archive Report 4996 2005/033, 8 February 2005, 4997 . 4999 [REGEX] Friedl, J., "Mastering Regular Expressions", 5000 ISBN 0-596-00289-0, August 2002. 5002 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5003 Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, August 5004 1996, . 5006 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5007 "OpenPGP Message Format", RFC 2440, DOI 10.17487/RFC2440, 5008 November 1998, . 5010 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 5011 Thayer, "OpenPGP Message Format", RFC 4880, 5012 DOI 10.17487/RFC4880, November 2007, 5013 . 5015 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5016 Curve Cryptography Algorithms", RFC 6090, 5017 DOI 10.17487/RFC6090, February 2011, 5018 . 5020 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5021 Elliptic Curve Cryptography", September 2000. 5023 [SP800-57] NIST, "Recommendation on Key Management", NIST Special 5024 Publication 800-57, March 2007, 5025 . 5028 Appendix A. Document Workflow 5030 This document is built from markdown using ruby-kramdown-rfc2629 5031 (https://rubygems.org/gems/kramdown-rfc2629), and tracked using git 5032 (https://git-scm.com/). The markdown source under development can be 5033 found in the file "crypto-refresh.md" in the "main" branch of the git 5034 repository (https://gitlab.com/openpgp-wg/rfc4880bis). Discussion of 5035 this document should take place on the openpgp@ietf.org mailing list 5036 (https://www.ietf.org/mailman/listinfo/openpgp). 5038 A non-substantive editorial nit can be submitted directly as a merge 5039 request (https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/ 5040 new). A substantive proposed edit may also be submitted as a merge 5041 request, but should simultaneously be sent to the mailing list for 5042 discussion. 5044 An open problem can be recorded and tracked as an issue 5045 (https://gitlab.com/openpgp-wg/rfc4880bis/-/issues) in the gitlab 5046 issue tracker, but discussion of the issue should take place on the 5047 mailing list. 5049 [Note to RFC-Editor: Please remove this section on publication.] 5051 Appendix B. ECC Point compression flag bytes 5053 This specification introduces the new flag byte 0x40 to indicate the 5054 point compression format. The value has been chosen so that the high 5055 bit is not cleared and thus to avoid accidental sign extension. Two 5056 other values might also be interesting for other ECC specifications: 5058 Flag Description 5059 ---- ----------- 5060 0x04 Standard flag for uncompressed format 5061 0x40 Native point format of the curve follows 5062 0x41 Only X coordinate follows. 5063 0x42 Only Y coordinate follows. 5065 Appendix C. Acknowledgements 5067 This memo also draws on much previous work from a number of other 5068 authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc 5069 Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, 5070 Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, 5071 Mark Weaver, and Philip R. Zimmermann. 5073 Authors' Addresses 5075 Werner Koch (editor) 5076 GnuPG e.V. 5077 Rochusstr. 44 5078 40479 Duesseldorf 5079 Germany 5081 Email: wk@gnupg.org 5082 URI: https://gnupg.org/verein 5083 Paul Wouters (editor) 5085 Email: pwouters@redhat.com