idnits 2.17.1 draft-ietf-openpgp-crypto-refresh-04.txt: -(3394): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(3396): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(3398): 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 : ---------------------------------------------------------------------------- == There are 5 instances of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. -- 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 == Line 5998 has weird spacing: '...0 dc ae dc 5b...' -- The document date (18 October 2021) is 922 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 460 -- Looks like a reference, but probably isn't: '1' on line 5161 -- Looks like a reference, but probably isn't: '2' on line 460 -- Looks like a reference, but probably isn't: '3' on line 5170 == Missing Reference: 'Optional' is mentioned on line 2483, but not defined == Missing Reference: 'BS' is mentioned on line 5161, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. 'BLOWFISH' -- Possible downref: Non-RFC (?) normative reference: ref. 'BZ2' -- Possible downref: Non-RFC (?) normative reference: ref. 'EAX' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS202' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' -- 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 7253 ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8032 ** Downref: Normative reference to an Informational RFC: RFC 9106 -- Possible downref: Non-RFC (?) normative reference: ref. 'SCHNEIER' -- Possible downref: Non-RFC (?) normative reference: ref. 'SP800-56A' -- Possible downref: Non-RFC (?) normative reference: ref. 'TWOFISH' -- Obsolete informational reference (is this intentional?): RFC 1991 (Obsoleted by RFC 4880) -- Obsolete informational reference (is this intentional?): RFC 2440 (Obsoleted by RFC 4880) Summary: 11 errors (**), 0 flaws (~~), 6 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 Aiven 6 Expires: 21 April 2022 18 October 2021 8 OpenPGP Message Format 9 draft-ietf-openpgp-crypto-refresh-04 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 21 April 2022. 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 . . . . . . . . . . . . . . . . . . . . . . . . 6 62 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 2. General functions . . . . . . . . . . . . . . . . . . . . . . 7 64 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 8 65 2.2. Authentication via Digital Signature . . . . . . . . . . 9 66 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 9 67 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 10 68 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 10 69 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 10 70 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 10 71 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 10 72 3.2.1. Using MPIs to encode other data . . . . . . . . . . . 11 73 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 11 74 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 11 75 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 11 76 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 12 77 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 12 78 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 12 79 3.7.1.1. Simple S2K . . . . . . . . . . . . . . . . . . . 12 80 3.7.1.2. Salted S2K . . . . . . . . . . . . . . . . . . . 13 81 3.7.1.3. Iterated and Salted S2K . . . . . . . . . . . . . 13 82 3.7.1.4. Argon2 . . . . . . . . . . . . . . . . . . . . . 14 83 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 15 84 3.7.2.1. Secret-Key Encryption . . . . . . . . . . . . . . 15 85 3.7.2.2. Symmetric-Key Message Encryption . . . . . . . . 16 86 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 16 87 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 16 88 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 16 89 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 17 90 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 18 91 4.2.2.1. One-Octet Lengths . . . . . . . . . . . . . . . . 18 92 4.2.2.2. Two-Octet Lengths . . . . . . . . . . . . . . . . 18 93 4.2.2.3. Five-Octet Lengths . . . . . . . . . . . . . . . 18 94 4.2.2.4. Partial Body Lengths . . . . . . . . . . . . . . 19 95 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 19 96 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 20 97 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 21 98 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 22 99 5.1.1. Algorithm Specific Fields for RSA encryption . . . . 22 100 5.1.2. Algorithm Specific Fields for Elgamal encryption . . 22 101 5.1.3. Algorithm-Specific Fields for ECDH encryption . . . . 22 102 5.1.4. Notes on PKESK . . . . . . . . . . . . . . . . . . . 23 103 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 23 104 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 24 105 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 26 106 5.2.3. Version 4 and 5 Signature Packet Formats . . . . . . 29 107 5.2.3.1. Algorithm-Specific Fields for RSA signatures . . 30 108 5.2.3.2. Algorithm-Specific Fields for DSA or ECDSA 109 signatures . . . . . . . . . . . . . . . . . . . . 30 110 5.2.3.3. Algorithm-Specific Fields for EdDSA signatures . 30 111 5.2.3.4. Notes on Signatures . . . . . . . . . . . . . . . 31 112 5.2.3.5. Signature Subpacket Specification . . . . . . . . 32 113 5.2.3.6. Signature Subpacket Types . . . . . . . . . . . . 34 114 5.2.3.7. Notes on Self-Signatures . . . . . . . . . . . . 35 115 5.2.3.8. Signature Creation Time . . . . . . . . . . . . . 36 116 5.2.3.9. Issuer . . . . . . . . . . . . . . . . . . . . . 36 117 5.2.3.10. Key Expiration Time . . . . . . . . . . . . . . . 36 118 5.2.3.11. Preferred Symmetric Algorithms . . . . . . . . . 36 119 5.2.3.12. Preferred Hash Algorithms . . . . . . . . . . . . 37 120 5.2.3.13. Preferred Compression Algorithms . . . . . . . . 37 121 5.2.3.14. Signature Expiration Time . . . . . . . . . . . . 37 122 5.2.3.15. Exportable Certification . . . . . . . . . . . . 37 123 5.2.3.16. Revocable . . . . . . . . . . . . . . . . . . . . 38 124 5.2.3.17. Trust Signature . . . . . . . . . . . . . . . . . 38 125 5.2.3.18. Regular Expression . . . . . . . . . . . . . . . 38 126 5.2.3.19. Revocation Key . . . . . . . . . . . . . . . . . 39 127 5.2.3.20. Notation Data . . . . . . . . . . . . . . . . . . 39 128 5.2.3.21. Key Server Preferences . . . . . . . . . . . . . 40 129 5.2.3.22. Preferred Key Server . . . . . . . . . . . . . . 41 130 5.2.3.23. Primary User ID . . . . . . . . . . . . . . . . . 41 131 5.2.3.24. Policy URI . . . . . . . . . . . . . . . . . . . 41 132 5.2.3.25. Key Flags . . . . . . . . . . . . . . . . . . . . 42 133 5.2.3.26. Signer's User ID . . . . . . . . . . . . . . . . 43 134 5.2.3.27. Reason for Revocation . . . . . . . . . . . . . . 43 135 5.2.3.28. Features . . . . . . . . . . . . . . . . . . . . 45 136 5.2.3.29. Signature Target . . . . . . . . . . . . . . . . 45 137 5.2.3.30. Embedded Signature . . . . . . . . . . . . . . . 46 138 5.2.3.31. Issuer Fingerprint . . . . . . . . . . . . . . . 46 139 5.2.3.32. Intended Recipient Fingerprint . . . . . . . . . 46 140 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 46 141 5.2.4.1. Subpacket Hints . . . . . . . . . . . . . . . . . 49 142 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 49 143 5.3.1. No v5 SKESK with SEIPD . . . . . . . . . . . . . . . 51 144 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 51 145 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 52 146 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 52 147 5.5.1.1. Public-Key Packet (Tag 6) . . . . . . . . . . . . 52 148 5.5.1.2. Public-Subkey Packet (Tag 14) . . . . . . . . . . 52 149 5.5.1.3. Secret-Key Packet (Tag 5) . . . . . . . . . . . . 52 150 5.5.1.4. Secret-Subkey Packet (Tag 7) . . . . . . . . . . 52 151 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 53 152 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 54 153 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 57 154 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 57 155 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 57 156 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 57 157 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 58 158 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 58 159 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 59 160 5.7. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 59 161 5.8. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 60 162 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 61 163 5.10. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 61 164 5.11. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 62 165 5.12. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 63 166 5.13. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 63 167 5.13.1. The Image Attribute Subpacket . . . . . . . . . . . 64 168 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 169 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 64 170 5.15. Modification Detection Code Packet (Tag 19) . . . . . . . 67 171 5.16. AEAD Encrypted Data Packet (Tag 20) . . . . . . . . . . . 68 172 5.16.1. EAX Mode . . . . . . . . . . . . . . . . . . . . . . 69 173 5.16.2. OCB Mode . . . . . . . . . . . . . . . . . . . . . . 70 174 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 70 175 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 71 176 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 71 177 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 74 178 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 76 179 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 76 180 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 77 181 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 77 182 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 78 183 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 79 184 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 79 185 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 80 186 9.2. ECC Curves for OpenPGP . . . . . . . . . . . . . . . . . 82 187 9.2.1. Curve-Specific Wire Formats . . . . . . . . . . . . . 83 188 9.3. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 84 189 9.4. Compression Algorithms . . . . . . . . . . . . . . . . . 85 190 9.5. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 86 191 9.6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . 87 192 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 87 193 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 87 194 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 88 195 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 88 196 10.2.1.1. Image Format Subpacket Types . . . . . . . . . . 88 197 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 88 198 10.2.2.1. Signature Notation Data Subpackets . . . . . . . 89 199 10.2.2.2. Signature Notation Data Subpacket Notation 200 Flags . . . . . . . . . . . . . . . . . . . . . . . 89 201 10.2.2.3. Key Server Preference Extensions . . . . . . . . 89 202 10.2.2.4. Key Flags Extensions . . . . . . . . . . . . . . 89 203 10.2.2.5. Reason for Revocation Extensions . . . . . . . . 90 204 10.2.2.6. Implementation Features . . . . . . . . . . . . 90 205 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 90 206 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 90 207 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 91 208 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 91 209 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 91 210 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 92 211 10.3.5. Elliptic Curve Algorithms . . . . . . . . . . . . . 92 212 10.4. Elliptic Curve Point and Scalar Wire Formats . . . . . . 93 213 10.5. Changes to existing registries . . . . . . . . . . . . . 93 214 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 93 215 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 93 216 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 95 217 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 95 218 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 96 219 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 96 220 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 96 221 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 97 222 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 99 223 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 99 224 13.2. EC Point Wire Formats . . . . . . . . . . . . . . . . . 100 225 13.2.1. SEC1 EC Point Wire Format . . . . . . . . . . . . . 100 226 13.2.2. Prefixed Native EC Point Wire Format . . . . . . . . 100 227 13.2.3. Notes on EC Point Wire Formats . . . . . . . . . . . 101 228 13.3. EC Scalar Wire Formats . . . . . . . . . . . . . . . . . 101 229 13.3.1. EC Octet String Wire Format . . . . . . . . . . . . 102 230 13.3.2. Elliptic Curve Prefixed Octet String Wire Format . . 103 231 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 103 232 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 104 233 14. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 107 234 14.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 107 235 14.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 107 236 14.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 108 237 14.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 108 238 14.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 109 239 14.3. Other Algorithm Preferences . . . . . . . . . . . . . . 110 240 14.3.1. Compression Preferences . . . . . . . . . . . . . . 110 241 14.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 111 243 14.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 111 244 14.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 111 245 14.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 112 246 14.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 112 247 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 112 248 14.9. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 113 249 14.10. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 113 250 14.11. Private or Experimental Parameters . . . . . . . . . . . 115 251 14.12. Extension of the MDC System . . . . . . . . . . . . . . 115 252 14.13. Meta-Considerations for Expansion . . . . . . . . . . . 116 253 15. Security Considerations . . . . . . . . . . . . . . . . . . . 116 254 16. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 122 255 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 124 256 17.1. Normative References . . . . . . . . . . . . . . . . . . 124 257 17.2. Informative References . . . . . . . . . . . . . . . . . 127 258 Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 128 259 A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 128 260 A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 129 261 A.3. Sample AEAD-EAX encryption and decryption . . . . . . . . 129 262 A.3.1. Sample Parameters . . . . . . . . . . . . . . . . . . 129 263 A.3.2. Sample symmetric-key encrypted session key packet 264 (v5) . . . . . . . . . . . . . . . . . . . . . . . . 130 265 A.3.3. Starting AEAD-EAX decryption of CEK . . . . . . . . . 130 266 A.3.4. Initial Content Encryption Key . . . . . . . . . . . 131 267 A.3.5. Sample AEAD encrypted data packet . . . . . . . . . . 131 268 A.3.6. Decryption of data . . . . . . . . . . . . . . . . . 131 269 A.3.7. Complete AEAD-EAX encrypted packet sequence . . . . . 132 270 A.4. Sample AEAD-OCB encryption and decryption . . . . . . . . 132 271 A.4.1. Sample Parameters . . . . . . . . . . . . . . . . . . 132 272 A.4.2. Sample symmetric-key encrypted session key packet 273 (v5) . . . . . . . . . . . . . . . . . . . . . . . . 133 274 A.4.3. Starting AEAD-OCB decryption of CEK . . . . . . . . . 133 275 A.4.4. Initial Content Encryption Key . . . . . . . . . . . 134 276 A.4.5. Sample AEAD encrypted data packet . . . . . . . . . . 134 277 A.4.6. Decryption of data . . . . . . . . . . . . . . . . . 134 278 A.4.7. Complete AEAD-OCB encrypted packet sequence . . . . . 135 279 Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 135 280 Appendix C. Document Workflow . . . . . . . . . . . . . . . . . 136 281 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 136 283 1. Introduction 285 { This is work in progress to update OpenPGP. Editorial notes are 286 enclosed in curly braces. } 288 This document provides information on the message-exchange packet 289 formats used by OpenPGP to provide encryption, decryption, signing, 290 and key management functions. It is a revision of RFC 4880, "OpenPGP 291 Message Format", which is a revision of RFC 2440, which itself 292 replaces RFC 1991, "PGP Message Exchange Formats" [RFC1991] [RFC2440] 293 [RFC4880]. 295 This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia in 296 OpenPGP) and RFC 6637 (Elliptic Curves in OpenPGP). 298 1.1. Terms 300 * OpenPGP - This is a term for security software that uses PGP 5 as 301 a basis, formalized in this document. 303 * PGP - Pretty Good Privacy. PGP is a family of software systems 304 developed by Philip R. Zimmermann from which OpenPGP is based. 306 * PGP 2 - This version of PGP has many variants; where necessary a 307 more detailed version number is used here. PGP 2 uses only RSA, 308 MD5, and IDEA for its cryptographic transforms. An informational 309 RFC, RFC 1991, was written describing this version of PGP. 311 * PGP 5 - This version of PGP is formerly known as "PGP 3" in the 312 community. It has new formats and corrects a number of problems 313 in the PGP 2 design. It is referred to here as PGP 5 because that 314 software was the first release of the "PGP 3" code base. 316 * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 317 implementation that avoids all encumbered algorithms. 318 Consequently, early versions of GnuPG did not include RSA public 319 keys. 321 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 322 Corporation and are used with permission. The term "OpenPGP" refers 323 to the protocol described in this and related documents. 325 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 326 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 327 document are to be interpreted as described in [RFC2119]. 329 The key words "PRIVATE USE", "SPECIFICATION REQUIRED", and "RFC 330 REQUIRED" that appear in this document when used to describe 331 namespace allocation are to be interpreted as described in [RFC8126]. 333 2. General functions 335 OpenPGP provides data integrity services for messages and data files 336 by using these core technologies: 338 * digital signatures 339 * encryption 341 * compression 343 * Radix-64 conversion 345 In addition, OpenPGP provides key management and certificate 346 services, but many of these are beyond the scope of this document. 348 2.1. Confidentiality via Encryption 350 OpenPGP combines symmetric-key encryption and public-key encryption 351 to provide confidentiality. When made confidential, first the object 352 is encrypted using a symmetric encryption algorithm. Each symmetric 353 key is used only once, for a single object. A new "session key" is 354 generated as a random number for each object (sometimes referred to 355 as a session). Since it is used only once, the session key is bound 356 to the message and transmitted with it. To protect the key, it is 357 encrypted with the receiver's public key. The sequence is as 358 follows: 360 1. The sender creates a message. 362 2. The sending OpenPGP generates a random number to be used as a 363 session key for this message only. 365 3. The session key is encrypted using each recipient's public key. 366 These "encrypted session keys" start the message. 368 4. The sending OpenPGP encrypts the message using the session key, 369 which forms the remainder of the message. Note that the message 370 is also usually compressed. 372 5. The receiving OpenPGP decrypts the session key using the 373 recipient's private key. 375 6. The receiving OpenPGP decrypts the message using the session key. 376 If the message was compressed, it will be decompressed. 378 With symmetric-key encryption, an object may be encrypted with a 379 symmetric key derived from a passphrase (or other shared secret), or 380 a two-stage mechanism similar to the public-key method described 381 above in which a session key is itself encrypted with a symmetric 382 algorithm keyed from a shared secret. 384 Both digital signature and confidentiality services may be applied to 385 the same message. First, a signature is generated for the message 386 and attached to the message. Then the message plus signature is 387 encrypted using a symmetric session key. Finally, the session key is 388 encrypted using public-key encryption and prefixed to the encrypted 389 block. 391 2.2. Authentication via Digital Signature 393 The digital signature uses a hash code or message digest algorithm, 394 and a public-key signature algorithm. The sequence is as follows: 396 1. The sender creates a message. 398 2. The sending software generates a hash code of the message. 400 3. The sending software generates a signature from the hash code 401 using the sender's private key. 403 4. The binary signature is attached to the message. 405 5. The receiving software keeps a copy of the message signature. 407 6. The receiving software generates a new hash code for the received 408 message and verifies it using the message's signature. If the 409 verification is successful, the message is accepted as authentic. 411 2.3. Compression 413 OpenPGP implementations SHOULD compress the message after applying 414 the signature but before encryption. 416 If an implementation does not implement compression, its authors 417 should be aware that most OpenPGP messages in the world are 418 compressed. Thus, it may even be wise for a space-constrained 419 implementation to implement decompression, but not compression. 421 Furthermore, compression has the added side effect that some types of 422 attacks can be thwarted by the fact that slightly altered, compressed 423 data rarely uncompresses without severe errors. This is hardly 424 rigorous, but it is operationally useful. These attacks can be 425 rigorously prevented by implementing and using Modification Detection 426 Codes as described in sections following. 428 2.4. Conversion to Radix-64 430 OpenPGP's underlying native representation for encrypted messages, 431 signature certificates, and keys is a stream of arbitrary octets. 432 Some systems only permit the use of blocks consisting of seven-bit, 433 printable text. For transporting OpenPGP's native raw binary octets 434 through channels that are not safe to raw binary data, a printable 435 encoding of these binary octets is needed. OpenPGP provides the 436 service of converting the raw 8-bit binary octet stream to a stream 437 of printable ASCII characters, called Radix-64 encoding or ASCII 438 Armor. 440 Implementations SHOULD provide Radix-64 conversions. 442 2.5. Signature-Only Applications 444 OpenPGP is designed for applications that use both encryption and 445 signatures, but there are a number of problems that are solved by a 446 signature-only implementation. Although this specification requires 447 both encryption and signatures, it is reasonable for there to be 448 subset implementations that are non-conformant only in that they omit 449 encryption. 451 3. Data Element Formats 453 This section describes the data elements used by OpenPGP. 455 3.1. Scalar Numbers 457 Scalar numbers are unsigned and are always stored in big-endian 458 format. Using n[k] to refer to the kth octet being interpreted, the 459 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 460 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 461 n[3]). 463 3.2. Multiprecision Integers 465 Multiprecision integers (also called MPIs) are unsigned integers used 466 to hold large integers such as the ones used in cryptographic 467 calculations. 469 An MPI consists of two pieces: a two-octet scalar that is the length 470 of the MPI in bits followed by a string of octets that contain the 471 actual integer. 473 These octets form a big-endian number; a big-endian number can be 474 made into an MPI by prefixing it with the appropriate length. 476 Examples: 478 (all numbers are in hexadecimal) 480 The string of octets [00 01 01] forms an MPI with the value 1. The 481 string [00 09 01 FF] forms an MPI with the value of 511. 483 Additional rules: 485 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 487 The length field of an MPI describes the length starting from its 488 most significant non-zero bit. Thus, the MPI [00 02 01] is not 489 formed correctly. It should be [00 01 01]. 491 Unused bits of an MPI MUST be zero. 493 Also note that when an MPI is encrypted, the length refers to the 494 plaintext MPI. It may be ill-formed in its ciphertext. 496 3.2.1. Using MPIs to encode other data 498 Note that MPIs are used in some places used to encode non-integer 499 data, such as an elliptic curve point (see Section 13.2, or an octet 500 string of known, fixed length (see Section 13.3). The wire 501 representation is the same: two octets of length in bits counted from 502 the first non-zero bit, followed by the smallest series of octets 503 that can represent the value while stripping off any leading zero 504 octets. 506 3.3. Key IDs 508 A Key ID is an eight-octet scalar that identifies a key. 509 Implementations SHOULD NOT assume that Key IDs are unique. 510 Section 12 describes how Key IDs are formed. 512 3.4. Text 514 Unless otherwise specified, the character set for text is the UTF-8 515 [RFC3629] encoding of Unicode [ISO10646]. 517 3.5. Time Fields 519 A time field is an unsigned four-octet number containing the number 520 of seconds elapsed since midnight, 1 January 1970 UTC. 522 3.6. Keyrings 524 A keyring is a collection of one or more keys in a file or database. 525 Traditionally, a keyring is simply a sequential list of keys, but may 526 be any suitable database. It is beyond the scope of this standard to 527 discuss the details of keyrings or other databases. 529 3.7. String-to-Key (S2K) Specifiers 531 String-to-key (S2K) specifiers are used to convert passphrase strings 532 into symmetric-key encryption/decryption keys. They are used in two 533 places, currently: to encrypt the secret part of private keys in the 534 private keyring, and to convert passphrases to encryption keys for 535 symmetrically encrypted messages. 537 3.7.1. String-to-Key (S2K) Specifier Types 539 There are three types of S2K specifiers currently supported, and some 540 reserved values: 542 +========+==================+==================+=================+ 543 | ID | S2K Type | Generate? | Reference | 544 +========+==================+==================+=================+ 545 | 0 | Simple S2K | N | Section 3.7.1.1 | 546 +--------+------------------+------------------+-----------------+ 547 | 1 | Salted S2K | Only when string | Section 3.7.1.2 | 548 | | | is high entropy | | 549 +--------+------------------+------------------+-----------------+ 550 | 2 | Reserved value | N | | 551 +--------+------------------+------------------+-----------------+ 552 | 3 | Iterated and | Y | Section 3.7.1.3 | 553 | | Salted S2K | | | 554 +--------+------------------+------------------+-----------------+ 555 | 4 | Argon2 | Y | Section 3.7.1.4 | 556 +--------+------------------+------------------+-----------------+ 557 | 100 to | Private/ | As appropriate | | 558 | 110 | Experimental S2K | | | 559 +--------+------------------+------------------+-----------------+ 561 Table 1: S2K type registry 563 These are described in the subsections below. 565 3.7.1.1. Simple S2K 567 This directly hashes the string to produce the key data. See below 568 for how this hashing is done. 570 Octet 0: 0x00 571 Octet 1: hash algorithm 573 Simple S2K hashes the passphrase to produce the session key. The 574 manner in which this is done depends on the size of the session key 575 (which will depend on the cipher used) and the size of the hash 576 algorithm's output. If the hash size is greater than the session key 577 size, the high-order (leftmost) octets of the hash are used as the 578 key. 580 If the hash size is less than the key size, multiple instances of the 581 hash context are created -- enough to produce the required key data. 582 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 583 is to say, the first instance has no preloading, the second gets 584 preloaded with 1 octet of zero, the third is preloaded with two 585 octets of zeros, and so forth). 587 As the data is hashed, it is given independently to each hash 588 context. Since the contexts have been initialized differently, they 589 will each produce different hash output. Once the passphrase is 590 hashed, the output data from the multiple hashes is concatenated, 591 first hash leftmost, to produce the key data, with any excess octets 592 on the right discarded. 594 3.7.1.2. Salted S2K 596 This includes a "salt" value in the S2K specifier -- some arbitrary 597 data -- that gets hashed along with the passphrase string, to help 598 prevent dictionary attacks. 600 Octet 0: 0x01 601 Octet 1: hash algorithm 602 Octets 2-9: 8-octet salt value 604 Salted S2K is exactly like Simple S2K, except that the input to the 605 hash function(s) consists of the 8 octets of salt from the S2K 606 specifier, followed by the passphrase. 608 3.7.1.3. Iterated and Salted S2K 610 This includes both a salt and an octet count. The salt is combined 611 with the passphrase and the resulting value is hashed repeatedly. 612 This further increases the amount of work an attacker must do to try 613 dictionary attacks. 615 Octet 0: 0x03 616 Octet 1: hash algorithm 617 Octets 2-9: 8-octet salt value 618 Octet 10: count, a one-octet, coded value 620 The count is coded into a one-octet number using the following 621 formula: 623 #define EXPBIAS 6 624 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 626 The above formula is in C, where "Int32" is a type for a 32-bit 627 integer, and the variable "c" is the coded count, Octet 10. 629 Iterated-Salted S2K hashes the passphrase and salt data multiple 630 times. The total number of octets to be hashed is specified in the 631 encoded count in the S2K specifier. Note that the resulting count 632 value is an octet count of how many octets will be hashed, not an 633 iteration count. 635 Initially, one or more hash contexts are set up as with the other S2K 636 algorithms, depending on how many octets of key data are needed. 637 Then the salt, followed by the passphrase data, is repeatedly hashed 638 until the number of octets specified by the octet count has been 639 hashed. The one exception is that if the octet count is less than 640 the size of the salt plus passphrase, the full salt plus passphrase 641 will be hashed even though that is greater than the octet count. 642 After the hashing is done, the data is unloaded from the hash 643 context(s) as with the other S2K algorithms. 645 3.7.1.4. Argon2 647 This S2K method hashes the passphrase using Argon2, specified in 648 [RFC9106]. This provides memory-hardness, further protecting the 649 passphrase against brute-force attacks. 651 Octet 0: 0x04 652 Octets 1-16: 16-octet salt value 653 Octet 17: one-octet number of passes t 654 Octet 18: one-octet degree of parallelism p 655 Octet 19: one-octet exponent indicating the memory size m 657 The salt SHOULD be unique for each password. 659 The number of passes t and the degree of parallelism p MUST be non- 660 zero. 662 The memory size m is 2**encoded_m, where "encoded_m" is the encoded 663 memory size in Octet 19. The encoded memory size MUST be a value 664 from 3+ceil(log_2(p)) to 31, such that the decoded memory size m is a 665 value from 8*p to 2**31. 667 Argon2 is invoked with the passphrase as P, the salt as S, the values 668 of t, p and m as described above, the required key size as the tag 669 length T, 0x13 as the version v, and Argon2id as the type. 671 For the recommended values of t, p and m, see Section 4 of [RFC9106]. 672 If the recommended value of m for a given application is not a power 673 of 2, it is RECOMMENDED to round up to the next power of 2 if the 674 resulting performance would be acceptable, and round down otherwise 675 (keeping in mind that m must be at least 8*p). 677 As an example, with the first recommended option (t=1, p=4, m=2**21), 678 the full S2K specifier would be: 680 04 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 681 XX 01 04 15 683 (where XX represents a random octet of salt). 685 3.7.2. String-to-Key Usage 687 Simple S2K and Salted S2K specifiers can be brute-forced when used 688 with a low-entropy string, such as those typically provided by users. 689 In addition, the usage of Simple S2K can lead to key and IV reuse 690 (see Section 5.3). Therefore, when generating S2K specifiers, 691 implementations MUST NOT use Simple S2K, and SHOULD NOT use Salted 692 S2K unless the implementation knows that the string is high-entropy 693 (e.g., it generated the string itself using a known-good source of 694 randomness). It is RECOMMENDED that implementations use Argon2. 696 3.7.2.1. Secret-Key Encryption 698 An S2K specifier can be stored in the secret keyring to specify how 699 to convert the passphrase to a key that unlocks the secret data. 700 Older versions of PGP just stored a symmetric cipher algorithm octet 701 preceding the secret data or a zero to indicate that the secret data 702 was unencrypted. The MD5 hash function was always used to convert 703 the passphrase to a key for the specified cipher algorithm. 705 For compatibility, when an S2K specifier is used, the special value 706 253, 254, or 255 is stored in the position where the cipher algorithm 707 octet would have been in the old data structure. This is then 708 followed immediately by a one-octet algorithm identifier, and then by 709 the S2K specifier as encoded above. 711 Therefore, preceding the secret data there will be one of these 712 possibilities: 714 0: secret data is unencrypted (no passphrase) 715 255, 254, or 253: followed by algorithm octet and S2K specifier 716 Cipher alg: use Simple S2K algorithm using MD5 hash 718 This last possibility, the cipher algorithm number with an implicit 719 use of MD5 and IDEA, is provided for backward compatibility; it MAY 720 be understood, but SHOULD NOT be generated, and is deprecated. 722 These are followed by an Initial Vector of the same length as the 723 block size of the cipher for the decryption of the secret values, if 724 they are encrypted, and then the secret-key values themselves. 726 3.7.2.2. Symmetric-Key Message Encryption 728 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 729 at the front of a message. This is used to allow S2K specifiers to 730 be used for the passphrase conversion or to create messages with a 731 mix of symmetric-key ESKs and public-key ESKs. This allows a message 732 to be decrypted either with a passphrase or a public-key pair. 734 PGP 2 always used IDEA with Simple string-to-key conversion when 735 encrypting a message with a symmetric algorithm. This is deprecated, 736 but MAY be used for backward-compatibility. 738 4. Packet Syntax 740 This section describes the packets used by OpenPGP. 742 4.1. Overview 744 An OpenPGP message is constructed from a number of records that are 745 traditionally called packets. A packet is a chunk of data that has a 746 tag specifying its meaning. An OpenPGP message, keyring, 747 certificate, and so forth consists of a number of packets. Some of 748 those packets may contain other OpenPGP packets (for example, a 749 compressed data packet, when uncompressed, contains OpenPGP packets). 751 Each packet consists of a packet header, followed by the packet body. 752 The packet header is of variable length. 754 4.2. Packet Headers 756 The first octet of the packet header is called the "Packet Tag". It 757 determines the format of the header and denotes the packet contents. 758 The remainder of the packet header is the length of the packet. 760 Note that the most significant bit is the leftmost bit, called bit 7. 761 A mask for this bit is 0x80 in hexadecimal. 763 ┌───────────────┐ 764 PTag │7 6 5 4 3 2 1 0│ 765 └───────────────┘ 766 Bit 7 -- Always one 767 Bit 6 -- New packet format if set 769 PGP 2.6.x only uses old format packets. Thus, software that 770 interoperates with those versions of PGP must only use old format 771 packets. If interoperability is not an issue, the new packet format 772 is RECOMMENDED. Note that old format packets have four bits of 773 packet tags, and new format packets have six; some features cannot be 774 used and still be backward-compatible. 776 Also note that packets with a tag greater than or equal to 16 MUST 777 use new format packets. The old format packets can only express tags 778 less than or equal to 15. 780 Old format packets contain: 782 Bits 5-2 -- packet tag 783 Bits 1-0 -- length-type 785 New format packets contain: 787 Bits 5-0 -- packet tag 789 4.2.1. Old Format Packet Lengths 791 The meaning of the length-type in old format packets is: 793 0 The packet has a one-octet length. The header is 2 octets long. 795 1 The packet has a two-octet length. The header is 3 octets long. 797 2 The packet has a four-octet length. The header is 5 octets long. 799 3 The packet is of indeterminate length. The header is 1 octet 800 long, and the implementation must determine how long the packet 801 is. If the packet is in a file, this means that the packet 802 extends until the end of the file. In general, an implementation 803 SHOULD NOT use indeterminate-length packets except where the end 804 of the data will be clear from the context, and even then it is 805 better to use a definite length, or a new format header. The new 806 format headers described below have a mechanism for precisely 807 encoding data of indeterminate length. 809 4.2.2. New Format Packet Lengths 811 New format packets have four possible ways of encoding length: 813 1. A one-octet Body Length header encodes packet lengths of up to 814 191 octets. 816 2. A two-octet Body Length header encodes packet lengths of 192 to 817 8383 octets. 819 3. A five-octet Body Length header encodes packet lengths of up to 820 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 821 encodes a four-octet scalar number.) 823 4. When the length of the packet body is not known in advance by the 824 issuer, Partial Body Length headers encode a packet of 825 indeterminate length, effectively making it a stream. 827 4.2.2.1. One-Octet Lengths 829 A one-octet Body Length header encodes a length of 0 to 191 octets. 830 This type of length header is recognized because the one octet value 831 is less than 192. The body length is equal to: 833 bodyLen = 1st_octet; 835 4.2.2.2. Two-Octet Lengths 837 A two-octet Body Length header encodes a length of 192 to 8383 838 octets. It is recognized because its first octet is in the range 192 839 to 223. The body length is equal to: 841 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 843 4.2.2.3. Five-Octet Lengths 845 A five-octet Body Length header consists of a single octet holding 846 the value 255, followed by a four-octet scalar. The body length is 847 equal to: 849 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 850 (4th_octet << 8) | 5th_octet 852 This basic set of one, two, and five-octet lengths is also used 853 internally to some packets. 855 4.2.2.4. Partial Body Lengths 857 A Partial Body Length header is one octet long and encodes the length 858 of only part of the data packet. This length is a power of 2, from 1 859 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 860 octet value that is greater than or equal to 224, and less than 255. 861 The Partial Body Length is equal to: 863 partialBodyLen = 1 << (1st_octet & 0x1F); 865 Each Partial Body Length header is followed by a portion of the 866 packet body data. The Partial Body Length header specifies this 867 portion's length. Another length header (one octet, two-octet, five- 868 octet, or partial) follows that portion. The last length header in 869 the packet MUST NOT be a Partial Body Length header. Partial Body 870 Length headers may only be used for the non-final parts of the 871 packet. 873 Note also that the last Body Length header can be a zero-length 874 header. 876 An implementation MAY use Partial Body Lengths for data packets, be 877 they literal, compressed, or encrypted. The first partial length 878 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 879 used for any other packet types. 881 4.2.3. Packet Length Examples 883 These examples show ways that new format packets might encode the 884 packet lengths. 886 A packet with length 100 may have its length encoded in one octet: 887 0x64. This is followed by 100 octets of data. 889 A packet with length 1723 may have its length encoded in two octets: 890 0xC5, 0xFB. This header is followed by the 1723 octets of data. 892 A packet with length 100000 may have its length encoded in five 893 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 895 It might also be encoded in the following octet stream: 0xEF, first 896 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 897 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 898 octets of data. This is just one possible encoding, and many 899 variations are possible on the size of the Partial Body Length 900 headers, as long as a regular Body Length header encodes the last 901 portion of the data. 903 Please note that in all of these explanations, the total length of 904 the packet is the length of the header(s) plus the length of the 905 body. 907 4.3. Packet Tags 909 The packet tag denotes what type of packet the body holds. Note that 910 old format headers can only have tags less than 16, whereas new 911 format headers can have tags as great as 63. The defined tags (in 912 decimal) are as follows: 914 +==========+====================================================+ 915 | Tag | Packet Type | 916 +==========+====================================================+ 917 | 0 | Reserved - a packet tag MUST NOT have this value | 918 +----------+----------------------------------------------------+ 919 | 1 | Public-Key Encrypted Session Key Packet | 920 +----------+----------------------------------------------------+ 921 | 2 | Signature Packet | 922 +----------+----------------------------------------------------+ 923 | 3 | Symmetric-Key Encrypted Session Key Packet | 924 +----------+----------------------------------------------------+ 925 | 4 | One-Pass Signature Packet | 926 +----------+----------------------------------------------------+ 927 | 5 | Secret-Key Packet | 928 +----------+----------------------------------------------------+ 929 | 6 | Public-Key Packet | 930 +----------+----------------------------------------------------+ 931 | 7 | Secret-Subkey Packet | 932 +----------+----------------------------------------------------+ 933 | 8 | Compressed Data Packet | 934 +----------+----------------------------------------------------+ 935 | 9 | Symmetrically Encrypted Data Packet | 936 +----------+----------------------------------------------------+ 937 | 10 | Marker Packet | 938 +----------+----------------------------------------------------+ 939 | 11 | Literal Data Packet | 940 +----------+----------------------------------------------------+ 941 | 12 | Trust Packet | 942 +----------+----------------------------------------------------+ 943 | 13 | User ID Packet | 944 +----------+----------------------------------------------------+ 945 | 14 | Public-Subkey Packet | 946 +----------+----------------------------------------------------+ 947 | 17 | User Attribute Packet | 948 +----------+----------------------------------------------------+ 949 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 950 +----------+----------------------------------------------------+ 951 | 19 | Modification Detection Code Packet | 952 +----------+----------------------------------------------------+ 953 | 20 | AEAD Encrypted Data Packet | 954 +----------+----------------------------------------------------+ 955 | 60 to 63 | Private or Experimental Values | 956 +----------+----------------------------------------------------+ 958 Table 2: Packet type registry 960 5. Packet Types 961 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 963 Zero or more Public-Key Encrypted Session Key packets and/or 964 Symmetric-Key Encrypted Session Key packets may precede an encryption 965 container (i.e. a Symmetrically Encrypted Integrity Protected Data 966 packet, an AEAD Encrypted Data packet, or -- for historic data -- a 967 Symmetrically Encrypted Data packet), which holds an encrypted 968 message. The message is encrypted with the session key, and the 969 session key is itself encrypted and stored in the Encrypted Session 970 Key packet(s). The encryption container is preceded by one Public- 971 Key Encrypted Session Key packet for each OpenPGP key to which the 972 message is encrypted. The recipient of the message finds a session 973 key that is encrypted to their public key, decrypts the session key, 974 and then uses the session key to decrypt the message. 976 The body of this packet consists of: 978 * A one-octet number giving the version number of the packet type. 979 The currently defined value for packet version is 3. 981 * An eight-octet number that gives the Key ID of the public key to 982 which the session key is encrypted. If the session key is 983 encrypted to a subkey, then the Key ID of this subkey is used here 984 instead of the Key ID of the primary key. 986 * A one-octet number giving the public-key algorithm used. 988 * A string of octets that is the encrypted session key. This string 989 takes up the remainder of the packet, and its contents are 990 dependent on the public-key algorithm used. 992 5.1.1. Algorithm Specific Fields for RSA encryption 994 * Multiprecision integer (MPI) of RSA-encrypted value m**e mod n. 996 5.1.2. Algorithm Specific Fields for Elgamal encryption 998 * MPI of Elgamal (Diffie-Hellman) value g**k mod p. 1000 * MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 1002 5.1.3. Algorithm-Specific Fields for ECDH encryption 1004 * MPI of an EC point representing an ephemeral public key, in the 1005 point format associated with the curve as specified in 1006 Section 9.2. 1008 * A one-octet size, followed by a symmetric key encoded using the 1009 method described in Section 13.5. 1011 5.1.4. Notes on PKESK 1013 The value "m" in the above formulas is derived from the session key 1014 as follows. First, the session key is prefixed with a one-octet 1015 algorithm identifier that specifies the symmetric encryption 1016 algorithm used to encrypt the following encryption container. Then a 1017 two-octet checksum is appended, which is equal to the sum of the 1018 preceding session key octets, not including the algorithm identifier, 1019 modulo 65536. This value is then encoded as described in PKCS#1 1020 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to form 1021 the "m" value used in the formulas above. See Section 14.1 in this 1022 document for notes on OpenPGP's use of PKCS#1. 1024 Note that when an implementation forms several PKESKs with one 1025 session key, forming a message that can be decrypted by several keys, 1026 the implementation MUST make a new PKCS#1 encoding for each key. 1028 An implementation MAY accept or use a Key ID of zero as a "wild card" 1029 or "speculative" Key ID. In this case, the receiving implementation 1030 would try all available private keys, checking for a valid decrypted 1031 session key. This format helps reduce traffic analysis of messages. 1033 5.2. Signature Packet (Tag 2) 1035 A Signature packet describes a binding between some public key and 1036 some data. The most common signatures are a signature of a file or a 1037 block of text, and a signature that is a certification of a User ID. 1039 Three versions of Signature packets are defined. Version 3 provides 1040 basic signature information, while versions 4 and 5 provide an 1041 expandable format with subpackets that can specify more information 1042 about the signature. PGP 2.6.x only accepts version 3 signatures. 1044 Implementations MUST generate version 5 signatures when using a 1045 version 5 key. Implementations SHOULD generate V4 signatures with 1046 version 4 keys. Implementations MUST NOT create version 3 1047 signatures; they MAY accept version 3 signatures. 1049 5.2.1. Signature Types 1051 There are a number of possible meanings for a signature, which are 1052 indicated in a signature type octet in any given signature. Please 1053 note that the vagueness of these meanings is not a flaw, but a 1054 feature of the system. Because OpenPGP places final authority for 1055 validity upon the receiver of a signature, it may be that one 1056 signer's casual act might be more rigorous than some other 1057 authority's positive act. See Section 5.2.4 for detailed information 1058 on how to compute and verify signatures of each type. 1060 These meanings are as follows: 1062 0x00: Signature of a binary document. 1063 This means the signer owns it, created it, or certifies that it 1064 has not been modified. 1066 0x01: Signature of a canonical text document. 1067 This means the signer owns it, created it, or certifies that it 1068 has not been modified. The signature is calculated over the text 1069 data with its line endings converted to . 1071 0x02: Standalone signature. 1072 This signature is a signature of only its own subpacket contents. 1073 It is calculated identically to a signature over a zero-length 1074 binary document. Note that it doesn't make sense to have a V3 1075 standalone signature. 1077 0x10: Generic certification of a User ID and Public-Key packet. 1078 The issuer of this certification does not make any particular 1079 assertion as to how well the certifier has checked that the owner 1080 of the key is in fact the person described by the User ID. 1082 0x11: Persona certification of a User ID and Public-Key packet. 1083 The issuer of this certification has not done any verification of 1084 the claim that the owner of this key is the User ID specified. 1086 0x12: Casual certification of a User ID and Public-Key packet. 1087 The issuer of this certification has done some casual verification 1088 of the claim of identity. 1090 0x13: Positive certification of a User ID and Public-Key packet. 1091 The issuer of this certification has done substantial verification 1092 of the claim of identity. Most OpenPGP implementations make their 1093 "key signatures" as 0x10 certifications. Some implementations can 1094 issue 0x11-0x13 certifications, but few differentiate between the 1095 types. 1097 0x18: Subkey Binding Signature. 1098 This signature is a statement by the top-level signing key that 1099 indicates that it owns the subkey. This signature is calculated 1100 directly on the primary key and subkey, and not on any User ID or 1101 other packets. A signature that binds a signing subkey MUST have 1102 an Embedded Signature subpacket in this binding signature that 1103 contains a 0x19 signature made by the signing subkey on the 1104 primary key and subkey. 1106 0x19: Primary Key Binding Signature. 1107 This signature is a statement by a signing subkey, indicating that 1108 it is owned by the primary key and subkey. This signature is 1109 calculated the same way as a 0x18 signature: directly on the 1110 primary key and subkey, and not on any User ID or other packets. 1112 0x1F: Signature directly on a key. 1113 This signature is calculated directly on a key. It binds the 1114 information in the Signature subpackets to the key, and is 1115 appropriate to be used for subpackets that provide information 1116 about the key, such as the Revocation Key subpacket. It is also 1117 appropriate for statements that non-self certifiers want to make 1118 about the key itself, rather than the binding between a key and a 1119 name. 1121 0x20: Key revocation signature. 1122 The signature is calculated directly on the key being revoked. A 1123 revoked key is not to be used. Only revocation signatures by the 1124 key being revoked, or by an authorized revocation key, should be 1125 considered valid revocation signatures. 1127 0x28: Subkey revocation signature. 1128 The signature is calculated directly on the subkey being revoked. 1129 A revoked subkey is not to be used. Only revocation signatures by 1130 the top-level signature key that is bound to this subkey, or by an 1131 authorized revocation key, should be considered valid revocation 1132 signatures. 1134 0x30: Certification revocation signature. 1135 This signature revokes an earlier User ID certification signature 1136 (signature class 0x10 through 0x13) or direct-key signature 1137 (0x1F). It should be issued by the same key that issued the 1138 revoked signature or an authorized revocation key. The signature 1139 is computed over the same data as the certificate that it revokes, 1140 and should have a later creation date than that certificate. 1142 0x40: Timestamp signature. 1143 This signature is only meaningful for the timestamp contained in 1144 it. 1146 0x50: Third-Party Confirmation signature. 1147 This signature is a signature over some other OpenPGP Signature 1148 packet(s). It is analogous to a notary seal on the signed data. 1149 A third-party signature SHOULD include Signature Target 1150 subpacket(s) to give easy identification. Note that we really do 1151 mean SHOULD. There are plausible uses for this (such as a blind 1152 party that only sees the signature, not the key or source 1153 document) that cannot include a target subpacket. 1155 5.2.2. Version 3 Signature Packet Format 1157 The body of a version 3 Signature Packet contains: 1159 * One-octet version number (3). 1161 * One-octet length of following hashed material. MUST be 5. 1163 - One-octet signature type. 1165 - Four-octet creation time. 1167 * Eight-octet Key ID of signer. 1169 * One-octet public-key algorithm. 1171 * One-octet hash algorithm. 1173 * Two-octet field holding left 16 bits of signed hash value. 1175 * One or more multiprecision integers comprising the signature. 1176 This portion is algorithm specific, as described below. 1178 The concatenation of the data to be signed, the signature type, and 1179 creation time from the Signature packet (5 additional octets) is 1180 hashed. The resulting hash value is used in the signature algorithm. 1181 The high 16 bits (first two octets) of the hash are included in the 1182 Signature packet to provide a way to reject some invalid signatures 1183 without performing a signature verification. 1185 Algorithm-Specific Fields for RSA signatures: 1187 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1189 Algorithm-Specific Fields for DSA and ECDSA signatures: 1191 * MPI of DSA or ECDSA value r. 1193 * MPI of DSA or ECDSA value s. 1195 The signature calculation is based on a hash of the signed data, as 1196 described above. The details of the calculation are different for 1197 DSA signatures than for RSA signatures. 1199 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1200 type EMSA-PKCS1-v1_5 as described in Section 9.2 of [RFC3447]. This 1201 requires inserting the hash value as an octet string into an ASN.1 1202 structure. The object identifier for the type of hash being used is 1203 included in the structure. The hexadecimal representations for the 1204 currently defined hash algorithms are as follows: 1206 +============+======================================================+ 1207 | algorithm | hexadecimal represenatation | 1208 +============+======================================================+ 1209 | MD5 | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 | 1210 +------------+------------------------------------------------------+ 1211 | RIPEMD-160 | 0x2B, 0x24, 0x03, 0x02, 0x01 | 1212 +------------+------------------------------------------------------+ 1213 | SHA-1 | 0x2B, 0x0E, 0x03, 0x02, 0x1A | 1214 +------------+------------------------------------------------------+ 1215 | SHA224 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1216 | | 0x02, 0x04 | 1217 +------------+------------------------------------------------------+ 1218 | SHA256 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1219 | | 0x02, 0x01 | 1220 +------------+------------------------------------------------------+ 1221 | SHA384 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1222 | | 0x02, 0x02 | 1223 +------------+------------------------------------------------------+ 1224 | SHA512 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1225 | | 0x02, 0x03 | 1226 +------------+------------------------------------------------------+ 1228 Table 3: Hash hexadecimal representations 1230 The ASN.1 Object Identifiers (OIDs) are as follows: 1232 +============+========================+ 1233 | algorithm | OID | 1234 +============+========================+ 1235 | MD5 | 1.2.840.113549.2.5 | 1236 +------------+------------------------+ 1237 | RIPEMD-160 | 1.3.36.3.2.1 | 1238 +------------+------------------------+ 1239 | SHA-1 | 1.3.14.3.2.26 | 1240 +------------+------------------------+ 1241 | SHA224 | 2.16.840.1.101.3.4.2.4 | 1242 +------------+------------------------+ 1243 | SHA256 | 2.16.840.1.101.3.4.2.1 | 1244 +------------+------------------------+ 1245 | SHA384 | 2.16.840.1.101.3.4.2.2 | 1246 +------------+------------------------+ 1247 | SHA512 | 2.16.840.1.101.3.4.2.3 | 1248 +------------+------------------------+ 1250 Table 4: Hash OIDs 1252 The full hash prefixes for these are as follows: 1254 +============+==========================================+ 1255 | algorithm | full hash prefix | 1256 +============+==========================================+ 1257 | MD5 | 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, | 1258 | | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, | 1259 | | 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 | 1260 +------------+------------------------------------------+ 1261 | RIPEMD-160 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1262 | | 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, | 1263 | | 0x00, 0x04, 0x14 | 1264 +------------+------------------------------------------+ 1265 | SHA-1 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1266 | | 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, | 1267 | | 0x00, 0x04, 0x14 | 1268 +------------+------------------------------------------+ 1269 | SHA224 | 0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, | 1270 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1271 | | 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C | 1272 +------------+------------------------------------------+ 1273 | SHA256 | 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, | 1274 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1275 | | 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 | 1276 +------------+------------------------------------------+ 1277 | SHA384 | 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, | 1278 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1279 | | 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 | 1280 +------------+------------------------------------------+ 1281 | SHA512 | 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, | 1282 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1283 | | 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 | 1284 +------------+------------------------------------------+ 1286 Table 5: Hash hexadecimal prefixes 1288 DSA signatures MUST use hashes that are equal in size to the number 1289 of bits of q, the group generated by the DSA key's generator value. 1291 If the output size of the chosen hash is larger than the number of 1292 bits of q, the hash result is truncated to fit by taking the number 1293 of leftmost bits equal to the number of bits of q. This (possibly 1294 truncated) hash function result is treated as a number and used 1295 directly in the DSA signature algorithm. 1297 5.2.3. Version 4 and 5 Signature Packet Formats 1299 The body of a V4 or V5 Signature packet contains: 1301 * One-octet version number. This is 4 for V4 signatures and 5 for 1302 V5 signatures. 1304 * One-octet signature type. 1306 * One-octet public-key algorithm. 1308 * One-octet hash algorithm. 1310 * Two-octet scalar octet count for following hashed subpacket data. 1311 Note that this is the length in octets of all of the hashed 1312 subpackets; a pointer incremented by this number will skip over 1313 the hashed subpackets. 1315 * Hashed subpacket data set (zero or more subpackets). 1317 * Two-octet scalar octet count for the following unhashed subpacket 1318 data. Note that this is the length in octets of all of the 1319 unhashed subpackets; a pointer incremented by this number will 1320 skip over the unhashed subpackets. 1322 * Unhashed subpacket data set (zero or more subpackets). 1324 * Two-octet field holding the left 16 bits of the signed hash value. 1326 * One or more multiprecision integers comprising the signature. 1327 This portion is algorithm specific: 1329 5.2.3.1. Algorithm-Specific Fields for RSA signatures 1331 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1333 5.2.3.2. Algorithm-Specific Fields for DSA or ECDSA signatures 1335 * MPI of DSA or ECDSA value r. 1337 * MPI of DSA or ECDSA value s. 1339 5.2.3.3. Algorithm-Specific Fields for EdDSA signatures 1341 * Two MPI-encoded values, whose contents and formatting depend on 1342 the choice of curve used (see Section 9.2.1). 1344 A version 3 signature MUST NOT be created and MUST NOT be used with 1345 EdDSA. 1347 5.2.3.3.1. Algorithm-Specific Fields for Ed25519 signatures 1349 The two MPIs for Ed25519 use octet strings R and S as described in 1350 [RFC8032]. 1352 * MPI of an EC point R, represented as a (non-prefixed) native 1353 (little-endian) octet string up to 32 octets. 1355 * MPI of EdDSA value S, also in (non-prefixed) native little-endian 1356 format with a length up to 32 octets. 1358 5.2.3.3.2. Algorithm-Specific Fields for Ed448 signatures 1360 For Ed448 signatures, the native signature format is used as 1361 described in [RFC8032]. The two MPIs are composed as follows: 1363 * The first MPI has a body of 58 octets: a prefix 0x40 octet, 1364 followed by 57 octets of the native signature. 1366 * The second MPI is set to 0 (this is a placeholder, and is unused). 1367 Note that an MPI with a value of 0 is encoded on the wire as a 1368 pair of zero octets: "00 00". 1370 5.2.3.4. Notes on Signatures 1372 The concatenation of the data being signed and the signature data 1373 from the version number through the hashed subpacket data (inclusive) 1374 is hashed. The resulting hash value is what is signed. The high 16 1375 bits (first two octets) of the hash are included in the Signature 1376 packet to provide a way to reject some invalid signatures without 1377 performing a signature verification. 1379 There are two fields consisting of Signature subpackets. The first 1380 field is hashed with the rest of the signature data, while the second 1381 is unhashed. The second set of subpackets is not cryptographically 1382 protected by the signature and should include only advisory 1383 information. 1385 The difference between a V4 and V5 signature is that the latter 1386 includes additional meta data. 1388 The algorithms for converting the hash function result to a signature 1389 are described in a section below. 1391 5.2.3.5. Signature Subpacket Specification 1393 A subpacket data set consists of zero or more Signature subpackets. 1394 In Signature packets, the subpacket data set is preceded by a two- 1395 octet scalar count of the length in octets of all the subpackets. A 1396 pointer incremented by this number will skip over the subpacket data 1397 set. 1399 Each subpacket consists of a subpacket header and a body. The header 1400 consists of: 1402 * the subpacket length (1, 2, or 5 octets), 1404 * the subpacket type (1 octet), 1406 and is followed by the subpacket-specific data. 1408 The length includes the type octet but not this length. Its format 1409 is similar to the "new" format packet header lengths, but cannot have 1410 Partial Body Lengths. That is: 1412 if the 1st octet < 192, then 1413 lengthOfLength = 1 1414 subpacketLen = 1st_octet 1416 if the 1st octet >= 192 and < 255, then 1417 lengthOfLength = 2 1418 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1420 if the 1st octet = 255, then 1421 lengthOfLength = 5 1422 subpacket length = [four-octet scalar starting at 2nd_octet] 1424 The value of the subpacket type octet may be: 1426 +============+========================================+ 1427 | Type | Description | 1428 +============+========================================+ 1429 | 0 | Reserved | 1430 +------------+----------------------------------------+ 1431 | 1 | Reserved | 1432 +------------+----------------------------------------+ 1433 | 2 | Signature Creation Time | 1434 +------------+----------------------------------------+ 1435 | 3 | Signature Expiration Time | 1436 +------------+----------------------------------------+ 1437 | 4 | Exportable Certification | 1438 +------------+----------------------------------------+ 1439 | 5 | Trust Signature | 1440 +------------+----------------------------------------+ 1441 | 6 | Regular Expression | 1442 +------------+----------------------------------------+ 1443 | 7 | Revocable | 1444 +------------+----------------------------------------+ 1445 | 8 | Reserved | 1446 +------------+----------------------------------------+ 1447 | 9 | Key Expiration Time | 1448 +------------+----------------------------------------+ 1449 | 10 | Placeholder for backward compatibility | 1450 +------------+----------------------------------------+ 1451 | 11 | Preferred Symmetric Algorithms | 1452 +------------+----------------------------------------+ 1453 | 12 | Revocation Key | 1454 +------------+----------------------------------------+ 1455 | 13 to 15 | Reserved | 1456 +------------+----------------------------------------+ 1457 | 16 | Issuer | 1458 +------------+----------------------------------------+ 1459 | 17 to 19 | Reserved | 1460 +------------+----------------------------------------+ 1461 | 20 | Notation Data | 1462 +------------+----------------------------------------+ 1463 | 21 | Preferred Hash Algorithms | 1464 +------------+----------------------------------------+ 1465 | 22 | Preferred Compression Algorithms | 1466 +------------+----------------------------------------+ 1467 | 23 | Key Server Preferences | 1468 +------------+----------------------------------------+ 1469 | 24 | Preferred Key Server | 1470 +------------+----------------------------------------+ 1471 | 25 | Primary User ID | 1472 +------------+----------------------------------------+ 1473 | 26 | Policy URI | 1474 +------------+----------------------------------------+ 1475 | 27 | Key Flags | 1476 +------------+----------------------------------------+ 1477 | 28 | Signer's User ID | 1478 +------------+----------------------------------------+ 1479 | 29 | Reason for Revocation | 1480 +------------+----------------------------------------+ 1481 | 30 | Features | 1482 +------------+----------------------------------------+ 1483 | 31 | Signature Target | 1484 +------------+----------------------------------------+ 1485 | 32 | Embedded Signature | 1486 +------------+----------------------------------------+ 1487 | 33 | Issuer Fingerprint | 1488 +------------+----------------------------------------+ 1489 | 34 | Reserved (Preferred AEAD Algorithms) | 1490 +------------+----------------------------------------+ 1491 | 35 | Intended Recipient Fingerprint | 1492 +------------+----------------------------------------+ 1493 | 37 | Reserved (Attested Certifications) | 1494 +------------+----------------------------------------+ 1495 | 38 | Reserved (Key Block) | 1496 +------------+----------------------------------------+ 1497 | 100 to 110 | Private or experimental | 1498 +------------+----------------------------------------+ 1500 Table 6: Subpacket type registry 1502 An implementation SHOULD ignore any subpacket of a type that it does 1503 not recognize. 1505 Bit 7 of the subpacket type is the "critical" bit. If set, it 1506 denotes that the subpacket is one that is critical for the evaluator 1507 of the signature to recognize. If a subpacket is encountered that is 1508 marked critical but is unknown to the evaluating software, the 1509 evaluator SHOULD consider the signature to be in error. 1511 An evaluator may "recognize" a subpacket, but not implement it. The 1512 purpose of the critical bit is to allow the signer to tell an 1513 evaluator that it would prefer a new, unknown feature to generate an 1514 error than be ignored. 1516 Implementations SHOULD implement the three preferred algorithm 1517 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1518 subpacket. Note, however, that if an implementation chooses not to 1519 implement some of the preferences, it is required to behave in a 1520 polite manner to respect the wishes of those users who do implement 1521 these preferences. 1523 5.2.3.6. Signature Subpacket Types 1525 A number of subpackets are currently defined. Some subpackets apply 1526 to the signature itself and some are attributes of the key. 1527 Subpackets that are found on a self-signature are placed on a 1528 certification made by the key itself. Note that a key may have more 1529 than one User ID, and thus may have more than one self-signature, and 1530 differing subpackets. 1532 A subpacket may be found either in the hashed or unhashed subpacket 1533 sections of a signature. If a subpacket is not hashed, then the 1534 information in it cannot be considered definitive because it is not 1535 part of the signature proper. 1537 5.2.3.7. Notes on Self-Signatures 1539 A self-signature is a binding signature made by the key to which the 1540 signature refers. There are three types of self-signatures, the 1541 certification signatures (types 0x10-0x13), the direct-key signature 1542 (type 0x1F), and the subkey binding signature (type 0x18). For 1543 certification self-signatures, each User ID may have a self- 1544 signature, and thus different subpackets in those self-signatures. 1545 For subkey binding signatures, each subkey in fact has a self- 1546 signature. Subpackets that appear in a certification self-signature 1547 apply to the user name, and subpackets that appear in the subkey 1548 self-signature apply to the subkey. Lastly, subpackets on the 1549 direct-key signature apply to the entire key. 1551 Implementing software should interpret a self-signature's preference 1552 subpackets as narrowly as possible. For example, suppose a key has 1553 two user names, Alice and Bob. Suppose that Alice prefers the 1554 symmetric algorithm AES-256, and Bob prefers Camellia-256 or AES-128. 1555 If the software locates this key via Alice's name, then the preferred 1556 algorithm is AES-256; if software locates the key via Bob's name, 1557 then the preferred algorithm is Camellia-256. If the key is located 1558 by Key ID, the algorithm of the primary User ID of the key provides 1559 the preferred symmetric algorithm. 1561 Revoking a self-signature or allowing it to expire has a semantic 1562 meaning that varies with the signature type. Revoking the self- 1563 signature on a User ID effectively retires that user name. The self- 1564 signature is a statement, "My name X is tied to my signing key K" and 1565 is corroborated by other users' certifications. If another user 1566 revokes their certification, they are effectively saying that they no 1567 longer believe that name and that key are tied together. Similarly, 1568 if the users themselves revoke their self-signature, then the users 1569 no longer go by that name, no longer have that email address, etc. 1570 Revoking a binding signature effectively retires that subkey. 1571 Revoking a direct-key signature cancels that signature. Please see 1572 Section 5.2.3.27 for more relevant detail. 1574 Since a self-signature contains important information about the key's 1575 use, an implementation SHOULD allow the user to rewrite the self- 1576 signature, and important information in it, such as preferences and 1577 key expiration. 1579 It is good practice to verify that a self-signature imported into an 1580 implementation doesn't advertise features that the implementation 1581 doesn't support, rewriting the signature as appropriate. 1583 An implementation that encounters multiple self-signatures on the 1584 same object may resolve the ambiguity in any way it sees fit, but it 1585 is RECOMMENDED that priority be given to the most recent self- 1586 signature. 1588 5.2.3.8. Signature Creation Time 1590 (4-octet time field) 1592 The time the signature was made. 1594 MUST be present in the hashed area. 1596 5.2.3.9. Issuer 1598 (8-octet Key ID) 1600 The OpenPGP Key ID of the key issuing the signature. If the version 1601 of that key is greater than 4, this subpacket MUST NOT be included in 1602 the signature. 1604 5.2.3.10. Key Expiration Time 1606 (4-octet time field) 1608 The validity period of the key. This is the number of seconds after 1609 the key creation time that the key expires. If this is not present 1610 or has a value of zero, the key never expires. This is found only on 1611 a self-signature. 1613 5.2.3.11. Preferred Symmetric Algorithms 1615 (array of one-octet values) 1617 Symmetric algorithm numbers that indicate which algorithms the key 1618 holder prefers to use. The subpacket body is an ordered list of 1619 octets with the most preferred listed first. It is assumed that only 1620 algorithms listed are supported by the recipient's software. 1621 Algorithm numbers are in Section 9.3. This is only found on a self- 1622 signature. 1624 5.2.3.12. Preferred Hash Algorithms 1626 (array of one-octet values) 1628 Message digest algorithm numbers that indicate which algorithms the 1629 key holder prefers to receive. Like the preferred symmetric 1630 algorithms, the list is ordered. Algorithm numbers are in 1631 Section 9.5. This is only found on a self-signature. 1633 5.2.3.13. Preferred Compression Algorithms 1635 (array of one-octet values) 1637 Compression algorithm numbers that indicate which algorithms the key 1638 holder prefers to use. Like the preferred symmetric algorithms, the 1639 list is ordered. Algorithm numbers are in Section 9.4. If this 1640 subpacket is not included, ZIP is preferred. A zero denotes that 1641 uncompressed data is preferred; the key holder's software might have 1642 no compression software in that implementation. This is only found 1643 on a self-signature. 1645 5.2.3.14. Signature Expiration Time 1647 (4-octet time field) 1649 The validity period of the signature. This is the number of seconds 1650 after the signature creation time that the signature expires. If 1651 this is not present or has a value of zero, it never expires. 1653 5.2.3.15. Exportable Certification 1655 (1 octet of exportability, 0 for not, 1 for exportable) 1657 This subpacket denotes whether a certification signature is 1658 "exportable", to be used by other users than the signature's issuer. 1659 The packet body contains a Boolean flag indicating whether the 1660 signature is exportable. If this packet is not present, the 1661 certification is exportable; it is equivalent to a flag containing a 1662 1. 1664 Non-exportable, or "local", certifications are signatures made by a 1665 user to mark a key as valid within that user's implementation only. 1667 Thus, when an implementation prepares a user's copy of a key for 1668 transport to another user (this is the process of "exporting" the 1669 key), any local certification signatures are deleted from the key. 1671 The receiver of a transported key "imports" it, and likewise trims 1672 any local certifications. In normal operation, there won't be any, 1673 assuming the import is performed on an exported key. However, there 1674 are instances where this can reasonably happen. For example, if an 1675 implementation allows keys to be imported from a key database in 1676 addition to an exported key, then this situation can arise. 1678 Some implementations do not represent the interest of a single user 1679 (for example, a key server). Such implementations always trim local 1680 certifications from any key they handle. 1682 5.2.3.16. Revocable 1684 (1 octet of revocability, 0 for not, 1 for revocable) 1686 Signature's revocability status. The packet body contains a Boolean 1687 flag indicating whether the signature is revocable. Signatures that 1688 are not revocable have any later revocation signatures ignored. They 1689 represent a commitment by the signer that he cannot revoke his 1690 signature for the life of his key. If this packet is not present, 1691 the signature is revocable. 1693 5.2.3.17. Trust Signature 1695 (1 octet "level" (depth), 1 octet of trust amount) 1697 Signer asserts that the key is not only valid but also trustworthy at 1698 the specified level. Level 0 has the same meaning as an ordinary 1699 validity signature. Level 1 means that the signed key is asserted to 1700 be a valid trusted introducer, with the 2nd octet of the body 1701 specifying the degree of trust. Level 2 means that the signed key is 1702 asserted to be trusted to issue level 1 trust signatures, i.e., that 1703 it is a "meta introducer". Generally, a level n trust signature 1704 asserts that a key is trusted to issue level n-1 trust signatures. 1705 The trust amount is in a range from 0-255, interpreted such that 1706 values less than 120 indicate partial trust and values of 120 or 1707 greater indicate complete trust. Implementations SHOULD emit values 1708 of 60 for partial trust and 120 for complete trust. 1710 5.2.3.18. Regular Expression 1712 (null-terminated regular expression) 1713 Used in conjunction with trust Signature packets (of level > 0) to 1714 limit the scope of trust that is extended. Only signatures by the 1715 target key on User IDs that match the regular expression in the body 1716 of this packet have trust extended by the trust Signature subpacket. 1717 The regular expression uses the same syntax as the Henry Spencer's 1718 "almost public domain" regular expression [REGEX] package. A 1719 description of the syntax is found in Section 8. 1721 5.2.3.19. Revocation Key 1723 (1 octet of class, 1 octet of public-key algorithm ID, 20 or 32 1724 octets of fingerprint) 1726 V4 keys use the full 20 octet fingerprint; V5 keys use the full 32 1727 octet fingerprint 1729 Authorizes the specified key to issue revocation signatures for this 1730 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1731 then this means that the revocation information is sensitive. Other 1732 bits are for future expansion to other kinds of authorizations. This 1733 is only found on a direct-key self-signature (type 0x1f). The use on 1734 other types of self-signatures is unspecified. 1736 If the "sensitive" flag is set, the keyholder feels this subpacket 1737 contains private trust information that describes a real-world 1738 sensitive relationship. If this flag is set, implementations SHOULD 1739 NOT export this signature to other users except in cases where the 1740 data needs to be available: when the signature is being sent to the 1741 designated revoker, or when it is accompanied by a revocation 1742 signature from that revoker. Note that it may be appropriate to 1743 isolate this subpacket within a separate signature so that it is not 1744 combined with other subpackets that need to be exported. 1746 5.2.3.20. Notation Data 1748 (4 octets of flags, 2 octets of name length (M), 2 octets of value 1749 length (N), M octets of name data, N octets of value data) 1751 This subpacket describes a "notation" on the signature that the 1752 issuer wishes to make. The notation has a name and a value, each of 1753 which are strings of octets. There may be more than one notation in 1754 a signature. Notations can be used for any extension the issuer of 1755 the signature cares to make. The "flags" field holds four octets of 1756 flags. 1758 All undefined flags MUST be zero. Defined flags are as follows: 1760 First octet: 1762 +======+================+==========================+ 1763 | flag | shorthand | definition | 1764 +======+================+==========================+ 1765 | 0x80 | human-readable | This note value is text. | 1766 +------+----------------+--------------------------+ 1768 Table 7: Notation flag registry (first octet) 1770 Other octets: none. 1772 Notation names are arbitrary strings encoded in UTF-8. They reside 1773 in two namespaces: The IETF namespace and the user namespace. 1775 The IETF namespace is registered with IANA. These names MUST NOT 1776 contain the "@" character (0x40). This is a tag for the user 1777 namespace. 1779 Names in the user namespace consist of a UTF-8 string tag followed by 1780 "@" followed by a DNS domain name. Note that the tag MUST NOT 1781 contain an "@" character. For example, the "sample" tag used by 1782 Example Corporation could be "sample@example.com". 1784 Names in a user space are owned and controlled by the owners of that 1785 domain. Obviously, it's bad form to create a new name in a DNS space 1786 that you don't own. 1788 Since the user namespace is in the form of an email address, 1789 implementers MAY wish to arrange for that address to reach a person 1790 who can be consulted about the use of the named tag. Note that due 1791 to UTF-8 encoding, not all valid user space name tags are valid email 1792 addresses. 1794 If there is a critical notation, the criticality applies to that 1795 specific notation and not to notations in general. 1797 5.2.3.21. Key Server Preferences 1799 (N octets of flags) 1801 This is a list of one-bit flags that indicate preferences that the 1802 key holder has about how the key is handled on a key server. All 1803 undefined flags MUST be zero. 1805 First octet: 1807 +======+===========+============================================+ 1808 | flag | shorthand | definition | 1809 +======+===========+============================================+ 1810 | 0x80 | No-modify | The key holder requests that this key only | 1811 | | | be modified or updated by the key holder | 1812 | | | or an administrator of the key server. | 1813 +------+-----------+--------------------------------------------+ 1815 Table 8: Key server preferences flag registry (first octet) 1817 This is found only on a self-signature. 1819 5.2.3.22. Preferred Key Server 1821 (String) 1823 This is a URI of a key server that the key holder prefers be used for 1824 updates. Note that keys with multiple User IDs can have a preferred 1825 key server for each User ID. Note also that since this is a URI, the 1826 key server can actually be a copy of the key retrieved by ftp, http, 1827 finger, etc. 1829 5.2.3.23. Primary User ID 1831 (1 octet, Boolean) 1833 This is a flag in a User ID's self-signature that states whether this 1834 User ID is the main User ID for this key. It is reasonable for an 1835 implementation to resolve ambiguities in preferences, etc. by 1836 referring to the primary User ID. If this flag is absent, its value 1837 is zero. If more than one User ID in a key is marked as primary, the 1838 implementation may resolve the ambiguity in any way it sees fit, but 1839 it is RECOMMENDED that priority be given to the User ID with the most 1840 recent self-signature. 1842 When appearing on a self-signature on a User ID packet, this 1843 subpacket applies only to User ID packets. When appearing on a self- 1844 signature on a User Attribute packet, this subpacket applies only to 1845 User Attribute packets. That is to say, there are two different and 1846 independent "primaries" -- one for User IDs, and one for User 1847 Attributes. 1849 5.2.3.24. Policy URI 1851 (String) 1853 This subpacket contains a URI of a document that describes the policy 1854 under which the signature was issued. 1856 5.2.3.25. Key Flags 1858 (N octets of flags) 1860 This subpacket contains a list of binary flags that hold information 1861 about a key. It is a string of octets, and an implementation MUST 1862 NOT assume a fixed size. This is so it can grow over time. If a 1863 list is shorter than an implementation expects, the unstated flags 1864 are considered to be zero. The defined flags are as follows: 1866 First octet: 1868 +======+=================================================+ 1869 | flag | definition | 1870 +======+=================================================+ 1871 | 0x01 | This key may be used to certify other keys. | 1872 +------+-------------------------------------------------+ 1873 | 0x02 | This key may be used to sign data. | 1874 +------+-------------------------------------------------+ 1875 | 0x04 | This key may be used to encrypt communications. | 1876 +------+-------------------------------------------------+ 1877 | 0x08 | This key may be used to encrypt storage. | 1878 +------+-------------------------------------------------+ 1879 | 0x10 | The private component of this key may have been | 1880 | | split by a secret-sharing mechanism. | 1881 +------+-------------------------------------------------+ 1882 | 0x20 | This key may be used for authentication. | 1883 +------+-------------------------------------------------+ 1884 | 0x80 | The private component of this key may be in the | 1885 | | possession of more than one person. | 1886 +------+-------------------------------------------------+ 1888 Table 9: Key flags registry (first octet) 1890 Second octet: 1892 +======+==========================+ 1893 | flag | definition | 1894 +======+==========================+ 1895 | 0x04 | Reserved (ADSK). | 1896 +------+--------------------------+ 1897 | 0x08 | Reserved (timestamping). | 1898 +------+--------------------------+ 1900 Table 10: Key flags registry 1901 (second octet) 1903 Usage notes: 1905 The flags in this packet may appear in self-signatures or in 1906 certification signatures. They mean different things depending on 1907 who is making the statement -- for example, a certification signature 1908 that has the "sign data" flag is stating that the certification is 1909 for that use. On the other hand, the "communications encryption" 1910 flag in a self-signature is stating a preference that a given key be 1911 used for communications. Note however, that it is a thorny issue to 1912 determine what is "communications" and what is "storage". This 1913 decision is left wholly up to the implementation; the authors of this 1914 document do not claim any special wisdom on the issue and realize 1915 that accepted opinion may change. 1917 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1918 self-signature only; they are meaningless on a certification 1919 signature. They SHOULD be placed only on a direct-key signature 1920 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1921 key the flag applies to. 1923 5.2.3.26. Signer's User ID 1925 (String) 1927 This subpacket allows a keyholder to state which User ID is 1928 responsible for the signing. Many keyholders use a single key for 1929 different purposes, such as business communications as well as 1930 personal communications. This subpacket allows such a keyholder to 1931 state which of their roles is making a signature. 1933 This subpacket is not appropriate to use to refer to a User Attribute 1934 packet. 1936 5.2.3.27. Reason for Revocation 1938 (1 octet of revocation code, N octets of reason string) 1940 This subpacket is used only in key revocation and certification 1941 revocation signatures. It describes the reason why the key or 1942 certificate was revoked. 1944 The first octet contains a machine-readable code that denotes the 1945 reason for the revocation: 1947 +=========+==================================+ 1948 | Code | Reason | 1949 +=========+==================================+ 1950 | 0 | No reason specified (key | 1951 | | revocations or cert revocations) | 1952 +---------+----------------------------------+ 1953 | 1 | Key is superseded (key | 1954 | | revocations) | 1955 +---------+----------------------------------+ 1956 | 2 | Key material has been | 1957 | | compromised (key revocations) | 1958 +---------+----------------------------------+ 1959 | 3 | Key is retired and no longer | 1960 | | used (key revocations) | 1961 +---------+----------------------------------+ 1962 | 32 | User ID information is no longer | 1963 | | valid (cert revocations) | 1964 +---------+----------------------------------+ 1965 | 100-110 | Private Use | 1966 +---------+----------------------------------+ 1968 Table 11: Reasons for revocation 1970 Following the revocation code is a string of octets that gives 1971 information about the Reason for Revocation in human-readable form 1972 (UTF-8). The string may be null, that is, of zero length. The 1973 length of the subpacket is the length of the reason string plus one. 1974 An implementation SHOULD implement this subpacket, include it in all 1975 revocation signatures, and interpret revocations appropriately. 1976 There are important semantic differences between the reasons, and 1977 there are thus important reasons for revoking signatures. 1979 If a key has been revoked because of a compromise, all signatures 1980 created by that key are suspect. However, if it was merely 1981 superseded or retired, old signatures are still valid. If the 1982 revoked signature is the self-signature for certifying a User ID, a 1983 revocation denotes that that user name is no longer in use. Such a 1984 revocation SHOULD include a 0x20 code. 1986 Note that any signature may be revoked, including a certification on 1987 some other person's key. There are many good reasons for revoking a 1988 certification signature, such as the case where the keyholder leaves 1989 the employ of a business with an email address. A revoked 1990 certification is no longer a part of validity calculations. 1992 5.2.3.28. Features 1994 (N octets of flags) 1996 The Features subpacket denotes which advanced OpenPGP features a 1997 user's implementation supports. This is so that as features are 1998 added to OpenPGP that cannot be backwards-compatible, a user can 1999 state that they can use that feature. The flags are single bits that 2000 indicate that a given feature is supported. 2002 This subpacket is similar to a preferences subpacket, and only 2003 appears in a self-signature. 2005 An implementation SHOULD NOT use a feature listed when sending to a 2006 user who does not state that they can use it. 2008 Defined features are as follows: 2010 First octet: 2012 +=========+============================================+ 2013 | feature | definition | 2014 +=========+============================================+ 2015 | 0x01 | Modification Detection (packets 18 and 19) | 2016 +---------+--------------------------------------------+ 2017 | 0x02 | AEAD Encrypted Data (packet 20) | 2018 +---------+--------------------------------------------+ 2019 | 0x04 | Reserved | 2020 +---------+--------------------------------------------+ 2022 Table 12: Features registry 2024 If an implementation implements any of the defined features, it 2025 SHOULD implement the Features subpacket, too. 2027 An implementation may freely infer features from other suitable 2028 implementation-dependent mechanisms. 2030 5.2.3.29. Signature Target 2032 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 2034 This subpacket identifies a specific target signature to which a 2035 signature refers. For revocation signatures, this subpacket provides 2036 explicit designation of which signature is being revoked. For a 2037 third-party or timestamp signature, this designates what signature is 2038 signed. All arguments are an identifier of that target signature. 2040 The N octets of hash data MUST be the size of the hash of the 2041 signature. For example, a target signature with a SHA-1 hash MUST 2042 have 20 octets of hash data. 2044 5.2.3.30. Embedded Signature 2046 (1 signature packet body) 2048 This subpacket contains a complete Signature packet body as specified 2049 in Section 5.2. It is useful when one signature needs to refer to, 2050 or be incorporated in, another signature. 2052 5.2.3.31. Issuer Fingerprint 2054 (1 octet key version number, N octets of fingerprint) 2056 The OpenPGP Key fingerprint of the key issuing the signature. This 2057 subpacket SHOULD be included in all signatures. If the version of 2058 the issuing key is 4 and an Issuer subpacket is also included in the 2059 signature, the key ID of the Issuer subpacket MUST match the low 64 2060 bits of the fingerprint. 2062 Note that the length N of the fingerprint for a version 4 key is 20 2063 octets; for a version 5 key N is 32. 2065 5.2.3.32. Intended Recipient Fingerprint 2067 (1 octet key version number, N octets of fingerprint) 2069 The OpenPGP Key fingerprint of the intended recipient primary key. 2070 If one or more subpackets of this type are included in a signature, 2071 it SHOULD be considered valid only in an encrypted context, where the 2072 key it was encrypted to is one of the indicated primary keys, or one 2073 of their subkeys. This can be used to prevent forwarding a signature 2074 outside of its intended, encrypted context. 2076 Note that the length N of the fingerprint for a version 4 key is 20 2077 octets; for a version 5 key N is 32. 2079 5.2.4. Computing Signatures 2081 All signatures are formed by producing a hash over the signature 2082 data, and then using the resulting hash in the signature algorithm. 2084 For binary document signatures (type 0x00), the document data is 2085 hashed directly. For text document signatures (type 0x01), the 2086 document is canonicalized by converting line endings to , and 2087 the resulting data is hashed. 2089 When a V4 signature is made over a key, the hash data starts with the 2090 octet 0x99, followed by a two-octet length of the key, and then body 2091 of the key packet; when a V5 signature is made over a key, the hash 2092 data starts with the octet 0x9a, followed by a four-octet length of 2093 the key, and then body of the key packet. A subkey binding signature 2094 (type 0x18) or primary key binding signature (type 0x19) then hashes 2095 the subkey using the same format as the main key (also using 0x99 or 2096 0x9a as the first octet). Primary key revocation signatures (type 2097 0x20) hash only the key being revoked. Subkey revocation signature 2098 (type 0x28) hash first the primary key and then the subkey being 2099 revoked. 2101 A certification signature (type 0x10 through 0x13) hashes the User ID 2102 being bound to the key into the hash context after the above data. A 2103 V3 certification hashes the contents of the User ID or attribute 2104 packet packet, without any header. A V4 or V5 certification hashes 2105 the constant 0xB4 for User ID certifications or the constant 0xD1 for 2106 User Attribute certifications, followed by a four-octet number giving 2107 the length of the User ID or User Attribute data, and then the User 2108 ID or User Attribute data. 2110 When a signature is made over a Signature packet (type 0x50, "Third- 2111 Party Confirmation signature"), the hash data starts with the octet 2112 0x88, followed by the four-octet length of the signature, and then 2113 the body of the Signature packet. (Note that this is an old-style 2114 packet header for a Signature packet with the length-of-length field 2115 set to zero.) The unhashed subpacket data of the Signature packet 2116 being hashed is not included in the hash, and the unhashed subpacket 2117 data length value is set to zero. 2119 Once the data body is hashed, then a trailer is hashed. This trailer 2120 depends on the version of the signature. 2122 * A V3 signature hashes five octets of the packet body, starting 2123 from the signature type field. This data is the signature type, 2124 followed by the four-octet signature time. 2126 * A V4 signature hashes the packet body starting from its first 2127 field, the version number, through the end of the hashed subpacket 2128 data and a final extra trailer. Thus, the hashed fields are: 2130 - the signature version (0x04), 2132 - the signature type, 2134 - the public-key algorithm, 2136 - the hash algorithm, 2137 - the hashed subpacket length, 2139 - the hashed subpacket body, 2141 - the two octets 0x04 and 0xFF, 2143 - a four-octet big-endian number that is the length of the hashed 2144 data from the Signature packet stopping right before the 0x04, 2145 0xff octets. 2147 The four-octet big-endian number is considered to be an 2148 unsigned integer modulo 2**32. 2150 * A V5 signature hashes the packet body starting from its first 2151 field, the version number, through the end of the hashed subpacket 2152 data and a final extra trailer. Thus, the hashed fields are: 2154 - the signature version (0x05), 2156 - the signature type, 2158 - the public-key algorithm, 2160 - the hash algorithm, 2162 - the hashed subpacket length, 2164 - the hashed subpacket body, 2166 - Only for document signatures (type 0x00 or 0x01) the following 2167 three data items are hashed here: 2169 o the one-octet content format, 2171 o the file name as a string (one octet length, followed by the 2172 file name), 2174 o a four-octet number that indicates a date, 2176 - the two octets 0x05 and 0xFF, 2178 - a eight-octet big-endian number that is the length of the 2179 hashed data from the Signature packet stopping right before the 2180 0x05, 0xff octets. 2182 The three data items hashed for document signatures need to 2183 mirror the values of the Literal Data packet. For detached and 2184 cleartext signatures 6 zero octets are hashed instead. 2186 After all this has been hashed in a single hash context, the 2187 resulting hash field is used in the signature algorithm and placed at 2188 the end of the Signature packet. 2190 5.2.4.1. Subpacket Hints 2192 It is certainly possible for a signature to contain conflicting 2193 information in subpackets. For example, a signature may contain 2194 multiple copies of a preference or multiple expiration times. In 2195 most cases, an implementation SHOULD use the last subpacket in the 2196 signature, but MAY use any conflict resolution scheme that makes more 2197 sense. Please note that we are intentionally leaving conflict 2198 resolution to the implementer; most conflicts are simply syntax 2199 errors, and the wishy-washy language here allows a receiver to be 2200 generous in what they accept, while putting pressure on a creator to 2201 be stingy in what they generate. 2203 Some apparent conflicts may actually make sense -- for example, 2204 suppose a keyholder has a V3 key and a V4 key that share the same RSA 2205 key material. Either of these keys can verify a signature created by 2206 the other, and it may be reasonable for a signature to contain an 2207 issuer subpacket for each key, as a way of explicitly tying those 2208 keys to the signature. 2210 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 2212 The Symmetric-Key Encrypted Session Key (SKESK) packet holds the 2213 symmetric-key encryption of a session key used to encrypt a message. 2214 Zero or more Public-Key Encrypted Session Key packets and/or 2215 Symmetric-Key Encrypted Session Key packets may precede a an 2216 encryption container (i.e. a Symmetrically Encrypted Integrity 2217 Protected Data packet, an AEAD Encrypted Data packet, or -- for 2218 historic data -- a Symmetrically Encrypted Data packet) that holds an 2219 encrypted message. The message is encrypted with a session key, and 2220 the session key is itself encrypted and stored in the Encrypted 2221 Session Key packet or the Symmetric-Key Encrypted Session Key packet. 2223 If the encryption container is preceded by one or more Symmetric-Key 2224 Encrypted Session Key packets, each specifies a passphrase that may 2225 be used to decrypt the message. This allows a message to be 2226 encrypted to a number of public keys, and also to one or more 2227 passphrases. This packet type is new and is not generated by PGP 2 2228 or PGP version 5.0. 2230 A version 4 Symmetric-Key Encrypted Session Key packet consists of: 2232 * A one-octet version number with value 4. 2234 * A one-octet number describing the symmetric algorithm used. 2236 * A string-to-key (S2K) specifier, length as defined above. 2238 * Optionally, the encrypted session key itself, which is decrypted 2239 with the string-to-key object. 2241 If the encrypted session key is not present (which can be detected on 2242 the basis of packet length and S2K specifier size), then the S2K 2243 algorithm applied to the passphrase produces the session key for 2244 decrypting the message, using the symmetric cipher algorithm from the 2245 Symmetric-Key Encrypted Session Key packet. 2247 If the encrypted session key is present, the result of applying the 2248 S2K algorithm to the passphrase is used to decrypt just that 2249 encrypted session key field, using CFB mode with an IV of all zeros. 2250 The decryption result consists of a one-octet algorithm identifier 2251 that specifies the symmetric-key encryption algorithm used to encrypt 2252 the following encryption container, followed by the session key 2253 octets themselves. 2255 Note: because an all-zero IV is used for this decryption, the S2K 2256 specifier MUST use a salt value, either a Salted S2K or an Iterated- 2257 Salted S2K. The salt value will ensure that the decryption key is 2258 not repeated even if the passphrase is reused. 2260 A version 5 Symmetric-Key Encrypted Session Key packet consists of: 2262 * A one-octet version number with value 5. 2264 * A one-octet cipher algorithm. 2266 * A one-octet AEAD algorithm. 2268 * A string-to-key (S2K) specifier, length as defined above. 2270 * A starting initialization vector of size specified by the AEAD 2271 algorithm. 2273 * The encrypted session key itself, which is decrypted with the 2274 string-to-key object using the given cipher and AEAD mode. 2276 * An authentication tag for the AEAD mode. 2278 The encrypted session key is encrypted using one of the AEAD 2279 algorithms specified for the AEAD Encrypted Data Packet. Note that 2280 no chunks are used and that there is only one authentication tag. 2281 The Packet Tag in new format encoding (bits 7 and 6 set, bits 5-0 2282 carry the packet tag), the packet version number, the cipher 2283 algorithm octet, and the AEAD algorithm octet are given as additional 2284 data. For example, the additional data used with EAX and AES-128 2285 consists of the octets 0xC3, 0x05, 0x07, and 0x01. 2287 5.3.1. No v5 SKESK with SEIPD 2289 Note that unlike the AEAD Encrypted Data Packet (AED, see 2290 Section 5.16), the Symmetrically Encrypted Integrity Protected Data 2291 Packet (SEIPD, see Section 5.14) does not internally indicate what 2292 cipher algorithm to use to decrypt it. Since the v5 SKESK packet's 2293 encrypted payload only indicates the key used, not the choice of 2294 cipher algorithm used for the subsequent encrypted data, a v5 SKESK 2295 packet can only provide a session key for an AED packet, and MUST NOT 2296 be used to provide a session key for a SEIPD Packet. 2298 5.4. One-Pass Signature Packets (Tag 4) 2300 The One-Pass Signature packet precedes the signed data and contains 2301 enough information to allow the receiver to begin calculating any 2302 hashes needed to verify the signature. It allows the Signature 2303 packet to be placed at the end of the message, so that the signer can 2304 compute the entire signed message in one pass. 2306 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 2308 The body of this packet consists of: 2310 * A one-octet version number. The current version is 3. 2312 * A one-octet signature type. Signature types are described in 2313 Section 5.2.1. 2315 * A one-octet number describing the hash algorithm used. 2317 * A one-octet number describing the public-key algorithm used. 2319 * An eight-octet number holding the Key ID of the signing key. 2321 * A one-octet number holding a flag showing whether the signature is 2322 nested. A zero value indicates that the next packet is another 2323 One-Pass Signature packet that describes another signature to be 2324 applied to the same message data. 2326 Note that if a message contains more than one one-pass signature, 2327 then the Signature packets bracket the message; that is, the first 2328 Signature packet after the message corresponds to the last one-pass 2329 packet and the final Signature packet corresponds to the first one- 2330 pass packet. 2332 5.5. Key Material Packet 2334 A key material packet contains all the information about a public or 2335 private key. There are four variants of this packet type, and two 2336 major versions. Consequently, this section is complex. 2338 5.5.1. Key Packet Variants 2340 5.5.1.1. Public-Key Packet (Tag 6) 2342 A Public-Key packet starts a series of packets that forms an OpenPGP 2343 key (sometimes called an OpenPGP certificate). 2345 5.5.1.2. Public-Subkey Packet (Tag 14) 2347 A Public-Subkey packet (tag 14) has exactly the same format as a 2348 Public-Key packet, but denotes a subkey. One or more subkeys may be 2349 associated with a top-level key. By convention, the top-level key 2350 provides signature services, and the subkeys provide encryption 2351 services. 2353 Note: in PGP version 2.6, tag 14 was intended to indicate a comment 2354 packet. This tag was selected for reuse because no previous version 2355 of PGP ever emitted comment packets but they did properly ignore 2356 them. Public-Subkey packets are ignored by PGP version 2.6 and do 2357 not cause it to fail, providing a limited degree of backward 2358 compatibility. 2360 5.5.1.3. Secret-Key Packet (Tag 5) 2362 A Secret-Key packet contains all the information that is found in a 2363 Public-Key packet, including the public-key material, but also 2364 includes the secret-key material after all the public-key fields. 2366 5.5.1.4. Secret-Subkey Packet (Tag 7) 2368 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2369 packet and has exactly the same format. 2371 5.5.2. Public-Key Packet Formats 2373 There are three versions of key-material packets. Version 3 packets 2374 were first generated by PGP version 2.6. Version 4 keys first 2375 appeared in PGP 5 and are the preferred key version for OpenPGP. 2377 OpenPGP implementations MUST create keys with version 4 format. V3 2378 keys are deprecated; an implementation MUST NOT generate a V3 key, 2379 but MAY accept it. 2381 A version 3 public key or public-subkey packet contains: 2383 * A one-octet version number (3). 2385 * A four-octet number denoting the time that the key was created. 2387 * A two-octet number denoting the time in days that this key is 2388 valid. If this number is zero, then it does not expire. 2390 * A one-octet number denoting the public-key algorithm of this key. 2392 * A series of multiprecision integers comprising the key material: 2394 - a multiprecision integer (MPI) of RSA public modulus n; 2396 - an MPI of RSA public encryption exponent e. 2398 V3 keys are deprecated. They contain three weaknesses. First, it is 2399 relatively easy to construct a V3 key that has the same Key ID as any 2400 other key because the Key ID is simply the low 64 bits of the public 2401 modulus. Secondly, because the fingerprint of a V3 key hashes the 2402 key material, but not its length, there is an increased opportunity 2403 for fingerprint collisions. Third, there are weaknesses in the MD5 2404 hash algorithm that make developers prefer other algorithms. See 2405 below for a fuller discussion of Key IDs and fingerprints. 2407 V2 keys are identical to the deprecated V3 keys except for the 2408 version number. An implementation MUST NOT generate them and MAY 2409 accept or reject them as it sees fit. 2411 The version 4 format is similar to the version 3 format except for 2412 the absence of a validity period. This has been moved to the 2413 Signature packet. In addition, fingerprints of version 4 keys are 2414 calculated differently from version 3 keys, as described in 2415 Section 12. 2417 A version 4 packet contains: 2419 * A one-octet version number (4). 2421 * A four-octet number denoting the time that the key was created. 2423 * A one-octet number denoting the public-key algorithm of this key. 2425 * A series of multiprecision integers comprising the key material. 2426 This is algorithm-specific and described in Section 5.6. 2428 The version 5 format is similar to the version 4 format except for 2429 the addition of a count for the key material. This count helps 2430 parsing secret key packets (which are an extension of the public key 2431 packet format) in the case of an unknown algorithm. In addition, 2432 fingerprints of version 5 keys are calculated differently from 2433 version 4 keys, as described in the section "Enhanced Key Formats". 2435 A version 5 packet contains: 2437 * A one-octet version number (5). 2439 * A four-octet number denoting the time that the key was created. 2441 * A one-octet number denoting the public-key algorithm of this key. 2443 * A four-octet scalar octet count for the following public key 2444 material. 2446 * A series of values comprising the public key material. This is 2447 algorithm-specific and described in Section 5.6. 2449 5.5.3. Secret-Key Packet Formats 2451 The Secret-Key and Secret-Subkey packets contain all the data of the 2452 Public-Key and Public-Subkey packets, with additional algorithm- 2453 specific secret-key data appended, usually in encrypted form. 2455 The packet contains: 2457 * A Public-Key or Public-Subkey packet, as described above. 2459 * One octet indicating string-to-key usage conventions. Zero 2460 indicates that the secret-key data is not encrypted. 255 or 254 2461 indicates that a string-to-key specifier is being given. Any 2462 other value is a symmetric-key encryption algorithm identifier. A 2463 version 5 packet MUST NOT use the value 255. 2465 * Only for a version 5 packet, a one-octet scalar octet count of the 2466 next 4 optional fields. 2468 * [Optional] If string-to-key usage octet was 255, 254, or 253, a 2469 one-octet symmetric encryption algorithm. 2471 * [Optional] If string-to-key usage octet was 253, a one-octet AEAD 2472 algorithm. 2474 * [Optional] If string-to-key usage octet was 255, 254, or 253, a 2475 string-to-key specifier. The length of the string-to-key 2476 specifier is implied by its type, as described above. 2478 * [Optional] If string-to-key usage octet was 253 (i.e. the secret 2479 data is AEAD-encrypted), an initialization vector (IV) of size 2480 specified by the AEAD algorithm (see Section 5.16), which is used 2481 as the nonce for the AEAD algorithm. 2483 * [Optional] If string-to-key usage octet was 255, 254, or a cipher 2484 algorithm identifier (i.e. the secret data is CFB-encrypted), an 2485 initialization vector (IV) of the same length as the cipher's 2486 block size. 2488 * Only for a version 5 packet, a four-octet scalar octet count for 2489 the following secret key material. This includes the encrypted 2490 SHA-1 hash or AEAD tag if the string-to-key usage octet is 254 or 2491 253. 2493 * Plain or encrypted multiprecision integers comprising the secret 2494 key data. This is algorithm-specific and described in section 2495 Section 5.6. If the string-to-key usage octet is 253, then an 2496 AEAD authentication tag is part of that data. If the string-to- 2497 key usage octet is 254, a 20-octet SHA-1 hash of the plaintext of 2498 the algorithm-specific portion is appended to plaintext and 2499 encrypted with it. If the string-to-key usage octet is 255 or 2500 another nonzero value (i.e., a symmetric-key encryption algorithm 2501 identifier), a two-octet checksum of the plaintext of the 2502 algorithm-specific portion (sum of all octets, mod 65536) is 2503 appended to plaintext and encrypted with it. (This is deprecated 2504 and SHOULD NOT be used, see below.) 2506 * If the string-to-key usage octet is zero, then a two-octet 2507 checksum of the algorithm-specific portion (sum of all octets, mod 2508 65536). 2510 Note that the version 5 packet format adds two count values to help 2511 parsing packets with unknown S2K or public key algorithms. 2513 Secret MPI values can be encrypted using a passphrase. If a string- 2514 to-key specifier is given, that describes the algorithm for 2515 converting the passphrase to a key, else a simple MD5 hash of the 2516 passphrase is used. Implementations MUST use a string-to-key 2517 specifier; the simple hash is for backward compatibility and is 2518 deprecated, though implementations MAY continue to use existing 2519 private keys in the old format. The cipher for encrypting the MPIs 2520 is specified in the Secret-Key packet. 2522 Encryption/decryption of the secret data is done using the key 2523 created from the passphrase and the initialization vector from the 2524 packet. If the string-to-key usage octet is not 253, CFB mode is 2525 used. A different mode is used with V3 keys (which are only RSA) 2526 than with other key formats. With V3 keys, the MPI bit count prefix 2527 (i.e., the first two octets) is not encrypted. Only the MPI non- 2528 prefix data is encrypted. Furthermore, the CFB state is 2529 resynchronized at the beginning of each new MPI value, so that the 2530 CFB block boundary is aligned with the start of the MPI data. 2532 With V4 and V5 keys, a simpler method is used. All secret MPI values 2533 are encrypted, including the MPI bitcount prefix. 2535 If the string-to-key usage octet is 253, the encrypted MPI values are 2536 encrypted as one combined plaintext using one of the AEAD algorithms 2537 specified for the AEAD Encrypted Data Packet. Note that no chunks 2538 are used and that there is only one authentication tag. As 2539 additional data, the Packet Tag in new format encoding (bits 7 and 6 2540 set, bits 5-0 carry the packet tag), followed by the public key 2541 packet fields, starting with the packet version number, are passed to 2542 the AEAD algorithm. For example, the additional data used with a 2543 Secret-Key Packet of version 4 consists of the octets 0xC5, 0x04, 2544 followed by four octets of creation time, one octet denoting the 2545 public-key algorithm, and the algorithm-specific public-key 2546 parameters. For a Secret-Subkey Packet, the first octet would be 2547 0xC7. For a version 5 key packet, the second octet would be 0x05, 2548 and the four-octet octet count of the public key material would be 2549 included as well (see Section 5.5.2). 2551 The two-octet checksum that follows the algorithm-specific portion is 2552 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2553 specific octets (including MPI prefix and data). With V3 keys, the 2554 checksum is stored in the clear. With V4 keys, the checksum is 2555 encrypted like the algorithm-specific data. This value is used to 2556 check that the passphrase was correct. However, this checksum is 2557 deprecated; an implementation SHOULD NOT use it, but should rather 2558 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2559 this is that there are some attacks that involve undetectably 2560 modifying the secret key. If the string-to-key usage octet is 253 no 2561 checksum or SHA-1 hash is used but the authentication tag of the AEAD 2562 algorithm follows. 2564 5.6. Algorithm-specific Parts of Keys 2566 The public and secret key format specifies algorithm-specific parts 2567 of a key. The following sections describe them in detail. 2569 5.6.1. Algorithm-Specific Part for RSA Keys 2571 The public key is this series of multiprecision integers: 2573 * MPI of RSA public modulus n; 2575 * MPI of RSA public encryption exponent e. 2577 The secret key is this series of multiprecision integers: 2579 * MPI of RSA secret exponent d; 2581 * MPI of RSA secret prime value p; 2583 * MPI of RSA secret prime value q (p < q); 2585 * MPI of u, the multiplicative inverse of p, mod q. 2587 5.6.2. Algorithm-Specific Part for DSA Keys 2589 The public key is this series of multiprecision integers: 2591 * MPI of DSA prime p; 2593 * MPI of DSA group order q (q is a prime divisor of p-1); 2595 * MPI of DSA group generator g; 2597 * MPI of DSA public-key value y (= g**x mod p where x is secret). 2599 The secret key is this single multiprecision integer: 2601 * MPI of DSA secret exponent x. 2603 5.6.3. Algorithm-Specific Part for Elgamal Keys 2605 The public key is this series of multiprecision integers: 2607 * MPI of Elgamal prime p; 2609 * MPI of Elgamal group generator g; 2610 * MPI of Elgamal public key value y (= g**x mod p where x is 2611 secret). 2613 The secret key is this single multiprecision integer: 2615 * MPI of Elgamal secret exponent x. 2617 5.6.4. Algorithm-Specific Part for ECDSA Keys 2619 The public key is this series of values: 2621 * A variable-length field containing a curve OID, which is formatted 2622 as follows: 2624 - A one-octet size of the following field; values 0 and 0xFF are 2625 reserved for future extensions, 2627 - The octets representing a curve OID (defined in Section 9.2); 2629 * MPI of an EC point representing a public key. 2631 The secret key is this single multiprecision integer: 2633 * MPI of an integer representing the secret key, which is a scalar 2634 of the public EC point. 2636 5.6.5. Algorithm-Specific Part for EdDSA Keys 2638 The public key is this series of values: 2640 * A variable-length field containing a curve OID, formatted as 2641 follows: 2643 - A one-octet size of the following field; values 0 and 0xFF are 2644 reserved for future extensions, 2646 - The octets representing a curve OID, defined in Section 9.2; 2648 * An MPI of an EC point representing a public key Q in prefixed 2649 native form (see Section 13.2.2). 2651 The secret key is this single multiprecision integer: 2653 * An MPI-encoded octet string representing the native form of the 2654 secret key, in the curve-specific format described in 2655 Section 9.2.1. 2657 See [RFC8032] for more details about the native octet strings. 2659 5.6.6. Algorithm-Specific Part for ECDH Keys 2661 The public key is this series of values: 2663 * A variable-length field containing a curve OID, which is formatted 2664 as follows: 2666 - A one-octet size of the following field; values 0 and 0xFF are 2667 reserved for future extensions, 2669 - Octets representing a curve OID, defined in Section 9.2; 2671 * MPI of an EC point representing a public key, in the point format 2672 associated with the curve as specified in Section 9.2.1 2674 * A variable-length field containing KDF parameters, which is 2675 formatted as follows: 2677 - A one-octet size of the following fields; values 0 and 0xFF are 2678 reserved for future extensions, 2680 - A one-octet value 1, reserved for future extensions, 2682 - A one-octet hash function ID used with a KDF, 2684 - A one-octet algorithm ID for the symmetric algorithm used to 2685 wrap the symmetric key used for the message encryption; see 2686 Section 13.5 for details. 2688 Observe that an ECDH public key is composed of the same sequence of 2689 fields that define an ECDSA key plus the KDF parameters field. 2691 The secret key is this single multiprecision integer: 2693 * An MPI representing the secret key, in the curve-specific format 2694 described in Section 9.2.1. 2696 5.7. Compressed Data Packet (Tag 8) 2698 The Compressed Data packet contains compressed data. Typically, this 2699 packet is found as the contents of an encrypted packet, or following 2700 a Signature or One-Pass Signature packet, and contains a literal data 2701 packet. 2703 The body of this packet consists of: 2705 * One octet that gives the algorithm used to compress the packet. 2707 * Compressed data, which makes up the remainder of the packet. 2709 A Compressed Data Packet's body contains an block that compresses 2710 some set of packets. See Section 11 for details on how messages are 2711 formed. 2713 ZIP-compressed packets are compressed with raw [RFC1951] DEFLATE 2714 blocks. Note that PGP V2.6 uses 13 bits of compression. If an 2715 implementation uses more bits of compression, PGP V2.6 cannot 2716 decompress it. 2718 ZLIB-compressed packets are compressed with [RFC1950] ZLIB-style 2719 blocks. 2721 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2722 algorithm. 2724 5.8. Symmetrically Encrypted Data Packet (Tag 9) 2726 The Symmetrically Encrypted Data packet contains data encrypted with 2727 a symmetric-key algorithm. When it has been decrypted, it contains 2728 other packets (usually a literal data packet or compressed data 2729 packet, but in theory other Symmetrically Encrypted Data packets or 2730 sequences of packets that form whole OpenPGP messages). 2732 This packet is obsolete. An implementation MUST NOT create this 2733 packet. An implementation MAY process such a packet but it MUST 2734 return a clear diagnostic that a non-integrity protected packet has 2735 been processed. The implementation SHOULD also return an error in 2736 this case and stop processing. 2738 The body of this packet consists of: 2740 * Encrypted data, the output of the selected symmetric-key cipher 2741 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2743 The symmetric cipher used may be specified in a Public-Key or 2744 Symmetric-Key Encrypted Session Key packet that precedes the 2745 Symmetrically Encrypted Data packet. In that case, the cipher 2746 algorithm octet is prefixed to the session key before it is 2747 encrypted. If no packets of these types precede the encrypted data, 2748 the IDEA algorithm is used with the session key calculated as the MD5 2749 hash of the passphrase, though this use is deprecated. 2751 The data is encrypted in CFB mode, with a CFB shift size equal to the 2752 cipher's block size. The Initial Vector (IV) is specified as all 2753 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2754 equal to the block size of the cipher plus two to the data before it 2755 is encrypted. The first block-size octets (for example, 8 octets for 2756 a 64-bit block length) are random, and the following two octets are 2757 copies of the last two octets of the IV. For example, in an 8-octet 2758 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2759 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2760 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2761 in both these examples, we consider the first octet to be numbered 1. 2763 After encrypting the first block-size-plus-two octets, the CFB state 2764 is resynchronized. The last block-size octets of ciphertext are 2765 passed through the cipher and the block boundary is reset. 2767 The repetition of 16 bits in the random data prefixed to the message 2768 allows the receiver to immediately check whether the session key is 2769 incorrect. See Section 15 for hints on the proper use of this "quick 2770 check". 2772 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) 2774 An experimental version of PGP used this packet as the Literal 2775 packet, but no released version of PGP generated Literal packets with 2776 this tag. With PGP 5, this packet has been reassigned and is 2777 reserved for use as the Marker packet. 2779 The body of this packet consists of: 2781 * The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2783 Such a packet MUST be ignored when received. It may be placed at the 2784 beginning of a message that uses features not available in PGP 2785 version 2.6 in order to cause that version to report that newer 2786 software is necessary to process the message. 2788 5.10. Literal Data Packet (Tag 11) 2790 A Literal Data packet contains the body of a message; data that is 2791 not to be further interpreted. 2793 The body of this packet consists of: 2795 * A one-octet field that describes how the data is formatted. 2797 If it is a "b" (0x62), then the Literal packet contains binary 2798 data. If it is a "t" (0x74), then it contains text data, and thus 2799 may need line ends converted to local form, or other text-mode 2800 changes. The tag "u" (0x75) means the same as "t", but also 2801 indicates that implementation believes that the literal data 2802 contains UTF-8 text. 2804 Early versions of PGP also defined a value of "l" as a 'local' 2805 mode for machine-local conversions. [RFC1991] incorrectly stated 2806 this local mode flag as "1" (ASCII numeral one). Both of these 2807 local modes are deprecated. 2809 * File name as a string (one-octet length, followed by a file name). 2810 This may be a zero-length string. Commonly, if the source of the 2811 encrypted data is a file, this will be the name of the encrypted 2812 file. An implementation MAY consider the file name in the Literal 2813 packet to be a more authoritative name than the actual file name. 2815 If the special name "_CONSOLE" is used, the message is considered 2816 to be "for your eyes only". This advises that the message data is 2817 unusually sensitive, and the receiving program should process it 2818 more carefully, perhaps avoiding storing the received data to 2819 disk, for example. 2821 * A four-octet number that indicates a date associated with the 2822 literal data. Commonly, the date might be the modification date 2823 of a file, or the time the packet was created, or a zero that 2824 indicates no specific time. 2826 * The remainder of the packet is literal data. 2828 Text data is stored with text endings (i.e., network- 2829 normal line endings). These should be converted to native line 2830 endings by the receiving software. 2832 Note that V3 and V4 signatures do not include the formatting octet, 2833 the file name, and the date field of the literal packet in a 2834 signature hash and thus are not protected against tampering in a 2835 signed document. In contrast V5 signatures include them. 2837 5.11. Trust Packet (Tag 12) 2839 The Trust packet is used only within keyrings and is not normally 2840 exported. Trust packets contain data that record the user's 2841 specifications of which key holders are trustworthy introducers, 2842 along with other information that implementing software uses for 2843 trust information. The format of Trust packets is defined by a given 2844 implementation. 2846 Trust packets SHOULD NOT be emitted to output streams that are 2847 transferred to other users, and they SHOULD be ignored on any input 2848 other than local keyring files. 2850 5.12. User ID Packet (Tag 13) 2852 A User ID packet consists of UTF-8 text that is intended to represent 2853 the name and email address of the key holder. By convention, it 2854 includes an [RFC2822] mail name-addr, but there are no restrictions 2855 on its content. The packet length in the header specifies the length 2856 of the User ID. 2858 5.13. User Attribute Packet (Tag 17) 2860 The User Attribute packet is a variation of the User ID packet. It 2861 is capable of storing more types of data than the User ID packet, 2862 which is limited to text. Like the User ID packet, a User Attribute 2863 packet may be certified by the key owner ("self-signed") or any other 2864 key owner who cares to certify it. Except as noted, a User Attribute 2865 packet may be used anywhere that a User ID packet may be used. 2867 While User Attribute packets are not a required part of the OpenPGP 2868 standard, implementations SHOULD provide at least enough 2869 compatibility to properly handle a certification signature on the 2870 User Attribute packet. A simple way to do this is by treating the 2871 User Attribute packet as a User ID packet with opaque contents, but 2872 an implementation may use any method desired. 2874 The User Attribute packet is made up of one or more attribute 2875 subpackets. Each subpacket consists of a subpacket header and a 2876 body. The header consists of: 2878 * the subpacket length (1, 2, or 5 octets) 2880 * the subpacket type (1 octet) 2882 and is followed by the subpacket specific data. 2884 The following table lists the currently known subpackets: 2886 +=========+===========================+ 2887 | Type | Attribute Subpacket | 2888 +=========+===========================+ 2889 | 1 | Image Attribute Subpacket | 2890 +---------+---------------------------+ 2891 | 100-110 | Private/Experimental Use | 2892 +---------+---------------------------+ 2894 Table 13: User Attribute type registry 2896 An implementation SHOULD ignore any subpacket of a type that it does 2897 not recognize. 2899 5.13.1. The Image Attribute Subpacket 2901 The Image Attribute subpacket is used to encode an image, presumably 2902 (but not required to be) that of the key owner. 2904 The Image Attribute subpacket begins with an image header. The first 2905 two octets of the image header contain the length of the image 2906 header. Note that unlike other multi-octet numerical values in this 2907 document, due to a historical accident this value is encoded as a 2908 little-endian number. The image header length is followed by a 2909 single octet for the image header version. The only currently 2910 defined version of the image header is 1, which is a 16-octet image 2911 header. The first three octets of a version 1 image header are thus 2912 0x10, 0x00, 0x01. 2914 The fourth octet of a version 1 image header designates the encoding 2915 format of the image. The only currently defined encoding format is 2916 the value 1 to indicate JPEG. Image format types 100 through 110 are 2917 reserved for private or experimental use. The rest of the version 1 2918 image header is made up of 12 reserved octets, all of which MUST be 2919 set to 0. 2921 The rest of the image subpacket contains the image itself. As the 2922 only currently defined image type is JPEG, the image is encoded in 2923 the JPEG File Interchange Format (JFIF), a standard file format for 2924 JPEG images [JFIF]. 2926 An implementation MAY try to determine the type of an image by 2927 examination of the image data if it is unable to handle a particular 2928 version of the image header or if a specified encoding format value 2929 is not recognized. 2931 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2933 The Symmetrically Encrypted Integrity Protected Data packet is a 2934 variant of the Symmetrically Encrypted Data packet. It is a new 2935 feature created for OpenPGP that addresses the problem of detecting a 2936 modification to encrypted data. It is used in combination with a 2937 Modification Detection Code packet. 2939 There is a corresponding feature in the features Signature subpacket 2940 that denotes that an implementation can properly use this packet 2941 type. An implementation MUST support decrypting and generating these 2942 packets. An implementation SHOULD specifically denote support for 2943 this packet, but it MAY infer it from other mechanisms. 2945 For example, an implementation might infer from the use of a cipher 2946 such as Advanced Encryption Standard (AES) or Twofish that a user 2947 supports this feature. It might place in the unhashed portion of 2948 another user's key signature a Features subpacket. It might also 2949 present a user with an opportunity to regenerate their own self- 2950 signature with a Features subpacket. 2952 This packet contains data encrypted with a symmetric-key algorithm 2953 and protected against modification by the SHA-1 hash algorithm. When 2954 it has been decrypted, it will typically contain other packets (often 2955 a Literal Data packet or Compressed Data packet). The last decrypted 2956 packet in this packet's payload MUST be a Modification Detection Code 2957 packet. 2959 The body of this packet consists of: 2961 * A one-octet version number. The only currently defined value is 2962 1. 2964 * Encrypted data, the output of the selected symmetric-key cipher 2965 operating in Cipher Feedback mode with shift amount equal to the 2966 block size of the cipher (CFB-n where n is the block size). 2968 The symmetric cipher used MUST be specified in a Public-Key or 2969 Symmetric-Key Encrypted Session Key packet that precedes the 2970 Symmetrically Encrypted Integrity Protected Data packet. In either 2971 case, the cipher algorithm octet is prefixed to the session key 2972 before it is encrypted. 2974 The data is encrypted in CFB mode, with a CFB shift size equal to the 2975 cipher's block size. The Initial Vector (IV) is specified as all 2976 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2977 the data before it is encrypted. The length of the octet string 2978 equals the block size of the cipher in octets, plus two. The first 2979 octets in the group, of length equal to the block size of the cipher, 2980 are random; the last two octets are each copies of their 2nd 2981 preceding octet. For example, with a cipher whose block size is 128 2982 bits or 16 octets, the prefix data will contain 16 random octets, 2983 then two more octets, which are copies of the 15th and 16th octets, 2984 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2985 special CFB resynchronization is done after encrypting this prefix 2986 data. See Section 14.10 for more details. 2988 The repetition of 16 bits in the random data prefixed to the message 2989 allows the receiver to immediately check whether the session key is 2990 incorrect. 2992 The plaintext of the data to be encrypted is passed through the SHA-1 2993 hash function, and the result of the hash is appended to the 2994 plaintext in a Modification Detection Code packet. The input to the 2995 hash function includes the prefix data described above; it includes 2996 all of the plaintext, and then also includes two octets of values 2997 0xD3, 0x14. These represent the encoding of a Modification Detection 2998 Code packet tag and length field of 20 octets. 3000 The resulting hash value is stored in a Modification Detection Code 3001 (MDC) packet, which MUST use the two octet encoding just given to 3002 represent its tag and length field. The body of the MDC packet is 3003 the 20-octet output of the SHA-1 hash. 3005 The Modification Detection Code packet is appended to the plaintext 3006 and encrypted along with the plaintext using the same CFB context. 3008 During decryption, the plaintext data should be hashed with SHA-1, 3009 including the prefix data as well as the packet tag and length field 3010 of the Modification Detection Code packet. The body of the MDC 3011 packet, upon decryption, is compared with the result of the SHA-1 3012 hash. 3014 Any failure of the MDC indicates that the message has been modified 3015 and MUST be treated as a security problem. Failures include a 3016 difference in the hash values, but also the absence of an MDC packet, 3017 or an MDC packet in any position other than the end of the plaintext. 3018 Any failure SHOULD be reported to the user. 3020 Note: future designs of new versions of this packet should consider 3021 rollback attacks since it will be possible for an attacker to change 3022 the version back to 1. 3024 NON-NORMATIVE EXPLANATION 3026 The MDC system, as packets 18 and 19 are called, were created to 3027 provide an integrity mechanism that is less strong than a 3028 signature, yet stronger than bare CFB encryption. 3030 It is a limitation of CFB encryption that damage to the ciphertext 3031 will corrupt the affected cipher blocks and the block following. 3032 Additionally, if data is removed from the end of a CFB-encrypted 3033 block, that removal is undetectable. (Note also that CBC mode has 3034 a similar limitation, but data removed from the front of the block 3035 is undetectable.) 3037 The obvious way to protect or authenticate an encrypted block is 3038 to digitally sign it. However, many people do not wish to 3039 habitually sign data, for a large number of reasons beyond the 3040 scope of this document. Suffice it to say that many people 3041 consider properties such as deniability to be as valuable as 3042 integrity. 3044 OpenPGP addresses this desire to have more security than raw 3045 encryption and yet preserve deniability with the MDC system. An 3046 MDC is intentionally not a MAC. Its name was not selected by 3047 accident. It is analogous to a checksum. 3049 Despite the fact that it is a relatively modest system, it has 3050 proved itself in the real world. It is an effective defense to 3051 several attacks that have surfaced since it has been created. It 3052 has met its modest goals admirably. 3054 Consequently, because it is a modest security system, it has 3055 modest requirements on the hash function(s) it employs. It does 3056 not rely on a hash function being collision-free, it relies on a 3057 hash function being one-way. If a forger, Frank, wishes to send 3058 Alice a (digitally) unsigned message that says, "I've always 3059 secretly loved you, signed Bob", it is far easier for him to 3060 construct a new message than it is to modify anything intercepted 3061 from Bob. (Note also that if Bob wishes to communicate secretly 3062 with Alice, but without authentication or identification and with 3063 a threat model that includes forgers, he has a problem that 3064 transcends mere cryptography.) 3066 Note also that unlike nearly every other OpenPGP subsystem, there 3067 are no parameters in the MDC system. It hard-defines SHA-1 as its 3068 hash function. This is not an accident. It is an intentional 3069 choice to avoid downgrade and cross-grade attacks while making a 3070 simple, fast system. (A downgrade attack would be an attack that 3071 replaced SHA2-256 with SHA-1, for example. A cross-grade attack 3072 would replace SHA-1 with another 160-bit hash, such as RIPE- 3073 MD/160, for example.) 3075 However, given the present state of hash function cryptanalysis 3076 and cryptography, it may be desirable to upgrade the MDC system to 3077 a new hash function. See Section 14.12 for guidance. 3079 5.15. Modification Detection Code Packet (Tag 19) 3081 The Modification Detection Code packet contains a SHA-1 hash of 3082 plaintext data, which is used to detect message modification. It is 3083 only used with a Symmetrically Encrypted Integrity Protected Data 3084 packet. The Modification Detection Code packet MUST be the last 3085 packet in the plaintext data that is encrypted in the Symmetrically 3086 Encrypted Integrity Protected Data packet, and MUST appear in no 3087 other place. 3089 A Modification Detection Code packet MUST have a length of 20 octets. 3091 The body of this packet consists of: 3093 * A 20-octet SHA-1 hash of the preceding plaintext data of the 3094 Symmetrically Encrypted Integrity Protected Data packet, including 3095 prefix data, the tag octet, and length octet of the Modification 3096 Detection Code packet. 3098 Note that the Modification Detection Code packet MUST always use a 3099 new format encoding of the packet tag, and a one-octet encoding of 3100 the packet length. The reason for this is that the hashing rules for 3101 modification detection include a one-octet tag and one-octet length 3102 in the data hash. While this is a bit restrictive, it reduces 3103 complexity. 3105 5.16. AEAD Encrypted Data Packet (Tag 20) 3107 This packet contains data encrypted with an authenticated encryption 3108 and additional data (AEAD) construction. When it has been decrypted, 3109 it will typically contain other packets (often a Literal Data packet 3110 or Compressed Data packet). 3112 The body of this packet starts with: 3114 * A one-octet version number. The only currently defined value is 3115 1. 3117 When the version is 1, it is followed by the following fields: 3119 * A one-octet cipher algorithm. 3121 * A one-octet AEAD algorithm. 3123 * A one-octet chunk size. 3125 * A initialization vector of size specified by the AEAD algorithm. 3127 * Encrypted data, the output of the selected symmetric-key cipher 3128 operating in the given AEAD mode. 3130 * A final, summary authentication tag for the AEAD mode. 3132 An AEAD encrypted data packet consists of one or more chunks of data. 3133 The plaintext of each chunk is of a size specified using the chunk 3134 size octet using the method specified below. 3136 The encrypted data consists of the encryption of each chunk of 3137 plaintext, followed immediately by the relevant authentication tag. 3138 If the last chunk of plaintext is smaller than the chunk size, the 3139 ciphertext for that data may be shorter; it is nevertheless followed 3140 by a full authentication tag. 3142 For each chunk, the AEAD construction is given the Packet Tag in new 3143 format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag), 3144 version number, cipher algorithm octet, AEAD algorithm octet, chunk 3145 size octet, and an eight-octet, big-endian chunk index as additional 3146 data. The index of the first chunk is zero. For example, the 3147 additional data of the first chunk using EAX and AES-128 with a chunk 3148 size of 2**16 octets consists of the octets 0xD4, 0x01, 0x07, 0x01, 3149 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, and 0x00. 3151 After the final chunk, the AEAD algorithm is used to produce a final 3152 authentication tag encrypting the empty string. This AEAD instance 3153 is given the additional data specified above, plus an eight-octet, 3154 big-endian value specifying the total number of plaintext octets 3155 encrypted. This allows detection of a truncated ciphertext. Please 3156 note that the big-endian number representing the chunk index in the 3157 additional data is increased accordingly, although it's not really a 3158 chunk. 3160 The chunk size octet specifies the size of chunks using the following 3161 formula (in C), where c is the chunk size octet: 3163 chunk_size = ((uint64_t)1 << (c + 6)) 3165 An implementation MUST accept chunk size octets with values from 0 to 3166 16. An implementation MUST NOT create data with a chunk size octet 3167 value larger than 16 (4 MiB chunks). 3169 A unique, random, unpredictable initialization vector MUST be used 3170 for each message. Failure to do so for each message can lead to a 3171 catastrophic failure depending on the choice of AEAD mode and 3172 symmetric key reuse. 3174 5.16.1. EAX Mode 3176 The EAX AEAD Algorithm used in this document is defined in [EAX]. 3178 The EAX algorithm can only use block ciphers with 16-octet blocks. 3179 The initialization vector is 16 octets long. EAX authentication tags 3180 are 16 octets long. 3182 The nonce for EAX mode is computed by treating the initialization 3183 vector as a 16-octet, big-endian value and exclusive-oring the low 3184 eight octets of it with the chunk index. 3186 5.16.2. OCB Mode 3188 The OCB AEAD Algorithm used in this document is defined in [RFC7253]. 3190 The OCB algorithm can only use block ciphers with 16-octet blocks. 3191 The initialization vector is 15 octets long. OCB authentication tags 3192 are 16 octets long. 3194 The nonce for OCB mode is computed by the exclusive-oring of the 3195 initialization vector as a 15-octet, big endian value, against the 3196 chunk index. 3198 6. Radix-64 Conversions 3200 As stated in the introduction, OpenPGP's underlying native 3201 representation for objects is a stream of arbitrary octets, and some 3202 systems desire these objects to be immune to damage caused by 3203 character set translation, data conversions, etc. 3205 In principle, any printable encoding scheme that met the requirements 3206 of the unsafe channel would suffice, since it would not change the 3207 underlying binary bit streams of the native OpenPGP data structures. 3208 The OpenPGP standard specifies one such printable encoding scheme to 3209 ensure interoperability. 3211 OpenPGP's Radix-64 encoding is composed of two parts: a base64 3212 encoding of the binary data and an optional checksum. The base64 3213 encoding is identical to the MIME base64 content-transfer-encoding 3214 [RFC2045]. 3216 The optional checksum is a 24-bit Cyclic Redundancy Check (CRC) 3217 converted to four characters of radix-64 encoding by the same MIME 3218 base64 transformation, preceded by an equal sign (=). The CRC is 3219 computed by using the generator 0x864CFB and an initialization of 3220 0xB704CE. The accumulation is done on the data before it is 3221 converted to radix-64, rather than on the converted data. A sample 3222 implementation of this algorithm is in the next section. 3224 If present, the checksum with its leading equal sign MUST appear on 3225 the next line after the base64 encoded data. 3227 Rationale for CRC-24: The size of 24 bits fits evenly into printable 3228 base64. The nonzero initialization can detect more errors than a 3229 zero initialization. 3231 6.1. An Implementation of the CRC-24 in "C" 3233 #define CRC24_INIT 0xB704CEL 3234 #define CRC24_GENERATOR 0x864CFBL 3236 typedef unsigned long crc24; 3237 crc24 crc_octets(unsigned char *octets, size_t len) 3238 { 3239 crc24 crc = CRC24_INIT; 3240 int i; 3241 while (len--) { 3242 crc ^= (*octets++) << 16; 3243 for (i = 0; i < 8; i++) { 3244 crc <<= 1; 3245 if (crc & 0x1000000) { 3246 crc &= 0xffffff; /* Clear bit 25 to avoid overflow */ 3247 crc ^= CRC24_GENERATOR; 3248 } 3249 } 3250 } 3251 return crc & 0xFFFFFFL; 3252 } 3254 6.2. Forming ASCII Armor 3256 When OpenPGP encodes data into ASCII Armor, it puts specific headers 3257 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 3258 later. An OpenPGP implementation MAY use ASCII armor to protect raw 3259 binary data. OpenPGP informs the user what kind of data is encoded 3260 in the ASCII armor through the use of the headers. 3262 Concatenating the following data creates ASCII Armor: 3264 * An Armor Header Line, appropriate for the type of data 3266 * Armor Headers 3268 * A blank (zero-length, or containing only whitespace) line 3270 * The ASCII-Armored data 3272 * An Armor Checksum 3274 * The Armor Tail, which depends on the Armor Header Line 3275 An Armor Header Line consists of the appropriate header line text 3276 surrounded by five (5) dashes ("-", 0x2D) on either side of the 3277 header line text. The header line text is chosen based upon the type 3278 of data that is being encoded in Armor, and how it is being encoded. 3279 Header line texts include the following strings: 3281 BEGIN PGP MESSAGE 3282 Used for signed, encrypted, or compressed files. 3284 BEGIN PGP PUBLIC KEY BLOCK 3285 Used for armoring public keys. 3287 BEGIN PGP PRIVATE KEY BLOCK 3288 Used for armoring private keys. 3290 BEGIN PGP MESSAGE, PART X/Y 3291 Used for multi-part messages, where the armor is split amongst Y 3292 parts, and this is the Xth part out of Y. 3294 BEGIN PGP MESSAGE, PART X 3295 Used for multi-part messages, where this is the Xth part of an 3296 unspecified number of parts. Requires the MESSAGE-ID Armor Header 3297 to be used. 3299 BEGIN PGP SIGNATURE 3300 Used for detached signatures, OpenPGP/MIME signatures, and 3301 cleartext signatures. Note that PGP 2 uses BEGIN PGP MESSAGE for 3302 detached signatures. 3304 Note that all these Armor Header Lines are to consist of a complete 3305 line. That is to say, there is always a line ending preceding the 3306 starting five dashes, and following the ending five dashes. The 3307 header lines, therefore, MUST start at the beginning of a line, and 3308 MUST NOT have text other than whitespace following them on the same 3309 line. These line endings are considered a part of the Armor Header 3310 Line for the purposes of determining the content they delimit. This 3311 is particularly important when computing a cleartext signature (see 3312 below). 3314 The Armor Headers are pairs of strings that can give the user or the 3315 receiving OpenPGP implementation some information about how to decode 3316 or use the message. The Armor Headers are a part of the armor, not a 3317 part of the message, and hence are not protected by any signatures 3318 applied to the message. 3320 The format of an Armor Header is that of a key-value pair. A colon 3321 (":" 0x38) and a single space (0x20) separate the key and value. 3322 OpenPGP should consider improperly formatted Armor Headers to be 3323 corruption of the ASCII Armor. Unknown keys should be reported to 3324 the user, but OpenPGP should continue to process the message. 3326 Note that some transport methods are sensitive to line length. While 3327 there is a limit of 76 characters for the Radix-64 data 3328 (Section 6.3), there is no limit to the length of Armor Headers. 3329 Care should be taken that the Armor Headers are short enough to 3330 survive transport. One way to do this is to repeat an Armor Header 3331 Key multiple times with different values for each so that no one line 3332 is overly long. 3334 Currently defined Armor Header Keys are as follows: 3336 * "Version", which states the OpenPGP implementation and version 3337 used to encode the message. To minimize metadata, implementations 3338 SHOULD NOT emit this key and its corresponding value except for 3339 debugging purposes with explicit user consent. 3341 * "Comment", a user-defined comment. OpenPGP defines all text to be 3342 in UTF-8. A comment may be any UTF-8 string. However, the whole 3343 point of armoring is to provide seven-bit-clean data. 3344 Consequently, if a comment has characters that are outside the US- 3345 ASCII range of UTF, they may very well not survive transport. 3347 * "MessageID", a 32-character string of printable characters. The 3348 string must be the same for all parts of a multi-part message that 3349 uses the "PART X" Armor Header. MessageID strings should be 3350 unique enough that the recipient of the mail can associate all the 3351 parts of a message with each other. A good checksum or 3352 cryptographic hash function is sufficient. 3354 The MessageID SHOULD NOT appear unless it is in a multi-part 3355 message. If it appears at all, it MUST be computed from the 3356 finished (encrypted, signed, etc.) message in a deterministic 3357 fashion, rather than contain a purely random value. This is to 3358 allow the legitimate recipient to determine that the MessageID 3359 cannot serve as a covert means of leaking cryptographic key 3360 information. 3362 * "Hash", a comma-separated list of hash algorithms used in this 3363 message. This is used only in cleartext signed messages. 3365 * "Charset", a description of the character set that the plaintext 3366 is in. Please note that OpenPGP defines text to be in UTF-8. An 3367 implementation will get best results by translating into and out 3368 of UTF-8. However, there are many instances where this is easier 3369 said than done. Also, there are communities of users who have no 3370 need for UTF-8 because they are all happy with a character set 3371 like ISO Latin-5 or a Japanese character set. In such instances, 3372 an implementation MAY override the UTF-8 default by using this 3373 header key. An implementation MAY implement this key and any 3374 translations it cares to; an implementation MAY ignore it and 3375 assume all text is UTF-8. 3377 The Armor Tail Line is composed in the same manner as the Armor 3378 Header Line, except the string "BEGIN" is replaced by the string 3379 "END". 3381 6.3. Encoding Binary in Radix-64 3383 The encoding process represents 24-bit groups of input bits as output 3384 strings of 4 encoded characters. Proceeding from left to right, a 3385 24-bit input group is formed by concatenating three 8-bit input 3386 groups. These 24 bits are then treated as four concatenated 6-bit 3387 groups, each of which is translated into a single digit in the 3388 Radix-64 alphabet. When encoding a bit stream with the Radix-64 3389 encoding, the bit stream must be presumed to be ordered with the most 3390 significant bit first. That is, the first bit in the stream will be 3391 the high-order bit in the first 8-bit octet, and the eighth bit will 3392 be the low-order bit in the first 8-bit octet, and so on. 3394 ┌──first octet──┬─second octet──┬──third octet──┐ 3395 │7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│ 3396 ├───────────┬───┴───────┬───────┴───┬───────────┤ 3397 │5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│ 3398 └──1.index──┴──2.index──┴──3.index──┴──4.index──┘ 3400 Each 6-bit group is used as an index into an array of 64 printable 3401 characters from the table below. The character referenced by the 3402 index is placed in the output string. 3404 +=====+========++=====+=========++=====+==========++=====+==========+ 3405 |Value|Encoding||Value|Encoding ||Value| Encoding ||Value| Encoding | 3406 +=====+========++=====+=========++=====+==========++=====+==========+ 3407 | 0|A || 17|R || 34| i || 51| z | 3408 +-----+--------++-----+---------++-----+----------++-----+----------+ 3409 | 1|B || 18|S || 35| j || 52| 0 | 3410 +-----+--------++-----+---------++-----+----------++-----+----------+ 3411 | 2|C || 19|T || 36| k || 53| 1 | 3412 +-----+--------++-----+---------++-----+----------++-----+----------+ 3413 | 3|D || 20|U || 37| l || 54| 2 | 3414 +-----+--------++-----+---------++-----+----------++-----+----------+ 3415 | 4|E || 21|V || 38| m || 55| 3 | 3416 +-----+--------++-----+---------++-----+----------++-----+----------+ 3417 | 5|F || 22|W || 39| n || 56| 4 | 3418 +-----+--------++-----+---------++-----+----------++-----+----------+ 3419 | 6|G || 23|X || 40| o || 57| 5 | 3420 +-----+--------++-----+---------++-----+----------++-----+----------+ 3421 | 7|H || 24|Y || 41| p || 58| 6 | 3422 +-----+--------++-----+---------++-----+----------++-----+----------+ 3423 | 8|I || 25|Z || 42| q || 59| 7 | 3424 +-----+--------++-----+---------++-----+----------++-----+----------+ 3425 | 9|J || 26|a || 43| r || 60| 8 | 3426 +-----+--------++-----+---------++-----+----------++-----+----------+ 3427 | 10|K || 27|b || 44| s || 61| 9 | 3428 +-----+--------++-----+---------++-----+----------++-----+----------+ 3429 | 11|L || 28|c || 45| t || 62| + | 3430 +-----+--------++-----+---------++-----+----------++-----+----------+ 3431 | 12|M || 29|d || 46| u || 63| / | 3432 +-----+--------++-----+---------++-----+----------++-----+----------+ 3433 | 13|N || 30|e || 47| v || | | 3434 +-----+--------++-----+---------++-----+----------++-----+----------+ 3435 | 14|O || 31|f || 48| w ||(pad)| = | 3436 +-----+--------++-----+---------++-----+----------++-----+----------+ 3437 | 15|P || 32|g || 49| x || | | 3438 +-----+--------++-----+---------++-----+----------++-----+----------+ 3439 | 16|Q || 33|h || 50| y || | | 3440 +-----+--------++-----+---------++-----+----------++-----+----------+ 3442 Table 14: Encoding for Radix-64 3444 The encoded output stream must be represented in lines of no more 3445 than 76 characters each. 3447 Special processing is performed if fewer than 24 bits are available 3448 at the end of the data being encoded. There are three possibilities: 3450 1. The last data group has 24 bits (3 octets). No special 3451 processing is needed. 3453 2. The last data group has 16 bits (2 octets). The first two 6-bit 3454 groups are processed as above. The third (incomplete) data group 3455 has two zero-value bits added to it, and is processed as above. 3456 A pad character (=) is added to the output. 3458 3. The last data group has 8 bits (1 octet). The first 6-bit group 3459 is processed as above. The second (incomplete) data group has 3460 four zero-value bits added to it, and is processed as above. Two 3461 pad characters (=) are added to the output. 3463 6.4. Decoding Radix-64 3465 In Radix-64 data, characters other than those in the table, line 3466 breaks, and other white space probably indicate a transmission error, 3467 about which a warning message or even a message rejection might be 3468 appropriate under some circumstances. Decoding software must ignore 3469 all white space. 3471 Because it is used only for padding at the end of the data, the 3472 occurrence of any "=" characters may be taken as evidence that the 3473 end of the data has been reached (without truncation in transit). No 3474 such assurance is possible, however, when the number of octets 3475 transmitted was a multiple of three and no "=" characters are 3476 present. 3478 6.5. Examples of Radix-64 3479 Input data: 0x14FB9C03D97E 3480 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 3481 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 3482 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 3483 Decimal: 5 15 46 28 0 61 37 62 3484 Output: F P u c A 9 l + 3485 Input data: 0x14FB9C03D9 3486 Hex: 1 4 F B 9 C | 0 3 D 9 3487 8-bit: 00010100 11111011 10011100 | 00000011 11011001 3488 pad with 00 3489 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 3490 Decimal: 5 15 46 28 0 61 36 3491 pad with = 3492 Output: F P u c A 9 k = 3493 Input data: 0x14FB9C03 3494 Hex: 1 4 F B 9 C | 0 3 3495 8-bit: 00010100 11111011 10011100 | 00000011 3496 pad with 0000 3497 6-bit: 000101 001111 101110 011100 | 000000 110000 3498 Decimal: 5 15 46 28 0 48 3499 pad with = = 3500 Output: F P u c A w = = 3502 6.6. Example of an ASCII Armored Message 3504 -----BEGIN PGP MESSAGE----- 3506 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3507 vBSFjNSiVHsuAA== 3508 =njUN 3509 -----END PGP MESSAGE----- 3511 Note that this example has extra indenting; an actual armored message 3512 would have no leading whitespace. 3514 7. Cleartext Signature Framework 3516 It is desirable to be able to sign a textual octet stream without 3517 ASCII armoring the stream itself, so the signed text is still 3518 readable without special software. In order to bind a signature to 3519 such a cleartext, this framework is used, which follows the same 3520 basic format and restrictions as the ASCII armoring described in 3521 Section 6.2. (Note that this framework is not intended to be 3522 reversible. [RFC3156] defines another way to sign cleartext messages 3523 for environments that support MIME.) 3525 The cleartext signed message consists of: 3527 * The cleartext header "-----BEGIN PGP SIGNED MESSAGE-----" on a 3528 single line, 3530 * One or more "Hash" Armor Headers, 3532 * Exactly one empty line not included into the message digest, 3534 * The dash-escaped cleartext that is included into the message 3535 digest, 3537 * The ASCII armored signature(s) including the "-----BEGIN PGP 3538 SIGNATURE-----" Armor Header and Armor Tail Lines. 3540 If the "Hash" Armor Header is given, the specified message digest 3541 algorithm(s) are used for the signature. If there are no such 3542 headers, MD5 is used. If MD5 is the only hash used, then an 3543 implementation MAY omit this header for improved V2.x compatibility. 3544 If more than one message digest is used in the signature, the "Hash" 3545 armor header contains a comma-delimited list of used message digests. 3547 Current message digest names are described below with the algorithm 3548 IDs. 3550 An implementation SHOULD add a line break after the cleartext, but 3551 MAY omit it if the cleartext ends with a line break. This is for 3552 visual clarity. 3554 7.1. Dash-Escaped Text 3556 The cleartext content of the message must also be dash-escaped. 3558 Dash-escaped cleartext is the ordinary cleartext where every line 3559 starting with a "-" (HYPHEN-MINUS, U+002D) is prefixed by the 3560 sequence "-" (HYPHEN-MINUS, U+002D) and " " (SPACE, U+0020). This 3561 prevents the parser from recognizing armor headers of the cleartext 3562 itself. An implementation MAY dash-escape any line, SHOULD dash- 3563 escape lines commencing "From" followed by a space, and MUST dash- 3564 escape any line commencing in a dash. The message digest is computed 3565 using the cleartext itself, not the dash-escaped form. 3567 As with binary signatures on text documents, a cleartext signature is 3568 calculated on the text using canonical line endings. The 3569 line ending (i.e., the ) before the "-----BEGIN PGP 3570 SIGNATURE-----" line that terminates the signed text is not 3571 considered part of the signed text. 3573 When reversing dash-escaping, an implementation MUST strip the string 3574 "-" if it occurs at the beginning of a line, and SHOULD warn on "-" 3575 and any character other than a space at the beginning of a line. 3577 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 3578 the end of any line is removed when the cleartext signature is 3579 generated. 3581 8. Regular Expressions 3583 A regular expression is zero or more branches, separated by "|". It 3584 matches anything that matches one of the branches. 3586 A branch is zero or more pieces, concatenated. It matches a match 3587 for the first, followed by a match for the second, etc. 3589 A piece is an atom possibly followed by "*", "+", or "?". An atom 3590 followed by "*" matches a sequence of 0 or more matches of the atom. 3591 An atom followed by "+" matches a sequence of 1 or more matches of 3592 the atom. An atom followed by "?" matches a match of the atom, or 3593 the null string. 3595 An atom is a regular expression in parentheses (matching a match for 3596 the regular expression), a range (see below), "." (matching any 3597 single character), "^" (matching the null string at the beginning of 3598 the input string), "$" (matching the null string at the end of the 3599 input string), a "\" followed by a single character (matching that 3600 character), or a single character with no other significance 3601 (matching that character). 3603 A range is a sequence of characters enclosed in "[]". It normally 3604 matches any single character from the sequence. If the sequence 3605 begins with "^", it matches any single character not from the rest of 3606 the sequence. If two characters in the sequence are separated by 3607 "-", this is shorthand for the full list of ASCII characters between 3608 them (e.g., "[0-9]" matches any decimal digit). To include a literal 3609 "]" in the sequence, make it the first character (following a 3610 possible "^"). To include a literal "-", make it the first or last 3611 character. 3613 9. Constants 3615 This section describes the constants used in OpenPGP. 3617 Note that these tables are not exhaustive lists; an implementation 3618 MAY implement an algorithm not on these lists, so long as the 3619 algorithm numbers are chosen from the private or experimental 3620 algorithm range. 3622 See Section 14 for more discussion of the algorithms. 3624 9.1. Public-Key Algorithms 3626 +===+==============+==========+=============+===========+===========+ 3627 | ID|Algorithm |Public Key|Secret Key | Signature |PKESK | 3628 | | |Format |Format | Format |Format | 3629 +===+==============+==========+=============+===========+===========+ 3630 | 1|RSA (Encrypt |MPI(n), |MPI(d), | MPI(m**d |MPI(m**e | 3631 | |or Sign) [HAC]|MPI(e) |MPI(p), | mod n) |mod n) | 3632 | | |[Section |MPI(q), | [Section |[Section | 3633 | | |5.6.1] |MPI(u) | 5.2.3.1] |5.1.1] | 3634 +---+--------------+----------+-------------+-----------+-----------+ 3635 | 2|RSA Encrypt- |MPI(n), |MPI(d), | N/A |MPI(m**e | 3636 | |Only [HAC] |MPI(e) |MPI(p), | |mod n) | 3637 | | |[Section |MPI(q), | |[Section | 3638 | | |5.6.1] |MPI(u) | |5.1.1] | 3639 +---+--------------+----------+-------------+-----------+-----------+ 3640 | 3|RSA Sign-Only |MPI(n), |MPI(d), | MPI(m**d |N/A | 3641 | |[HAC] |MPI(e) |MPI(p), | mod n) | | 3642 | | |[Section |MPI(q), | [Section | | 3643 | | |5.6.1] |MPI(u) | 5.2.3.1] | | 3644 +---+--------------+----------+-------------+-----------+-----------+ 3645 | 16|Elgamal |MPI(p), |MPI(x) | N/A |MPI(g**k | 3646 | |(Encrypt-Only)|MPI(g), | | |mod p), MPI| 3647 | |[ELGAMAL] |MPI(y) | | |(m * y**k | 3648 | |[HAC] |[Section | | |mod p) | 3649 | | |5.6.3] | | |[Section | 3650 | | | | | |5.1.2] | 3651 +---+--------------+----------+-------------+-----------+-----------+ 3652 | 17|DSA (Digital |MPI(p), |MPI(x) | MPI(r), |N/A | 3653 | |Signature |MPI(q), | | MPI(s) | | 3654 | |Algorithm) |MPI(g), | | [Section | | 3655 | |[FIPS186] |MPI(y) | | 5.2.3.2] | | 3656 | |[HAC] |[Section | | | | 3657 | | |5.6.2] | | | | 3658 +---+--------------+----------+-------------+-----------+-----------+ 3659 | 18|ECDH public |OID, |MPI(secret) | N/A |MPI(point | 3660 | |key algorithm |MPI(point | | |in curve- | 3661 | | |in curve- | | |specific | 3662 | | |specific | | |point | 3663 | | |point | | |format), | 3664 | | |format), | | |size octet,| 3665 | | |KDFParams | | |encoded key| 3666 | | |[see | | |[Section | 3667 | | |Section | | |9.2.1, | 3668 | | |9.2.1, | | |Section | 3669 | | |Section | | |5.1.3, | 3670 | | |5.6.6] | | |Section | 3671 | | | | | |13.5] | 3672 +---+--------------+----------+-------------+-----------+-----------+ 3673 | 19|ECDSA public |OID, |MPI(secret) | MPI(r), |N/A | 3674 | |key algorithm |MPI(point | | MPI(s) | | 3675 | |[FIPS186] |in SEC1 | | [Section | | 3676 | | |format) | | 5.2.3.2] | | 3677 | | |[Section | | | | 3678 | | |5.6.4] | | | | 3679 +---+--------------+----------+-------------+-----------+-----------+ 3680 | 20|Reserved | | | | | 3681 | |(formerly | | | | | 3682 | |Elgamal | | | | | 3683 | |Encrypt or | | | | | 3684 | |Sign) | | | | | 3685 +---+--------------+----------+-------------+-----------+-----------+ 3686 | 21|Reserved for | | | | | 3687 | |Diffie-Hellman| | | | | 3688 | |(X9.42, as | | | | | 3689 | |defined for | | | | | 3690 | |IETF-S/MIME) | | | | | 3691 +---+--------------+----------+-------------+-----------+-----------+ 3692 | 22|EdDSA |OID, |MPI(value in | MPI, MPI |N/A | 3693 | |[RFC8032] |MPI(point |curve- | [see | | 3694 | | |in |specific | Section | | 3695 | | |prefixed |format) [see | 9.2.1, | | 3696 | | |native |Section | Section | | 3697 | | |format) |9.2.1] | 5.2.3.3] | | 3698 | | |[Section | | | | 3699 | | |5.6.5] | | | | 3700 +---+--------------+----------+-------------+-----------+-----------+ 3701 | 23|Reserved | | | | | 3702 | |(AEDH) | | | | | 3703 +---+--------------+----------+-------------+-----------+-----------+ 3704 | 24|Reserved | | | | | 3705 | |(AEDSA) | | | | | 3706 +---+--------------+----------+-------------+-----------+-----------+ 3707 |100|Private/ | | | | | 3708 | to|Experimental | | | | | 3709 |110|algorithm | | | | | 3710 +---+--------------+----------+-------------+-----------+-----------+ 3712 Table 15: Public-key algorithm registry 3714 Implementations MUST implement DSA for signatures, and Elgamal for 3715 encryption. Implementations SHOULD implement RSA keys (1). RSA 3716 Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD NOT 3717 be generated, but may be interpreted. See Section 14.5. See 3718 Section 14.9 for notes on Elgamal Encrypt or Sign (20), and X9.42 3719 (21). Implementations MAY implement any other algorithm. 3721 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3722 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 of this 3723 document. 3725 9.2. ECC Curves for OpenPGP 3727 The parameter curve OID is an array of octets that define a named 3728 curve. 3730 The table below specifies the exact sequence of octets for each named 3731 curve referenced in this document. It also specifies which public 3732 key algorithms the curve can be used with, as well as the size of 3733 expected elements in octets: 3735 +======================+===+==============+==========+======+=======+ 3736 |ASN.1 Object |OID|Curve OID |Curve name|Usage |Field | 3737 |Identifier |len|octets in | | |Size | 3738 | | |hexadecimal | | |(fsize)| 3739 | | |representation| | | | 3740 +======================+===+==============+==========+======+=======+ 3741 |1.2.840.10045.3.1.7 |8 |2A 86 48 CE 3D|NIST P-256|ECDSA,|32 | 3742 | | |03 01 07 | |ECDH | | 3743 +----------------------+---+--------------+----------+------+-------+ 3744 |1.3.132.0.34 |5 |2B 81 04 00 22|NIST P-384|ECDSA,|48 | 3745 | | | | |ECDH | | 3746 +----------------------+---+--------------+----------+------+-------+ 3747 |1.3.132.0.35 |5 |2B 81 04 00 23|NIST P-521|ECDSA,|66 | 3748 | | | | |ECDH | | 3749 +----------------------+---+--------------+----------+------+-------+ 3750 |1.3.6.1.4.1.11591.15.1|9 |2B 06 01 04 01|Ed25519 |EdDSA |32 | 3751 | | |DA 47 0F 01 | | | | 3752 +----------------------+---+--------------+----------+------+-------+ 3753 |1.3.101.113 |3 |2B 65 71 |Ed448 |EdDSA |57 | 3754 +----------------------+---+--------------+----------+------+-------+ 3755 |1.3.6.1.4.1.3029.1.5.1|10 |2B 06 01 04 01|Curve25519|ECDH |32 | 3756 | | |97 55 01 05 01| | | | 3757 +----------------------+---+--------------+----------+------+-------+ 3758 |1.3.101.111 |3 |2B 65 6F |X448 |ECDH |56 | 3759 +----------------------+---+--------------+----------+------+-------+ 3761 Table 16: ECC Curve OID and usage registry 3763 The "Field Size (fsize)" column represents the field size of the 3764 group in number of octets, rounded up, such that x or y coordinates 3765 for a point on the curve, native point representations, or scalars 3766 with high enough entropy for the curve can be represented in that 3767 many octets. 3769 The sequence of octets in the third column is the result of applying 3770 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3771 with subsequent truncation. The truncation removes the two fields of 3772 encoded Object Identifier. The first omitted field is one octet 3773 representing the Object Identifier tag, and the second omitted field 3774 is the length of the Object Identifier body. For example, the 3775 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3776 86 48 CE 3D 03 01 07", from which the first entry in the table above 3777 is constructed by omitting the first two octets. Only the truncated 3778 sequence of octets is the valid representation of a curve OID. 3780 9.2.1. Curve-Specific Wire Formats 3782 Some Elliptic Curve Public Key Algorithms use different conventions 3783 for specific fields depending on the curve in use. Each field is 3784 always formatted as an MPI, but with a curve-specific framing. This 3785 table summarizes those distinctions. 3787 +============+========+========+=========+===========+==============+ 3788 | Curve |ECDH |ECDH |EdDSA |EdDSA |EdDSA | 3789 | |Point |Secret |Secret |Signature |Signature | 3790 | |Format |Key MPI |Key MPI |first MPI |second MPI | 3791 +============+========+========+=========+===========+==============+ 3792 | NIST P-256 |SEC1 |integer |N/A |N/A |N/A | 3793 +------------+--------+--------+---------+-----------+--------------+ 3794 | NIST P-384 |SEC1 |integer |N/A |N/A |N/A | 3795 +------------+--------+--------+---------+-----------+--------------+ 3796 | NIST P-521 |SEC1 |integer |N/A |N/A |N/A | 3797 +------------+--------+--------+---------+-----------+--------------+ 3798 | Ed25519 |N/A |N/A |32 octets|32 octets |32 octets of S| 3799 | | | |of secret|of R | | 3800 +------------+--------+--------+---------+-----------+--------------+ 3801 | Ed448 |N/A |N/A |prefixed |prefixed |0 [this is an | 3802 | | | |57 octets|114 octets |unused | 3803 | | | |of secret|of |placeholder] | 3804 | | | | |signature | | 3805 +------------+--------+--------+---------+-----------+--------------+ 3806 | Curve25519 |prefixed|integer |N/A |N/A |N/A | 3807 | |native | | | | | 3808 +------------+--------+--------+---------+-----------+--------------+ 3809 | X448 |prefixed|prefixed|N/A |N/A |N/A | 3810 | |native |56 | | | | 3811 | | |octets | | | | 3812 | | |of | | | | 3813 | | |secret | | | | 3814 +------------+--------+--------+---------+-----------+--------------+ 3816 Table 17: Curve-specific wire formats 3818 For the native octet-string forms of EdDSA values, see [RFC8032]. 3819 For the native octet-string forms of ECDH secret scalars and points, 3820 see [RFC7748]. 3822 9.3. Symmetric-Key Algorithms 3824 +==========+====================================================+ 3825 | ID | Algorithm | 3826 +==========+====================================================+ 3827 | 0 | Plaintext or unencrypted data | 3828 +----------+----------------------------------------------------+ 3829 | 1 | IDEA [IDEA] | 3830 +----------+----------------------------------------------------+ 3831 | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] - 168 bit | 3832 | | key derived from 192) | 3833 +----------+----------------------------------------------------+ 3834 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3835 +----------+----------------------------------------------------+ 3836 | 4 | Blowfish (128 bit key, 16 rounds) [BLOWFISH] | 3837 +----------+----------------------------------------------------+ 3838 | 5 | Reserved | 3839 +----------+----------------------------------------------------+ 3840 | 6 | Reserved | 3841 +----------+----------------------------------------------------+ 3842 | 7 | AES with 128-bit key [AES] | 3843 +----------+----------------------------------------------------+ 3844 | 8 | AES with 192-bit key | 3845 +----------+----------------------------------------------------+ 3846 | 9 | AES with 256-bit key | 3847 +----------+----------------------------------------------------+ 3848 | 10 | Twofish with 256-bit key [TWOFISH] | 3849 +----------+----------------------------------------------------+ 3850 | 11 | Camellia with 128-bit key [RFC3713] | 3851 +----------+----------------------------------------------------+ 3852 | 12 | Camellia with 192-bit key | 3853 +----------+----------------------------------------------------+ 3854 | 13 | Camellia with 256-bit key | 3855 +----------+----------------------------------------------------+ 3856 | 100 to | Private/Experimental algorithm | 3857 | 110 | | 3858 +----------+----------------------------------------------------+ 3859 | 253, 254 | Reserved to avoid collision with Secret Key | 3860 | and 255 | Encryption (see Section 3.7.2.1 and Section 5.5.3) | 3861 +----------+----------------------------------------------------+ 3863 Table 18: Symmetric-key algorithm registry 3865 Implementations MUST implement TripleDES. Implementations SHOULD 3866 implement AES-128 and CAST5. Implementations that interoperate with 3867 PGP 2.6 or earlier need to support IDEA, as that is the only 3868 symmetric cipher those versions use. Implementations MAY implement 3869 any other algorithm. 3871 9.4. Compression Algorithms 3873 +============+================================+ 3874 | ID | Algorithm | 3875 +============+================================+ 3876 | 0 | Uncompressed | 3877 +------------+--------------------------------+ 3878 | 1 | ZIP [RFC1951] | 3879 +------------+--------------------------------+ 3880 | 2 | ZLIB [RFC1950] | 3881 +------------+--------------------------------+ 3882 | 3 | BZip2 [BZ2] | 3883 +------------+--------------------------------+ 3884 | 100 to 110 | Private/Experimental algorithm | 3885 +------------+--------------------------------+ 3887 Table 19: Compression algorithm registry 3889 Implementations MUST implement uncompressed data. Implementations 3890 SHOULD implement ZIP. Implementations MAY implement any other 3891 algorithm. 3893 9.5. Hash Algorithms 3895 +============+================================+=============+ 3896 | ID | Algorithm | Text Name | 3897 +============+================================+=============+ 3898 | 1 | MD5 [HAC] | "MD5" | 3899 +------------+--------------------------------+-------------+ 3900 | 2 | SHA-1 [FIPS180] | "SHA1" | 3901 +------------+--------------------------------+-------------+ 3902 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3903 +------------+--------------------------------+-------------+ 3904 | 4 | Reserved | | 3905 +------------+--------------------------------+-------------+ 3906 | 5 | Reserved | | 3907 +------------+--------------------------------+-------------+ 3908 | 6 | Reserved | | 3909 +------------+--------------------------------+-------------+ 3910 | 7 | Reserved | | 3911 +------------+--------------------------------+-------------+ 3912 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3913 +------------+--------------------------------+-------------+ 3914 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3915 +------------+--------------------------------+-------------+ 3916 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3917 +------------+--------------------------------+-------------+ 3918 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3919 +------------+--------------------------------+-------------+ 3920 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3921 +------------+--------------------------------+-------------+ 3922 | 13 | Reserved | | 3923 +------------+--------------------------------+-------------+ 3924 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3925 +------------+--------------------------------+-------------+ 3926 | 100 to 110 | Private/Experimental algorithm | | 3927 +------------+--------------------------------+-------------+ 3929 Table 20: Hash algorithm registry 3931 Implementations MUST implement SHA-1. Implementations MAY implement 3932 other algorithms. MD5 is deprecated. 3934 9.6. AEAD Algorithms 3936 +========+======================+===========+====================+ 3937 | ID | Algorithm | IV length | authentication tag | 3938 | | | (octets) | length (octets) | 3939 +========+======================+===========+====================+ 3940 | 1 | EAX [EAX] | 16 | 16 | 3941 +--------+----------------------+-----------+--------------------+ 3942 | 2 | OCB [RFC7253] | 15 | 16 | 3943 +--------+----------------------+-----------+--------------------+ 3944 | 100 to | Private/Experimental | | | 3945 | 110 | algorithm | | | 3946 +--------+----------------------+-----------+--------------------+ 3948 Table 21: AEAD algorithm registry 3950 10. IANA Considerations 3952 Because this document obsoletes [RFC4880], IANA is requested to 3953 update all registration information that references [RFC4880] to 3954 instead reference this RFC. 3956 OpenPGP is highly parameterized, and consequently there are a number 3957 of considerations for allocating parameters for extensions. This 3958 section describes how IANA should look at extensions to the protocol 3959 as described in this document. 3961 10.1. New String-to-Key Specifier Types 3963 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3964 a string into a key. This specification creates a registry of S2K 3965 specifier types. The registry includes the S2K type, the name of the 3966 S2K, and a reference to the defining specification. The initial 3967 values for this registry can be found in Section 3.7.1. Adding a new 3968 S2K specifier MUST be done through the SPECIFICATION REQUIRED method, 3969 as described in [RFC8126]. 3971 IANA should add a column "Generate?" to the S2K type registry, with 3972 initial values taken from Section 3.7.1. 3974 10.2. New Packets 3976 Major new features of OpenPGP are defined through new packet types. 3977 This specification creates a registry of packet types. The registry 3978 includes the packet type, the name of the packet, and a reference to 3979 the defining specification. The initial values for this registry can 3980 be found in Section 4.3. Adding a new packet type MUST be done 3981 through the RFC REQUIRED method, as described in [RFC8126]. 3983 10.2.1. User Attribute Types 3985 The User Attribute packet permits an extensible mechanism for other 3986 types of certificate identification. This specification creates a 3987 registry of User Attribute types. The registry includes the User 3988 Attribute type, the name of the User Attribute, and a reference to 3989 the defining specification. The initial values for this registry can 3990 be found in Section 5.13. Adding a new User Attribute type MUST be 3991 done through the SPECIFICATION REQUIRED method, as described in 3992 [RFC8126]. 3994 10.2.1.1. Image Format Subpacket Types 3996 Within User Attribute packets, there is an extensible mechanism for 3997 other types of image-based User Attributes. This specification 3998 creates a registry of Image Attribute subpacket types. The registry 3999 includes the Image Attribute subpacket type, the name of the Image 4000 Attribute subpacket, and a reference to the defining specification. 4001 The initial values for this registry can be found in Section 5.13.1. 4002 Adding a new Image Attribute subpacket type MUST be done through the 4003 SPECIFICATION REQUIRED method, as described in [RFC8126]. 4005 10.2.2. New Signature Subpackets 4007 OpenPGP signatures contain a mechanism for signed (or unsigned) data 4008 to be added to them for a variety of purposes in the Signature 4009 subpackets as discussed in Section 5.2.3.5. This specification 4010 creates a registry of Signature subpacket types. The registry 4011 includes the Signature subpacket type, the name of the subpacket, and 4012 a reference to the defining specification. The initial values for 4013 this registry can be found in Section 5.2.3.5. Adding a new 4014 Signature subpacket MUST be done through the SPECIFICATION REQUIRED 4015 method, as described in [RFC8126]. 4017 10.2.2.1. Signature Notation Data Subpackets 4019 OpenPGP signatures further contain a mechanism for extensions in 4020 signatures. These are the Notation Data subpackets, which contain a 4021 key/value pair. Notations contain a user space that is completely 4022 unmanaged and an IETF space. 4024 This specification creates a registry of Signature Notation Data 4025 types. The registry includes the Signature Notation Data type, the 4026 name of the Signature Notation Data, its allowed values, and a 4027 reference to the defining specification. The initial values for this 4028 registry can be found in Section 5.2.3.20. Adding a new Signature 4029 Notation Data subpacket MUST be done through the SPECIFICATION 4030 REQUIRED method, as described in [RFC8126]. 4032 10.2.2.2. Signature Notation Data Subpacket Notation Flags 4034 This specification creates a new registry of Signature Notation Data 4035 Subpacket Notation Flags. The registry includes the columns "Flag", 4036 "Description", "Security Recommended", "Interoperability 4037 Recommended", and "Reference". The initial values for this registry 4038 can be found in Section 5.2.3.20. Adding a new item MUST be done 4039 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 4041 10.2.2.3. Key Server Preference Extensions 4043 OpenPGP signatures contain a mechanism for preferences to be 4044 specified about key servers. This specification creates a registry 4045 of key server preferences. The registry includes the key server 4046 preference, the name of the preference, and a reference to the 4047 defining specification. The initial values for this registry can be 4048 found in Section 5.2.3.21. Adding a new key server preference MUST 4049 be done through the SPECIFICATION REQUIRED method, as described in 4050 [RFC8126]. 4052 10.2.2.4. Key Flags Extensions 4054 OpenPGP signatures contain a mechanism for flags to be specified 4055 about key usage. This specification creates a registry of key usage 4056 flags. The registry includes the key flags value, the name of the 4057 flag, and a reference to the defining specification. The initial 4058 values for this registry can be found in Section 5.2.3.25. Adding a 4059 new key usage flag MUST be done through the SPECIFICATION REQUIRED 4060 method, as described in [RFC8126]. 4062 10.2.2.5. Reason for Revocation Extensions 4064 OpenPGP signatures contain a mechanism for flags to be specified 4065 about why a key was revoked. This specification creates a registry 4066 of "Reason for Revocation" flags. The registry includes the "Reason 4067 for Revocation" flags value, the name of the flag, and a reference to 4068 the defining specification. The initial values for this registry can 4069 be found in Section 5.2.3.27. Adding a new feature flag MUST be done 4070 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 4072 10.2.2.6. Implementation Features 4074 OpenPGP signatures contain a mechanism for flags to be specified 4075 stating which optional features an implementation supports. This 4076 specification creates a registry of feature-implementation flags. 4077 The registry includes the feature-implementation flags value, the 4078 name of the flag, and a reference to the defining specification. The 4079 initial values for this registry can be found in Section 5.2.3.28. 4080 Adding a new feature-implementation flag MUST be done through the 4081 SPECIFICATION REQUIRED method, as described in [RFC8126]. 4083 Also see Section 14.13 for more information about when feature flags 4084 are needed. 4086 10.2.3. New Packet Versions 4088 The core OpenPGP packets all have version numbers, and can be revised 4089 by introducing a new version of an existing packet. This 4090 specification creates a registry of packet types. The registry 4091 includes the packet type, the number of the version, and a reference 4092 to the defining specification. The initial values for this registry 4093 can be found in Section 5. Adding a new packet version MUST be done 4094 through the RFC REQUIRED method, as described in [RFC8126]. 4096 10.3. New Algorithms 4098 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 4099 new algorithm is usually simple. For example, adding in a new 4100 symmetric cipher usually would not need anything more than allocating 4101 a constant for that cipher. If that cipher had other than a 64-bit 4102 or 128-bit block size, there might need to be additional 4103 documentation describing how OpenPGP-CFB mode would be adjusted. 4104 Similarly, when DSA was expanded from a maximum of 1024-bit public 4105 keys to 3072-bit public keys, the revision of FIPS 186 contained 4106 enough information itself to allow implementation. Changes to this 4107 document were made mainly for emphasis. 4109 10.3.1. Public-Key Algorithms 4111 OpenPGP specifies a number of public-key algorithms. This 4112 specification creates a registry of public-key algorithm identifiers. 4113 The registry includes the algorithm name, its key sizes and 4114 parameters, and a reference to the defining specification. The 4115 initial values for this registry can be found in Section 9.1. Adding 4116 a new public-key algorithm MUST be done through the SPECIFICATION 4117 REQUIRED method, as described in [RFC8126]. 4119 This document requests IANA register the following new public-key 4120 algorithm: 4122 +====+============================+========================+ 4123 | ID | Algorithm | Reference | 4124 +====+============================+========================+ 4125 | 22 | EdDSA public key algorithm | This doc, Section 14.8 | 4126 +----+----------------------------+------------------------+ 4128 Table 22: New public-Key algorithms registered 4130 [ Note to RFC-Editor: Please remove the table above on publication. ] 4132 10.3.2. Symmetric-Key Algorithms 4134 OpenPGP specifies a number of symmetric-key algorithms. This 4135 specification creates a registry of symmetric-key algorithm 4136 identifiers. The registry includes the algorithm name, its key sizes 4137 and block size, and a reference to the defining specification. The 4138 initial values for this registry can be found in Section 9.3. Adding 4139 a new symmetric-key algorithm MUST be done through the SPECIFICATION 4140 REQUIRED method, as described in [RFC8126]. 4142 10.3.3. Hash Algorithms 4144 OpenPGP specifies a number of hash algorithms. This specification 4145 creates a registry of hash algorithm identifiers. The registry 4146 includes the algorithm name, a text representation of that name, its 4147 block size, an OID hash prefix, and a reference to the defining 4148 specification. The initial values for this registry can be found in 4149 Section 9.5 for the algorithm identifiers and text names, and 4150 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 4151 new hash algorithm MUST be done through the SPECIFICATION REQUIRED 4152 method, as described in [RFC8126]. 4154 This document requests IANA register the following hash algorithms: 4156 +====+===========+===========+ 4157 | ID | Algorithm | Reference | 4158 +====+===========+===========+ 4159 | 12 | SHA3-256 | This doc | 4160 +----+-----------+-----------+ 4161 | 13 | Reserved | | 4162 +----+-----------+-----------+ 4163 | 14 | SHA3-512 | This doc | 4164 +----+-----------+-----------+ 4166 Table 23: New hash 4167 algorithms registered 4169 [Notes to RFC-Editor: Please remove the table above on publication. 4170 It is desirable not to reuse old or reserved algorithms because some 4171 existing tools might print a wrong description. The ID 13 has been 4172 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 4173 counterparts.] 4175 10.3.4. Compression Algorithms 4177 OpenPGP specifies a number of compression algorithms. This 4178 specification creates a registry of compression algorithm 4179 identifiers. The registry includes the algorithm name and a 4180 reference to the defining specification. The initial values for this 4181 registry can be found in Section 9.4. Adding a new compression key 4182 algorithm MUST be done through the SPECIFICATION REQUIRED method, as 4183 described in [RFC8126]. 4185 10.3.5. Elliptic Curve Algorithms 4187 This document requests IANA add a registry of elliptic curves for use 4188 in OpenPGP. 4190 Each curve is identified on the wire by OID, and is acceptable for 4191 use in certain OpenPGP public key algorithms. The table's initial 4192 headings and values can be found in Section 9.2. Adding a new 4193 elliptic curve algorithm to OpenPGP MUST be done through the 4194 SPECIFICATION REQUIRED method, as described in [RFC8126]. If the new 4195 curve can be used for ECDH or EdDSA, it must also be added to the 4196 "Curve-specific wire formats" table described in Section 9.2.1. 4198 10.4. Elliptic Curve Point and Scalar Wire Formats 4200 This document requests IANA add a registry of wire formats that 4201 represent elliptic curve points. The table's initial headings and 4202 values can be found in Section 13.2. Adding a new EC point wire 4203 format MUST be done through the SPECIFICATION REQUIRED method, as 4204 described in [RFC8126]. 4206 This document also requests IANA add a registry of wire formats that 4207 represent scalars for use with elliptic curve cryptography. The 4208 table's initial headings and values can be found in Section 13.3. 4209 Adding a new EC scalar wire format MUST be done through the 4210 SPECIFICATION REQUIRED method, as described in [RFC8126]. 4212 This document also requests that IANA add a registry mapping curve- 4213 specific MPI octet-string encoding conventions for ECDH and EdDSA. 4214 The table's initial headings and values can be found in 4215 Section 9.2.1. Adding a new elliptic curve algorithm to OpenPGP MUST 4216 be done through the SPECIFICATION REQUIRED method, as described in 4217 [RFC8126], and requires adding an entry to this table if the curve is 4218 to be used with either EdDSA or ECDH. 4220 10.5. Changes to existing registries 4222 This document requests IANA add the following wire format columns to 4223 the OpenPGP public-key algorithm registry: 4225 * Public Key Format 4227 * Secret Key Format 4229 * Signature Format 4231 * PKESK Format 4233 And populate them with the values found in Section 9.1. 4235 11. Packet Composition 4237 OpenPGP packets are assembled into sequences in order to create 4238 messages and to transfer keys. Not all possible packet sequences are 4239 meaningful and correct. This section describes the rules for how 4240 packets should be placed into sequences. 4242 11.1. Transferable Public Keys 4244 OpenPGP users may transfer public keys. The essential elements of a 4245 transferable public key are as follows: 4247 * One Public-Key packet 4249 * Zero or more revocation signatures 4251 * One or more User ID packets 4253 * After each User ID packet, zero or more Signature packets 4254 (certifications) 4256 * Zero or more User Attribute packets 4258 * After each User Attribute packet, zero or more Signature packets 4259 (certifications) 4261 * Zero or more Subkey packets 4263 * After each Subkey packet, one Signature packet, plus optionally a 4264 revocation 4266 The Public-Key packet occurs first. Each of the following User ID 4267 packets provides the identity of the owner of this public key. If 4268 there are multiple User ID packets, this corresponds to multiple 4269 means of identifying the same unique individual user; for example, a 4270 user may have more than one email address, and construct a User ID 4271 for each one. 4273 Immediately following each User ID packet, there are zero or more 4274 Signature packets. Each Signature packet is calculated on the 4275 immediately preceding User ID packet and the initial Public-Key 4276 packet. The signature serves to certify the corresponding public key 4277 and User ID. In effect, the signer is testifying to his or her 4278 belief that this public key belongs to the user identified by this 4279 User ID. 4281 Within the same section as the User ID packets, there are zero or 4282 more User Attribute packets. Like the User ID packets, a User 4283 Attribute packet is followed by zero or more Signature packets 4284 calculated on the immediately preceding User Attribute packet and the 4285 initial Public-Key packet. 4287 User Attribute packets and User ID packets may be freely intermixed 4288 in this section, so long as the signatures that follow them are 4289 maintained on the proper User Attribute or User ID packet. 4291 After the User ID packet or Attribute packet, there may be zero or 4292 more Subkey packets. In general, subkeys are provided in cases where 4293 the top-level public key is a signature-only key. However, any V4 or 4294 V5 key may have subkeys, and the subkeys may be encryption-only keys, 4295 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 4296 subkeys. 4298 Each Subkey packet MUST be followed by one Signature packet, which 4299 should be a subkey binding signature issued by the top-level key. 4300 For subkeys that can issue signatures, the subkey binding signature 4301 MUST contain an Embedded Signature subpacket with a primary key 4302 binding signature (0x19) issued by the subkey on the top-level key. 4304 Subkey and Key packets may each be followed by a revocation Signature 4305 packet to indicate that the key is revoked. Revocation signatures 4306 are only accepted if they are issued by the key itself, or by a key 4307 that is authorized to issue revocations via a Revocation Key 4308 subpacket in a self-signature by the top-level key. 4310 Transferable public-key packet sequences may be concatenated to allow 4311 transferring multiple public keys in one operation. 4313 11.2. Transferable Secret Keys 4315 OpenPGP users may transfer secret keys. The format of a transferable 4316 secret key is the same as a transferable public key except that 4317 secret-key and secret-subkey packets are used instead of the public 4318 key and public-subkey packets. Implementations SHOULD include self- 4319 signatures on any User IDs and subkeys, as this allows for a complete 4320 public key to be automatically extracted from the transferable secret 4321 key. Implementations MAY choose to omit the self-signatures, 4322 especially if a transferable public key accompanies the transferable 4323 secret key. 4325 11.3. OpenPGP Messages 4327 An OpenPGP message is a packet or sequence of packets that 4328 corresponds to the following grammatical rules (comma represents 4329 sequential composition, and vertical bar separates alternatives): 4331 OpenPGP Message :- Encrypted Message | Signed Message | Compressed 4332 Message | Literal Message. 4334 Compressed Message :- Compressed Data Packet. 4336 Literal Message :- Literal Data Packet. 4338 ESK :- Public-Key Encrypted Session Key Packet | Symmetric-Key 4339 Encrypted Session Key Packet. 4341 ESK Sequence :- ESK | ESK Sequence, ESK. 4343 Encrypted Data :- Symmetrically Encrypted Data Packet | 4344 Symmetrically Encrypted Integrity Protected Data Packet | AEAD 4345 Encrypted Data Packet 4347 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 4349 One-Pass Signed Message :- One-Pass Signature Packet, OpenPGP 4350 Message, Corresponding Signature Packet. 4352 Signed Message :- Signature Packet, OpenPGP Message | One-Pass 4353 Signed Message. 4355 In addition, decrypting a Symmetrically Encrypted and Integrity 4356 Protected Data packet, an AEAD Encrypted Data packet, or -- for 4357 historic data -- a Symmetrically Encrypted Data packet must yield a 4358 valid OpenPGP Message. Decompressing a Compressed Data packet must 4359 also yield a valid OpenPGP Message. 4361 Note that some subtle combinations that are formally acceptable by 4362 this grammar are nonetheless unacceptable. For example, a v5 SKESK 4363 packet cannot effectively precede a SEIPD packet, since that 4364 combination does not include any information about the choice of 4365 symmetric cipher used for SEIPD (see Section 5.3.1 for more details). 4367 11.4. Detached Signatures 4369 Some OpenPGP applications use so-called "detached signatures". For 4370 example, a program bundle may contain a file, and with it a second 4371 file that is a detached signature of the first file. These detached 4372 signatures are simply a Signature packet stored separately from the 4373 data for which they are a signature. 4375 12. Enhanced Key Formats 4377 12.1. Key Structures 4379 The format of an OpenPGP V3 key is as follows. Entries in square 4380 brackets are optional and ellipses indicate repetition. 4382 RSA Public Key 4383 [Revocation Self Signature] 4384 User ID [Signature ...] 4385 [User ID [Signature ...] ...] 4387 Each signature certifies the RSA public key and the preceding User 4388 ID. The RSA public key can have many User IDs and each User ID can 4389 have many signatures. V3 keys are deprecated. Implementations MUST 4390 NOT generate new V3 keys, but MAY continue to use existing ones. 4392 The format of an OpenPGP V4 key that uses multiple public keys is 4393 similar except that the other keys are added to the end as "subkeys" 4394 of the primary key. 4396 Primary-Key 4397 [Revocation Self Signature] 4398 [Direct Key Signature...] 4399 User ID [Signature ...] 4400 [User ID [Signature ...] ...] 4401 [User Attribute [Signature ...] ...] 4402 [[Subkey [Binding-Signature-Revocation ...] 4403 Subkey-Binding-Signature ...] ...] 4405 A subkey always has at least one subkey binding signature after it 4406 that is issued using the primary key to tie the two keys together. 4407 These binding signatures may be in either V3 or V4 format, but SHOULD 4408 be V4. Subkeys that can issue signatures MUST have a V4 binding 4409 signature due to the REQUIRED embedded primary key binding signature. 4411 In a V4 key, the primary key MUST be a key capable of certification. 4412 The subkeys may be keys of any other type. There may be other 4413 constructions of V4 keys, too. For example, there may be a single- 4414 key RSA key in V4 format, a DSA primary key with an RSA encryption 4415 key, or RSA primary key with an Elgamal subkey, etc. 4417 It is also possible to have a signature-only subkey. This permits a 4418 primary key that collects certifications (key signatures), but is 4419 used only for certifying subkeys that are used for encryption and 4420 signatures. 4422 12.2. Key IDs and Fingerprints 4424 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 4425 the public modulus of the RSA key. 4427 The fingerprint of a V3 key is formed by hashing the body (but not 4428 the two-octet length) of the MPIs that form the key material (public 4429 modulus n, followed by exponent e) with MD5. Note that both V3 keys 4430 and MD5 are deprecated. 4432 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 4433 followed by the two-octet packet length, followed by the entire 4434 Public-Key packet starting with the version field. The Key ID is the 4435 low-order 64 bits of the fingerprint. Here are the fields of the 4436 hash material, with the example of a DSA key: 4438 a.1) 0x99 (1 octet) 4440 a.2) two-octet, big-endian scalar octet count of (b)-(e) 4442 b) version number = 4 (1 octet); 4444 c) timestamp of key creation (4 octets); 4446 d) algorithm (1 octet): 17 = DSA (example); 4448 e) Algorithm-specific fields. 4450 Algorithm-Specific Fields for DSA keys (example): 4452 e.1) MPI of DSA prime p; 4454 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 4456 e.3) MPI of DSA group generator g; 4458 e.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 4460 A V5 fingerprint is the 256-bit SHA2-256 hash of the octet 0x9A, 4461 followed by the four-octet packet length, followed by the entire 4462 Public-Key packet starting with the version field. The Key ID is the 4463 high-order 64 bits of the fingerprint. Here are the fields of the 4464 hash material, with the example of a DSA key: 4466 a.1) 0x9A (1 octet) 4468 a.2) four-octet scalar octet count of (b)-(f) 4470 b) version number = 5 (1 octet); 4472 c) timestamp of key creation (4 octets); 4474 d) algorithm (1 octet): 17 = DSA (example); 4476 e) four-octet scalar octet count for the following key material; 4478 f) algorithm-specific fields. 4480 Algorithm-Specific Fields for DSA keys (example): 4482 f.1) MPI of DSA prime p; 4484 f.2) MPI of DSA group order q (q is a prime divisor of p-1); 4486 f.3) MPI of DSA group generator g; 4488 f.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 4490 Note that it is possible for there to be collisions of Key IDs -- two 4491 different keys with the same Key ID. Note that there is a much 4492 smaller, but still non-zero, probability that two different keys have 4493 the same fingerprint. 4495 Also note that if V3, V4, and V5 format keys share the same RSA key 4496 material, they will have different Key IDs as well as different 4497 fingerprints. 4499 Finally, the Key ID and fingerprint of a subkey are calculated in the 4500 same way as for a primary key, including the 0x99 (V3 and V4 key) or 4501 0x9A (V5 key) as the first octet (even though this is not a valid 4502 packet ID for a public subkey). 4504 13. Elliptic Curve Cryptography 4506 This section describes algorithms and parameters used with Elliptic 4507 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 4508 found in [KOBLITZ]. 4510 13.1. Supported ECC Curves 4512 This document references three named prime field curves defined in 4513 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521". These 4514 three [FIPS186] curves can be used with ECDSA and ECDH public key 4515 algorithms. Additionally, curve "Curve25519" and "Curve448" are 4516 referenced for use with Ed25519 and Ed448 (EdDSA signing, see 4517 [RFC8032]); and X25519 and X448 (ECDH encryption, see [RFC7748]). 4519 The named curves are referenced as a sequence of octets in this 4520 document, called throughout, curve OID. Section 9.2 describes in 4521 detail how this sequence of octets is formed. 4523 13.2. EC Point Wire Formats 4525 A point on an elliptic curve will always be represented on the wire 4526 as an MPI. Each curve uses a specific point format for the data 4527 within the MPI itself. Each format uses a designated prefix octet to 4528 ensure that the high octet has at least one bit set to make the MPI a 4529 constant size. 4531 +=================+================+================+ 4532 | Name | Wire Format | Reference | 4533 +=================+================+================+ 4534 | SEC1 | 0x04 || x || y | Section 13.2.1 | 4535 +-----------------+----------------+----------------+ 4536 | Prefixed native | 0x40 || native | Section 13.2.2 | 4537 +-----------------+----------------+----------------+ 4539 Table 24: Elliptic Curve Point Wire Formats 4541 13.2.1. SEC1 EC Point Wire Format 4543 For a SEC1-encoded (uncompressed) point the content of the MPI is: 4545 B = 04 || x || y 4547 where x and y are coordinates of the point P = (x, y), and each is 4548 encoded in the big-endian format and zero-padded to the adjusted 4549 underlying field size. The adjusted underlying field size is the 4550 underlying field size rounded up to the nearest 8-bit boundary, as 4551 noted in the "fsize" column in Section 9.2. This encoding is 4552 compatible with the definition given in [SEC1]. 4554 13.2.2. Prefixed Native EC Point Wire Format 4556 For a custom compressed point the content of the MPI is: 4558 B = 40 || p 4560 where p is the public key of the point encoded using the rules 4561 defined for the specified curve. This format is used for ECDH keys 4562 based on curves expressed in Montgomery form, and for points when 4563 using EdDSA. 4565 13.2.3. Notes on EC Point Wire Formats 4567 Given the above definitions, the exact size of the MPI payload for an 4568 encoded point is 515 bits for "Curve P-256", 771 for "Curve P-384", 4569 1059 for "Curve P-521", 263 for both "Curve25519" and "Ed25519", 463 4570 for "Ed448", and 455 for "X448". For example, the length of a EdDSA 4571 public key for the curve Ed25519 is 263 bits: 7 bits to represent the 4572 0x40 prefix octet and 32 octets for the native value of the public 4573 key. 4575 Even though the zero point, also called the point at infinity, may 4576 occur as a result of arithmetic operations on points of an elliptic 4577 curve, it SHALL NOT appear in data structures defined in this 4578 document. 4580 Each particular curve uses a designated wire format for the point 4581 found in its public key or ECDH data structure. An implementation 4582 MUST NOT use a different wire format for a point than the wire format 4583 associated with the curve. 4585 13.3. EC Scalar Wire Formats 4587 Some non-curve values in elliptic curve cryptography (e.g. secret 4588 keys and signature components) are not points on a curve, but are 4589 also encoded on the wire in OpenPGP as an MPI. 4591 Because of different patterns of deployment, some curves treat these 4592 values as opaque bit strings with the high bit set, while others are 4593 treated as actual integers, encoded in the standard OpenPGP big- 4594 endian form. The choice of encoding is specific to the public key 4595 algorithm in use. 4597 +==========+=====================================+===========+ 4598 | Type | Description | Reference | 4599 +==========+=====================================+===========+ 4600 | integer | An integer, big-endian encoded as a | Section | 4601 | | standard OpenPGP MPI | 3.2 | 4602 +----------+-------------------------------------+-----------+ 4603 | octet | An octet string of fixed length, | Section | 4604 | string | that may be shorter on the wire due | 13.3.1 | 4605 | | to leading zeros being stripped by | | 4606 | | the MPI encoding, and may need to | | 4607 | | be zero-padded before usage | | 4608 +----------+-------------------------------------+-----------+ 4609 | prefixed | An octet string of fixed length N, | Section | 4610 | N octets | prefixed with octet 0x40 to ensure | 13.3.2 | 4611 | | no leading zero octet | | 4612 +----------+-------------------------------------+-----------+ 4614 Table 25: Elliptic Curve Scalar Encodings 4616 13.3.1. EC Octet String Wire Format 4618 Some opaque strings of octets are represented on the wire as an MPI 4619 by simply stripping the leading zeros and counting the remaining 4620 bits. These strings are of known, fixed length. They are 4621 represented in this document as "MPI(N octets of X)" where "N" is the 4622 expected length in octets of the octet string. 4624 For example, a five-octet opaque string ("MPI(5 octets of X)") where 4625 "X" has the value "00 02 ee 19 00" would be represented on the wire 4626 as an MPI like so: "00 1a 02 ee 19 00". 4628 To encode "X" to the wire format, we set the MPI's two-octet bit 4629 counter to the value of the highest set bit (bit 26, or 0x001a), and 4630 do not transfer the leading all-zero octet to the wire. 4632 To reverse the process, an implementation that knows this value has 4633 an expected length of 5 octets can take the following steps: 4635 * ensure that the MPI's two-octet bitcount is less than or equal to 4636 40 (5 octets of 8 bits) 4638 * allocate 5 octets, setting all to zero initially 4640 * copy the MPI data octets (without the two count octets) into the 4641 lower octets of the allocated space 4643 13.3.2. Elliptic Curve Prefixed Octet String Wire Format 4645 Another way to ensure that a fixed-length bytestring is encoded 4646 simply to the wire while remaining in MPI format is to prefix the 4647 bytestring with a dedicated non-zero octet. This specification uses 4648 0x40 as the prefix octet. This is represented in this standard as 4649 "MPI(prefixed N octets of X)", where "N" is the known bytestring 4650 length. 4652 For example, a five-octet opaque string using "MPI(prefixed 5 octets 4653 of X)" where "X" has the value "00 02 ee 19 00" would be written to 4654 the wire form as: "00 2f 40 00 02 ee 19 00". 4656 To encode the string, we prefix it with the octet 0x40 (whose 7th bit 4657 is set), then set the MPI's two-octet bit counter to 47 (0x002f, 7 4658 bits for the prefix octet and 40 bits for the string). 4660 To decode the string from the wire, an implementation that knows that 4661 the variable is formed in this way can: 4663 * ensure that the first three octets of the MPI (the two bit-count 4664 octets plus the prefix octet) are "00 2f 40", and 4666 * use the remainder of the MPI directly off the wire. 4668 Note that this is a similar approach to that used in the EC point 4669 encodings found in Section 13.2.2. 4671 13.4. Key Derivation Function 4673 A key derivation function (KDF) is necessary to implement EC 4674 encryption. The Concatenation Key Derivation Function (Approved 4675 Alternative 1) [SP800-56A] with the KDF hash function that is 4676 SHA2-256 [FIPS180] or stronger is REQUIRED. 4678 For convenience, the synopsis of the encoding method is given below 4679 with significant simplifications attributable to the restricted 4680 choice of hash functions in this document. However, [SP800-56A] is 4681 the normative source of the definition. 4683 // Implements KDF( X, oBits, Param ); 4684 // Input: point X = (x,y) 4685 // oBits - the desired size of output 4686 // hBits - the size of output of hash function Hash 4687 // Param - octets representing the parameters 4688 // Assumes that oBits <= hBits 4689 // Convert the point X to the octet string: 4690 // ZB' = 04 || x || y 4691 // and extract the x portion from ZB' 4692 ZB = x; 4693 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 4694 return oBits leftmost bits of MB. 4696 Note that ZB in the KDF description above is the compact 4697 representation of X as defined in Section 4.2 of [RFC6090]. 4699 13.5. EC DH Algorithm (ECDH) 4701 The method is a combination of an ECC Diffie-Hellman method to 4702 establish a shared secret, a key derivation method to process the 4703 shared secret into a derived key, and a key wrapping method that uses 4704 the derived key to protect a session key used to encrypt a message. 4706 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 4707 be implemented with the following restrictions: the ECC CDH primitive 4708 employed by this method is modified to always assume the cofactor is 4709 1, the KDF specified in Section 13.4 is used, and the KDF parameters 4710 specified below are used. 4712 The KDF parameters are encoded as a concatenation of the following 5 4713 variable-length and fixed-length fields, which are compatible with 4714 the definition of the OtherInfo bitstring [SP800-56A]: 4716 * A variable-length field containing a curve OID, which is formatted 4717 as follows: 4719 - A one-octet size of the following field, 4721 - The octets representing a curve OID defined in Section 9.2; 4723 * A one-octet public key algorithm ID defined in Section 9.1; 4725 * A variable-length field containing KDF parameters, which are 4726 identical to the corresponding field in the ECDH public key, and 4727 are formatted as follows: 4729 - A one-octet size of the following fields; values 0 and 0xFF are 4730 reserved for future extensions, 4732 - A one-octet value 0x01, reserved for future extensions, 4734 - A one-octet hash function ID used with the KDF, 4736 - A one-octet algorithm ID for the symmetric algorithm used to 4737 wrap the symmetric key for message encryption; see Section 13.5 4738 for details; 4740 * 20 octets representing the UTF-8 encoding of the string "Anonymous 4741 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 4742 73 20 53 65 6E 64 65 72 20 20 20 20; 4744 * 20 octets representing a recipient encryption subkey or a primary 4745 key fingerprint identifying the key material that is needed for 4746 decryption (for version 5 keys the 20 leftmost octets of the 4747 fingerprint are used). 4749 The size of the KDF parameters sequence, defined above, is either 54 4750 for the NIST curve P-256, 51 for the curves P-384 and P-521, 56 for 4751 Curve25519, or 49 for X448. 4753 The key wrapping method is described in [RFC3394]. The KDF produces 4754 a symmetric key that is used as a key-encryption key (KEK) as 4755 specified in [RFC3394]. Refer to Section 15 for the details 4756 regarding the choice of the KEK algorithm, which SHOULD be one of 4757 three AES algorithms. Key wrapping and unwrapping is performed with 4758 the default initial value of [RFC3394]. 4760 The input to the key wrapping method is the value "m" derived from 4761 the session key, as described in Section 5.1, "Public-Key Encrypted 4762 Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step 4763 is omitted. The result is padded using the method described in 4764 [PKCS5] to an 8-octet granularity. For example, the following 4765 AES-256 session key, in which 32 octets are denoted from k0 to k31, 4766 is composed to form the following 40 octet sequence: 4768 09 k0 k1 ... k31 s0 s1 05 05 05 05 05 4770 The octets s0 and s1 above denote the checksum. This encoding allows 4771 the sender to obfuscate the size of the symmetric encryption key used 4772 to encrypt the data. For example, assuming that an AES algorithm is 4773 used for the session key, the sender MAY use 21, 13, and 5 octets of 4774 padding for AES-128, AES-192, and AES-256, respectively, to provide 4775 the same number of octets, 40 total, as an input to the key wrapping 4776 method. 4778 The output of the method consists of two fields. The first field is 4779 the MPI containing the ephemeral key used to establish the shared 4780 secret. The second field is composed of the following two subfields: 4782 * One octet encoding the size in octets of the result of the key 4783 wrapping method; the value 255 is reserved for future extensions; 4785 * Up to 254 octets representing the result of the key wrapping 4786 method, applied to the 8-octet padded session key, as described 4787 above. 4789 Note that for session key sizes 128, 192, and 256 bits, the size of 4790 the result of the key wrapping method is, respectively, 32, 40, and 4791 48 octets, unless size obfuscation is used. 4793 For convenience, the synopsis of the encoding method is given below; 4794 however, this section, [SP800-56A], and [RFC3394] are the normative 4795 sources of the definition. 4797 * Obtain the authenticated recipient public key R 4799 * Generate an ephemeral key pair {v, V=vG} 4801 * Compute the shared point S = vR; 4803 * m = symm_alg_ID || session key || checksum || pkcs5_padding; 4805 * curve_OID_len = (octet)len(curve_OID); 4807 * Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 4808 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 4809 Sender " || recipient_fingerprint; 4811 * Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 4813 * Compute Z = KDF( S, Z_len, Param ); 4815 * Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4817 * VB = convert point V to the octet string 4819 * Output (MPI(VB) || len(C) || C). 4821 The decryption is the inverse of the method given. Note that the 4822 recipient obtains the shared secret by calculating 4824 S = rV = rvG, where (r,R) is the recipient's key pair. 4826 Consistent with Section 5.16 and Section 5.14, AEAD encryption or a 4827 Modification Detection Code (MDC) MUST be used anytime the symmetric 4828 key is protected by ECDH. 4830 14. Notes on Algorithms 4832 14.1. PKCS#1 Encoding in OpenPGP 4834 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4835 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4836 has changed in the past. To avoid potential confusion and 4837 interoperability problems, we are including local copies in this 4838 document, adapted from those in PKCS#1 v2.1 [RFC3447]. [RFC3447] 4839 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4840 Nonetheless, we believe that there is value in having a self- 4841 contained document that avoids problems in the future with needed 4842 changes in the conventions. 4844 14.1.1. EME-PKCS1-v1_5-ENCODE 4846 Input: 4848 k = the length in octets of the key modulus. 4850 M = message to be encoded, an octet string of length mLen, where 4851 mLen <= k - 11. 4853 Output: 4855 EM = encoded message, an octet string of length k. 4857 Error: "message too long". 4859 1. Length checking: If mLen > k - 11, output "message too long" and 4860 stop. 4862 2. Generate an octet string PS of length k - mLen - 3 consisting of 4863 pseudo-randomly generated nonzero octets. The length of PS will 4864 be at least eight octets. 4866 3. Concatenate PS, the message M, and other padding to form an 4867 encoded message EM of length k octets as 4869 EM = 0x00 || 0x02 || PS || 0x00 || M. 4871 4. Output EM. 4873 14.1.2. EME-PKCS1-v1_5-DECODE 4875 Input: 4877 EM = encoded message, an octet string 4879 Output: 4881 M = message, an octet string. 4883 Error: "decryption error". 4885 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4886 into an octet string PS consisting of nonzero octets and a message M 4887 as follows 4889 EM = 0x00 || 0x02 || PS || 0x00 || M. 4891 If the first octet of EM does not have hexadecimal value 0x00, if the 4892 second octet of EM does not have hexadecimal value 0x02, if there is 4893 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4894 length of PS is less than 8 octets, output "decryption error" and 4895 stop. See also the security note in Section 15 regarding differences 4896 in reporting between a decryption error and a padding error. 4898 14.1.3. EMSA-PKCS1-v1_5 4900 This encoding method is deterministic and only has an encoding 4901 operation. 4903 Option: 4905 Hash - a hash function in which hLen denotes the length in octets of 4906 the hash function output. 4908 Input: 4910 M = message to be encoded. 4912 emLen = intended length in octets of the encoded message, at least 4913 tLen + 11, where tLen is the octet length of the DER encoding T of 4914 a certain value computed during the encoding operation. 4916 Output: 4918 EM = encoded message, an octet string of length emLen. 4920 Errors: "message too long"; "intended encoded message length too 4921 short". 4923 Steps: 4925 1. Apply the hash function to the message M to produce a hash value 4926 H: 4928 H = Hash(M). 4930 If the hash function outputs "message too long," output "message 4931 too long" and stop. 4933 2. Using the list in Section 5.2.2, produce an ASN.1 DER value for 4934 the hash function used. Let T be the full hash prefix from the 4935 list, and let tLen be the length in octets of T. 4937 3. If emLen < tLen + 11, output "intended encoded message length too 4938 short" and stop. 4940 4. Generate an octet string PS consisting of emLen - tLen - 3 octets 4941 with hexadecimal value 0xFF. The length of PS will be at least 8 4942 octets. 4944 5. Concatenate PS, the hash prefix T, and other padding to form the 4945 encoded message EM as 4947 EM = 0x00 || 0x01 || PS || 0x00 || T. 4949 6. Output EM. 4951 14.2. Symmetric Algorithm Preferences 4953 The symmetric algorithm preference is an ordered list of algorithms 4954 that the keyholder accepts. Since it is found on a self-signature, 4955 it is possible that a keyholder may have multiple, different 4956 preferences. For example, Alice may have AES-128 only specified for 4957 "alice@work.com" but Camellia-256, Twofish, and AES-128 specified for 4958 "alice@home.org". Note that it is also possible for preferences to 4959 be in a subkey's binding signature. 4961 Since TripleDES is the MUST-implement algorithm, if it is not 4962 explicitly in the list, it is tacitly at the end. However, it is 4963 good form to place it there explicitly. Note also that if an 4964 implementation does not implement the preference, then it is 4965 implicitly a TripleDES-only implementation. 4967 An implementation MUST NOT use a symmetric algorithm that is not in 4968 the recipient's preference list. When encrypting to more than one 4969 recipient, the implementation finds a suitable algorithm by taking 4970 the intersection of the preferences of the recipients. Note that the 4971 MUST-implement algorithm, TripleDES, ensures that the intersection is 4972 not null. The implementation may use any mechanism to pick an 4973 algorithm in the intersection. 4975 If an implementation can decrypt a message that a keyholder doesn't 4976 have in their preferences, the implementation SHOULD decrypt the 4977 message anyway, but MUST warn the keyholder that the protocol has 4978 been violated. For example, suppose that Alice, above, has software 4979 that implements all algorithms in this specification. Nonetheless, 4980 she prefers subsets for work or home. If she is sent a message 4981 encrypted with IDEA, which is not in her preferences, the software 4982 warns her that someone sent her an IDEA-encrypted message, but it 4983 would ideally decrypt it anyway. 4985 14.3. Other Algorithm Preferences 4987 Other algorithm preferences work similarly to the symmetric algorithm 4988 preference, in that they specify which algorithms the keyholder 4989 accepts. There are two interesting cases that other comments need to 4990 be made about, though, the compression preferences and the hash 4991 preferences. 4993 14.3.1. Compression Preferences 4995 Compression has been an integral part of PGP since its first days. 4996 OpenPGP and all previous versions of PGP have offered compression. 4997 In this specification, the default is for messages to be compressed, 4998 although an implementation is not required to do so. Consequently, 4999 the compression preference gives a way for a keyholder to request 5000 that messages not be compressed, presumably because they are using a 5001 minimal implementation that does not include compression. 5002 Additionally, this gives a keyholder a way to state that it can 5003 support alternate algorithms. 5005 Like the algorithm preferences, an implementation MUST NOT use an 5006 algorithm that is not in the preference vector. If the preferences 5007 are not present, then they are assumed to be [ZIP(1), 5008 Uncompressed(0)]. 5010 Additionally, an implementation MUST implement this preference to the 5011 degree of recognizing when to send an uncompressed message. A robust 5012 implementation would satisfy this requirement by looking at the 5013 recipient's preference and acting accordingly. A minimal 5014 implementation can satisfy this requirement by never generating a 5015 compressed message, since all implementations can handle messages 5016 that have not been compressed. 5018 14.3.2. Hash Algorithm Preferences 5020 Typically, the choice of a hash algorithm is something the signer 5021 does, rather than the verifier, because a signer rarely knows who is 5022 going to be verifying the signature. This preference, though, allows 5023 a protocol based upon digital signatures ease in negotiation. 5025 Thus, if Alice is authenticating herself to Bob with a signature, it 5026 makes sense for her to use a hash algorithm that Bob's software uses. 5027 This preference allows Bob to state in his key which algorithms Alice 5028 may use. 5030 Since SHA1 is the MUST-implement hash algorithm, if it is not 5031 explicitly in the list, it is tacitly at the end. However, it is 5032 good form to place it there explicitly. 5034 14.4. Plaintext 5036 Algorithm 0, "plaintext", may only be used to denote secret keys that 5037 are stored in the clear. Implementations MUST NOT use plaintext in 5038 Symmetrically Encrypted Data packets; they must use Literal Data 5039 packets to encode unencrypted or literal data. 5041 14.5. RSA 5043 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 5044 keys. These types are deprecated. The "key flags" subpacket in a 5045 signature is a much better way to express the same idea, and 5046 generalizes it to all algorithms. An implementation SHOULD NOT 5047 create such a key, but MAY interpret it. 5049 An implementation SHOULD NOT implement RSA keys of size less than 5050 1024 bits. 5052 14.6. DSA 5054 An implementation SHOULD NOT implement DSA keys of size less than 5055 1024 bits. It MUST NOT implement a DSA key with a q size of less 5056 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 5057 q size MUST be a multiple of 8 bits. The Digital Signature Standard 5058 (DSS) [FIPS186] specifies that DSA be used in one of the following 5059 ways: 5061 * 1024-bit key, 160-bit q, SHA-1, SHA2-224, SHA2-256, SHA2-384, or 5062 SHA2-512 hash 5064 * 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 5065 hash 5067 * 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 5069 * 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 5071 The above key and q size pairs were chosen to best balance the 5072 strength of the key with the strength of the hash. Implementations 5073 SHOULD use one of the above key and q size pairs when generating DSA 5074 keys. If DSS compliance is desired, one of the specified SHA hashes 5075 must be used as well. [FIPS186] is the ultimate authority on DSS, 5076 and should be consulted for all questions of DSS compliance. 5078 Note that earlier versions of this standard only allowed a 160-bit q 5079 with no truncation allowed, so earlier implementations may not be 5080 able to handle signatures with a different q size or a truncated 5081 hash. 5083 14.7. Elgamal 5085 An implementation SHOULD NOT implement Elgamal keys of size less than 5086 1024 bits. 5088 14.8. EdDSA 5090 Although the EdDSA algorithm allows arbitrary data as input, its use 5091 with OpenPGP requires that a digest of the message is used as input 5092 (pre-hashed). See section Section 5.2.4, "Computing Signatures" for 5093 details. Truncation of the resulting digest is never applied; the 5094 resulting digest value is used verbatim as input to the EdDSA 5095 algorithm. 5097 For clarity: while [RFC8032] describes different variants of EdDSA, 5098 OpenPGP uses the "pure" variant (PureEdDSA). The hashing that 5099 happens with OpenPGP is done as part of the standard OpenPGP 5100 signature process, and that hash itself is fed as the input message 5101 to the PureEdDSA algorithm. 5103 As specified in [RFC8032], Ed448 also expects a "context string". In 5104 OpenPGP, Ed448 is used with the empty string as a context string. 5106 14.9. Reserved Algorithm Numbers 5108 A number of algorithm IDs have been reserved for algorithms that 5109 would be useful to use in an OpenPGP implementation, yet there are 5110 issues that prevent an implementer from actually implementing the 5111 algorithm. These are marked in Section 9.1 as "reserved for". 5113 The reserved public-key algorithm X9.42 (21) does not have the 5114 necessary parameters, parameter order, or semantics defined. The 5115 same is currently true for reserved public-key algorithms AEDH (23) 5116 and AEDSA (24). 5118 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 5119 with a public-key identifier of 20. These are no longer permitted. 5120 An implementation MUST NOT generate such keys. An implementation 5121 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 5123 14.10. OpenPGP CFB Mode 5125 OpenPGP does symmetric encryption using a variant of Cipher Feedback 5126 mode (CFB mode). This section describes the procedure it uses in 5127 detail. This mode is what is used for Symmetrically Encrypted Data 5128 Packets; the mechanism used for encrypting secret-key material is 5129 similar, and is described in the sections above. 5131 In the description below, the value BS is the block size in octets of 5132 the cipher. Most ciphers have a block size of 8 octets. The AES and 5133 Twofish have a block size of 16 octets. Also note that the 5134 description below assumes that the IV and CFB arrays start with an 5135 index of 1 (unlike the C language, which assumes arrays start with a 5136 zero index). 5138 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 5139 prefixes the plaintext with BS+2 octets of random data, such that 5140 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 5141 resynchronization after encrypting those BS+2 octets. 5143 Thus, for an algorithm that has a block size of 8 octets (64 bits), 5144 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 5145 octets 9 and 10. For an algorithm with a block size of 16 octets 5146 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 5147 octets 15 and 16. Those extra two octets are an easy check for a 5148 correct key. 5150 Step by step, here is the procedure: 5152 1. The feedback register (FR) is set to the IV, which is all zeros. 5154 2. FR is encrypted to produce FRE (FR Encrypted). This is the 5155 encryption of an all-zero value. 5157 3. FRE is xored with the first BS octets of random data prefixed to 5158 the plaintext to produce C[1] through C[BS], the first BS octets 5159 of ciphertext. 5161 4. FR is loaded with C[1] through C[BS]. 5163 5. FR is encrypted to produce FRE, the encryption of the first BS 5164 octets of ciphertext. 5166 6. The left two octets of FRE get xored with the next two octets of 5167 data that were prefixed to the plaintext. This produces C[BS+1] 5168 and C[BS+2], the next two octets of ciphertext. 5170 7. (The resynchronization step) FR is loaded with C[3] through 5171 C[BS+2]. 5173 8. FR is encrypted to produce FRE. 5175 9. FRE is xored with the first BS octets of the given plaintext, 5176 now that we have finished encrypting the BS+2 octets of prefixed 5177 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 5178 octets of ciphertext. 5180 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 5181 for an 8-octet block). 5183 11. FR is encrypted to produce FRE. 5185 12. FRE is xored with the next BS octets of plaintext, to produce 5186 the next BS octets of ciphertext. These are loaded into FR, and 5187 the process is repeated until the plaintext is used up. 5189 14.11. Private or Experimental Parameters 5191 S2K specifiers, Signature subpacket types, User Attribute types, 5192 image format types, and algorithms described in Section 9 all reserve 5193 the range 100 to 110 for private and experimental use. Packet types 5194 reserve the range 60 to 63 for private and experimental use. These 5195 are intentionally managed with the PRIVATE USE method, as described 5196 in [RFC8126]. 5198 However, implementations need to be careful with these and promote 5199 them to full IANA-managed parameters when they grow beyond the 5200 original, limited system. 5202 14.12. Extension of the MDC System 5204 As described in the non-normative explanation in Section 5.14, the 5205 MDC system is uniquely unparameterized in OpenPGP. This was an 5206 intentional decision to avoid cross-grade attacks. If the MDC system 5207 is extended to a stronger hash function, care must be taken to avoid 5208 downgrade and cross-grade attacks. 5210 One simple way to do this is to create new packets for a new MDC. 5211 For example, instead of the MDC system using packets 18 and 19, a new 5212 MDC could use 20 and 21. This has obvious drawbacks (it uses two 5213 packet numbers for each new hash function in a space that is limited 5214 to a maximum of 60). 5216 Another simple way to extend the MDC system is to create new versions 5217 of packet 18, and reflect this in packet 19. For example, suppose 5218 that V2 of packet 18 implicitly used SHA-256. This would require 5219 packet 19 to have a length of 32 octets. The change in the version 5220 in packet 18 and the size of packet 19 prevent a downgrade attack. 5222 There are two drawbacks to this latter approach. The first is that 5223 using the version number of a packet to carry algorithm information 5224 is not tidy from a protocol-design standpoint. It is possible that 5225 there might be several versions of the MDC system in common use, but 5226 this untidiness would reflect untidiness in cryptographic consensus 5227 about hash function security. The second is that different versions 5228 of packet 19 would have to have unique sizes. If there were two 5229 versions each with 256-bit hashes, they could not both have 32-octet 5230 packet 19s without admitting the chance of a cross-grade attack. 5232 Yet another, complex approach to extend the MDC system would be a 5233 hybrid of the two above -- create a new pair of MDC packets that are 5234 fully parameterized, and yet protected from downgrade and cross- 5235 grade. 5237 Any change to the MDC system MUST be done through the IETF CONSENSUS 5238 method, as described in [RFC8126]. 5240 14.13. Meta-Considerations for Expansion 5242 If OpenPGP is extended in a way that is not backwards-compatible, 5243 meaning that old implementations will not gracefully handle their 5244 absence of a new feature, the extension proposal can be declared in 5245 the key holder's self-signature as part of the Features signature 5246 subpacket. 5248 We cannot state definitively what extensions will not be upwards- 5249 compatible, but typically new algorithms are upwards-compatible, 5250 whereas new packets are not. 5252 If an extension proposal does not update the Features system, it 5253 SHOULD include an explanation of why this is unnecessary. If the 5254 proposal contains neither an extension to the Features system nor an 5255 explanation of why such an extension is unnecessary, the proposal 5256 SHOULD be rejected. 5258 15. Security Considerations 5260 * As with any technology involving cryptography, you should check 5261 the current literature to determine if any algorithms used here 5262 have been found to be vulnerable to attack. 5264 * This specification uses Public-Key Cryptography technologies. It 5265 is assumed that the private key portion of a public-private key 5266 pair is controlled and secured by the proper party or parties. 5268 * Certain operations in this specification involve the use of random 5269 numbers. An appropriate entropy source should be used to generate 5270 these numbers (see [RFC4086]). 5272 * The MD5 hash algorithm has been found to have weaknesses, with 5273 collisions found in a number of cases. MD5 is deprecated for use 5274 in OpenPGP. Implementations MUST NOT generate new signatures 5275 using MD5 as a hash function. They MAY continue to consider old 5276 signatures that used MD5 as valid. 5278 * SHA2-224 and SHA2-384 require the same work as SHA2-256 and 5279 SHA2-512, respectively. In general, there are few reasons to use 5280 them outside of DSS compatibility. You need a situation where one 5281 needs more security than smaller hashes, but does not want to have 5282 the full 256-bit or 512-bit data length. 5284 * Many security protocol designers think that it is a bad idea to 5285 use a single key for both privacy (encryption) and integrity 5286 (signatures). In fact, this was one of the motivating forces 5287 behind the V4 key format with separate signature and encryption 5288 keys. If you as an implementer promote dual-use keys, you should 5289 at least be aware of this controversy. 5291 * The DSA algorithm will work with any hash, but is sensitive to the 5292 quality of the hash algorithm. Verifiers should be aware that 5293 even if the signer used a strong hash, an attacker could have 5294 modified the signature to use a weak one. Only signatures using 5295 acceptably strong hash algorithms should be accepted as valid. 5297 * As OpenPGP combines many different asymmetric, symmetric, and hash 5298 algorithms, each with different measures of strength, care should 5299 be taken that the weakest element of an OpenPGP message is still 5300 sufficiently strong for the purpose at hand. While consensus 5301 about the strength of a given algorithm may evolve, NIST Special 5302 Publication 800-57 [SP800-57] recommends the following list of 5303 equivalent strengths: 5305 +=====================+===========+====================+ 5306 | Asymmetric key size | Hash size | Symmetric key size | 5307 +=====================+===========+====================+ 5308 | 1024 | 160 | 80 | 5309 +---------------------+-----------+--------------------+ 5310 | 2048 | 224 | 112 | 5311 +---------------------+-----------+--------------------+ 5312 | 3072 | 256 | 128 | 5313 +---------------------+-----------+--------------------+ 5314 | 7680 | 384 | 192 | 5315 +---------------------+-----------+--------------------+ 5316 | 15360 | 512 | 256 | 5317 +---------------------+-----------+--------------------+ 5319 Table 26: Key length equivalences 5321 * There is a somewhat-related potential security problem in 5322 signatures. If an attacker can find a message that hashes to the 5323 same hash with a different algorithm, a bogus signature structure 5324 can be constructed that evaluates correctly. 5326 For example, suppose Alice DSA signs message M using hash 5327 algorithm H. Suppose that Mallet finds a message M' that has the 5328 same hash value as M with H'. Mallet can then construct a 5329 signature block that verifies as Alice's signature of M' with H'. 5330 However, this would also constitute a weakness in either H or H' 5331 or both. Should this ever occur, a revision will have to be made 5332 to this document to revise the allowed hash algorithms. 5334 * If you are building an authentication system, the recipient may 5335 specify a preferred signing algorithm. However, the signer would 5336 be foolish to use a weak algorithm simply because the recipient 5337 requests it. 5339 * Some of the encryption algorithms mentioned in this document have 5340 been analyzed less than others. For example, although CAST5 is 5341 presently considered strong, it has been analyzed less than 5342 TripleDES. Other algorithms may have other controversies 5343 surrounding them. 5345 * In late summer 2002, Jallad, Katz, and Schneier published an 5346 interesting attack on the OpenPGP protocol and some of its 5347 implementations [JKS02]. In this attack, the attacker modifies a 5348 message and sends it to a user who then returns the erroneously 5349 decrypted message to the attacker. The attacker is thus using the 5350 user as a random oracle, and can often decrypt the message. 5352 Compressing data can ameliorate this attack. The incorrectly 5353 decrypted data nearly always decompresses in ways that defeat the 5354 attack. However, this is not a rigorous fix, and leaves open some 5355 small vulnerabilities. For example, if an implementation does not 5356 compress a message before encryption (perhaps because it knows it 5357 was already compressed), then that message is vulnerable. Because 5358 of this happenstance -- that modification attacks can be thwarted 5359 by decompression errors -- an implementation SHOULD treat a 5360 decompression error as a security problem, not merely a data 5361 problem. 5363 This attack can be defeated by the use of Modification Detection, 5364 provided that the implementation does not let the user naively 5365 return the data to the attacker. An implementation MUST treat an 5366 MDC failure as a security problem, not merely a data problem. 5368 In either case, the implementation MAY allow the user access to 5369 the erroneous data, but MUST warn the user as to potential 5370 security problems should that data be returned to the sender. 5372 While this attack is somewhat obscure, requiring a special set of 5373 circumstances to create it, it is nonetheless quite serious as it 5374 permits someone to trick a user to decrypt a message. 5375 Consequently, it is important that: 5377 1. Implementers treat MDC errors and decompression failures as 5378 security problems. 5380 2. Implementers implement Modification Detection with all due 5381 speed and encourage its spread. 5383 3. Users migrate to implementations that support Modification 5384 Detection with all due speed. 5386 * PKCS#1 has been found to be vulnerable to attacks in which a 5387 system that reports errors in padding differently from errors in 5388 decryption becomes a random oracle that can leak the private key 5389 in mere millions of queries. Implementations must be aware of 5390 this attack and prevent it from happening. The simplest solution 5391 is to report a single error code for all variants of decryption 5392 errors so as not to leak information to an attacker. 5394 * Some technologies mentioned here may be subject to government 5395 control in some countries. 5397 * In winter 2005, Serge Mister and Robert Zuccherato from Entrust 5398 released a paper describing a way that the "quick check" in 5399 OpenPGP CFB mode can be used with a random oracle to decrypt two 5400 octets of every cipher block [MZ05]. They recommend as prevention 5401 not using the quick check at all. 5403 Many implementers have taken this advice to heart for any data 5404 that is symmetrically encrypted and for which the session key is 5405 public-key encrypted. In this case, the quick check is not needed 5406 as the public-key encryption of the session key should guarantee 5407 that it is the right session key. In other cases, the 5408 implementation should use the quick check with care. 5410 On the one hand, there is a danger to using it if there is a 5411 random oracle that can leak information to an attacker. In 5412 plainer language, there is a danger to using the quick check if 5413 timing information about the check can be exposed to an attacker, 5414 particularly via an automated service that allows rapidly repeated 5415 queries. 5417 On the other hand, it is inconvenient to the user to be informed 5418 that they typed in the wrong passphrase only after a petabyte of 5419 data is decrypted. There are many cases in cryptographic 5420 engineering where the implementer must use care and wisdom, and 5421 this is one. 5423 * Refer to [FIPS186], B.4.1, for the method to generate a uniformly 5424 distributed ECC private key. 5426 * The curves proposed in this document correspond to the symmetric 5427 key sizes 128 bits, 192 bits, and 256 bits, as described in the 5428 table below. This allows a compliant application to offer 5429 balanced public key security, which is compatible with the 5430 symmetric key strength for each AES algorithm defined here. 5432 The following table defines the hash and the symmetric encryption 5433 algorithm that SHOULD be used with a given curve for ECDSA or 5434 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 5435 be used for a given ECC curve. However, note that the increase in 5436 the strength of the hash algorithm or the symmetric key algorithm 5437 may not increase the overall security offered by the given ECC 5438 key. 5440 +============+=====+==============+=====================+===========+ 5441 | Curve name | ECC | RSA | Hash size strength, | Symmetric | 5442 | | | strength | informative | key size | 5443 +============+=====+==============+=====================+===========+ 5444 | NIST P-256 | 256 | 3072 | 256 | 128 | 5445 +------------+-----+--------------+---------------------+-----------+ 5446 | NIST P-384 | 384 | 7680 | 384 | 192 | 5447 +------------+-----+--------------+---------------------+-----------+ 5448 | NIST P-521 | 521 | 15360 | 512 | 256 | 5449 +------------+-----+--------------+---------------------+-----------+ 5451 Table 27: Elliptic Curve cryptographic guidance 5453 * Requirement levels indicated elsewhere in this document lead to 5454 the following combinations of algorithms in the OpenPGP profile: 5455 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 5456 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 5457 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 5458 combinations. 5460 Consistent with the table above, the following table defines the 5461 KDF hash algorithm and the AES KEK encryption algorithm that 5462 SHOULD be used with a given curve for ECDH. A stronger KDF hash 5463 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 5465 +============+=================+======================+ 5466 | Curve name | Recommended KDF | Recommended KEK | 5467 | | hash algorithm | encryption algorithm | 5468 +============+=================+======================+ 5469 | NIST P-256 | SHA2-256 | AES-128 | 5470 +------------+-----------------+----------------------+ 5471 | NIST P-384 | SHA2-384 | AES-192 | 5472 +------------+-----------------+----------------------+ 5473 | NIST P-521 | SHA2-512 | AES-256 | 5474 +------------+-----------------+----------------------+ 5476 Table 28: Elliptic Curve KDF and KEK recommendations 5478 * This document explicitly discourages the use of algorithms other 5479 than AES as a KEK algorithm because backward compatibility of the 5480 ECDH format is not a concern. The KEK algorithm is only used 5481 within the scope of a Public-Key Encrypted Session Key Packet, 5482 which represents an ECDH key recipient of a message. Compare this 5483 with the algorithm used for the session key of the message, which 5484 MAY be different from a KEK algorithm. 5486 Compliant applications SHOULD implement, advertise through key 5487 preferences, and use the strongest algorithms specified in this 5488 document. 5490 Note that the symmetric algorithm preference list may make it 5491 impossible to use the balanced strength of symmetric key 5492 algorithms for a corresponding public key. For example, the 5493 presence of the symmetric key algorithm IDs and their order in the 5494 key preference list affects the algorithm choices available to the 5495 encoding side, which in turn may make the adherence to the table 5496 above infeasible. Therefore, compliance with this specification 5497 is a concern throughout the life of the key starting immediately 5498 after the key generation when the key preferences are first added 5499 to a key. It is generally advisable to position a symmetric 5500 algorithm ID of strength matching the public key at the head of 5501 the key preference list. 5503 Encryption to multiple recipients often results in an unordered 5504 intersection subset. For example, if the first recipient's set is 5505 {A, B} and the second's is {B, A}, the intersection is an 5506 unordered set of two algorithms, A and B. In this case, a 5507 compliant application SHOULD choose the stronger encryption 5508 algorithm. 5510 Resource constraints, such as limited computational power, are a 5511 reason why an application might prefer to use the weakest 5512 algorithm. On the other side of the spectrum are applications 5513 that can implement every algorithm defined in this document. Most 5514 applications are expected to fall into either of these two 5515 categories. A compliant application in the second, or strongest, 5516 category SHOULD prefer AES-256 to AES-192. 5518 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 5519 method. 5521 MDC MUST be used when a symmetric encryption key is protected by 5522 ECDH. None of the ECC methods described in this document are 5523 allowed with deprecated V3 keys. 5525 Side channel attacks are a concern when a compliant application's 5526 use of the OpenPGP format can be modeled by a decryption or 5527 signing oracle, for example, when an application is a network 5528 service performing decryption to unauthenticated remote users. 5529 ECC scalar multiplication operations used in ECDSA and ECDH are 5530 vulnerable to side channel attacks. Countermeasures can often be 5531 taken at the higher protocol level, such as limiting the number of 5532 allowed failures or time-blinding of the operations associated 5533 with each network interface. Mitigations at the scalar 5534 multiplication level seek to eliminate any measurable distinction 5535 between the ECC point addition and doubling operations. 5537 16. Implementation Nits 5539 This section is a collection of comments to help an implementer, 5540 particularly with an eye to backward compatibility. Previous 5541 implementations of PGP are not OpenPGP compliant. Often the 5542 differences are small, but small differences are frequently more 5543 vexing than large differences. Thus, this is a non-comprehensive 5544 list of potential problems and gotchas for a developer who is trying 5545 to be backward-compatible. 5547 * The IDEA algorithm is patented, and yet it is required for PGP 2 5548 interoperability. It is also the de-facto preferred algorithm for 5549 a V3 key with a V3 self-signature (or no self-signature). 5551 * When exporting a private key, PGP 2 generates the header "BEGIN 5552 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 5553 All previous versions ignore the implied data type, and look 5554 directly at the packet data type. 5556 * PGP versions 2.0 through 2.5 generated V2 Public-Key packets. 5557 These are identical to the deprecated V3 keys except for the 5558 version number. An implementation MUST NOT generate them and may 5559 accept or reject them as it sees fit. Some older PGP versions 5560 generated V2 PKESK packets (Tag 1) as well. An implementation may 5561 accept or reject V2 PKESK packets as it sees fit, and MUST NOT 5562 generate them. 5564 * PGP version 2.6 will not accept key-material packets with versions 5565 greater than 3. 5567 * There are many ways possible for two keys to have the same key 5568 material, but different fingerprints (and thus Key IDs). Perhaps 5569 the most interesting is an RSA key that has been "upgraded" to V4 5570 format, but since a V4 fingerprint is constructed by hashing the 5571 key creation time along with other things, two V4 keys created at 5572 different times, yet with the same key material will have 5573 different fingerprints. 5575 * If an implementation is using zlib to interoperate with PGP 2, 5576 then the "windowBits" parameter should be set to -13. 5578 * The 0x19 back signatures were not required for signing subkeys 5579 until relatively recently. Consequently, there may be keys in the 5580 wild that do not have these back signatures. Implementing 5581 software may handle these keys as it sees fit. 5583 * OpenPGP does not put limits on the size of public keys. However, 5584 larger keys are not necessarily better keys. Larger keys take 5585 more computation time to use, and this can quickly become 5586 impractical. Different OpenPGP implementations may also use 5587 different upper bounds for public key sizes, and so care should be 5588 taken when choosing sizes to maintain interoperability. As of 5589 2007 most implementations have an upper bound of 4096 bits. 5591 * ASCII armor is an optional feature of OpenPGP. The OpenPGP 5592 working group strives for a minimal set of mandatory-to-implement 5593 features, and since there could be useful implementations that 5594 only use binary object formats, this is not a "MUST" feature for 5595 an implementation. For example, an implementation that is using 5596 OpenPGP as a mechanism for file signatures may find ASCII armor 5597 unnecessary. OpenPGP permits an implementation to declare what 5598 features it does and does not support, but ASCII armor is not one 5599 of these. Since most implementations allow binary and armored 5600 objects to be used indiscriminately, an implementation that does 5601 not implement ASCII armor may find itself with compatibility 5602 issues with general-purpose implementations. Moreover, 5603 implementations of OpenPGP-MIME [RFC3156] already have a 5604 requirement for ASCII armor so those implementations will 5605 necessarily have support. 5607 17. References 5609 17.1. Normative References 5611 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 5612 November 2001, 5613 . 5616 [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 5617 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 5618 Cambridge Security Workshop Proceedings Springer-Verlag, 5619 1994, pp191-204, December 1993, 5620 . 5622 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, 5623 . 5625 [EAX] Bellare, M., Rogaway, P., and D. Wagner, "A Conventional 5626 Authenticated-Encryption Mode", April 2003. 5628 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 5629 Scheme Based on Discrete Logarithms", IEEE Transactions on 5630 Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 5631 1985. 5633 [FIPS180] National Institute of Standards and Technology, U.S. 5634 Department of Commerce, "Secure Hash Standard (SHS), FIPS 5635 180-4", August 2015, 5636 . 5638 [FIPS186] National Institute of Standards and Technology, U.S. 5639 Department of Commerce, "Digital Signature Standard (DSS), 5640 FIPS 186-4", July 2013, 5641 . 5643 [FIPS202] National Institute of Standards and Technology, U.S. 5644 Department of Commerce, "SHA-3 Standard: Permutation-Based 5645 Hash and Extendable-Output Functions, FIPS 202", August 5646 2015, . 5648 [HAC] Menezes, A.J., Oorschot, P.v., and S. Vanstone, "Handbook 5649 of Applied Cryptography", 1996. 5651 [IDEA] Lai, X., "On the design and security of block ciphers", 5652 ETH Series in Information Processing, J.L. Massey 5653 (editor) Vol. 1, Hartung-Gorre Verlag Konstanz, Technische 5654 Hochschule (Zurich), 1992. 5656 [ISO10646] International Organization for Standardization, 5657 "Information Technology - Universal Multiple-octet coded 5658 Character Set (UCS) - Part 1: Architecture and Basic 5659 Multilingual Plane", ISO Standard 10646-1, May 1993. 5661 [JFIF] CA, E.H.M., "JPEG File Interchange Format (Version 5662 1.02).", September 1996. 5664 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 5665 Cryptography Standard", 25 March 1999. 5667 [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format 5668 Specification version 3.3", RFC 1950, 5669 DOI 10.17487/RFC1950, May 1996, 5670 . 5672 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 5673 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 5674 . 5676 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5677 Extensions (MIME) Part One: Format of Internet Message 5678 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 5679 . 5681 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5682 Requirement Levels", BCP 14, RFC 2119, 5683 DOI 10.17487/RFC2119, March 1997, 5684 . 5686 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 5687 DOI 10.17487/RFC2144, May 1997, 5688 . 5690 [RFC2822] Resnick, P., Ed., "Internet Message Format", RFC 2822, 5691 DOI 10.17487/RFC2822, April 2001, 5692 . 5694 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 5695 "MIME Security with OpenPGP", RFC 3156, 5696 DOI 10.17487/RFC3156, August 2001, 5697 . 5699 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 5700 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 5701 September 2002, . 5703 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 5704 Standards (PKCS) #1: RSA Cryptography Specifications 5705 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 5706 2003, . 5708 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5709 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 5710 2003, . 5712 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 5713 the Camellia Encryption Algorithm", RFC 3713, 5714 DOI 10.17487/RFC3713, April 2004, 5715 . 5717 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 5718 "Randomness Requirements for Security", BCP 106, RFC 4086, 5719 DOI 10.17487/RFC4086, June 2005, 5720 . 5722 [RFC7253] Krovetz, T. and P. Rogaway, "The OCB Authenticated- 5723 Encryption Algorithm", RFC 7253, DOI 10.17487/RFC7253, May 5724 2014, . 5726 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 5727 for Security", RFC 7748, DOI 10.17487/RFC7748, January 5728 2016, . 5730 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 5731 Signature Algorithm (EdDSA)", RFC 8032, 5732 DOI 10.17487/RFC8032, January 2017, 5733 . 5735 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 5736 Writing an IANA Considerations Section in RFCs", BCP 26, 5737 RFC 8126, DOI 10.17487/RFC8126, June 2017, 5738 . 5740 [RFC9106] Biryukov, A., Dinu, D., Khovratovich, D., and S. 5741 Josefsson, "Argon2 Memory-Hard Function for Password 5742 Hashing and Proof-of-Work Applications", RFC 9106, 5743 DOI 10.17487/RFC9106, September 2021, 5744 . 5746 [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: 5747 protocols, algorithms, and source code in C", 1996. 5749 [SP800-56A] 5750 Barker, E., Johnson, D., and M. Smid, "Recommendation for 5751 Pair-Wise Key Establishment Schemes Using Discrete 5752 Logarithm Cryptography", NIST Special Publication 800-56A 5753 Revision 1, March 2007. 5755 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 5756 C., and N. Ferguson, "The Twofish Encryption Algorithm", 5757 1999. 5759 17.2. Informative References 5761 [BLEICHENBACHER] 5762 Bleichenbacher, D., "Generating ElGamal Signatures Without 5763 Knowing the Secret Key", Lecture Notes in Computer 5764 Science Volume 1070, pp. 10-18, 1996. 5766 [JKS02] Jallad, K., Katz, J., and B. Schneier, "Implementation of 5767 Chosen-Ciphertext Attacks against PGP and GnuPG", 2002, 5768 . 5770 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 5771 Chapter VI. Elliptic Curves", ISBN 0-387-96576-9, 1997. 5773 [MZ05] Mister, S. and R. Zuccherato, "An Attack on CFB Mode 5774 Encryption As Used By OpenPGP", IACR ePrint Archive Report 5775 2005/033, 8 February 2005, 5776 . 5778 [REGEX] Friedl, J., "Mastering Regular Expressions", 5779 ISBN 0-596-00289-0, August 2002. 5781 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5782 Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, August 5783 1996, . 5785 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5786 "OpenPGP Message Format", RFC 2440, DOI 10.17487/RFC2440, 5787 November 1998, . 5789 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 5790 Thayer, "OpenPGP Message Format", RFC 4880, 5791 DOI 10.17487/RFC4880, November 2007, 5792 . 5794 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5795 Curve Cryptography Algorithms", RFC 6090, 5796 DOI 10.17487/RFC6090, February 2011, 5797 . 5799 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5800 Elliptic Curve Cryptography", September 2000. 5802 [SP800-57] NIST, "Recommendation on Key Management", NIST Special 5803 Publication 800-57, March 2007, 5804 . 5807 Appendix A. Test vectors 5809 To help implementing this specification a non-normative example for 5810 the EdDSA algorithm is given. 5812 A.1. Sample EdDSA key 5814 The secret key used for this example is: 5816 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 5818 Note that this is the raw secret key used as input to the EdDSA 5819 signing operation. The key was created on 2014-08-19 14:28:27 and 5820 thus the fingerprint of the OpenPGP key is: 5822 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 5824 The algorithm specific input parameters without the MPI length 5825 headers are: 5827 oid: 2b06010401da470f01 5828 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 5830 The entire public key packet is thus: 5832 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 5833 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 5834 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 5835 43 ee 3b 24 06 5837 A.2. Sample EdDSA signature 5839 The signature is created using the sample key over the input data 5840 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 5841 function is: 5843 m: 4f70656e504750040016080006050255f95f9504ff0000000c 5845 Using the SHA2-256 hash algorithm yields the digest: 5847 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 5849 Which is fed into the EdDSA signature function and yields this 5850 signature: 5852 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 5854 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 5856 The entire signature packet is thus: 5858 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 5859 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 5860 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 5861 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 5862 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 5863 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 5865 A.3. Sample AEAD-EAX encryption and decryption 5867 Encryption is performed with the string "Hello, world!", using 5868 AES-128 with AEAD-EAX encryption. 5870 A.3.1. Sample Parameters 5872 S2K: 5874 type 3 5876 Iterations: 5878 524288 (144), SHA2-256 5880 Salt: 5882 cd5a9f70fbe0bc65 5884 A.3.2. Sample symmetric-key encrypted session key packet (v5) 5886 Packet header: 5888 c3 3e 5890 Version, algorithms, S2K fields: 5892 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5894 AEAD IV: 5896 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5898 AEAD encrypted CEK: 5900 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 5902 Authentication tag: 5904 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 5906 A.3.3. Starting AEAD-EAX decryption of CEK 5908 The derived key is: 5910 b2 55 69 b9 54 32 45 66 45 27 c4 97 6e 7a 5d 6e 5912 Authenticated Data: 5914 c3 05 07 01 5916 Nonce: 5918 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5920 Decrypted CEK: 5922 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d 5924 A.3.4. Initial Content Encryption Key 5926 This key would typically be extracted from an SKESK or PKESK. In 5927 this example, it is extracted from an SKESK packet, as described 5928 above. 5930 CEK: 5932 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d 5934 A.3.5. Sample AEAD encrypted data packet 5936 Packet header: 5938 d4 4a 5940 Version, AES-128, EAX, Chunk bits (14): 5942 01 07 01 0e 5944 IV: 5946 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5948 AEAD-EAX Encrypted data chunk #0: 5950 5d c1 1a 81 dc 0c b8 a2 f6 f3 d9 00 16 38 4a 56 5951 fc 82 1a e1 1a e8 5953 Chunk #0 authentication tag: 5955 db cb 49 86 26 55 de a8 8d 06 a8 14 86 80 1b 0f 5957 Final (zero-size chunk #1) authentication tag: 5959 f3 87 bd 2e ab 01 3d e1 25 95 86 90 6e ab 24 76 5961 A.3.6. Decryption of data 5963 Starting AEAD-EAX decryption of data, using the CEK. 5965 Chunk #0: 5967 Authenticated data: 5969 d4 01 07 01 0e 00 00 00 00 00 00 00 00 5971 Nonce: 5973 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 5975 Decrypted chunk #0. 5977 Literal data packet with the string contents "Hello, world!\n". 5979 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 5980 6f 72 6c 64 21 0a 5982 Authenticating final tag: 5984 Authenticated data: 5986 d4 01 07 01 0e 00 00 00 00 00 00 00 01 00 00 00 5987 00 00 00 00 16 5989 Nonce: 5991 b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 11 5993 A.3.7. Complete AEAD-EAX encrypted packet sequence 5995 Symmetric-key encrypted session key packet (v5): 5997 c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 5998 bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 5999 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb 6000 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 6002 AEAD encrypted data packet: 6004 d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f 6005 ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3 6006 d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86 6007 26 55 de a8 8d 06 a8 14 86 80 1b 0f f3 87 bd 2e 6008 ab 01 3d e1 25 95 86 90 6e ab 24 76 6010 A.4. Sample AEAD-OCB encryption and decryption 6012 Encryption is performed with the string "Hello, world!" using AES-128 6013 with AEAD-OCB encryption. 6015 A.4.1. Sample Parameters 6017 S2K: 6019 type 3 6021 Iterations: 6023 524288 (144), SHA2-256 6025 Salt: 6027 9f0b7da3e5ea6477 6029 A.4.2. Sample symmetric-key encrypted session key packet (v5) 6031 Packet header: 6033 c3 3d 6035 Version, algorithms, S2K fields: 6037 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 6039 AEAD IV: 6041 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 6043 AEAD encrypted CEK: 6045 67 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da 6047 Authentication tag: 6049 c5 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 6051 A.4.3. Starting AEAD-OCB decryption of CEK 6053 The derived key is: 6055 eb 9d a7 8a 9d 5d f8 0e c7 02 05 96 39 9b 65 08 6057 Authenticated Data: 6059 c3 05 07 02 6061 Nonce: 6063 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 6065 Decrypted CEK: 6067 d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 6069 A.4.4. Initial Content Encryption Key 6071 This key would typically be extracted from an SKESK or PKESK. In 6072 this example, it is extracted from an SKESK packet, as described 6073 above. 6075 Decrypted CEK: 6077 d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 6079 A.4.5. Sample AEAD encrypted data packet 6081 Packet header: 6083 d4 49 6085 Version, AES-128, OCB, Chunk bits (14): 6087 01 07 02 0e 6089 IV: 6091 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 6093 AEAD-OCB Encrypted data chunk #0: 6095 7b 0f 77 01 19 66 11 a1 54 ba 9c 25 74 cd 05 62 6096 84 a8 ef 68 03 5c 6098 Chunk #0 authentication tag: 6100 62 3d 93 cc 70 8a 43 21 1b b6 ea f2 b2 7f 7c 18 6102 Final (zero-size chunk #1) authentication tag: 6104 d5 71 bc d8 3b 20 ad d3 a0 8b 73 af 15 b9 a0 98 6106 A.4.6. Decryption of data 6108 Starting AEAD-OCB decryption of data, using the CEK. 6110 Chunk #0: 6112 Authenticated data: 6114 d4 01 07 02 0e 00 00 00 00 00 00 00 00 6116 Nonce: 6118 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 6120 Decrypted chunk #0. 6122 Literal data packet with the string contents "Hello, world!\n". 6124 cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 6125 6f 72 6c 64 21 0a 6127 Authenticating final tag: 6129 Authenticated data: 6131 d4 01 07 02 0e 00 00 00 00 00 00 00 01 00 00 00 6132 00 00 00 00 16 6134 Nonce: 6136 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 57 6138 A.4.7. Complete AEAD-OCB encrypted packet sequence 6140 Symmetric-key encrypted session key packet (v5): 6142 c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 6143 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67 6144 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5 6145 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed 6147 AEAD encrypted data packet: 6149 d4 49 01 07 02 0e 5e d2 bc 1e 47 0a be 8f 1d 64 6150 4c 7a 6c 8a 56 7b 0f 77 01 19 66 11 a1 54 ba 9c 6151 25 74 cd 05 62 84 a8 ef 68 03 5c 62 3d 93 cc 70 6152 8a 43 21 1b b6 ea f2 b2 7f 7c 18 d5 71 bc d8 3b 6153 20 ad d3 a0 8b 73 af 15 b9 a0 98 6155 Appendix B. Acknowledgements 6157 This memo also draws on much previous work from a number of other 6158 authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc 6159 Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, 6160 Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, 6161 Mark Weaver, and Philip R. Zimmermann. 6163 Appendix C. Document Workflow 6165 This document is built from markdown using ruby-kramdown-rfc2629 6166 (https://rubygems.org/gems/kramdown-rfc2629), and tracked using git 6167 (https://git-scm.com/). The markdown source under development can be 6168 found in the file "crypto-refresh.md" in the "main" branch of the git 6169 repository (https://gitlab.com/openpgp-wg/rfc4880bis). Discussion of 6170 this document should take place on the openpgp@ietf.org mailing list 6171 (https://www.ietf.org/mailman/listinfo/openpgp). 6173 A non-substantive editorial nit can be submitted directly as a merge 6174 request (https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/ 6175 new). A substantive proposed edit may also be submitted as a merge 6176 request, but should simultaneously be sent to the mailing list for 6177 discussion. 6179 An open problem can be recorded and tracked as an issue 6180 (https://gitlab.com/openpgp-wg/rfc4880bis/-/issues) in the gitlab 6181 issue tracker, but discussion of the issue should take place on the 6182 mailing list. 6184 [Note to RFC-Editor: Please remove this section on publication.] 6186 Authors' Addresses 6188 Werner Koch (editor) 6189 GnuPG e.V. 6190 Rochusstr. 44 6191 40479 Duesseldorf 6192 Germany 6194 Email: wk@gnupg.org 6195 URI: https://gnupg.org/verein 6197 Paul Wouters (editor) 6198 Aiven 6200 Email: paul.wouters@aiven.io