idnits 2.17.00 (12 Aug 2021) /tmp/idnits62512/draft-ietf-openpgp-crypto-refresh-03.txt: -(3089): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(3091): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(3093): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == There are 8 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document obsoletes RFC6637, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC4880, but the abstract doesn't seem to directly say this. It does mention RFC4880 though, so this could be OK. -- The draft header indicates that this document obsoletes RFC5581, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (2 May 2021) is 384 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 417 -- Looks like a reference, but probably isn't: '1' on line 4556 -- Looks like a reference, but probably isn't: '2' on line 417 -- Looks like a reference, but probably isn't: '3' on line 4565 == Missing Reference: 'Optional' is mentioned on line 2296, but not defined == Missing Reference: 'Binding-Signature-Revocation' is mentioned on line 3902, but not defined == Missing Reference: 'BS' is mentioned on line 4556, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. 'BLOWFISH' -- Possible downref: Non-RFC (?) normative reference: ref. 'BZ2' -- Possible downref: Non-RFC (?) normative reference: ref. 'ELGAMAL' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS180' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS186' -- Possible downref: Non-RFC (?) normative reference: ref. 'FIPS202' -- Possible downref: Non-RFC (?) normative reference: ref. 'HAC' -- Possible downref: Non-RFC (?) normative reference: ref. 'IDEA' -- Possible downref: Non-RFC (?) normative reference: ref. 'ISO10646' -- Possible downref: Non-RFC (?) normative reference: ref. 'JFIF' -- Possible downref: Non-RFC (?) normative reference: ref. 'PKCS5' ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Downref: Normative reference to an Informational RFC: RFC 1951 ** Downref: Normative reference to an Informational RFC: RFC 2144 ** Obsolete normative reference: RFC 2822 (Obsoleted by RFC 5322) ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Downref: Normative reference to an Informational RFC: RFC 3713 ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8032 -- 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: 9 errors (**), 0 flaws (~~), 5 warnings (==), 26 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 No Hats 6 Expires: 3 November 2021 2 May 2021 8 OpenPGP Message Format 9 draft-ietf-openpgp-crypto-refresh-03 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 3 November 2021. 45 Copyright Notice 47 Copyright (c) 2021 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 52 license-info) in effect on the date of publication of this document. 53 Please review these documents carefully, as they describe your rights 54 and restrictions with respect to this document. Code Components 55 extracted from this document must include Simplified BSD License text 56 as described in Section 4.e of the Trust Legal Provisions and are 57 provided without warranty as described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 62 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 6 63 2. General functions . . . . . . . . . . . . . . . . . . . . . . 7 64 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 7 65 2.2. Authentication via Digital Signature . . . . . . . . . . 8 66 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 8 67 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 9 68 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 9 69 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 9 70 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 9 71 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 9 72 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 10 73 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 10 74 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 10 75 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 11 76 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 11 77 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 11 78 3.7.1.1. Simple S2K . . . . . . . . . . . . . . . . . . . 11 79 3.7.1.2. Salted S2K . . . . . . . . . . . . . . . . . . . 12 80 3.7.1.3. Iterated and Salted S2K . . . . . . . . . . . . . 12 81 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 13 82 3.7.2.1. Secret-Key Encryption . . . . . . . . . . . . . . 13 83 3.7.2.2. Symmetric-Key Message Encryption . . . . . . . . 14 84 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 14 85 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 14 86 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 14 87 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 15 88 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 16 89 4.2.2.1. One-Octet Lengths . . . . . . . . . . . . . . . . 16 90 4.2.2.2. Two-Octet Lengths . . . . . . . . . . . . . . . . 16 91 4.2.2.3. Five-Octet Lengths . . . . . . . . . . . . . . . 16 92 4.2.2.4. Partial Body Lengths . . . . . . . . . . . . . . 17 93 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 17 94 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 18 95 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 19 96 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 20 97 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 21 98 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 21 99 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 24 100 5.2.3. Version 4 and 5 Signature Packet Formats . . . . . . 27 101 5.2.3.1. Signature Subpacket Specification . . . . . . . . 29 102 5.2.3.2. Signature Subpacket Types . . . . . . . . . . . . 32 103 5.2.3.3. Notes on Self-Signatures . . . . . . . . . . . . 32 104 5.2.3.4. Signature Creation Time . . . . . . . . . . . . . 33 105 5.2.3.5. Issuer . . . . . . . . . . . . . . . . . . . . . 34 106 5.2.3.6. Key Expiration Time . . . . . . . . . . . . . . . 34 107 5.2.3.7. Preferred Symmetric Algorithms . . . . . . . . . 34 108 5.2.3.8. Preferred Hash Algorithms . . . . . . . . . . . . 34 109 5.2.3.9. Preferred Compression Algorithms . . . . . . . . 34 110 5.2.3.10. Signature Expiration Time . . . . . . . . . . . . 35 111 5.2.3.11. Exportable Certification . . . . . . . . . . . . 35 112 5.2.3.12. Revocable . . . . . . . . . . . . . . . . . . . . 35 113 5.2.3.13. Trust Signature . . . . . . . . . . . . . . . . . 36 114 5.2.3.14. Regular Expression . . . . . . . . . . . . . . . 36 115 5.2.3.15. Revocation Key . . . . . . . . . . . . . . . . . 36 116 5.2.3.16. Notation Data . . . . . . . . . . . . . . . . . . 37 117 5.2.3.17. Key Server Preferences . . . . . . . . . . . . . 38 118 5.2.3.18. Preferred Key Server . . . . . . . . . . . . . . 38 119 5.2.3.19. Primary User ID . . . . . . . . . . . . . . . . . 38 120 5.2.3.20. Policy URI . . . . . . . . . . . . . . . . . . . 39 121 5.2.3.21. Key Flags . . . . . . . . . . . . . . . . . . . . 39 122 5.2.3.22. Signer's User ID . . . . . . . . . . . . . . . . 41 123 5.2.3.23. Reason for Revocation . . . . . . . . . . . . . . 41 124 5.2.3.24. Features . . . . . . . . . . . . . . . . . . . . 43 125 5.2.3.25. Signature Target . . . . . . . . . . . . . . . . 43 126 5.2.3.26. Embedded Signature . . . . . . . . . . . . . . . 44 127 5.2.3.27. Issuer Fingerprint . . . . . . . . . . . . . . . 44 128 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 44 129 5.2.4.1. Subpacket Hints . . . . . . . . . . . . . . . . . 47 130 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 47 131 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 48 132 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 49 133 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 49 134 5.5.1.1. Public-Key Packet (Tag 6) . . . . . . . . . . . . 49 135 5.5.1.2. Public-Subkey Packet (Tag 14) . . . . . . . . . . 49 136 5.5.1.3. Secret-Key Packet (Tag 5) . . . . . . . . . . . . 49 137 5.5.1.4. Secret-Subkey Packet (Tag 7) . . . . . . . . . . 50 138 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 50 139 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 51 140 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 53 141 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 53 142 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 54 143 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 54 144 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 54 145 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 55 146 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 55 147 5.7. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 56 148 5.8. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 57 149 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 58 150 5.10. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 58 151 5.11. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 59 152 5.12. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 59 153 5.13. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 59 154 5.13.1. The Image Attribute Subpacket . . . . . . . . . . . 60 155 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 156 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 61 157 5.15. Modification Detection Code Packet (Tag 19) . . . . . . . 64 158 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 65 159 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 65 160 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 66 161 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 69 162 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 71 163 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 71 164 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 72 165 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 72 166 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 73 167 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 74 168 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 74 169 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 75 170 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 76 171 9.3. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 76 172 9.4. Compression Algorithms . . . . . . . . . . . . . . . . . 77 173 9.5. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 78 174 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 79 175 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 79 176 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 79 177 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 79 178 10.2.1.1. Image Format Subpacket Types . . . . . . . . . . 79 179 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 80 180 10.2.2.1. Signature Notation Data Subpackets . . . . . . . 80 181 10.2.2.2. Signature Notation Data Subpacket Notation 182 Flags . . . . . . . . . . . . . . . . . . . . . . . 80 183 10.2.2.3. Key Server Preference Extensions . . . . . . . . 81 184 10.2.2.4. Key Flags Extensions . . . . . . . . . . . . . . 81 185 10.2.2.5. Reason for Revocation Extensions . . . . . . . . 81 186 10.2.2.6. Implementation Features . . . . . . . . . . . . 81 187 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 82 188 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 82 189 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 82 190 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 83 191 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 83 192 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 84 193 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 84 194 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 84 195 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 85 196 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 86 197 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 86 198 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 86 199 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 87 200 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 88 201 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 89 202 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 89 203 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 90 204 13.3. EdDSA Point Format . . . . . . . . . . . . . . . . . . . 91 205 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 91 206 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 91 207 14. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 94 208 14.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 94 209 14.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 94 210 14.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 95 211 14.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 96 212 14.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 97 213 14.3. Other Algorithm Preferences . . . . . . . . . . . . . . 97 214 14.3.1. Compression Preferences . . . . . . . . . . . . . . 98 215 14.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 98 216 14.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 98 217 14.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 99 218 14.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 99 219 14.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 99 220 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 100 221 14.9. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 100 222 14.10. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 100 223 14.11. Private or Experimental Parameters . . . . . . . . . . . 102 224 14.12. Extension of the MDC System . . . . . . . . . . . . . . 102 225 14.13. Meta-Considerations for Expansion . . . . . . . . . . . 103 226 15. Security Considerations . . . . . . . . . . . . . . . . . . . 103 227 16. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 109 228 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 111 229 17.1. Normative References . . . . . . . . . . . . . . . . . . 111 230 17.2. Informative References . . . . . . . . . . . . . . . . . 114 231 Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 115 232 A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 115 233 A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 116 234 Appendix B. Document Workflow . . . . . . . . . . . . . . . . . 116 235 Appendix C. ECC Point compression flag bytes . . . . . . . . . . 117 236 Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 117 237 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 117 239 1. Introduction 241 { This is work in progress to update OpenPGP. Editorial notes are 242 enclosed in curly braces. } 244 This document provides information on the message-exchange packet 245 formats used by OpenPGP to provide encryption, decryption, signing, 246 and key management functions. It is a revision of RFC 4880, "OpenPGP 247 Message Format", which is a revision of RFC 2440, which itself 248 replaces RFC 1991, "PGP Message Exchange Formats" [RFC1991] [RFC2440] 249 [RFC4880]. 251 This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia 252 cipher) and RFC 6637 (ECC for OpenPGP). 254 1.1. Terms 256 * OpenPGP - This is a term for security software that uses PGP 5 as 257 a basis, formalized in this document. 259 * PGP - Pretty Good Privacy. PGP is a family of software systems 260 developed by Philip R. Zimmermann from which OpenPGP is based. 262 * PGP 2 - This version of PGP has many variants; where necessary a 263 more detailed version number is used here. PGP 2 uses only RSA, 264 MD5, and IDEA for its cryptographic transforms. An informational 265 RFC, RFC 1991, was written describing this version of PGP. 267 * PGP 5 - This version of PGP is formerly known as "PGP 3" in the 268 community. It has new formats and corrects a number of problems 269 in the PGP 2 design. It is referred to here as PGP 5 because that 270 software was the first release of the "PGP 3" code base. 272 * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP 273 implementation that avoids all encumbered algorithms. 274 Consequently, early versions of GnuPG did not include RSA public 275 keys. 277 "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP 278 Corporation and are used with permission. The term "OpenPGP" refers 279 to the protocol described in this and related documents. 281 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 282 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 283 document are to be interpreted as described in [RFC2119]. 285 The key words "PRIVATE USE", "SPECIFICATION REQUIRED", and "RFC 286 REQUIRED" that appear in this document when used to describe 287 namespace allocation are to be interpreted as described in [RFC8126]. 289 2. General functions 291 OpenPGP provides data integrity services for messages and data files 292 by using these core technologies: 294 * digital signatures 296 * encryption 298 * compression 300 * Radix-64 conversion 302 In addition, OpenPGP provides key management and certificate 303 services, but many of these are beyond the scope of this document. 305 2.1. Confidentiality via Encryption 307 OpenPGP combines symmetric-key encryption and public-key encryption 308 to provide confidentiality. When made confidential, first the object 309 is encrypted using a symmetric encryption algorithm. Each symmetric 310 key is used only once, for a single object. A new "session key" is 311 generated as a random number for each object (sometimes referred to 312 as a session). Since it is used only once, the session key is bound 313 to the message and transmitted with it. To protect the key, it is 314 encrypted with the receiver's public key. The sequence is as 315 follows: 317 1. The sender creates a message. 319 2. The sending OpenPGP generates a random number to be used as a 320 session key for this message only. 322 3. The session key is encrypted using each recipient's public key. 323 These "encrypted session keys" start the message. 325 4. The sending OpenPGP encrypts the message using the session key, 326 which forms the remainder of the message. Note that the message 327 is also usually compressed. 329 5. The receiving OpenPGP decrypts the session key using the 330 recipient's private key. 332 6. The receiving OpenPGP decrypts the message using the session key. 333 If the message was compressed, it will be decompressed. 335 With symmetric-key encryption, an object may be encrypted with a 336 symmetric key derived from a passphrase (or other shared secret), or 337 a two-stage mechanism similar to the public-key method described 338 above in which a session key is itself encrypted with a symmetric 339 algorithm keyed from a shared secret. 341 Both digital signature and confidentiality services may be applied to 342 the same message. First, a signature is generated for the message 343 and attached to the message. Then the message plus signature is 344 encrypted using a symmetric session key. Finally, the session key is 345 encrypted using public-key encryption and prefixed to the encrypted 346 block. 348 2.2. Authentication via Digital Signature 350 The digital signature uses a hash code or message digest algorithm, 351 and a public-key signature algorithm. The sequence is as follows: 353 1. The sender creates a message. 355 2. The sending software generates a hash code of the message. 357 3. The sending software generates a signature from the hash code 358 using the sender's private key. 360 4. The binary signature is attached to the message. 362 5. The receiving software keeps a copy of the message signature. 364 6. The receiving software generates a new hash code for the received 365 message and verifies it using the message's signature. If the 366 verification is successful, the message is accepted as authentic. 368 2.3. Compression 370 OpenPGP implementations SHOULD compress the message after applying 371 the signature but before encryption. 373 If an implementation does not implement compression, its authors 374 should be aware that most OpenPGP messages in the world are 375 compressed. Thus, it may even be wise for a space-constrained 376 implementation to implement decompression, but not compression. 378 Furthermore, compression has the added side effect that some types of 379 attacks can be thwarted by the fact that slightly altered, compressed 380 data rarely uncompresses without severe errors. This is hardly 381 rigorous, but it is operationally useful. These attacks can be 382 rigorously prevented by implementing and using Modification Detection 383 Codes as described in sections following. 385 2.4. Conversion to Radix-64 387 OpenPGP's underlying native representation for encrypted messages, 388 signature certificates, and keys is a stream of arbitrary octets. 389 Some systems only permit the use of blocks consisting of seven-bit, 390 printable text. For transporting OpenPGP's native raw binary octets 391 through channels that are not safe to raw binary data, a printable 392 encoding of these binary octets is needed. OpenPGP provides the 393 service of converting the raw 8-bit binary octet stream to a stream 394 of printable ASCII characters, called Radix-64 encoding or ASCII 395 Armor. 397 Implementations SHOULD provide Radix-64 conversions. 399 2.5. Signature-Only Applications 401 OpenPGP is designed for applications that use both encryption and 402 signatures, but there are a number of problems that are solved by a 403 signature-only implementation. Although this specification requires 404 both encryption and signatures, it is reasonable for there to be 405 subset implementations that are non-conformant only in that they omit 406 encryption. 408 3. Data Element Formats 410 This section describes the data elements used by OpenPGP. 412 3.1. Scalar Numbers 414 Scalar numbers are unsigned and are always stored in big-endian 415 format. Using n[k] to refer to the kth octet being interpreted, the 416 value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a 417 four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + 418 n[3]). 420 3.2. Multiprecision Integers 422 Multiprecision integers (also called MPIs) are unsigned integers used 423 to hold large integers such as the ones used in cryptographic 424 calculations. 426 An MPI consists of two pieces: a two-octet scalar that is the length 427 of the MPI in bits followed by a string of octets that contain the 428 actual integer. 430 These octets form a big-endian number; a big-endian number can be 431 made into an MPI by prefixing it with the appropriate length. 433 Examples: 435 (all numbers are in hexadecimal) 437 The string of octets [00 01 01] forms an MPI with the value 1. The 438 string [00 09 01 FF] forms an MPI with the value of 511. 440 Additional rules: 442 The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. 444 The length field of an MPI describes the length starting from its 445 most significant non-zero bit. Thus, the MPI [00 02 01] is not 446 formed correctly. It should be [00 01 01]. 448 Unused bits of an MPI MUST be zero. 450 Also note that when an MPI is encrypted, the length refers to the 451 plaintext MPI. It may be ill-formed in its ciphertext. 453 3.3. Key IDs 455 A Key ID is an eight-octet scalar that identifies a key. 456 Implementations SHOULD NOT assume that Key IDs are unique. 457 Section 12 describes how Key IDs are formed. 459 3.4. Text 461 Unless otherwise specified, the character set for text is the UTF-8 462 [RFC3629] encoding of Unicode [ISO10646]. 464 3.5. Time Fields 466 A time field is an unsigned four-octet number containing the number 467 of seconds elapsed since midnight, 1 January 1970 UTC. 469 3.6. Keyrings 471 A keyring is a collection of one or more keys in a file or database. 472 Traditionally, a keyring is simply a sequential list of keys, but may 473 be any suitable database. It is beyond the scope of this standard to 474 discuss the details of keyrings or other databases. 476 3.7. String-to-Key (S2K) Specifiers 478 String-to-key (S2K) specifiers are used to convert passphrase strings 479 into symmetric-key encryption/decryption keys. They are used in two 480 places, currently: to encrypt the secret part of private keys in the 481 private keyring, and to convert passphrases to encryption keys for 482 symmetrically encrypted messages. 484 3.7.1. String-to-Key (S2K) Specifier Types 486 There are three types of S2K specifiers currently supported, and some 487 reserved values: 489 +============+==========================+ 490 | ID | S2K Type | 491 +============+==========================+ 492 | 0 | Simple S2K | 493 +------------+--------------------------+ 494 | 1 | Salted S2K | 495 +------------+--------------------------+ 496 | 2 | Reserved value | 497 +------------+--------------------------+ 498 | 3 | Iterated and Salted S2K | 499 +------------+--------------------------+ 500 | 100 to 110 | Private/Experimental S2K | 501 +------------+--------------------------+ 503 Table 1: S2K type registry 505 These are described in the subsections below. 507 3.7.1.1. Simple S2K 509 This directly hashes the string to produce the key data. See below 510 for how this hashing is done. 512 Octet 0: 0x00 513 Octet 1: hash algorithm 515 Simple S2K hashes the passphrase to produce the session key. The 516 manner in which this is done depends on the size of the session key 517 (which will depend on the cipher used) and the size of the hash 518 algorithm's output. If the hash size is greater than the session key 519 size, the high-order (leftmost) octets of the hash are used as the 520 key. 522 If the hash size is less than the key size, multiple instances of the 523 hash context are created -- enough to produce the required key data. 524 These instances are preloaded with 0, 1, 2, ... octets of zeros (that 525 is to say, the first instance has no preloading, the second gets 526 preloaded with 1 octet of zero, the third is preloaded with two 527 octets of zeros, and so forth). 529 As the data is hashed, it is given independently to each hash 530 context. Since the contexts have been initialized differently, they 531 will each produce different hash output. Once the passphrase is 532 hashed, the output data from the multiple hashes is concatenated, 533 first hash leftmost, to produce the key data, with any excess octets 534 on the right discarded. 536 3.7.1.2. Salted S2K 538 This includes a "salt" value in the S2K specifier -- some arbitrary 539 data -- that gets hashed along with the passphrase string, to help 540 prevent dictionary attacks. 542 Octet 0: 0x01 543 Octet 1: hash algorithm 544 Octets 2-9: 8-octet salt value 546 Salted S2K is exactly like Simple S2K, except that the input to the 547 hash function(s) consists of the 8 octets of salt from the S2K 548 specifier, followed by the passphrase. 550 3.7.1.3. Iterated and Salted S2K 552 This includes both a salt and an octet count. The salt is combined 553 with the passphrase and the resulting value is hashed repeatedly. 554 This further increases the amount of work an attacker must do to try 555 dictionary attacks. 557 Octet 0: 0x03 558 Octet 1: hash algorithm 559 Octets 2-9: 8-octet salt value 560 Octet 10: count, a one-octet, coded value 562 The count is coded into a one-octet number using the following 563 formula: 565 #define EXPBIAS 6 566 count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); 568 The above formula is in C, where "Int32" is a type for a 32-bit 569 integer, and the variable "c" is the coded count, Octet 10. 571 Iterated-Salted S2K hashes the passphrase and salt data multiple 572 times. The total number of octets to be hashed is specified in the 573 encoded count in the S2K specifier. Note that the resulting count 574 value is an octet count of how many octets will be hashed, not an 575 iteration count. 577 Initially, one or more hash contexts are set up as with the other S2K 578 algorithms, depending on how many octets of key data are needed. 579 Then the salt, followed by the passphrase data, is repeatedly hashed 580 until the number of octets specified by the octet count has been 581 hashed. The one exception is that if the octet count is less than 582 the size of the salt plus passphrase, the full salt plus passphrase 583 will be hashed even though that is greater than the octet count. 584 After the hashing is done, the data is unloaded from the hash 585 context(s) as with the other S2K algorithms. 587 3.7.2. String-to-Key Usage 589 Simple S2K and Salted S2K specifiers are not particularly secure when 590 used with a low-entropy secret, such as those typically provided by 591 users. Implementations SHOULD NOT use these methods on encryption of 592 either keys and messages. 594 3.7.2.1. Secret-Key Encryption 596 An S2K specifier can be stored in the secret keyring to specify how 597 to convert the passphrase to a key that unlocks the secret data. 598 Older versions of PGP just stored a cipher algorithm octet preceding 599 the secret data or a zero to indicate that the secret data was 600 unencrypted. The MD5 hash function was always used to convert the 601 passphrase to a key for the specified cipher algorithm. 603 For compatibility, when an S2K specifier is used, the special value 604 254 or 255 is stored in the position where the hash algorithm octet 605 would have been in the old data structure. This is then followed 606 immediately by a one-octet algorithm identifier, and then by the S2K 607 specifier as encoded above. 609 Therefore, preceding the secret data there will be one of these 610 possibilities: 612 0: secret data is unencrypted (no passphrase) 613 255 or 254: followed by algorithm octet and S2K specifier 614 Cipher alg: use Simple S2K algorithm using MD5 hash 616 This last possibility, the cipher algorithm number with an implicit 617 use of MD5 and IDEA, is provided for backward compatibility; it MAY 618 be understood, but SHOULD NOT be generated, and is deprecated. 620 These are followed by an Initial Vector of the same length as the 621 block size of the cipher for the decryption of the secret values, if 622 they are encrypted, and then the secret-key values themselves. 624 3.7.2.2. Symmetric-Key Message Encryption 626 OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet 627 at the front of a message. This is used to allow S2K specifiers to 628 be used for the passphrase conversion or to create messages with a 629 mix of symmetric-key ESKs and public-key ESKs. This allows a message 630 to be decrypted either with a passphrase or a public-key pair. 632 PGP 2 always used IDEA with Simple string-to-key conversion when 633 encrypting a message with a symmetric algorithm. This is deprecated, 634 but MAY be used for backward-compatibility. 636 4. Packet Syntax 638 This section describes the packets used by OpenPGP. 640 4.1. Overview 642 An OpenPGP message is constructed from a number of records that are 643 traditionally called packets. A packet is a chunk of data that has a 644 tag specifying its meaning. An OpenPGP message, keyring, 645 certificate, and so forth consists of a number of packets. Some of 646 those packets may contain other OpenPGP packets (for example, a 647 compressed data packet, when uncompressed, contains OpenPGP packets). 649 Each packet consists of a packet header, followed by the packet body. 650 The packet header is of variable length. 652 4.2. Packet Headers 654 The first octet of the packet header is called the "Packet Tag". It 655 determines the format of the header and denotes the packet contents. 656 The remainder of the packet header is the length of the packet. 658 Note that the most significant bit is the leftmost bit, called bit 7. 659 A mask for this bit is 0x80 in hexadecimal. 661 ┌───────────────┐ 662 PTag │7 6 5 4 3 2 1 0│ 663 └───────────────┘ 664 Bit 7 -- Always one 665 Bit 6 -- New packet format if set 667 PGP 2.6.x only uses old format packets. Thus, software that 668 interoperates with those versions of PGP must only use old format 669 packets. If interoperability is not an issue, the new packet format 670 is RECOMMENDED. Note that old format packets have four bits of 671 packet tags, and new format packets have six; some features cannot be 672 used and still be backward-compatible. 674 Also note that packets with a tag greater than or equal to 16 MUST 675 use new format packets. The old format packets can only express tags 676 less than or equal to 15. 678 Old format packets contain: 680 Bits 5-2 -- packet tag 681 Bits 1-0 -- length-type 683 New format packets contain: 685 Bits 5-0 -- packet tag 687 4.2.1. Old Format Packet Lengths 689 The meaning of the length-type in old format packets is: 691 0 The packet has a one-octet length. The header is 2 octets long. 693 1 The packet has a two-octet length. The header is 3 octets long. 695 2 The packet has a four-octet length. The header is 5 octets long. 697 3 The packet is of indeterminate length. The header is 1 octet 698 long, and the implementation must determine how long the packet 699 is. If the packet is in a file, this means that the packet 700 extends until the end of the file. In general, an implementation 701 SHOULD NOT use indeterminate-length packets except where the end 702 of the data will be clear from the context, and even then it is 703 better to use a definite length, or a new format header. The new 704 format headers described below have a mechanism for precisely 705 encoding data of indeterminate length. 707 4.2.2. New Format Packet Lengths 709 New format packets have four possible ways of encoding length: 711 1. A one-octet Body Length header encodes packet lengths of up to 712 191 octets. 714 2. A two-octet Body Length header encodes packet lengths of 192 to 715 8383 octets. 717 3. A five-octet Body Length header encodes packet lengths of up to 718 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually 719 encodes a four-octet scalar number.) 721 4. When the length of the packet body is not known in advance by the 722 issuer, Partial Body Length headers encode a packet of 723 indeterminate length, effectively making it a stream. 725 4.2.2.1. One-Octet Lengths 727 A one-octet Body Length header encodes a length of 0 to 191 octets. 728 This type of length header is recognized because the one octet value 729 is less than 192. The body length is equal to: 731 bodyLen = 1st_octet; 733 4.2.2.2. Two-Octet Lengths 735 A two-octet Body Length header encodes a length of 192 to 8383 736 octets. It is recognized because its first octet is in the range 192 737 to 223. The body length is equal to: 739 bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 741 4.2.2.3. Five-Octet Lengths 743 A five-octet Body Length header consists of a single octet holding 744 the value 255, followed by a four-octet scalar. The body length is 745 equal to: 747 bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | 748 (4th_octet << 8) | 5th_octet 750 This basic set of one, two, and five-octet lengths is also used 751 internally to some packets. 753 4.2.2.4. Partial Body Lengths 755 A Partial Body Length header is one octet long and encodes the length 756 of only part of the data packet. This length is a power of 2, from 1 757 to 1,073,741,824 (2 to the 30th power). It is recognized by its one 758 octet value that is greater than or equal to 224, and less than 255. 759 The Partial Body Length is equal to: 761 partialBodyLen = 1 << (1st_octet & 0x1F); 763 Each Partial Body Length header is followed by a portion of the 764 packet body data. The Partial Body Length header specifies this 765 portion's length. Another length header (one octet, two-octet, five- 766 octet, or partial) follows that portion. The last length header in 767 the packet MUST NOT be a Partial Body Length header. Partial Body 768 Length headers may only be used for the non-final parts of the 769 packet. 771 Note also that the last Body Length header can be a zero-length 772 header. 774 An implementation MAY use Partial Body Lengths for data packets, be 775 they literal, compressed, or encrypted. The first partial length 776 MUST be at least 512 octets long. Partial Body Lengths MUST NOT be 777 used for any other packet types. 779 4.2.3. Packet Length Examples 781 These examples show ways that new format packets might encode the 782 packet lengths. 784 A packet with length 100 may have its length encoded in one octet: 785 0x64. This is followed by 100 octets of data. 787 A packet with length 1723 may have its length encoded in two octets: 788 0xC5, 0xFB. This header is followed by the 1723 octets of data. 790 A packet with length 100000 may have its length encoded in five 791 octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. 793 It might also be encoded in the following octet stream: 0xEF, first 794 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one 795 octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 796 octets of data. This is just one possible encoding, and many 797 variations are possible on the size of the Partial Body Length 798 headers, as long as a regular Body Length header encodes the last 799 portion of the data. 801 Please note that in all of these explanations, the total length of 802 the packet is the length of the header(s) plus the length of the 803 body. 805 4.3. Packet Tags 807 The packet tag denotes what type of packet the body holds. Note that 808 old format headers can only have tags less than 16, whereas new 809 format headers can have tags as great as 63. The defined tags (in 810 decimal) are as follows: 812 +==========+====================================================+ 813 | Tag | Packet Type | 814 +==========+====================================================+ 815 | 0 | Reserved - a packet tag MUST NOT have this value | 816 +----------+----------------------------------------------------+ 817 | 1 | Public-Key Encrypted Session Key Packet | 818 +----------+----------------------------------------------------+ 819 | 2 | Signature Packet | 820 +----------+----------------------------------------------------+ 821 | 3 | Symmetric-Key Encrypted Session Key Packet | 822 +----------+----------------------------------------------------+ 823 | 4 | One-Pass Signature Packet | 824 +----------+----------------------------------------------------+ 825 | 5 | Secret-Key Packet | 826 +----------+----------------------------------------------------+ 827 | 6 | Public-Key Packet | 828 +----------+----------------------------------------------------+ 829 | 7 | Secret-Subkey Packet | 830 +----------+----------------------------------------------------+ 831 | 8 | Compressed Data Packet | 832 +----------+----------------------------------------------------+ 833 | 9 | Symmetrically Encrypted Data Packet | 834 +----------+----------------------------------------------------+ 835 | 10 | Marker Packet | 836 +----------+----------------------------------------------------+ 837 | 11 | Literal Data Packet | 838 +----------+----------------------------------------------------+ 839 | 12 | Trust Packet | 840 +----------+----------------------------------------------------+ 841 | 13 | User ID Packet | 842 +----------+----------------------------------------------------+ 843 | 14 | Public-Subkey Packet | 844 +----------+----------------------------------------------------+ 845 | 17 | User Attribute Packet | 846 +----------+----------------------------------------------------+ 847 | 18 | Sym. Encrypted and Integrity Protected Data Packet | 848 +----------+----------------------------------------------------+ 849 | 19 | Modification Detection Code Packet | 850 +----------+----------------------------------------------------+ 851 | 20 | Reserved (AEAD Encrypted Data) | 852 +----------+----------------------------------------------------+ 853 | 60 to 63 | Private or Experimental Values | 854 +----------+----------------------------------------------------+ 856 Table 2: Packet type registry 858 5. Packet Types 859 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 861 A Public-Key Encrypted Session Key packet holds the session key used 862 to encrypt a message. Zero or more Public-Key Encrypted Session Key 863 packets and/or Symmetric-Key Encrypted Session Key packets may 864 precede a Symmetrically Encrypted Data Packet, which holds an 865 encrypted message. The message is encrypted with the session key, 866 and the session key is itself encrypted and stored in the Encrypted 867 Session Key packet(s). The Symmetrically Encrypted Data Packet is 868 preceded by one Public-Key Encrypted Session Key packet for each 869 OpenPGP key to which the message is encrypted. The recipient of the 870 message finds a session key that is encrypted to their public key, 871 decrypts the session key, and then uses the session key to decrypt 872 the message. 874 The body of this packet consists of: 876 * A one-octet number giving the version number of the packet type. 877 The currently defined value for packet version is 3. 879 * An eight-octet number that gives the Key ID of the public key to 880 which the session key is encrypted. If the session key is 881 encrypted to a subkey, then the Key ID of this subkey is used here 882 instead of the Key ID of the primary key. 884 * A one-octet number giving the public-key algorithm used. 886 * A string of octets that is the encrypted session key. This string 887 takes up the remainder of the packet, and its contents are 888 dependent on the public-key algorithm used. 890 Algorithm Specific Fields for RSA encryption: 892 - Multiprecision integer (MPI) of RSA encrypted value m**e mod n. 894 Algorithm Specific Fields for Elgamal encryption: 896 - MPI of Elgamal (Diffie-Hellman) value g**k mod p. 898 - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. 900 Algorithm-Specific Fields for ECDH encryption: 902 - MPI of an EC point representing an ephemeral public key. 904 - a one-octet size, followed by a symmetric key encoded using the 905 method described in Section 13.5. 907 The value "m" in the above formulas is derived from the session key 908 as follows. First, the session key is prefixed with a one-octet 909 algorithm identifier that specifies the symmetric encryption 910 algorithm used to encrypt the following Symmetrically Encrypted Data 911 Packet. Then a two-octet checksum is appended, which is equal to the 912 sum of the preceding session key octets, not including the algorithm 913 identifier, modulo 65536. This value is then encoded as described in 914 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to 915 form the "m" value used in the formulas above. See Section 14.1 in 916 this document for notes on OpenPGP's use of PKCS#1. 918 Note that when an implementation forms several PKESKs with one 919 session key, forming a message that can be decrypted by several keys, 920 the implementation MUST make a new PKCS#1 encoding for each key. 922 An implementation MAY accept or use a Key ID of zero as a "wild card" 923 or "speculative" Key ID. In this case, the receiving implementation 924 would try all available private keys, checking for a valid decrypted 925 session key. This format helps reduce traffic analysis of messages. 927 5.2. Signature Packet (Tag 2) 929 A Signature packet describes a binding between some public key and 930 some data. The most common signatures are a signature of a file or a 931 block of text, and a signature that is a certification of a User ID. 933 Three versions of Signature packets are defined. Version 3 provides 934 basic signature information, while versions 4 and 5 provide an 935 expandable format with subpackets that can specify more information 936 about the signature. PGP 2.6.x only accepts version 3 signatures. 938 Implementations MUST generate version 5 signatures when using a 939 version 5 key. Implementations SHOULD generate V4 signatures with 940 version 4 keys. Implementations MUST NOT create version 3 941 signatures; they MAY accept version 3 signatures. 943 5.2.1. Signature Types 945 There are a number of possible meanings for a signature, which are 946 indicated in a signature type octet in any given signature. Please 947 note that the vagueness of these meanings is not a flaw, but a 948 feature of the system. Because OpenPGP places final authority for 949 validity upon the receiver of a signature, it may be that one 950 signer's casual act might be more rigorous than some other 951 authority's positive act. See Section 5.2.4 for detailed information 952 on how to compute and verify signatures of each type. 954 These meanings are as follows: 956 0x00: Signature of a binary document. 957 This means the signer owns it, created it, or certifies that it 958 has not been modified. 960 0x01: Signature of a canonical text document. 961 This means the signer owns it, created it, or certifies that it 962 has not been modified. The signature is calculated over the text 963 data with its line endings converted to . 965 0x02: Standalone signature. 966 This signature is a signature of only its own subpacket contents. 967 It is calculated identically to a signature over a zero-length 968 binary document. Note that it doesn't make sense to have a V3 969 standalone signature. 971 0x10: Generic certification of a User ID and Public-Key packet. 972 The issuer of this certification does not make any particular 973 assertion as to how well the certifier has checked that the owner 974 of the key is in fact the person described by the User ID. 976 0x11: Persona certification of a User ID and Public-Key packet. 977 The issuer of this certification has not done any verification of 978 the claim that the owner of this key is the User ID specified. 980 0x12: Casual certification of a User ID and Public-Key packet. 981 The issuer of this certification has done some casual verification 982 of the claim of identity. 984 0x13: Positive certification of a User ID and Public-Key packet. 985 The issuer of this certification has done substantial verification 986 of the claim of identity. Most OpenPGP implementations make their 987 "key signatures" as 0x10 certifications. Some implementations can 988 issue 0x11-0x13 certifications, but few differentiate between the 989 types. 991 0x18: Subkey Binding Signature. 992 This signature is a statement by the top-level signing key that 993 indicates that it owns the subkey. This signature is calculated 994 directly on the primary key and subkey, and not on any User ID or 995 other packets. A signature that binds a signing subkey MUST have 996 an Embedded Signature subpacket in this binding signature that 997 contains a 0x19 signature made by the signing subkey on the 998 primary key and subkey. 1000 0x19: Primary Key Binding Signature. 1001 This signature is a statement by a signing subkey, indicating that 1002 it is owned by the primary key and subkey. This signature is 1003 calculated the same way as a 0x18 signature: directly on the 1004 primary key and subkey, and not on any User ID or other packets. 1006 0x1F: Signature directly on a key. 1007 This signature is calculated directly on a key. It binds the 1008 information in the Signature subpackets to the key, and is 1009 appropriate to be used for subpackets that provide information 1010 about the key, such as the Revocation Key subpacket. It is also 1011 appropriate for statements that non-self certifiers want to make 1012 about the key itself, rather than the binding between a key and a 1013 name. 1015 0x20: Key revocation signature. 1016 The signature is calculated directly on the key being revoked. A 1017 revoked key is not to be used. Only revocation signatures by the 1018 key being revoked, or by an authorized revocation key, should be 1019 considered valid revocation signatures. 1021 0x28: Subkey revocation signature. 1022 The signature is calculated directly on the subkey being revoked. 1023 A revoked subkey is not to be used. Only revocation signatures by 1024 the top-level signature key that is bound to this subkey, or by an 1025 authorized revocation key, should be considered valid revocation 1026 signatures. 1028 0x30: Certification revocation signature. 1029 This signature revokes an earlier User ID certification signature 1030 (signature class 0x10 through 0x13) or direct-key signature 1031 (0x1F). It should be issued by the same key that issued the 1032 revoked signature or an authorized revocation key. The signature 1033 is computed over the same data as the certificate that it revokes, 1034 and should have a later creation date than that certificate. 1036 0x40: Timestamp signature. 1037 This signature is only meaningful for the timestamp contained in 1038 it. 1040 0x50: Third-Party Confirmation signature. 1041 This signature is a signature over some other OpenPGP Signature 1042 packet(s). It is analogous to a notary seal on the signed data. 1043 A third-party signature SHOULD include Signature Target 1044 subpacket(s) to give easy identification. Note that we really do 1045 mean SHOULD. There are plausible uses for this (such as a blind 1046 party that only sees the signature, not the key or source 1047 document) that cannot include a target subpacket. 1049 5.2.2. Version 3 Signature Packet Format 1051 The body of a version 3 Signature Packet contains: 1053 * One-octet version number (3). 1055 * One-octet length of following hashed material. MUST be 5. 1057 - One-octet signature type. 1059 - Four-octet creation time. 1061 * Eight-octet Key ID of signer. 1063 * One-octet public-key algorithm. 1065 * One-octet hash algorithm. 1067 * Two-octet field holding left 16 bits of signed hash value. 1069 * One or more multiprecision integers comprising the signature. 1070 This portion is algorithm specific, as described below. 1072 The concatenation of the data to be signed, the signature type, and 1073 creation time from the Signature packet (5 additional octets) is 1074 hashed. The resulting hash value is used in the signature algorithm. 1075 The high 16 bits (first two octets) of the hash are included in the 1076 Signature packet to provide a way to reject some invalid signatures 1077 without performing a signature verification. 1079 Algorithm-Specific Fields for RSA signatures: 1081 * Multiprecision integer (MPI) of RSA signature value m**d mod n. 1083 Algorithm-Specific Fields for DSA and ECDSA signatures: 1085 * MPI of DSA or ECDSA value r. 1087 * MPI of DSA or ECDSA value s. 1089 The signature calculation is based on a hash of the signed data, as 1090 described above. The details of the calculation are different for 1091 DSA signatures than for RSA signatures. 1093 With RSA signatures, the hash value is encoded using PKCS#1 encoding 1094 type EMSA-PKCS1-v1_5 as described in Section 9.2 of [RFC3447]. This 1095 requires inserting the hash value as an octet string into an ASN.1 1096 structure. The object identifier for the type of hash being used is 1097 included in the structure. The hexadecimal representations for the 1098 currently defined hash algorithms are as follows: 1100 +============+======================================================+ 1101 | algorithm | hexadecimal represenatation | 1102 +============+======================================================+ 1103 | MD5 | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 | 1104 +------------+------------------------------------------------------+ 1105 | RIPEMD-160 | 0x2B, 0x24, 0x03, 0x02, 0x01 | 1106 +------------+------------------------------------------------------+ 1107 | SHA-1 | 0x2B, 0x0E, 0x03, 0x02, 0x1A | 1108 +------------+------------------------------------------------------+ 1109 | SHA224 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1110 | | 0x02, 0x04 | 1111 +------------+------------------------------------------------------+ 1112 | SHA256 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1113 | | 0x02, 0x01 | 1114 +------------+------------------------------------------------------+ 1115 | SHA384 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1116 | | 0x02, 0x02 | 1117 +------------+------------------------------------------------------+ 1118 | SHA512 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, | 1119 | | 0x02, 0x03 | 1120 +------------+------------------------------------------------------+ 1122 Table 3: Hash hexadecimal representations 1124 The ASN.1 Object Identifiers (OIDs) are as follows: 1126 +============+========================+ 1127 | algorithm | OID | 1128 +============+========================+ 1129 | MD5 | 1.2.840.113549.2.5 | 1130 +------------+------------------------+ 1131 | RIPEMD-160 | 1.3.36.3.2.1 | 1132 +------------+------------------------+ 1133 | SHA-1 | 1.3.14.3.2.26 | 1134 +------------+------------------------+ 1135 | SHA224 | 2.16.840.1.101.3.4.2.4 | 1136 +------------+------------------------+ 1137 | SHA256 | 2.16.840.1.101.3.4.2.1 | 1138 +------------+------------------------+ 1139 | SHA384 | 2.16.840.1.101.3.4.2.2 | 1140 +------------+------------------------+ 1141 | SHA512 | 2.16.840.1.101.3.4.2.3 | 1142 +------------+------------------------+ 1144 Table 4: Hash OIDs 1146 The full hash prefixes for these are as follows: 1148 +============+==========================================+ 1149 | algorithm | full hash prefix | 1150 +============+==========================================+ 1151 | MD5 | 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, | 1152 | | 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, | 1153 | | 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 | 1154 +------------+------------------------------------------+ 1155 | RIPEMD-160 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1156 | | 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, | 1157 | | 0x00, 0x04, 0x14 | 1158 +------------+------------------------------------------+ 1159 | SHA-1 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, | 1160 | | 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, | 1161 | | 0x00, 0x04, 0x14 | 1162 +------------+------------------------------------------+ 1163 | SHA224 | 0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, | 1164 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1165 | | 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C | 1166 +------------+------------------------------------------+ 1167 | SHA256 | 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, | 1168 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1169 | | 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 | 1170 +------------+------------------------------------------+ 1171 | SHA384 | 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, | 1172 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1173 | | 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 | 1174 +------------+------------------------------------------+ 1175 | SHA512 | 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, | 1176 | | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, | 1177 | | 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 | 1178 +------------+------------------------------------------+ 1180 Table 5: Hash hexadecimal prefixes 1182 DSA signatures MUST use hashes that are equal in size to the number 1183 of bits of q, the group generated by the DSA key's generator value. 1185 If the output size of the chosen hash is larger than the number of 1186 bits of q, the hash result is truncated to fit by taking the number 1187 of leftmost bits equal to the number of bits of q. This (possibly 1188 truncated) hash function result is treated as a number and used 1189 directly in the DSA signature algorithm. 1191 5.2.3. Version 4 and 5 Signature Packet Formats 1193 The body of a V4 or V5 Signature packet contains: 1195 * One-octet version number. This is 4 for V4 signatures and 5 for 1196 V5 signatures. 1198 * One-octet signature type. 1200 * One-octet public-key algorithm. 1202 * One-octet hash algorithm. 1204 * Two-octet scalar octet count for following hashed subpacket data. 1205 Note that this is the length in octets of all of the hashed 1206 subpackets; a pointer incremented by this number will skip over 1207 the hashed subpackets. 1209 * Hashed subpacket data set (zero or more subpackets). 1211 * Two-octet scalar octet count for the following unhashed subpacket 1212 data. Note that this is the length in octets of all of the 1213 unhashed subpackets; a pointer incremented by this number will 1214 skip over the unhashed subpackets. 1216 * Unhashed subpacket data set (zero or more subpackets). 1218 * Two-octet field holding the left 16 bits of the signed hash value. 1220 * One or more multiprecision integers comprising the signature. 1221 This portion is algorithm specific: 1223 Algorithm-Specific Fields for RSA signatures: 1225 - Multiprecision integer (MPI) of RSA signature value m**d mod n. 1227 Algorithm-Specific Fields for DSA or ECDSA signatures: 1229 - MPI of DSA or ECDSA value r. 1231 - MPI of DSA or ECDSA value s. 1233 Algorithm-Specific Fields for EdDSA signatures: 1235 - MPI of an EC point r. 1237 - EdDSA value s, in MPI, in the little endian representation. 1239 The format of R and S for use with EdDSA is described in [RFC8032]. 1240 A version 3 signature MUST NOT be created and MUST NOT be used with 1241 EdDSA. 1243 The concatenation of the data being signed and the signature data 1244 from the version number through the hashed subpacket data (inclusive) 1245 is hashed. The resulting hash value is what is signed. The high 16 1246 bits (first two octets) of the hash are included in the Signature 1247 packet to provide a way to reject some invalid signatures without 1248 performing a signature verification. 1250 There are two fields consisting of Signature subpackets. The first 1251 field is hashed with the rest of the signature data, while the second 1252 is unhashed. The second set of subpackets is not cryptographically 1253 protected by the signature and should include only advisory 1254 information. 1256 The difference between a V4 and V5 signature is that the latter 1257 includes additional meta data. 1259 The algorithms for converting the hash function result to a signature 1260 are described in a section below. 1262 5.2.3.1. Signature Subpacket Specification 1264 A subpacket data set consists of zero or more Signature subpackets. 1265 In Signature packets, the subpacket data set is preceded by a two- 1266 octet scalar count of the length in octets of all the subpackets. A 1267 pointer incremented by this number will skip over the subpacket data 1268 set. 1270 Each subpacket consists of a subpacket header and a body. The header 1271 consists of: 1273 * the subpacket length (1, 2, or 5 octets), 1275 * the subpacket type (1 octet), 1277 and is followed by the subpacket-specific data. 1279 The length includes the type octet but not this length. Its format 1280 is similar to the "new" format packet header lengths, but cannot have 1281 Partial Body Lengths. That is: 1283 if the 1st octet < 192, then 1284 lengthOfLength = 1 1285 subpacketLen = 1st_octet 1287 if the 1st octet >= 192 and < 255, then 1288 lengthOfLength = 2 1289 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 1291 if the 1st octet = 255, then 1292 lengthOfLength = 5 1293 subpacket length = [four-octet scalar starting at 2nd_octet] 1295 The value of the subpacket type octet may be: 1297 +============+===========================================+ 1298 | Type | Description | 1299 +============+===========================================+ 1300 | 0 | Reserved | 1301 +------------+-------------------------------------------+ 1302 | 1 | Reserved | 1303 +------------+-------------------------------------------+ 1304 | 2 | Signature Creation Time | 1305 +------------+-------------------------------------------+ 1306 | 3 | Signature Expiration Time | 1307 +------------+-------------------------------------------+ 1308 | 4 | Exportable Certification | 1309 +------------+-------------------------------------------+ 1310 | 5 | Trust Signature | 1311 +------------+-------------------------------------------+ 1312 | 6 | Regular Expression | 1313 +------------+-------------------------------------------+ 1314 | 7 | Revocable | 1315 +------------+-------------------------------------------+ 1316 | 8 | Reserved | 1317 +------------+-------------------------------------------+ 1318 | 9 | Key Expiration Time | 1319 +------------+-------------------------------------------+ 1320 | 10 | Placeholder for backward compatibility | 1321 +------------+-------------------------------------------+ 1322 | 11 | Preferred Symmetric Algorithms | 1323 +------------+-------------------------------------------+ 1324 | 12 | Revocation Key | 1325 +------------+-------------------------------------------+ 1326 | 13 to 15 | Reserved | 1327 +------------+-------------------------------------------+ 1328 | 16 | Issuer | 1329 +------------+-------------------------------------------+ 1330 | 17 to 19 | Reserved | 1331 +------------+-------------------------------------------+ 1332 | 20 | Notation Data | 1333 +------------+-------------------------------------------+ 1334 | 21 | Preferred Hash Algorithms | 1335 +------------+-------------------------------------------+ 1336 | 22 | Preferred Compression Algorithms | 1337 +------------+-------------------------------------------+ 1338 | 23 | Key Server Preferences | 1339 +------------+-------------------------------------------+ 1340 | 24 | Preferred Key Server | 1341 +------------+-------------------------------------------+ 1342 | 25 | Primary User ID | 1343 +------------+-------------------------------------------+ 1344 | 26 | Policy URI | 1345 +------------+-------------------------------------------+ 1346 | 27 | Key Flags | 1347 +------------+-------------------------------------------+ 1348 | 28 | Signer's User ID | 1349 +------------+-------------------------------------------+ 1350 | 29 | Reason for Revocation | 1351 +------------+-------------------------------------------+ 1352 | 30 | Features | 1353 +------------+-------------------------------------------+ 1354 | 31 | Signature Target | 1355 +------------+-------------------------------------------+ 1356 | 32 | Embedded Signature | 1357 +------------+-------------------------------------------+ 1358 | 33 | Issuer Fingerprint | 1359 +------------+-------------------------------------------+ 1360 | 34 | Reserved (Preferred AEAD Algorithms) | 1361 +------------+-------------------------------------------+ 1362 | 35 | Reserved (Intended Recipient Fingerprint) | 1363 +------------+-------------------------------------------+ 1364 | 37 | Reserved (Attested Certifications) | 1365 +------------+-------------------------------------------+ 1366 | 38 | Reserved (Key Block) | 1367 +------------+-------------------------------------------+ 1368 | 100 to 110 | Private or experimental | 1369 +------------+-------------------------------------------+ 1371 Table 6: Subpacket type registry 1373 An implementation SHOULD ignore any subpacket of a type that it does 1374 not recognize. 1376 Bit 7 of the subpacket type is the "critical" bit. If set, it 1377 denotes that the subpacket is one that is critical for the evaluator 1378 of the signature to recognize. If a subpacket is encountered that is 1379 marked critical but is unknown to the evaluating software, the 1380 evaluator SHOULD consider the signature to be in error. 1382 An evaluator may "recognize" a subpacket, but not implement it. The 1383 purpose of the critical bit is to allow the signer to tell an 1384 evaluator that it would prefer a new, unknown feature to generate an 1385 error than be ignored. 1387 Implementations SHOULD implement the three preferred algorithm 1388 subpackets (11, 21, and 22), as well as the "Reason for Revocation" 1389 subpacket. Note, however, that if an implementation chooses not to 1390 implement some of the preferences, it is required to behave in a 1391 polite manner to respect the wishes of those users who do implement 1392 these preferences. 1394 5.2.3.2. Signature Subpacket Types 1396 A number of subpackets are currently defined. Some subpackets apply 1397 to the signature itself and some are attributes of the key. 1398 Subpackets that are found on a self-signature are placed on a 1399 certification made by the key itself. Note that a key may have more 1400 than one User ID, and thus may have more than one self-signature, and 1401 differing subpackets. 1403 A subpacket may be found either in the hashed or unhashed subpacket 1404 sections of a signature. If a subpacket is not hashed, then the 1405 information in it cannot be considered definitive because it is not 1406 part of the signature proper. 1408 5.2.3.3. Notes on Self-Signatures 1410 A self-signature is a binding signature made by the key to which the 1411 signature refers. There are three types of self-signatures, the 1412 certification signatures (types 0x10-0x13), the direct-key signature 1413 (type 0x1F), and the subkey binding signature (type 0x18). For 1414 certification self-signatures, each User ID may have a self- 1415 signature, and thus different subpackets in those self-signatures. 1416 For subkey binding signatures, each subkey in fact has a self- 1417 signature. Subpackets that appear in a certification self-signature 1418 apply to the user name, and subpackets that appear in the subkey 1419 self-signature apply to the subkey. Lastly, subpackets on the 1420 direct-key signature apply to the entire key. 1422 Implementing software should interpret a self-signature's preference 1423 subpackets as narrowly as possible. For example, suppose a key has 1424 two user names, Alice and Bob. Suppose that Alice prefers the 1425 symmetric algorithm AES-256, and Bob prefers Camellia-256 or AES-128. 1426 If the software locates this key via Alice's name, then the preferred 1427 algorithm is AES-256; if software locates the key via Bob's name, 1428 then the preferred algorithm is Camellia-256. If the key is located 1429 by Key ID, the algorithm of the primary User ID of the key provides 1430 the preferred symmetric algorithm. 1432 Revoking a self-signature or allowing it to expire has a semantic 1433 meaning that varies with the signature type. Revoking the self- 1434 signature on a User ID effectively retires that user name. The self- 1435 signature is a statement, "My name X is tied to my signing key K" and 1436 is corroborated by other users' certifications. If another user 1437 revokes their certification, they are effectively saying that they no 1438 longer believe that name and that key are tied together. Similarly, 1439 if the users themselves revoke their self-signature, then the users 1440 no longer go by that name, no longer have that email address, etc. 1441 Revoking a binding signature effectively retires that subkey. 1442 Revoking a direct-key signature cancels that signature. Please see 1443 Section 5.2.3.23 for more relevant detail. 1445 Since a self-signature contains important information about the key's 1446 use, an implementation SHOULD allow the user to rewrite the self- 1447 signature, and important information in it, such as preferences and 1448 key expiration. 1450 It is good practice to verify that a self-signature imported into an 1451 implementation doesn't advertise features that the implementation 1452 doesn't support, rewriting the signature as appropriate. 1454 An implementation that encounters multiple self-signatures on the 1455 same object may resolve the ambiguity in any way it sees fit, but it 1456 is RECOMMENDED that priority be given to the most recent self- 1457 signature. 1459 5.2.3.4. Signature Creation Time 1461 (4-octet time field) 1463 The time the signature was made. 1465 MUST be present in the hashed area. 1467 5.2.3.5. Issuer 1469 (8-octet Key ID) 1471 The OpenPGP Key ID of the key issuing the signature. If the version 1472 of that key is greater than 4, this subpacket MUST NOT be included in 1473 the signature. 1475 5.2.3.6. Key Expiration Time 1477 (4-octet time field) 1479 The validity period of the key. This is the number of seconds after 1480 the key creation time that the key expires. If this is not present 1481 or has a value of zero, the key never expires. This is found only on 1482 a self-signature. 1484 5.2.3.7. Preferred Symmetric Algorithms 1486 (array of one-octet values) 1488 Symmetric algorithm numbers that indicate which algorithms the key 1489 holder prefers to use. The subpacket body is an ordered list of 1490 octets with the most preferred listed first. It is assumed that only 1491 algorithms listed are supported by the recipient's software. 1492 Algorithm numbers are in Section 9.3. This is only found on a self- 1493 signature. 1495 5.2.3.8. Preferred Hash Algorithms 1497 (array of one-octet values) 1499 Message digest algorithm numbers that indicate which algorithms the 1500 key holder prefers to receive. Like the preferred symmetric 1501 algorithms, the list is ordered. Algorithm numbers are in 1502 Section 9.5. This is only found on a self-signature. 1504 5.2.3.9. Preferred Compression Algorithms 1506 (array of one-octet values) 1508 Compression algorithm numbers that indicate which algorithms the key 1509 holder prefers to use. Like the preferred symmetric algorithms, the 1510 list is ordered. Algorithm numbers are in Section 9.4. If this 1511 subpacket is not included, ZIP is preferred. A zero denotes that 1512 uncompressed data is preferred; the key holder's software might have 1513 no compression software in that implementation. This is only found 1514 on a self-signature. 1516 5.2.3.10. Signature Expiration Time 1518 (4-octet time field) 1520 The validity period of the signature. This is the number of seconds 1521 after the signature creation time that the signature expires. If 1522 this is not present or has a value of zero, it never expires. 1524 5.2.3.11. Exportable Certification 1526 (1 octet of exportability, 0 for not, 1 for exportable) 1528 This subpacket denotes whether a certification signature is 1529 "exportable", to be used by other users than the signature's issuer. 1530 The packet body contains a Boolean flag indicating whether the 1531 signature is exportable. If this packet is not present, the 1532 certification is exportable; it is equivalent to a flag containing a 1533 1. 1535 Non-exportable, or "local", certifications are signatures made by a 1536 user to mark a key as valid within that user's implementation only. 1538 Thus, when an implementation prepares a user's copy of a key for 1539 transport to another user (this is the process of "exporting" the 1540 key), any local certification signatures are deleted from the key. 1542 The receiver of a transported key "imports" it, and likewise trims 1543 any local certifications. In normal operation, there won't be any, 1544 assuming the import is performed on an exported key. However, there 1545 are instances where this can reasonably happen. For example, if an 1546 implementation allows keys to be imported from a key database in 1547 addition to an exported key, then this situation can arise. 1549 Some implementations do not represent the interest of a single user 1550 (for example, a key server). Such implementations always trim local 1551 certifications from any key they handle. 1553 5.2.3.12. Revocable 1555 (1 octet of revocability, 0 for not, 1 for revocable) 1557 Signature's revocability status. The packet body contains a Boolean 1558 flag indicating whether the signature is revocable. Signatures that 1559 are not revocable have any later revocation signatures ignored. They 1560 represent a commitment by the signer that he cannot revoke his 1561 signature for the life of his key. If this packet is not present, 1562 the signature is revocable. 1564 5.2.3.13. Trust Signature 1566 (1 octet "level" (depth), 1 octet of trust amount) 1568 Signer asserts that the key is not only valid but also trustworthy at 1569 the specified level. Level 0 has the same meaning as an ordinary 1570 validity signature. Level 1 means that the signed key is asserted to 1571 be a valid trusted introducer, with the 2nd octet of the body 1572 specifying the degree of trust. Level 2 means that the signed key is 1573 asserted to be trusted to issue level 1 trust signatures, i.e., that 1574 it is a "meta introducer". Generally, a level n trust signature 1575 asserts that a key is trusted to issue level n-1 trust signatures. 1576 The trust amount is in a range from 0-255, interpreted such that 1577 values less than 120 indicate partial trust and values of 120 or 1578 greater indicate complete trust. Implementations SHOULD emit values 1579 of 60 for partial trust and 120 for complete trust. 1581 5.2.3.14. Regular Expression 1583 (null-terminated regular expression) 1585 Used in conjunction with trust Signature packets (of level > 0) to 1586 limit the scope of trust that is extended. Only signatures by the 1587 target key on User IDs that match the regular expression in the body 1588 of this packet have trust extended by the trust Signature subpacket. 1589 The regular expression uses the same syntax as the Henry Spencer's 1590 "almost public domain" regular expression [REGEX] package. A 1591 description of the syntax is found in Section 8. 1593 5.2.3.15. Revocation Key 1595 (1 octet of class, 1 octet of public-key algorithm ID, 20 or 32 1596 octets of fingerprint) 1598 V4 keys use the full 20 octet fingerprint; V5 keys use the full 32 1599 octet fingerprint 1601 Authorizes the specified key to issue revocation signatures for this 1602 key. Class octet must have bit 0x80 set. If the bit 0x40 is set, 1603 then this means that the revocation information is sensitive. Other 1604 bits are for future expansion to other kinds of authorizations. This 1605 is only found on a direct-key self-signature (type 0x1f). The use on 1606 other types of self-signatures is unspecified. 1608 If the "sensitive" flag is set, the keyholder feels this subpacket 1609 contains private trust information that describes a real-world 1610 sensitive relationship. If this flag is set, implementations SHOULD 1611 NOT export this signature to other users except in cases where the 1612 data needs to be available: when the signature is being sent to the 1613 designated revoker, or when it is accompanied by a revocation 1614 signature from that revoker. Note that it may be appropriate to 1615 isolate this subpacket within a separate signature so that it is not 1616 combined with other subpackets that need to be exported. 1618 5.2.3.16. Notation Data 1620 (4 octets of flags, 2 octets of name length (M), 2 octets of value 1621 length (N), M octets of name data, N octets of value data) 1623 This subpacket describes a "notation" on the signature that the 1624 issuer wishes to make. The notation has a name and a value, each of 1625 which are strings of octets. There may be more than one notation in 1626 a signature. Notations can be used for any extension the issuer of 1627 the signature cares to make. The "flags" field holds four octets of 1628 flags. 1630 All undefined flags MUST be zero. Defined flags are as follows: 1632 First octet: 1634 +======+================+==========================+ 1635 | flag | shorthand | definition | 1636 +======+================+==========================+ 1637 | 0x80 | human-readable | This note value is text. | 1638 +------+----------------+--------------------------+ 1640 Table 7: Notation flag registry (first octet) 1642 Other octets: none. 1644 Notation names are arbitrary strings encoded in UTF-8. They reside 1645 in two namespaces: The IETF namespace and the user namespace. 1647 The IETF namespace is registered with IANA. These names MUST NOT 1648 contain the "@" character (0x40). This is a tag for the user 1649 namespace. 1651 Names in the user namespace consist of a UTF-8 string tag followed by 1652 "@" followed by a DNS domain name. Note that the tag MUST NOT 1653 contain an "@" character. For example, the "sample" tag used by 1654 Example Corporation could be "sample@example.com". 1656 Names in a user space are owned and controlled by the owners of that 1657 domain. Obviously, it's bad form to create a new name in a DNS space 1658 that you don't own. 1660 Since the user namespace is in the form of an email address, 1661 implementers MAY wish to arrange for that address to reach a person 1662 who can be consulted about the use of the named tag. Note that due 1663 to UTF-8 encoding, not all valid user space name tags are valid email 1664 addresses. 1666 If there is a critical notation, the criticality applies to that 1667 specific notation and not to notations in general. 1669 5.2.3.17. Key Server Preferences 1671 (N octets of flags) 1673 This is a list of one-bit flags that indicate preferences that the 1674 key holder has about how the key is handled on a key server. All 1675 undefined flags MUST be zero. 1677 First octet: 1679 +======+===========+============================================+ 1680 | flag | shorthand | definition | 1681 +======+===========+============================================+ 1682 | 0x80 | No-modify | The key holder requests that this key only | 1683 | | | be modified or updated by the key holder | 1684 | | | or an administrator of the key server. | 1685 +------+-----------+--------------------------------------------+ 1687 Table 8: Key server preferences flag registry (first octet) 1689 This is found only on a self-signature. 1691 5.2.3.18. Preferred Key Server 1693 (String) 1695 This is a URI of a key server that the key holder prefers be used for 1696 updates. Note that keys with multiple User IDs can have a preferred 1697 key server for each User ID. Note also that since this is a URI, the 1698 key server can actually be a copy of the key retrieved by ftp, http, 1699 finger, etc. 1701 5.2.3.19. Primary User ID 1703 (1 octet, Boolean) 1705 This is a flag in a User ID's self-signature that states whether this 1706 User ID is the main User ID for this key. It is reasonable for an 1707 implementation to resolve ambiguities in preferences, etc. by 1708 referring to the primary User ID. If this flag is absent, its value 1709 is zero. If more than one User ID in a key is marked as primary, the 1710 implementation may resolve the ambiguity in any way it sees fit, but 1711 it is RECOMMENDED that priority be given to the User ID with the most 1712 recent self-signature. 1714 When appearing on a self-signature on a User ID packet, this 1715 subpacket applies only to User ID packets. When appearing on a self- 1716 signature on a User Attribute packet, this subpacket applies only to 1717 User Attribute packets. That is to say, there are two different and 1718 independent "primaries" -- one for User IDs, and one for User 1719 Attributes. 1721 5.2.3.20. Policy URI 1723 (String) 1725 This subpacket contains a URI of a document that describes the policy 1726 under which the signature was issued. 1728 5.2.3.21. Key Flags 1730 (N octets of flags) 1732 This subpacket contains a list of binary flags that hold information 1733 about a key. It is a string of octets, and an implementation MUST 1734 NOT assume a fixed size. This is so it can grow over time. If a 1735 list is shorter than an implementation expects, the unstated flags 1736 are considered to be zero. The defined flags are as follows: 1738 First octet: 1740 +======+=================================================+ 1741 | flag | definition | 1742 +======+=================================================+ 1743 | 0x01 | This key may be used to certify other keys. | 1744 +------+-------------------------------------------------+ 1745 | 0x02 | This key may be used to sign data. | 1746 +------+-------------------------------------------------+ 1747 | 0x04 | This key may be used to encrypt communications. | 1748 +------+-------------------------------------------------+ 1749 | 0x08 | This key may be used to encrypt storage. | 1750 +------+-------------------------------------------------+ 1751 | 0x10 | The private component of this key may have been | 1752 | | split by a secret-sharing mechanism. | 1753 +------+-------------------------------------------------+ 1754 | 0x20 | This key may be used for authentication. | 1755 +------+-------------------------------------------------+ 1756 | 0x80 | The private component of this key may be in the | 1757 | | possession of more than one person. | 1758 +------+-------------------------------------------------+ 1760 Table 9: Key flags registry (first octet) 1762 Second octet: 1764 +======+==========================+ 1765 | flag | definition | 1766 +======+==========================+ 1767 | 0x04 | Reserved (ADSK). | 1768 +------+--------------------------+ 1769 | 0x08 | Reserved (timestamping). | 1770 +------+--------------------------+ 1772 Table 10: Key flags registry 1773 (second octet) 1775 Usage notes: 1777 The flags in this packet may appear in self-signatures or in 1778 certification signatures. They mean different things depending on 1779 who is making the statement -- for example, a certification signature 1780 that has the "sign data" flag is stating that the certification is 1781 for that use. On the other hand, the "communications encryption" 1782 flag in a self-signature is stating a preference that a given key be 1783 used for communications. Note however, that it is a thorny issue to 1784 determine what is "communications" and what is "storage". This 1785 decision is left wholly up to the implementation; the authors of this 1786 document do not claim any special wisdom on the issue and realize 1787 that accepted opinion may change. 1789 The "split key" (0x10) and "group key" (0x80) flags are placed on a 1790 self-signature only; they are meaningless on a certification 1791 signature. They SHOULD be placed only on a direct-key signature 1792 (type 0x1F) or a subkey signature (type 0x18), one that refers to the 1793 key the flag applies to. 1795 5.2.3.22. Signer's User ID 1797 (String) 1799 This subpacket allows a keyholder to state which User ID is 1800 responsible for the signing. Many keyholders use a single key for 1801 different purposes, such as business communications as well as 1802 personal communications. This subpacket allows such a keyholder to 1803 state which of their roles is making a signature. 1805 This subpacket is not appropriate to use to refer to a User Attribute 1806 packet. 1808 5.2.3.23. Reason for Revocation 1810 (1 octet of revocation code, N octets of reason string) 1812 This subpacket is used only in key revocation and certification 1813 revocation signatures. It describes the reason why the key or 1814 certificate was revoked. 1816 The first octet contains a machine-readable code that denotes the 1817 reason for the revocation: 1819 +=========+==================================+ 1820 | Code | Reason | 1821 +=========+==================================+ 1822 | 0 | No reason specified (key | 1823 | | revocations or cert revocations) | 1824 +---------+----------------------------------+ 1825 | 1 | Key is superseded (key | 1826 | | revocations) | 1827 +---------+----------------------------------+ 1828 | 2 | Key material has been | 1829 | | compromised (key revocations) | 1830 +---------+----------------------------------+ 1831 | 3 | Key is retired and no longer | 1832 | | used (key revocations) | 1833 +---------+----------------------------------+ 1834 | 32 | User ID information is no longer | 1835 | | valid (cert revocations) | 1836 +---------+----------------------------------+ 1837 | 100-110 | Private Use | 1838 +---------+----------------------------------+ 1840 Table 11: Reasons for revocation 1842 Following the revocation code is a string of octets that gives 1843 information about the Reason for Revocation in human-readable form 1844 (UTF-8). The string may be null, that is, of zero length. The 1845 length of the subpacket is the length of the reason string plus one. 1846 An implementation SHOULD implement this subpacket, include it in all 1847 revocation signatures, and interpret revocations appropriately. 1848 There are important semantic differences between the reasons, and 1849 there are thus important reasons for revoking signatures. 1851 If a key has been revoked because of a compromise, all signatures 1852 created by that key are suspect. However, if it was merely 1853 superseded or retired, old signatures are still valid. If the 1854 revoked signature is the self-signature for certifying a User ID, a 1855 revocation denotes that that user name is no longer in use. Such a 1856 revocation SHOULD include a 0x20 code. 1858 Note that any signature may be revoked, including a certification on 1859 some other person's key. There are many good reasons for revoking a 1860 certification signature, such as the case where the keyholder leaves 1861 the employ of a business with an email address. A revoked 1862 certification is no longer a part of validity calculations. 1864 5.2.3.24. Features 1866 (N octets of flags) 1868 The Features subpacket denotes which advanced OpenPGP features a 1869 user's implementation supports. This is so that as features are 1870 added to OpenPGP that cannot be backwards-compatible, a user can 1871 state that they can use that feature. The flags are single bits that 1872 indicate that a given feature is supported. 1874 This subpacket is similar to a preferences subpacket, and only 1875 appears in a self-signature. 1877 An implementation SHOULD NOT use a feature listed when sending to a 1878 user who does not state that they can use it. 1880 Defined features are as follows: 1882 First octet: 1884 +=========+============================================+ 1885 | feature | definition | 1886 +=========+============================================+ 1887 | 0x01 | Modification Detection (packets 18 and 19) | 1888 +---------+--------------------------------------------+ 1889 | 0x02 | Reserved (AEAD Data & v5 SKESK) | 1890 +---------+--------------------------------------------+ 1891 | 0x04 | Version 5 Public-Key Packet format and | 1892 | | corresponding new fingerprint format | 1893 +---------+--------------------------------------------+ 1895 Table 12: Features registry 1897 If an implementation implements any of the defined features, it 1898 SHOULD implement the Features subpacket, too. 1900 An implementation may freely infer features from other suitable 1901 implementation-dependent mechanisms. 1903 5.2.3.25. Signature Target 1905 (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) 1907 This subpacket identifies a specific target signature to which a 1908 signature refers. For revocation signatures, this subpacket provides 1909 explicit designation of which signature is being revoked. For a 1910 third-party or timestamp signature, this designates what signature is 1911 signed. All arguments are an identifier of that target signature. 1913 The N octets of hash data MUST be the size of the hash of the 1914 signature. For example, a target signature with a SHA-1 hash MUST 1915 have 20 octets of hash data. 1917 5.2.3.26. Embedded Signature 1919 (1 signature packet body) 1921 This subpacket contains a complete Signature packet body as specified 1922 in Section 5.2. It is useful when one signature needs to refer to, 1923 or be incorporated in, another signature. 1925 5.2.3.27. Issuer Fingerprint 1927 (1 octet key version number, N octets of fingerprint) 1929 The OpenPGP Key fingerprint of the key issuing the signature. This 1930 subpacket SHOULD be included in all signatures. If the version of 1931 the issuing key is 4 and an Issuer subpacket is also included in the 1932 signature, the key ID of the Issuer subpacket MUST match the low 64 1933 bits of the fingerprint. 1935 Note that the length N of the fingerprint for a version 4 key is 20 1936 octets; for a version 5 key N is 32. 1938 5.2.4. Computing Signatures 1940 All signatures are formed by producing a hash over the signature 1941 data, and then using the resulting hash in the signature algorithm. 1943 For binary document signatures (type 0x00), the document data is 1944 hashed directly. For text document signatures (type 0x01), the 1945 document is canonicalized by converting line endings to , and 1946 the resulting data is hashed. 1948 When a V4 signature is made over a key, the hash data starts with the 1949 octet 0x99, followed by a two-octet length of the key, and then body 1950 of the key packet; when a V5 signature is made over a key, the hash 1951 data starts with the octet 0x9a, followed by a four-octet length of 1952 the key, and then body of the key packet. A subkey binding signature 1953 (type 0x18) or primary key binding signature (type 0x19) then hashes 1954 the subkey using the same format as the main key (also using 0x99 or 1955 0x9a as the first octet). Primary key revocation signatures (type 1956 0x20) hash only the key being revoked. Subkey revocation signature 1957 (type 0x28) hash first the primary key and then the subkey being 1958 revoked. 1960 A certification signature (type 0x10 through 0x13) hashes the User ID 1961 being bound to the key into the hash context after the above data. A 1962 V3 certification hashes the contents of the User ID or attribute 1963 packet packet, without any header. A V4 or V5 certification hashes 1964 the constant 0xB4 for User ID certifications or the constant 0xD1 for 1965 User Attribute certifications, followed by a four-octet number giving 1966 the length of the User ID or User Attribute data, and then the User 1967 ID or User Attribute data. 1969 When a signature is made over a Signature packet (type 0x50, "Third- 1970 Party Confirmation signature"), the hash data starts with the octet 1971 0x88, followed by the four-octet length of the signature, and then 1972 the body of the Signature packet. (Note that this is an old-style 1973 packet header for a Signature packet with the length-of-length field 1974 set to zero.) The unhashed subpacket data of the Signature packet 1975 being hashed is not included in the hash, and the unhashed subpacket 1976 data length value is set to zero. 1978 Once the data body is hashed, then a trailer is hashed. This trailer 1979 depends on the version of the signature. 1981 * A V3 signature hashes five octets of the packet body, starting 1982 from the signature type field. This data is the signature type, 1983 followed by the four-octet signature time. 1985 * A V4 signature hashes the packet body starting from its first 1986 field, the version number, through the end of the hashed subpacket 1987 data and a final extra trailer. Thus, the hashed fields are: 1989 - the signature version (0x04), 1991 - the signature type, 1993 - the public-key algorithm, 1995 - the hash algorithm, 1997 - the hashed subpacket length, 1999 - the hashed subpacket body, 2001 - the two octets 0x04 and 0xFF, 2003 - a four-octet big-endian number that is the length of the hashed 2004 data from the Signature packet stopping right before the 0x04, 2005 0xff octets. 2007 The four-octet big-endian number is considered to be an 2008 unsigned integer modulo 2^32. 2010 * A V5 signature hashes the packet body starting from its first 2011 field, the version number, through the end of the hashed subpacket 2012 data and a final extra trailer. Thus, the hashed fields are: 2014 - the signature version (0x05), 2016 - the signature type, 2018 - the public-key algorithm, 2020 - the hash algorithm, 2022 - the hashed subpacket length, 2024 - the hashed subpacket body, 2026 - Only for document signatures (type 0x00 or 0x01) the following 2027 three data items are hashed here: 2029 o the one-octet content format, 2031 o the file name as a string (one octet length, followed by the 2032 file name), 2034 o a four-octet number that indicates a date, 2036 - the two octets 0x05 and 0xFF, 2038 - a eight-octet big-endian number that is the length of the 2039 hashed data from the Signature packet stopping right before the 2040 0x05, 0xff octets. 2042 The three data items hashed for document signatures need to 2043 mirror the values of the Literal Data packet. For detached and 2044 cleartext signatures 6 zero bytes are hashed instead. 2046 After all this has been hashed in a single hash context, the 2047 resulting hash field is used in the signature algorithm and placed at 2048 the end of the Signature packet. 2050 5.2.4.1. Subpacket Hints 2052 It is certainly possible for a signature to contain conflicting 2053 information in subpackets. For example, a signature may contain 2054 multiple copies of a preference or multiple expiration times. In 2055 most cases, an implementation SHOULD use the last subpacket in the 2056 signature, but MAY use any conflict resolution scheme that makes more 2057 sense. Please note that we are intentionally leaving conflict 2058 resolution to the implementer; most conflicts are simply syntax 2059 errors, and the wishy-washy language here allows a receiver to be 2060 generous in what they accept, while putting pressure on a creator to 2061 be stingy in what they generate. 2063 Some apparent conflicts may actually make sense -- for example, 2064 suppose a keyholder has a V3 key and a V4 key that share the same RSA 2065 key material. Either of these keys can verify a signature created by 2066 the other, and it may be reasonable for a signature to contain an 2067 issuer subpacket for each key, as a way of explicitly tying those 2068 keys to the signature. 2070 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) 2072 The Symmetric-Key Encrypted Session Key packet holds the symmetric- 2073 key encryption of a session key used to encrypt a message. Zero or 2074 more Public-Key Encrypted Session Key packets and/or Symmetric-Key 2075 Encrypted Session Key packets may precede a Symmetrically Encrypted 2076 Data packet that holds an encrypted message. The message is 2077 encrypted with a session key, and the session key is itself encrypted 2078 and stored in the Encrypted Session Key packet or the Symmetric-Key 2079 Encrypted Session Key packet. 2081 If the Symmetrically Encrypted Data packet is preceded by one or more 2082 Symmetric-Key Encrypted Session Key packets, each specifies a 2083 passphrase that may be used to decrypt the message. This allows a 2084 message to be encrypted to a number of public keys, and also to one 2085 or more passphrases. This packet type is new and is not generated by 2086 PGP 2 or PGP version 5.0. 2088 The body of this packet consists of: 2090 * A one-octet version number. The only currently defined version is 2091 4. 2093 * A one-octet number describing the symmetric algorithm used. 2095 * A string-to-key (S2K) specifier, length as defined above. 2097 * Optionally, the encrypted session key itself, which is decrypted 2098 with the string-to-key object. 2100 If the encrypted session key is not present (which can be detected on 2101 the basis of packet length and S2K specifier size), then the S2K 2102 algorithm applied to the passphrase produces the session key for 2103 decrypting the message, using the symmetric cipher algorithm from the 2104 Symmetric-Key Encrypted Session Key packet. 2106 If the encrypted session key is present, the result of applying the 2107 S2K algorithm to the passphrase is used to decrypt just that 2108 encrypted session key field, using CFB mode with an IV of all zeros. 2109 The decryption result consists of a one-octet algorithm identifier 2110 that specifies the symmetric-key encryption algorithm used to encrypt 2111 the following Symmetrically Encrypted Data packet, followed by the 2112 session key octets themselves. 2114 Note: because an all-zero IV is used for this decryption, the S2K 2115 specifier MUST use a salt value, either a Salted S2K or an Iterated- 2116 Salted S2K. The salt value will ensure that the decryption key is 2117 not repeated even if the passphrase is reused. 2119 5.4. One-Pass Signature Packets (Tag 4) 2121 The One-Pass Signature packet precedes the signed data and contains 2122 enough information to allow the receiver to begin calculating any 2123 hashes needed to verify the signature. It allows the Signature 2124 packet to be placed at the end of the message, so that the signer can 2125 compute the entire signed message in one pass. 2127 A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. 2129 The body of this packet consists of: 2131 * A one-octet version number. The current version is 3. 2133 * A one-octet signature type. Signature types are described in 2134 Section 5.2.1. 2136 * A one-octet number describing the hash algorithm used. 2138 * A one-octet number describing the public-key algorithm used. 2140 * An eight-octet number holding the Key ID of the signing key. 2142 * A one-octet number holding a flag showing whether the signature is 2143 nested. A zero value indicates that the next packet is another 2144 One-Pass Signature packet that describes another signature to be 2145 applied to the same message data. 2147 Note that if a message contains more than one one-pass signature, 2148 then the Signature packets bracket the message; that is, the first 2149 Signature packet after the message corresponds to the last one-pass 2150 packet and the final Signature packet corresponds to the first one- 2151 pass packet. 2153 5.5. Key Material Packet 2155 A key material packet contains all the information about a public or 2156 private key. There are four variants of this packet type, and two 2157 major versions. Consequently, this section is complex. 2159 5.5.1. Key Packet Variants 2161 5.5.1.1. Public-Key Packet (Tag 6) 2163 A Public-Key packet starts a series of packets that forms an OpenPGP 2164 key (sometimes called an OpenPGP certificate). 2166 5.5.1.2. Public-Subkey Packet (Tag 14) 2168 A Public-Subkey packet (tag 14) has exactly the same format as a 2169 Public-Key packet, but denotes a subkey. One or more subkeys may be 2170 associated with a top-level key. By convention, the top-level key 2171 provides signature services, and the subkeys provide encryption 2172 services. 2174 Note: in PGP version 2.6, tag 14 was intended to indicate a comment 2175 packet. This tag was selected for reuse because no previous version 2176 of PGP ever emitted comment packets but they did properly ignore 2177 them. Public-Subkey packets are ignored by PGP version 2.6 and do 2178 not cause it to fail, providing a limited degree of backward 2179 compatibility. 2181 5.5.1.3. Secret-Key Packet (Tag 5) 2183 A Secret-Key packet contains all the information that is found in a 2184 Public-Key packet, including the public-key material, but also 2185 includes the secret-key material after all the public-key fields. 2187 5.5.1.4. Secret-Subkey Packet (Tag 7) 2189 A Secret-Subkey packet (tag 7) is the subkey analog of the Secret Key 2190 packet and has exactly the same format. 2192 5.5.2. Public-Key Packet Formats 2194 There are three versions of key-material packets. Version 3 packets 2195 were first generated by PGP version 2.6. Version 4 keys first 2196 appeared in PGP 5 and are the preferred key version for OpenPGP. 2198 OpenPGP implementations MUST create keys with version 4 format. V3 2199 keys are deprecated; an implementation MUST NOT generate a V3 key, 2200 but MAY accept it. 2202 A version 3 public key or public-subkey packet contains: 2204 * A one-octet version number (3). 2206 * A four-octet number denoting the time that the key was created. 2208 * A two-octet number denoting the time in days that this key is 2209 valid. If this number is zero, then it does not expire. 2211 * A one-octet number denoting the public-key algorithm of this key. 2213 * A series of multiprecision integers comprising the key material: 2215 - a multiprecision integer (MPI) of RSA public modulus n; 2217 - an MPI of RSA public encryption exponent e. 2219 V3 keys are deprecated. They contain three weaknesses. First, it is 2220 relatively easy to construct a V3 key that has the same Key ID as any 2221 other key because the Key ID is simply the low 64 bits of the public 2222 modulus. Secondly, because the fingerprint of a V3 key hashes the 2223 key material, but not its length, there is an increased opportunity 2224 for fingerprint collisions. Third, there are weaknesses in the MD5 2225 hash algorithm that make developers prefer other algorithms. See 2226 below for a fuller discussion of Key IDs and fingerprints. 2228 V2 keys are identical to the deprecated V3 keys except for the 2229 version number. An implementation MUST NOT generate them and MAY 2230 accept or reject them as it sees fit. 2232 The version 4 format is similar to the version 3 format except for 2233 the absence of a validity period. This has been moved to the 2234 Signature packet. In addition, fingerprints of version 4 keys are 2235 calculated differently from version 3 keys, as described in 2236 Section 12. 2238 A version 4 packet contains: 2240 * A one-octet version number (4). 2242 * A four-octet number denoting the time that the key was created. 2244 * A one-octet number denoting the public-key algorithm of this key. 2246 * A series of multiprecision integers comprising the key material. 2247 This is algorithm-specific and described in Section 5.6. 2249 The version 5 format is similar to the version 4 format except for 2250 the addition of a count for the key material. This count helps 2251 parsing secret key packets (which are an extension of the public key 2252 packet format) in the case of an unknown algoritm. In addition, 2253 fingerprints of version 5 keys are calculated differently from 2254 version 4 keys, as described in the section "Enhanced Key Formats". 2256 A version 5 packet contains: 2258 * A one-octet version number (5). 2260 * A four-octet number denoting the time that the key was created. 2262 * A one-octet number denoting the public-key algorithm of this key. 2264 * A four-octet scalar octet count for the following public key 2265 material. 2267 * A series of values comprising the public key material. This is 2268 algorithm-specific and described in Section 5.6. 2270 5.5.3. Secret-Key Packet Formats 2272 The Secret-Key and Secret-Subkey packets contain all the data of the 2273 Public-Key and Public-Subkey packets, with additional algorithm- 2274 specific secret-key data appended, usually in encrypted form. 2276 The packet contains: 2278 * A Public-Key or Public-Subkey packet, as described above. 2280 * One octet indicating string-to-key usage conventions. Zero 2281 indicates that the secret-key data is not encrypted. 255 or 254 2282 indicates that a string-to-key specifier is being given. Any 2283 other value is a symmetric-key encryption algorithm identifier. A 2284 version 5 packet MUST NOT use the value 255. 2286 * Only for a version 5 packet, a one-octet scalar octet count of the 2287 next 4 optional fields. 2289 * [Optional] If string-to-key usage octet was 255 or 254, a one- 2290 octet symmetric encryption algorithm. 2292 * [Optional] If string-to-key usage octet was 255 or 254, a string- 2293 to-key specifier. The length of the string-to-key specifier is 2294 implied by its type, as described above. 2296 * [Optional] If secret data is encrypted (string-to-key usage octet 2297 not zero), an Initial Vector (IV) of the same length as the 2298 cipher's block size. 2300 * Only for a version 5 packet, a four-octet scalar octet count for 2301 the following secret key material. This includes the encrypted 2302 SHA-1 hash or AEAD tag if the string-to-key usage octet is 254 or 2303 253. 2305 * Plain or encrypted multiprecision integers comprising the secret 2306 key data. This is algorithm-specific and described in section 2307 Section 5.6. 2309 * If the string-to-key usage octet is zero or 255, then a two-octet 2310 checksum of the plaintext of the algorithm-specific portion (sum 2311 of all octets, mod 65536). If the string-to-key usage octet was 2312 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- 2313 specific portion. This checksum or hash is encrypted together 2314 with the algorithm-specific fields (if string-to-key usage octet 2315 is not zero). Note that for all other values, a two-octet 2316 checksum is required. 2318 Note that the version 5 packet format adds two count values to help 2319 parsing packets with unknown S2K or public key algorithms. 2321 Secret MPI values can be encrypted using a passphrase. If a string- 2322 to-key specifier is given, that describes the algorithm for 2323 converting the passphrase to a key, else a simple MD5 hash of the 2324 passphrase is used. Implementations MUST use a string-to-key 2325 specifier; the simple hash is for backward compatibility and is 2326 deprecated, though implementations MAY continue to use existing 2327 private keys in the old format. The cipher for encrypting the MPIs 2328 is specified in the Secret-Key packet. 2330 Encryption/decryption of the secret data is done in CFB mode using 2331 the key created from the passphrase and the Initial Vector from the 2332 packet. A different mode is used with V3 keys (which are only RSA) 2333 than with other key formats. With V3 keys, the MPI bit count prefix 2334 (i.e., the first two octets) is not encrypted. Only the MPI non- 2335 prefix data is encrypted. Furthermore, the CFB state is 2336 resynchronized at the beginning of each new MPI value, so that the 2337 CFB block boundary is aligned with the start of the MPI data. 2339 With V4 and V5 keys, a simpler method is used. All secret MPI values 2340 are encrypted in CFB mode, including the MPI bitcount prefix. 2342 The two-octet checksum that follows the algorithm-specific portion is 2343 the algebraic sum, mod 65536, of the plaintext of all the algorithm- 2344 specific octets (including MPI prefix and data). With V3 keys, the 2345 checksum is stored in the clear. With V4 keys, the checksum is 2346 encrypted like the algorithm-specific data. This value is used to 2347 check that the passphrase was correct. However, this checksum is 2348 deprecated; an implementation SHOULD NOT use it, but should rather 2349 use the SHA-1 hash denoted with a usage octet of 254. The reason for 2350 this is that there are some attacks that involve undetectably 2351 modifying the secret key. 2353 5.6. Algorithm-specific Parts of Keys 2355 The public and secret key format specifies algorithm-specific parts 2356 of a key. The following sections describe them in detail. 2358 5.6.1. Algorithm-Specific Part for RSA Keys 2360 The public key is this series of multiprecision integers: 2362 * MPI of RSA public modulus n; 2364 * MPI of RSA public encryption exponent e. 2366 The secret key is this series of multiprecision integers: 2368 * MPI of RSA secret exponent d; 2369 * MPI of RSA secret prime value p; 2371 * MPI of RSA secret prime value q (p < q); 2373 * MPI of u, the multiplicative inverse of p, mod q. 2375 5.6.2. Algorithm-Specific Part for DSA Keys 2377 The public key is this series of multiprecision integers: 2379 * MPI of DSA prime p; 2381 * MPI of DSA group order q (q is a prime divisor of p-1); 2383 * MPI of DSA group generator g; 2385 * MPI of DSA public-key value y (= g**x mod p where x is secret). 2387 The secret key is this single multiprecision integer: 2389 * MPI of DSA secret exponent x. 2391 5.6.3. Algorithm-Specific Part for Elgamal Keys 2393 The public key is this series of multiprecision integers: 2395 * MPI of Elgamal prime p; 2397 * MPI of Elgamal group generator g; 2399 * MPI of Elgamal public key value y (= g**x mod p where x is 2400 secret). 2402 The secret key is this single multiprecision integer: 2404 * MPI of Elgamal secret exponent x. 2406 5.6.4. Algorithm-Specific Part for ECDSA Keys 2408 The public key is this series of values: 2410 * a variable-length field containing a curve OID, formatted as 2411 follows: 2413 - a one-octet size of the following field; values 0 and 0xFF are 2414 reserved for future extensions, 2416 - the octets representing a curve OID, defined in Section 9.2; 2418 * a MPI of an EC point representing a public key. 2420 The secret key is this single multiprecision integer: 2422 * MPI of an integer representing the secret key, which is a scalar 2423 of the public EC point. 2425 5.6.5. Algorithm-Specific Part for EdDSA Keys 2427 The public key is this series of values: 2429 * a variable-length field containing a curve OID, formatted as 2430 follows: 2432 - a one-octet size of the following field; values 0 and 0xFF are 2433 reserved for future extensions, 2435 - the octets representing a curve OID, defined in Section 9.2; 2437 * a MPI of an EC point representing a public key Q as described 2438 under EdDSA Point Format below. 2440 The secret key is this single multiprecision integer: 2442 * MPI of an integer representing the secret key, which is a scalar 2443 of the public EC point. 2445 5.6.6. Algorithm-Specific Part for ECDH Keys 2447 The public key is this series of values: 2449 * a variable-length field containing a curve OID, formatted as 2450 follows: 2452 - a one-octet size of the following field; values 0 and 0xFF are 2453 reserved for future extensions, 2455 - the octets representing a curve OID, defined in Section 9.2; 2457 * a MPI of an EC point representing a public key; 2459 * a variable-length field containing KDF parameters, formatted as 2460 follows: 2462 - a one-octet size of the following fields; values 0 and 0xff are 2463 reserved for future extensions; 2465 - a one-octet value 1, reserved for future extensions; 2466 - a one-octet hash function ID used with a KDF; 2468 - a one-octet algorithm ID for the symmetric algorithm used to 2469 wrap the symmetric key used for the message encryption; see 2470 Section 13.5 for details. 2472 Observe that an ECDH public key is composed of the same sequence of 2473 fields that define an ECDSA key, plus the KDF parameters field. 2475 The secret key is this single multiprecision integer: 2477 * MPI of an integer representing the secret key, which is a scalar 2478 of the public EC point. 2480 5.7. Compressed Data Packet (Tag 8) 2482 The Compressed Data packet contains compressed data. Typically, this 2483 packet is found as the contents of an encrypted packet, or following 2484 a Signature or One-Pass Signature packet, and contains a literal data 2485 packet. 2487 The body of this packet consists of: 2489 * One octet that gives the algorithm used to compress the packet. 2491 * Compressed data, which makes up the remainder of the packet. 2493 A Compressed Data Packet's body contains an block that compresses 2494 some set of packets. See Section 11 for details on how messages are 2495 formed. 2497 ZIP-compressed packets are compressed with raw [RFC1951] DEFLATE 2498 blocks. Note that PGP V2.6 uses 13 bits of compression. If an 2499 implementation uses more bits of compression, PGP V2.6 cannot 2500 decompress it. 2502 ZLIB-compressed packets are compressed with [RFC1950] ZLIB-style 2503 blocks. 2505 BZip2-compressed packets are compressed using the BZip2 [BZ2] 2506 algorithm. 2508 5.8. Symmetrically Encrypted Data Packet (Tag 9) 2510 The Symmetrically Encrypted Data packet contains data encrypted with 2511 a symmetric-key algorithm. When it has been decrypted, it contains 2512 other packets (usually a literal data packet or compressed data 2513 packet, but in theory other Symmetrically Encrypted Data packets or 2514 sequences of packets that form whole OpenPGP messages). 2516 This packet is obsolete. An implementation MUST NOT create this 2517 packet. An implementation MAY process such a packet but it MUST 2518 return a clear diagnostic that a non-integrity protected packet has 2519 been processed. The implementation SHOULD also return an error in 2520 this case and stop processing. 2522 The body of this packet consists of: 2524 * Encrypted data, the output of the selected symmetric-key cipher 2525 operating in OpenPGP's variant of Cipher Feedback (CFB) mode. 2527 The symmetric cipher used may be specified in a Public-Key or 2528 Symmetric-Key Encrypted Session Key packet that precedes the 2529 Symmetrically Encrypted Data packet. In that case, the cipher 2530 algorithm octet is prefixed to the session key before it is 2531 encrypted. If no packets of these types precede the encrypted data, 2532 the IDEA algorithm is used with the session key calculated as the MD5 2533 hash of the passphrase, though this use is deprecated. 2535 The data is encrypted in CFB mode, with a CFB shift size equal to the 2536 cipher's block size. The Initial Vector (IV) is specified as all 2537 zeros. Instead of using an IV, OpenPGP prefixes a string of length 2538 equal to the block size of the cipher plus two to the data before it 2539 is encrypted. The first block-size octets (for example, 8 octets for 2540 a 64-bit block length) are random, and the following two octets are 2541 copies of the last two octets of the IV. For example, in an 8-octet 2542 block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of 2543 octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 2544 and octet 18 is a repeat of octet 16. As a pedantic clarification, 2545 in both these examples, we consider the first octet to be numbered 1. 2547 After encrypting the first block-size-plus-two octets, the CFB state 2548 is resynchronized. The last block-size octets of ciphertext are 2549 passed through the cipher and the block boundary is reset. 2551 The repetition of 16 bits in the random data prefixed to the message 2552 allows the receiver to immediately check whether the session key is 2553 incorrect. See Section 15 for hints on the proper use of this "quick 2554 check". 2556 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) 2558 An experimental version of PGP used this packet as the Literal 2559 packet, but no released version of PGP generated Literal packets with 2560 this tag. With PGP 5, this packet has been reassigned and is 2561 reserved for use as the Marker packet. 2563 The body of this packet consists of: 2565 * The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). 2567 Such a packet MUST be ignored when received. It may be placed at the 2568 beginning of a message that uses features not available in PGP 2569 version 2.6 in order to cause that version to report that newer 2570 software is necessary to process the message. 2572 5.10. Literal Data Packet (Tag 11) 2574 A Literal Data packet contains the body of a message; data that is 2575 not to be further interpreted. 2577 The body of this packet consists of: 2579 * A one-octet field that describes how the data is formatted. 2581 If it is a "b" (0x62), then the Literal packet contains binary 2582 data. If it is a "t" (0x74), then it contains text data, and thus 2583 may need line ends converted to local form, or other text-mode 2584 changes. The tag "u" (0x75) means the same as "t", but also 2585 indicates that implementation believes that the literal data 2586 contains UTF-8 text. 2588 Early versions of PGP also defined a value of "l" as a 'local' 2589 mode for machine-local conversions. [RFC1991] incorrectly stated 2590 this local mode flag as "1" (ASCII numeral one). Both of these 2591 local modes are deprecated. 2593 * File name as a string (one-octet length, followed by a file name). 2594 This may be a zero-length string. Commonly, if the source of the 2595 encrypted data is a file, this will be the name of the encrypted 2596 file. An implementation MAY consider the file name in the Literal 2597 packet to be a more authoritative name than the actual file name. 2599 If the special name "_CONSOLE" is used, the message is considered 2600 to be "for your eyes only". This advises that the message data is 2601 unusually sensitive, and the receiving program should process it 2602 more carefully, perhaps avoiding storing the received data to 2603 disk, for example. 2605 * A four-octet number that indicates a date associated with the 2606 literal data. Commonly, the date might be the modification date 2607 of a file, or the time the packet was created, or a zero that 2608 indicates no specific time. 2610 * The remainder of the packet is literal data. 2612 Text data is stored with text endings (i.e., network- 2613 normal line endings). These should be converted to native line 2614 endings by the receiving software. 2616 Note that V3 and V4 signatures do not include the formatting octet, 2617 the file name, and the date field of the literal packet in a 2618 signature hash and thus are not protected against tampering in a 2619 signed document. In contrast V5 signatures include them. 2621 5.11. Trust Packet (Tag 12) 2623 The Trust packet is used only within keyrings and is not normally 2624 exported. Trust packets contain data that record the user's 2625 specifications of which key holders are trustworthy introducers, 2626 along with other information that implementing software uses for 2627 trust information. The format of Trust packets is defined by a given 2628 implementation. 2630 Trust packets SHOULD NOT be emitted to output streams that are 2631 transferred to other users, and they SHOULD be ignored on any input 2632 other than local keyring files. 2634 5.12. User ID Packet (Tag 13) 2636 A User ID packet consists of UTF-8 text that is intended to represent 2637 the name and email address of the key holder. By convention, it 2638 includes an [RFC2822] mail name-addr, but there are no restrictions 2639 on its content. The packet length in the header specifies the length 2640 of the User ID. 2642 5.13. User Attribute Packet (Tag 17) 2644 The User Attribute packet is a variation of the User ID packet. It 2645 is capable of storing more types of data than the User ID packet, 2646 which is limited to text. Like the User ID packet, a User Attribute 2647 packet may be certified by the key owner ("self-signed") or any other 2648 key owner who cares to certify it. Except as noted, a User Attribute 2649 packet may be used anywhere that a User ID packet may be used. 2651 While User Attribute packets are not a required part of the OpenPGP 2652 standard, implementations SHOULD provide at least enough 2653 compatibility to properly handle a certification signature on the 2654 User Attribute packet. A simple way to do this is by treating the 2655 User Attribute packet as a User ID packet with opaque contents, but 2656 an implementation may use any method desired. 2658 The User Attribute packet is made up of one or more attribute 2659 subpackets. Each subpacket consists of a subpacket header and a 2660 body. The header consists of: 2662 * the subpacket length (1, 2, or 5 octets) 2664 * the subpacket type (1 octet) 2666 and is followed by the subpacket specific data. 2668 The following table lists the currently known subpackets: 2670 +=========+===========================+ 2671 | Type | Attribute Subpacket | 2672 +=========+===========================+ 2673 | 1 | Image Attribute Subpacket | 2674 +---------+---------------------------+ 2675 | 100-110 | Private/Experimental Use | 2676 +---------+---------------------------+ 2678 Table 13: User Attribute type registry 2680 An implementation SHOULD ignore any subpacket of a type that it does 2681 not recognize. 2683 5.13.1. The Image Attribute Subpacket 2685 The Image Attribute subpacket is used to encode an image, presumably 2686 (but not required to be) that of the key owner. 2688 The Image Attribute subpacket begins with an image header. The first 2689 two octets of the image header contain the length of the image 2690 header. Note that unlike other multi-octet numerical values in this 2691 document, due to a historical accident this value is encoded as a 2692 little-endian number. The image header length is followed by a 2693 single octet for the image header version. The only currently 2694 defined version of the image header is 1, which is a 16-octet image 2695 header. The first three octets of a version 1 image header are thus 2696 0x10, 0x00, 0x01. 2698 The fourth octet of a version 1 image header designates the encoding 2699 format of the image. The only currently defined encoding format is 2700 the value 1 to indicate JPEG. Image format types 100 through 110 are 2701 reserved for private or experimental use. The rest of the version 1 2702 image header is made up of 12 reserved octets, all of which MUST be 2703 set to 0. 2705 The rest of the image subpacket contains the image itself. As the 2706 only currently defined image type is JPEG, the image is encoded in 2707 the JPEG File Interchange Format (JFIF), a standard file format for 2708 JPEG images [JFIF]. 2710 An implementation MAY try to determine the type of an image by 2711 examination of the image data if it is unable to handle a particular 2712 version of the image header or if a specified encoding format value 2713 is not recognized. 2715 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 18) 2717 The Symmetrically Encrypted Integrity Protected Data packet is a 2718 variant of the Symmetrically Encrypted Data packet. It is a new 2719 feature created for OpenPGP that addresses the problem of detecting a 2720 modification to encrypted data. It is used in combination with a 2721 Modification Detection Code packet. 2723 There is a corresponding feature in the features Signature subpacket 2724 that denotes that an implementation can properly use this packet 2725 type. An implementation MUST support decrypting these packets and 2726 SHOULD prefer generating them to the older Symmetrically Encrypted 2727 Data packet when possible. Since this data packet protects against 2728 modification attacks, this standard encourages its proliferation. 2729 While blanket adoption of this data packet would create 2730 interoperability problems, rapid adoption is nevertheless important. 2731 An implementation SHOULD specifically denote support for this packet, 2732 but it MAY infer it from other mechanisms. 2734 For example, an implementation might infer from the use of a cipher 2735 such as Advanced Encryption Standard (AES) or Twofish that a user 2736 supports this feature. It might place in the unhashed portion of 2737 another user's key signature a Features subpacket. It might also 2738 present a user with an opportunity to regenerate their own self- 2739 signature with a Features subpacket. 2741 This packet contains data encrypted with a symmetric-key algorithm 2742 and protected against modification by the SHA-1 hash algorithm. When 2743 it has been decrypted, it will typically contain other packets (often 2744 a Literal Data packet or Compressed Data packet). The last decrypted 2745 packet in this packet's payload MUST be a Modification Detection Code 2746 packet. 2748 The body of this packet consists of: 2750 * A one-octet version number. The only currently defined value is 2751 1. 2753 * Encrypted data, the output of the selected symmetric-key cipher 2754 operating in Cipher Feedback mode with shift amount equal to the 2755 block size of the cipher (CFB-n where n is the block size). 2757 The symmetric cipher used MUST be specified in a Public-Key or 2758 Symmetric-Key Encrypted Session Key packet that precedes the 2759 Symmetrically Encrypted Data packet. In either case, the cipher 2760 algorithm octet is prefixed to the session key before it is 2761 encrypted. 2763 The data is encrypted in CFB mode, with a CFB shift size equal to the 2764 cipher's block size. The Initial Vector (IV) is specified as all 2765 zeros. Instead of using an IV, OpenPGP prefixes an octet string to 2766 the data before it is encrypted. The length of the octet string 2767 equals the block size of the cipher in octets, plus two. The first 2768 octets in the group, of length equal to the block size of the cipher, 2769 are random; the last two octets are each copies of their 2nd 2770 preceding octet. For example, with a cipher whose block size is 128 2771 bits or 16 octets, the prefix data will contain 16 random octets, 2772 then two more octets, which are copies of the 15th and 16th octets, 2773 respectively. Unlike the Symmetrically Encrypted Data Packet, no 2774 special CFB resynchronization is done after encrypting this prefix 2775 data. See Section 14.10 for more details. 2777 The repetition of 16 bits in the random data prefixed to the message 2778 allows the receiver to immediately check whether the session key is 2779 incorrect. 2781 The plaintext of the data to be encrypted is passed through the SHA-1 2782 hash function, and the result of the hash is appended to the 2783 plaintext in a Modification Detection Code packet. The input to the 2784 hash function includes the prefix data described above; it includes 2785 all of the plaintext, and then also includes two octets of values 2786 0xD3, 0x14. These represent the encoding of a Modification Detection 2787 Code packet tag and length field of 20 octets. 2789 The resulting hash value is stored in a Modification Detection Code 2790 (MDC) packet, which MUST use the two octet encoding just given to 2791 represent its tag and length field. The body of the MDC packet is 2792 the 20-octet output of the SHA-1 hash. 2794 The Modification Detection Code packet is appended to the plaintext 2795 and encrypted along with the plaintext using the same CFB context. 2797 During decryption, the plaintext data should be hashed with SHA-1, 2798 including the prefix data as well as the packet tag and length field 2799 of the Modification Detection Code packet. The body of the MDC 2800 packet, upon decryption, is compared with the result of the SHA-1 2801 hash. 2803 Any failure of the MDC indicates that the message has been modified 2804 and MUST be treated as a security problem. Failures include a 2805 difference in the hash values, but also the absence of an MDC packet, 2806 or an MDC packet in any position other than the end of the plaintext. 2807 Any failure SHOULD be reported to the user. 2809 Note: future designs of new versions of this packet should consider 2810 rollback attacks since it will be possible for an attacker to change 2811 the version back to 1. 2813 NON-NORMATIVE EXPLANATION 2815 The MDC system, as packets 18 and 19 are called, were created to 2816 provide an integrity mechanism that is less strong than a 2817 signature, yet stronger than bare CFB encryption. 2819 It is a limitation of CFB encryption that damage to the ciphertext 2820 will corrupt the affected cipher blocks and the block following. 2821 Additionally, if data is removed from the end of a CFB-encrypted 2822 block, that removal is undetectable. (Note also that CBC mode has 2823 a similar limitation, but data removed from the front of the block 2824 is undetectable.) 2826 The obvious way to protect or authenticate an encrypted block is 2827 to digitally sign it. However, many people do not wish to 2828 habitually sign data, for a large number of reasons beyond the 2829 scope of this document. Suffice it to say that many people 2830 consider properties such as deniability to be as valuable as 2831 integrity. 2833 OpenPGP addresses this desire to have more security than raw 2834 encryption and yet preserve deniability with the MDC system. An 2835 MDC is intentionally not a MAC. Its name was not selected by 2836 accident. It is analogous to a checksum. 2838 Despite the fact that it is a relatively modest system, it has 2839 proved itself in the real world. It is an effective defense to 2840 several attacks that have surfaced since it has been created. It 2841 has met its modest goals admirably. 2843 Consequently, because it is a modest security system, it has 2844 modest requirements on the hash function(s) it employs. It does 2845 not rely on a hash function being collision-free, it relies on a 2846 hash function being one-way. If a forger, Frank, wishes to send 2847 Alice a (digitally) unsigned message that says, "I've always 2848 secretly loved you, signed Bob", it is far easier for him to 2849 construct a new message than it is to modify anything intercepted 2850 from Bob. (Note also that if Bob wishes to communicate secretly 2851 with Alice, but without authentication or identification and with 2852 a threat model that includes forgers, he has a problem that 2853 transcends mere cryptography.) 2855 Note also that unlike nearly every other OpenPGP subsystem, there 2856 are no parameters in the MDC system. It hard-defines SHA-1 as its 2857 hash function. This is not an accident. It is an intentional 2858 choice to avoid downgrade and cross-grade attacks while making a 2859 simple, fast system. (A downgrade attack would be an attack that 2860 replaced SHA2-256 with SHA-1, for example. A cross-grade attack 2861 would replace SHA-1 with another 160-bit hash, such as RIPE- 2862 MD/160, for example.) 2864 However, given the present state of hash function cryptanalysis 2865 and cryptography, it may be desirable to upgrade the MDC system to 2866 a new hash function. See Section 14.12 for guidance. 2868 5.15. Modification Detection Code Packet (Tag 19) 2870 The Modification Detection Code packet contains a SHA-1 hash of 2871 plaintext data, which is used to detect message modification. It is 2872 only used with a Symmetrically Encrypted Integrity Protected Data 2873 packet. The Modification Detection Code packet MUST be the last 2874 packet in the plaintext data that is encrypted in the Symmetrically 2875 Encrypted Integrity Protected Data packet, and MUST appear in no 2876 other place. 2878 A Modification Detection Code packet MUST have a length of 20 octets. 2880 The body of this packet consists of: 2882 * A 20-octet SHA-1 hash of the preceding plaintext data of the 2883 Symmetrically Encrypted Integrity Protected Data packet, including 2884 prefix data, the tag octet, and length octet of the Modification 2885 Detection Code packet. 2887 Note that the Modification Detection Code packet MUST always use a 2888 new format encoding of the packet tag, and a one-octet encoding of 2889 the packet length. The reason for this is that the hashing rules for 2890 modification detection include a one-octet tag and one-octet length 2891 in the data hash. While this is a bit restrictive, it reduces 2892 complexity. 2894 6. Radix-64 Conversions 2896 As stated in the introduction, OpenPGP's underlying native 2897 representation for objects is a stream of arbitrary octets, and some 2898 systems desire these objects to be immune to damage caused by 2899 character set translation, data conversions, etc. 2901 In principle, any printable encoding scheme that met the requirements 2902 of the unsafe channel would suffice, since it would not change the 2903 underlying binary bit streams of the native OpenPGP data structures. 2904 The OpenPGP standard specifies one such printable encoding scheme to 2905 ensure interoperability. 2907 OpenPGP's Radix-64 encoding is composed of two parts: a base64 2908 encoding of the binary data and an optional checksum. The base64 2909 encoding is identical to the MIME base64 content-transfer-encoding 2910 [RFC2045]. 2912 The optional checksum is a 24-bit Cyclic Redundancy Check (CRC) 2913 converted to four characters of radix-64 encoding by the same MIME 2914 base64 transformation, preceded by an equal sign (=). The CRC is 2915 computed by using the generator 0x864CFB and an initialization of 2916 0xB704CE. The accumulation is done on the data before it is 2917 converted to radix-64, rather than on the converted data. A sample 2918 implementation of this algorithm is in the next section. 2920 If present, the checksum with its leading equal sign MUST appear on 2921 the next line after the base64 encoded data. 2923 Rationale for CRC-24: The size of 24 bits fits evenly into printable 2924 base64. The nonzero initialization can detect more errors than a 2925 zero initialization. 2927 6.1. An Implementation of the CRC-24 in "C" 2928 #define CRC24_INIT 0xB704CEL 2929 #define CRC24_GENERATOR 0x864CFBL 2931 typedef unsigned long crc24; 2932 crc24 crc_octets(unsigned char *octets, size_t len) 2933 { 2934 crc24 crc = CRC24_INIT; 2935 int i; 2936 while (len--) { 2937 crc ^= (*octets++) << 16; 2938 for (i = 0; i < 8; i++) { 2939 crc <<= 1; 2940 if (crc & 0x1000000) { 2941 crc &= 0xffffff; /* Clear bit 25 to avoid overflow */ 2942 crc ^= CRC24_GENERATOR; 2943 } 2944 } 2945 } 2946 return crc & 0xFFFFFFL; 2947 } 2949 6.2. Forming ASCII Armor 2951 When OpenPGP encodes data into ASCII Armor, it puts specific headers 2952 around the Radix-64 encoded data, so OpenPGP can reconstruct the data 2953 later. An OpenPGP implementation MAY use ASCII armor to protect raw 2954 binary data. OpenPGP informs the user what kind of data is encoded 2955 in the ASCII armor through the use of the headers. 2957 Concatenating the following data creates ASCII Armor: 2959 * An Armor Header Line, appropriate for the type of data 2961 * Armor Headers 2963 * A blank (zero-length, or containing only whitespace) line 2965 * The ASCII-Armored data 2967 * An Armor Checksum 2969 * The Armor Tail, which depends on the Armor Header Line 2971 An Armor Header Line consists of the appropriate header line text 2972 surrounded by five (5) dashes ("-", 0x2D) on either side of the 2973 header line text. The header line text is chosen based upon the type 2974 of data that is being encoded in Armor, and how it is being encoded. 2975 Header line texts include the following strings: 2977 BEGIN PGP MESSAGE 2978 Used for signed, encrypted, or compressed files. 2980 BEGIN PGP PUBLIC KEY BLOCK 2981 Used for armoring public keys. 2983 BEGIN PGP PRIVATE KEY BLOCK 2984 Used for armoring private keys. 2986 BEGIN PGP MESSAGE, PART X/Y 2987 Used for multi-part messages, where the armor is split amongst Y 2988 parts, and this is the Xth part out of Y. 2990 BEGIN PGP MESSAGE, PART X 2991 Used for multi-part messages, where this is the Xth part of an 2992 unspecified number of parts. Requires the MESSAGE-ID Armor Header 2993 to be used. 2995 BEGIN PGP SIGNATURE 2996 Used for detached signatures, OpenPGP/MIME signatures, and 2997 cleartext signatures. Note that PGP 2 uses BEGIN PGP MESSAGE for 2998 detached signatures. 3000 Note that all these Armor Header Lines are to consist of a complete 3001 line. That is to say, there is always a line ending preceding the 3002 starting five dashes, and following the ending five dashes. The 3003 header lines, therefore, MUST start at the beginning of a line, and 3004 MUST NOT have text other than whitespace following them on the same 3005 line. These line endings are considered a part of the Armor Header 3006 Line for the purposes of determining the content they delimit. This 3007 is particularly important when computing a cleartext signature (see 3008 below). 3010 The Armor Headers are pairs of strings that can give the user or the 3011 receiving OpenPGP implementation some information about how to decode 3012 or use the message. The Armor Headers are a part of the armor, not a 3013 part of the message, and hence are not protected by any signatures 3014 applied to the message. 3016 The format of an Armor Header is that of a key-value pair. A colon 3017 (":" 0x38) and a single space (0x20) separate the key and value. 3018 OpenPGP should consider improperly formatted Armor Headers to be 3019 corruption of the ASCII Armor. Unknown keys should be reported to 3020 the user, but OpenPGP should continue to process the message. 3022 Note that some transport methods are sensitive to line length. While 3023 there is a limit of 76 characters for the Radix-64 data 3024 (Section 6.3), there is no limit to the length of Armor Headers. 3026 Care should be taken that the Armor Headers are short enough to 3027 survive transport. One way to do this is to repeat an Armor Header 3028 Key multiple times with different values for each so that no one line 3029 is overly long. 3031 Currently defined Armor Header Keys are as follows: 3033 * "Version", which states the OpenPGP implementation and version 3034 used to encode the message. 3036 * "Comment", a user-defined comment. OpenPGP defines all text to be 3037 in UTF-8. A comment may be any UTF-8 string. However, the whole 3038 point of armoring is to provide seven-bit-clean data. 3039 Consequently, if a comment has characters that are outside the US- 3040 ASCII range of UTF, they may very well not survive transport. 3042 * "MessageID", a 32-character string of printable characters. The 3043 string must be the same for all parts of a multi-part message that 3044 uses the "PART X" Armor Header. MessageID strings should be 3045 unique enough that the recipient of the mail can associate all the 3046 parts of a message with each other. A good checksum or 3047 cryptographic hash function is sufficient. 3049 The MessageID SHOULD NOT appear unless it is in a multi-part 3050 message. If it appears at all, it MUST be computed from the 3051 finished (encrypted, signed, etc.) message in a deterministic 3052 fashion, rather than contain a purely random value. This is to 3053 allow the legitimate recipient to determine that the MessageID 3054 cannot serve as a covert means of leaking cryptographic key 3055 information. 3057 * "Hash", a comma-separated list of hash algorithms used in this 3058 message. This is used only in cleartext signed messages. 3060 * "Charset", a description of the character set that the plaintext 3061 is in. Please note that OpenPGP defines text to be in UTF-8. An 3062 implementation will get best results by translating into and out 3063 of UTF-8. However, there are many instances where this is easier 3064 said than done. Also, there are communities of users who have no 3065 need for UTF-8 because they are all happy with a character set 3066 like ISO Latin-5 or a Japanese character set. In such instances, 3067 an implementation MAY override the UTF-8 default by using this 3068 header key. An implementation MAY implement this key and any 3069 translations it cares to; an implementation MAY ignore it and 3070 assume all text is UTF-8. 3072 The Armor Tail Line is composed in the same manner as the Armor 3073 Header Line, except the string "BEGIN" is replaced by the string 3074 "END". 3076 6.3. Encoding Binary in Radix-64 3078 The encoding process represents 24-bit groups of input bits as output 3079 strings of 4 encoded characters. Proceeding from left to right, a 3080 24-bit input group is formed by concatenating three 8-bit input 3081 groups. These 24 bits are then treated as four concatenated 6-bit 3082 groups, each of which is translated into a single digit in the 3083 Radix-64 alphabet. When encoding a bit stream with the Radix-64 3084 encoding, the bit stream must be presumed to be ordered with the most 3085 significant bit first. That is, the first bit in the stream will be 3086 the high-order bit in the first 8-bit octet, and the eighth bit will 3087 be the low-order bit in the first 8-bit octet, and so on. 3089 ┌──first octet──┬─second octet──┬──third octet──┐ 3090 │7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│7 6 5 4 3 2 1 0│ 3091 ├───────────┬───┴───────┬───────┴───┬───────────┤ 3092 │5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│5 4 3 2 1 0│ 3093 └──1.index──┴──2.index──┴──3.index──┴──4.index──┘ 3095 Each 6-bit group is used as an index into an array of 64 printable 3096 characters from the table below. The character referenced by the 3097 index is placed in the output string. 3099 +=====+========++=====+=========++=====+==========++=====+==========+ 3100 |Value|Encoding||Value|Encoding ||Value| Encoding ||Value| Encoding | 3101 +=====+========++=====+=========++=====+==========++=====+==========+ 3102 | 0|A || 17|R || 34| i || 51| z | 3103 +-----+--------++-----+---------++-----+----------++-----+----------+ 3104 | 1|B || 18|S || 35| j || 52| 0 | 3105 +-----+--------++-----+---------++-----+----------++-----+----------+ 3106 | 2|C || 19|T || 36| k || 53| 1 | 3107 +-----+--------++-----+---------++-----+----------++-----+----------+ 3108 | 3|D || 20|U || 37| l || 54| 2 | 3109 +-----+--------++-----+---------++-----+----------++-----+----------+ 3110 | 4|E || 21|V || 38| m || 55| 3 | 3111 +-----+--------++-----+---------++-----+----------++-----+----------+ 3112 | 5|F || 22|W || 39| n || 56| 4 | 3113 +-----+--------++-----+---------++-----+----------++-----+----------+ 3114 | 6|G || 23|X || 40| o || 57| 5 | 3115 +-----+--------++-----+---------++-----+----------++-----+----------+ 3116 | 7|H || 24|Y || 41| p || 58| 6 | 3117 +-----+--------++-----+---------++-----+----------++-----+----------+ 3118 | 8|I || 25|Z || 42| q || 59| 7 | 3119 +-----+--------++-----+---------++-----+----------++-----+----------+ 3120 | 9|J || 26|a || 43| r || 60| 8 | 3121 +-----+--------++-----+---------++-----+----------++-----+----------+ 3122 | 10|K || 27|b || 44| s || 61| 9 | 3123 +-----+--------++-----+---------++-----+----------++-----+----------+ 3124 | 11|L || 28|c || 45| t || 62| + | 3125 +-----+--------++-----+---------++-----+----------++-----+----------+ 3126 | 12|M || 29|d || 46| u || 63| / | 3127 +-----+--------++-----+---------++-----+----------++-----+----------+ 3128 | 13|N || 30|e || 47| v || | | 3129 +-----+--------++-----+---------++-----+----------++-----+----------+ 3130 | 14|O || 31|f || 48| w ||(pad)| = | 3131 +-----+--------++-----+---------++-----+----------++-----+----------+ 3132 | 15|P || 32|g || 49| x || | | 3133 +-----+--------++-----+---------++-----+----------++-----+----------+ 3134 | 16|Q || 33|h || 50| y || | | 3135 +-----+--------++-----+---------++-----+----------++-----+----------+ 3137 Table 14: Encoding for Radix-64 3139 The encoded output stream must be represented in lines of no more 3140 than 76 characters each. 3142 Special processing is performed if fewer than 24 bits are available 3143 at the end of the data being encoded. There are three possibilities: 3145 1. The last data group has 24 bits (3 octets). No special 3146 processing is needed. 3148 2. The last data group has 16 bits (2 octets). The first two 6-bit 3149 groups are processed as above. The third (incomplete) data group 3150 has two zero-value bits added to it, and is processed as above. 3151 A pad character (=) is added to the output. 3153 3. The last data group has 8 bits (1 octet). The first 6-bit group 3154 is processed as above. The second (incomplete) data group has 3155 four zero-value bits added to it, and is processed as above. Two 3156 pad characters (=) are added to the output. 3158 6.4. Decoding Radix-64 3160 In Radix-64 data, characters other than those in the table, line 3161 breaks, and other white space probably indicate a transmission error, 3162 about which a warning message or even a message rejection might be 3163 appropriate under some circumstances. Decoding software must ignore 3164 all white space. 3166 Because it is used only for padding at the end of the data, the 3167 occurrence of any "=" characters may be taken as evidence that the 3168 end of the data has been reached (without truncation in transit). No 3169 such assurance is possible, however, when the number of octets 3170 transmitted was a multiple of three and no "=" characters are 3171 present. 3173 6.5. Examples of Radix-64 3174 Input data: 0x14FB9C03D97E 3175 Hex: 1 4 F B 9 C | 0 3 D 9 7 E 3176 8-bit: 00010100 11111011 10011100 | 00000011 11011001 01111110 3177 6-bit: 000101 001111 101110 011100 | 000000 111101 100101 111110 3178 Decimal: 5 15 46 28 0 61 37 62 3179 Output: F P u c A 9 l + 3180 Input data: 0x14FB9C03D9 3181 Hex: 1 4 F B 9 C | 0 3 D 9 3182 8-bit: 00010100 11111011 10011100 | 00000011 11011001 3183 pad with 00 3184 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 3185 Decimal: 5 15 46 28 0 61 36 3186 pad with = 3187 Output: F P u c A 9 k = 3188 Input data: 0x14FB9C03 3189 Hex: 1 4 F B 9 C | 0 3 3190 8-bit: 00010100 11111011 10011100 | 00000011 3191 pad with 0000 3192 6-bit: 000101 001111 101110 011100 | 000000 110000 3193 Decimal: 5 15 46 28 0 48 3194 pad with = = 3195 Output: F P u c A w = = 3197 6.6. Example of an ASCII Armored Message 3199 -----BEGIN PGP MESSAGE----- 3200 Version: OpenPrivacy 0.99 3202 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS 3203 vBSFjNSiVHsuAA== 3204 =njUN 3205 -----END PGP MESSAGE----- 3207 Note that this example has extra indenting; an actual armored message 3208 would have no leading whitespace. 3210 7. Cleartext Signature Framework 3212 It is desirable to be able to sign a textual octet stream without 3213 ASCII armoring the stream itself, so the signed text is still 3214 readable without special software. In order to bind a signature to 3215 such a cleartext, this framework is used, which follows the same 3216 basic format and restrictions as the ASCII armoring described in 3217 Section 6.2. (Note that this framework is not intended to be 3218 reversible. [RFC3156] defines another way to sign cleartext messages 3219 for environments that support MIME.) 3221 The cleartext signed message consists of: 3223 * The cleartext header "-----BEGIN PGP SIGNED MESSAGE-----" on a 3224 single line, 3226 * One or more "Hash" Armor Headers, 3228 * Exactly one empty line not included into the message digest, 3230 * The dash-escaped cleartext that is included into the message 3231 digest, 3233 * The ASCII armored signature(s) including the "-----BEGIN PGP 3234 SIGNATURE-----" Armor Header and Armor Tail Lines. 3236 If the "Hash" Armor Header is given, the specified message digest 3237 algorithm(s) are used for the signature. If there are no such 3238 headers, MD5 is used. If MD5 is the only hash used, then an 3239 implementation MAY omit this header for improved V2.x compatibility. 3240 If more than one message digest is used in the signature, the "Hash" 3241 armor header contains a comma-delimited list of used message digests. 3243 Current message digest names are described below with the algorithm 3244 IDs. 3246 An implementation SHOULD add a line break after the cleartext, but 3247 MAY omit it if the cleartext ends with a line break. This is for 3248 visual clarity. 3250 7.1. Dash-Escaped Text 3252 The cleartext content of the message must also be dash-escaped. 3254 Dash-escaped cleartext is the ordinary cleartext where every line 3255 starting with a dash "-" (0x2D) is prefixed by the sequence dash "-" 3256 (0x2D) and space ` ` (0x20). This prevents the parser from 3257 recognizing armor headers of the cleartext itself. An implementation 3258 MAY dash-escape any line, SHOULD dash-escape lines commencing "From" 3259 followed by a space, and MUST dash-escape any line commencing in a 3260 dash. The message digest is computed using the cleartext itself, not 3261 the dash-escaped form. 3263 As with binary signatures on text documents, a cleartext signature is 3264 calculated on the text using canonical line endings. The 3265 line ending (i.e., the ) before the "-----BEGIN PGP 3266 SIGNATURE-----" line that terminates the signed text is not 3267 considered part of the signed text. 3269 When reversing dash-escaping, an implementation MUST strip the string 3270 "-" if it occurs at the beginning of a line, and SHOULD warn on "-" 3271 and any character other than a space at the beginning of a line. 3273 Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at 3274 the end of any line is removed when the cleartext signature is 3275 generated. 3277 8. Regular Expressions 3279 A regular expression is zero or more branches, separated by "|". It 3280 matches anything that matches one of the branches. 3282 A branch is zero or more pieces, concatenated. It matches a match 3283 for the first, followed by a match for the second, etc. 3285 A piece is an atom possibly followed by "*", "+", or "?". An atom 3286 followed by "*" matches a sequence of 0 or more matches of the atom. 3287 An atom followed by "+" matches a sequence of 1 or more matches of 3288 the atom. An atom followed by "?" matches a match of the atom, or 3289 the null string. 3291 An atom is a regular expression in parentheses (matching a match for 3292 the regular expression), a range (see below), "." (matching any 3293 single character), "^" (matching the null string at the beginning of 3294 the input string), "$" (matching the null string at the end of the 3295 input string), a "\" followed by a single character (matching that 3296 character), or a single character with no other significance 3297 (matching that character). 3299 A range is a sequence of characters enclosed in "[]". It normally 3300 matches any single character from the sequence. If the sequence 3301 begins with "^", it matches any single character not from the rest of 3302 the sequence. If two characters in the sequence are separated by 3303 "-", this is shorthand for the full list of ASCII characters between 3304 them (e.g., "[0-9]" matches any decimal digit). To include a literal 3305 "]" in the sequence, make it the first character (following a 3306 possible "^"). To include a literal "-", make it the first or last 3307 character. 3309 9. Constants 3311 This section describes the constants used in OpenPGP. 3313 Note that these tables are not exhaustive lists; an implementation 3314 MAY implement an algorithm not on these lists, so long as the 3315 algorithm numbers are chosen from the private or experimental 3316 algorithm range. 3318 See Section 14 for more discussion of the algorithms. 3320 9.1. Public-Key Algorithms 3322 +========+===================================================+ 3323 | ID | Algorithm | 3324 +========+===================================================+ 3325 | 1 | RSA (Encrypt or Sign) [HAC] | 3326 +--------+---------------------------------------------------+ 3327 | 2 | RSA Encrypt-Only [HAC] | 3328 +--------+---------------------------------------------------+ 3329 | 3 | RSA Sign-Only [HAC] | 3330 +--------+---------------------------------------------------+ 3331 | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | 3332 +--------+---------------------------------------------------+ 3333 | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | 3334 +--------+---------------------------------------------------+ 3335 | 18 | ECDH public key algorithm | 3336 +--------+---------------------------------------------------+ 3337 | 19 | ECDSA public key algorithm [FIPS186] | 3338 +--------+---------------------------------------------------+ 3339 | 20 | Reserved (formerly Elgamal Encrypt or Sign) | 3340 +--------+---------------------------------------------------+ 3341 | 21 | Reserved for Diffie-Hellman (X9.42, as defined | 3342 | | for IETF-S/MIME) | 3343 +--------+---------------------------------------------------+ 3344 | 22 | EdDSA [RFC8032] | 3345 +--------+---------------------------------------------------+ 3346 | 23 | Reserved (AEDH) | 3347 +--------+---------------------------------------------------+ 3348 | 24 | Reserved (AEDSA) | 3349 +--------+---------------------------------------------------+ 3350 | 100 to | Private/Experimental algorithm | 3351 | 110 | | 3352 +--------+---------------------------------------------------+ 3354 Table 15: Public-key algorithm registry 3356 Implementations MUST implement DSA for signatures, and Elgamal for 3357 encryption. Implementations SHOULD implement RSA keys (1). RSA 3358 Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD NOT 3359 be generated, but may be interpreted. See Section 14.5. See 3360 Section 14.9 for notes on Elgamal Encrypt or Sign (20), and X9.42 3361 (21). Implementations MAY implement any other algorithm. 3363 A compatible specification of ECDSA is given in [RFC6090] as "KT-I 3364 Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this 3365 document. 3367 9.2. ECC Curve OID 3369 The parameter curve OID is an array of octets that define a named 3370 curve. The table below specifies the exact sequence of bytes for 3371 each named curve referenced in this document: 3373 +========================+=====+=================+============+ 3374 | ASN.1 Object | OID | Curve OID bytes | Curve name | 3375 | Identifier | len | in hexadecimal | | 3376 | | | representation | | 3377 +========================+=====+=================+============+ 3378 | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | 3379 | | | 03 01 07 | | 3380 +------------------------+-----+-----------------+------------+ 3381 | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | 3382 +------------------------+-----+-----------------+------------+ 3383 | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | 3384 +------------------------+-----+-----------------+------------+ 3385 | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 | Ed25519 | 3386 | | | DA 47 0F 01 | | 3387 +------------------------+-----+-----------------+------------+ 3388 | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | 3389 | | | 97 55 01 05 01 | | 3390 +------------------------+-----+-----------------+------------+ 3392 Table 16: ECC Curve OID registry 3394 The sequence of octets in the third column is the result of applying 3395 the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier 3396 with subsequent truncation. The truncation removes the two fields of 3397 encoded Object Identifier. The first omitted field is one octet 3398 representing the Object Identifier tag, and the second omitted field 3399 is the length of the Object Identifier body. For example, the 3400 complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 3401 86 48 CE 3D 03 01 07", from which the first entry in the table above 3402 is constructed by omitting the first two octets. Only the truncated 3403 sequence of octets is the valid representation of a curve OID. 3405 9.3. Symmetric-Key Algorithms 3407 +========+=======================================+ 3408 | ID | Algorithm | 3409 +========+=======================================+ 3410 | 0 | Plaintext or unencrypted data | 3411 +--------+---------------------------------------+ 3412 | 1 | IDEA [IDEA] | 3413 +--------+---------------------------------------+ 3414 | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] | 3415 | | - 168 bit key derived from 192) | 3416 +--------+---------------------------------------+ 3417 | 3 | CAST5 (128 bit key, as per [RFC2144]) | 3418 +--------+---------------------------------------+ 3419 | 4 | Blowfish (128 bit key, 16 rounds) | 3420 | | [BLOWFISH] | 3421 +--------+---------------------------------------+ 3422 | 5 | Reserved | 3423 +--------+---------------------------------------+ 3424 | 6 | Reserved | 3425 +--------+---------------------------------------+ 3426 | 7 | AES with 128-bit key [AES] | 3427 +--------+---------------------------------------+ 3428 | 8 | AES with 192-bit key | 3429 +--------+---------------------------------------+ 3430 | 9 | AES with 256-bit key | 3431 +--------+---------------------------------------+ 3432 | 10 | Twofish with 256-bit key [TWOFISH] | 3433 +--------+---------------------------------------+ 3434 | 11 | Camellia with 128-bit key [RFC3713] | 3435 +--------+---------------------------------------+ 3436 | 12 | Camellia with 192-bit key | 3437 +--------+---------------------------------------+ 3438 | 13 | Camellia with 256-bit key | 3439 +--------+---------------------------------------+ 3440 | 100 to | Private/Experimental algorithm | 3441 | 110 | | 3442 +--------+---------------------------------------+ 3444 Table 17: Symmetric-key algorithm registry 3446 Implementations MUST implement TripleDES. Implementations SHOULD 3447 implement AES-128 and CAST5. Implementations that interoperate with 3448 PGP 2.6 or earlier need to support IDEA, as that is the only 3449 symmetric cipher those versions use. Implementations MAY implement 3450 any other algorithm. 3452 9.4. Compression Algorithms 3454 +============+================================+ 3455 | ID | Algorithm | 3456 +============+================================+ 3457 | 0 | Uncompressed | 3458 +------------+--------------------------------+ 3459 | 1 | ZIP [RFC1951] | 3460 +------------+--------------------------------+ 3461 | 2 | ZLIB [RFC1950] | 3462 +------------+--------------------------------+ 3463 | 3 | BZip2 [BZ2] | 3464 +------------+--------------------------------+ 3465 | 100 to 110 | Private/Experimental algorithm | 3466 +------------+--------------------------------+ 3468 Table 18: Compression algorithm registry 3470 Implementations MUST implement uncompressed data. Implementations 3471 SHOULD implement ZIP. Implementations MAY implement any other 3472 algorithm. 3474 9.5. Hash Algorithms 3476 +============+================================+=============+ 3477 | ID | Algorithm | Text Name | 3478 +============+================================+=============+ 3479 | 1 | MD5 [HAC] | "MD5" | 3480 +------------+--------------------------------+-------------+ 3481 | 2 | SHA-1 [FIPS180] | "SHA1" | 3482 +------------+--------------------------------+-------------+ 3483 | 3 | RIPE-MD/160 [HAC] | "RIPEMD160" | 3484 +------------+--------------------------------+-------------+ 3485 | 4 | Reserved | | 3486 +------------+--------------------------------+-------------+ 3487 | 5 | Reserved | | 3488 +------------+--------------------------------+-------------+ 3489 | 6 | Reserved | | 3490 +------------+--------------------------------+-------------+ 3491 | 7 | Reserved | | 3492 +------------+--------------------------------+-------------+ 3493 | 8 | SHA2-256 [FIPS180] | "SHA256" | 3494 +------------+--------------------------------+-------------+ 3495 | 9 | SHA2-384 [FIPS180] | "SHA384" | 3496 +------------+--------------------------------+-------------+ 3497 | 10 | SHA2-512 [FIPS180] | "SHA512" | 3498 +------------+--------------------------------+-------------+ 3499 | 11 | SHA2-224 [FIPS180] | "SHA224" | 3500 +------------+--------------------------------+-------------+ 3501 | 12 | SHA3-256 [FIPS202] | "SHA3-256" | 3502 +------------+--------------------------------+-------------+ 3503 | 13 | Reserved | | 3504 +------------+--------------------------------+-------------+ 3505 | 14 | SHA3-512 [FIPS202] | "SHA3-512" | 3506 +------------+--------------------------------+-------------+ 3507 | 100 to 110 | Private/Experimental algorithm | | 3508 +------------+--------------------------------+-------------+ 3510 Table 19: Hash algorithm registry 3512 Implementations MUST implement SHA-1. Implementations MAY implement 3513 other algorithms. MD5 is deprecated. 3515 10. IANA Considerations 3517 OpenPGP is highly parameterized, and consequently there are a number 3518 of considerations for allocating parameters for extensions. This 3519 section describes how IANA should look at extensions to the protocol 3520 as described in this document. 3522 10.1. New String-to-Key Specifier Types 3524 OpenPGP S2K specifiers contain a mechanism for new algorithms to turn 3525 a string into a key. This specification creates a registry of S2K 3526 specifier types. The registry includes the S2K type, the name of the 3527 S2K, and a reference to the defining specification. The initial 3528 values for this registry can be found in Section 3.7.1. Adding a new 3529 S2K specifier MUST be done through the SPECIFICATION REQUIRED method, 3530 as described in [RFC8126]. 3532 10.2. New Packets 3534 Major new features of OpenPGP are defined through new packet types. 3535 This specification creates a registry of packet types. The registry 3536 includes the packet type, the name of the packet, and a reference to 3537 the defining specification. The initial values for this registry can 3538 be found in Section 4.3. Adding a new packet type MUST be done 3539 through the RFC REQUIRED method, as described in [RFC8126]. 3541 10.2.1. User Attribute Types 3543 The User Attribute packet permits an extensible mechanism for other 3544 types of certificate identification. This specification creates a 3545 registry of User Attribute types. The registry includes the User 3546 Attribute type, the name of the User Attribute, and a reference to 3547 the defining specification. The initial values for this registry can 3548 be found in Section 5.13. Adding a new User Attribute type MUST be 3549 done through the SPECIFICATION REQUIRED method, as described in 3550 [RFC8126]. 3552 10.2.1.1. Image Format Subpacket Types 3554 Within User Attribute packets, there is an extensible mechanism for 3555 other types of image-based User Attributes. This specification 3556 creates a registry of Image Attribute subpacket types. The registry 3557 includes the Image Attribute subpacket type, the name of the Image 3558 Attribute subpacket, and a reference to the defining specification. 3559 The initial values for this registry can be found in Section 5.13.1. 3561 Adding a new Image Attribute subpacket type MUST be done through the 3562 SPECIFICATION REQUIRED method, as described in [RFC8126]. 3564 10.2.2. New Signature Subpackets 3566 OpenPGP signatures contain a mechanism for signed (or unsigned) data 3567 to be added to them for a variety of purposes in the Signature 3568 subpackets as discussed in Section 5.2.3.1. This specification 3569 creates a registry of Signature subpacket types. The registry 3570 includes the Signature subpacket type, the name of the subpacket, and 3571 a reference to the defining specification. The initial values for 3572 this registry can be found in Section 5.2.3.1. Adding a new 3573 Signature subpacket MUST be done through the SPECIFICATION REQUIRED 3574 method, as described in [RFC8126]. 3576 10.2.2.1. Signature Notation Data Subpackets 3578 OpenPGP signatures further contain a mechanism for extensions in 3579 signatures. These are the Notation Data subpackets, which contain a 3580 key/value pair. Notations contain a user space that is completely 3581 unmanaged and an IETF space. 3583 This specification creates a registry of Signature Notation Data 3584 types. The registry includes the Signature Notation Data type, the 3585 name of the Signature Notation Data, its allowed values, and a 3586 reference to the defining specification. The initial values for this 3587 registry can be found in Section 5.2.3.16. Adding a new Signature 3588 Notation Data subpacket MUST be done through the SPECIFICATION 3589 REQUIRED method, as described in [RFC8126]. 3591 10.2.2.2. Signature Notation Data Subpacket Notation Flags 3593 This specification creates a new registry of Signature Notation Data 3594 Subpacket Notation Flags. The registry includes the columns "Flag", 3595 "Description", "Security Recommended", "Interoperability 3596 Recommended", and "Reference". The initial values for this registry 3597 can be found in Section 5.2.3.16. Adding a new item MUST be done 3598 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 3600 10.2.2.3. Key Server Preference Extensions 3602 OpenPGP signatures contain a mechanism for preferences to be 3603 specified about key servers. This specification creates a registry 3604 of key server preferences. The registry includes the key server 3605 preference, the name of the preference, and a reference to the 3606 defining specification. The initial values for this registry can be 3607 found in Section 5.2.3.17. Adding a new key server preference MUST 3608 be done through the SPECIFICATION REQUIRED method, as described in 3609 [RFC8126]. 3611 10.2.2.4. Key Flags Extensions 3613 OpenPGP signatures contain a mechanism for flags to be specified 3614 about key usage. This specification creates a registry of key usage 3615 flags. The registry includes the key flags value, the name of the 3616 flag, and a reference to the defining specification. The initial 3617 values for this registry can be found in Section 5.2.3.21. Adding a 3618 new key usage flag MUST be done through the SPECIFICATION REQUIRED 3619 method, as described in [RFC8126]. 3621 10.2.2.5. Reason for Revocation Extensions 3623 OpenPGP signatures contain a mechanism for flags to be specified 3624 about why a key was revoked. This specification creates a registry 3625 of "Reason for Revocation" flags. The registry includes the "Reason 3626 for Revocation" flags value, the name of the flag, and a reference to 3627 the defining specification. The initial values for this registry can 3628 be found in Section 5.2.3.23. Adding a new feature flag MUST be done 3629 through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 3631 10.2.2.6. Implementation Features 3633 OpenPGP signatures contain a mechanism for flags to be specified 3634 stating which optional features an implementation supports. This 3635 specification creates a registry of feature-implementation flags. 3636 The registry includes the feature-implementation flags value, the 3637 name of the flag, and a reference to the defining specification. The 3638 initial values for this registry can be found in Section 5.2.3.24. 3639 Adding a new feature-implementation flag MUST be done through the 3640 SPECIFICATION REQUIRED method, as described in [RFC8126]. 3642 Also see Section 14.13 for more information about when feature flags 3643 are needed. 3645 10.2.3. New Packet Versions 3647 The core OpenPGP packets all have version numbers, and can be revised 3648 by introducing a new version of an existing packet. This 3649 specification creates a registry of packet types. The registry 3650 includes the packet type, the number of the version, and a reference 3651 to the defining specification. The initial values for this registry 3652 can be found in Section 5. Adding a new packet version MUST be done 3653 through the RFC REQUIRED method, as described in [RFC8126]. 3655 10.3. New Algorithms 3657 Section 9 lists the core algorithms that OpenPGP uses. Adding in a 3658 new algorithm is usually simple. For example, adding in a new 3659 symmetric cipher usually would not need anything more than allocating 3660 a constant for that cipher. If that cipher had other than a 64-bit 3661 or 128-bit block size, there might need to be additional 3662 documentation describing how OpenPGP-CFB mode would be adjusted. 3663 Similarly, when DSA was expanded from a maximum of 1024-bit public 3664 keys to 3072-bit public keys, the revision of FIPS 186 contained 3665 enough information itself to allow implementation. Changes to this 3666 document were made mainly for emphasis. 3668 10.3.1. Public-Key Algorithms 3670 OpenPGP specifies a number of public-key algorithms. This 3671 specification creates a registry of public-key algorithm identifiers. 3672 The registry includes the algorithm name, its key sizes and 3673 parameters, and a reference to the defining specification. The 3674 initial values for this registry can be found in Section 9.1. Adding 3675 a new public-key algorithm MUST be done through the SPECIFICATION 3676 REQUIRED method, as described in [RFC8126]. 3678 This document requests IANA register the following new public-key 3679 algorithm: 3681 +====+============================+========================+ 3682 | ID | Algorithm | Reference | 3683 +====+============================+========================+ 3684 | 22 | EdDSA public key algorithm | This doc, Section 14.8 | 3685 +----+----------------------------+------------------------+ 3687 Table 20: New public-Key algorithms registered 3689 [ Note to RFC-Editor: Please remove the table above on publication. ] 3691 10.3.2. Symmetric-Key Algorithms 3693 OpenPGP specifies a number of symmetric-key algorithms. This 3694 specification creates a registry of symmetric-key algorithm 3695 identifiers. The registry includes the algorithm name, its key sizes 3696 and block size, and a reference to the defining specification. The 3697 initial values for this registry can be found in Section 9.3. Adding 3698 a new symmetric-key algorithm MUST be done through the SPECIFICATION 3699 REQUIRED method, as described in [RFC8126]. 3701 10.3.3. Hash Algorithms 3703 OpenPGP specifies a number of hash algorithms. This specification 3704 creates a registry of hash algorithm identifiers. The registry 3705 includes the algorithm name, a text representation of that name, its 3706 block size, an OID hash prefix, and a reference to the defining 3707 specification. The initial values for this registry can be found in 3708 Section 9.5 for the algorithm identifiers and text names, and 3709 Section 5.2.2 for the OIDs and expanded signature prefixes. Adding a 3710 new hash algorithm MUST be done through the SPECIFICATION REQUIRED 3711 method, as described in [RFC8126]. 3713 This document requests IANA register the following hash algorithms: 3715 +====+===========+===========+ 3716 | ID | Algorithm | Reference | 3717 +====+===========+===========+ 3718 | 12 | SHA3-256 | This doc | 3719 +----+-----------+-----------+ 3720 | 13 | Reserved | | 3721 +----+-----------+-----------+ 3722 | 14 | SHA3-512 | This doc | 3723 +----+-----------+-----------+ 3725 Table 21: New hash 3726 algorithms registered 3728 [Notes to RFC-Editor: Please remove the table above on publication. 3729 It is desirable not to reuse old or reserved algorithms because some 3730 existing tools might print a wrong description. The ID 13 has been 3731 reserved so that the SHA3 algorithm IDs align nicely with their SHA2 3732 counterparts.] 3734 10.3.4. Compression Algorithms 3736 OpenPGP specifies a number of compression algorithms. This 3737 specification creates a registry of compression algorithm 3738 identifiers. The registry includes the algorithm name and a 3739 reference to the defining specification. The initial values for this 3740 registry can be found in Section 9.4. Adding a new compression key 3741 algorithm MUST be done through the SPECIFICATION REQUIRED method, as 3742 described in [RFC8126]. 3744 11. Packet Composition 3746 OpenPGP packets are assembled into sequences in order to create 3747 messages and to transfer keys. Not all possible packet sequences are 3748 meaningful and correct. This section describes the rules for how 3749 packets should be placed into sequences. 3751 11.1. Transferable Public Keys 3753 OpenPGP users may transfer public keys. The essential elements of a 3754 transferable public key are as follows: 3756 * One Public-Key packet 3758 * Zero or more revocation signatures 3760 * One or more User ID packets 3762 * After each User ID packet, zero or more Signature packets 3763 (certifications) 3765 * Zero or more User Attribute packets 3767 * After each User Attribute packet, zero or more Signature packets 3768 (certifications) 3770 * Zero or more Subkey packets 3772 * After each Subkey packet, one Signature packet, plus optionally a 3773 revocation 3775 The Public-Key packet occurs first. Each of the following User ID 3776 packets provides the identity of the owner of this public key. If 3777 there are multiple User ID packets, this corresponds to multiple 3778 means of identifying the same unique individual user; for example, a 3779 user may have more than one email address, and construct a User ID 3780 for each one. 3782 Immediately following each User ID packet, there are zero or more 3783 Signature packets. Each Signature packet is calculated on the 3784 immediately preceding User ID packet and the initial Public-Key 3785 packet. The signature serves to certify the corresponding public key 3786 and User ID. In effect, the signer is testifying to his or her 3787 belief that this public key belongs to the user identified by this 3788 User ID. 3790 Within the same section as the User ID packets, there are zero or 3791 more User Attribute packets. Like the User ID packets, a User 3792 Attribute packet is followed by zero or more Signature packets 3793 calculated on the immediately preceding User Attribute packet and the 3794 initial Public-Key packet. 3796 User Attribute packets and User ID packets may be freely intermixed 3797 in this section, so long as the signatures that follow them are 3798 maintained on the proper User Attribute or User ID packet. 3800 After the User ID packet or Attribute packet, there may be zero or 3801 more Subkey packets. In general, subkeys are provided in cases where 3802 the top-level public key is a signature-only key. However, any V4 or 3803 V5 key may have subkeys, and the subkeys may be encryption-only keys, 3804 signature-only keys, or general-purpose keys. V3 keys MUST NOT have 3805 subkeys. 3807 Each Subkey packet MUST be followed by one Signature packet, which 3808 should be a subkey binding signature issued by the top-level key. 3809 For subkeys that can issue signatures, the subkey binding signature 3810 MUST contain an Embedded Signature subpacket with a primary key 3811 binding signature (0x19) issued by the subkey on the top-level key. 3813 Subkey and Key packets may each be followed by a revocation Signature 3814 packet to indicate that the key is revoked. Revocation signatures 3815 are only accepted if they are issued by the key itself, or by a key 3816 that is authorized to issue revocations via a Revocation Key 3817 subpacket in a self-signature by the top-level key. 3819 Transferable public-key packet sequences may be concatenated to allow 3820 transferring multiple public keys in one operation. 3822 11.2. Transferable Secret Keys 3824 OpenPGP users may transfer secret keys. The format of a transferable 3825 secret key is the same as a transferable public key except that 3826 secret-key and secret-subkey packets are used instead of the public 3827 key and public-subkey packets. Implementations SHOULD include self- 3828 signatures on any User IDs and subkeys, as this allows for a complete 3829 public key to be automatically extracted from the transferable secret 3830 key. Implementations MAY choose to omit the self-signatures, 3831 especially if a transferable public key accompanies the transferable 3832 secret key. 3834 11.3. OpenPGP Messages 3836 An OpenPGP message is a packet or sequence of packets that 3837 corresponds to the following grammatical rules (comma represents 3838 sequential composition, and vertical bar separates alternatives): 3840 OpenPGP Message :- Encrypted Message | Signed Message | Compressed 3841 Message | Literal Message. 3843 Compressed Message :- Compressed Data Packet. 3845 Literal Message :- Literal Data Packet. 3847 ESK :- Public-Key Encrypted Session Key Packet | Symmetric-Key 3848 Encrypted Session Key Packet. 3850 ESK Sequence :- ESK | ESK Sequence, ESK. 3852 Encrypted Data :- Symmetrically Encrypted Data Packet | 3853 Symmetrically Encrypted Integrity Protected Data Packet 3855 Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. 3857 One-Pass Signed Message :- One-Pass Signature Packet, OpenPGP 3858 Message, Corresponding Signature Packet. 3860 Signed Message :- Signature Packet, OpenPGP Message | One-Pass 3861 Signed Message. 3863 In addition, decrypting a Symmetrically Encrypted Data packet or a 3864 Symmetrically Encrypted Integrity Protected Data packet as well as 3865 decompressing a Compressed Data packet must yield a valid OpenPGP 3866 Message. 3868 11.4. Detached Signatures 3870 Some OpenPGP applications use so-called "detached signatures". For 3871 example, a program bundle may contain a file, and with it a second 3872 file that is a detached signature of the first file. These detached 3873 signatures are simply a Signature packet stored separately from the 3874 data for which they are a signature. 3876 12. Enhanced Key Formats 3877 12.1. Key Structures 3879 The format of an OpenPGP V3 key is as follows. Entries in square 3880 brackets are optional and ellipses indicate repetition. 3882 RSA Public Key 3883 [Revocation Self Signature] 3884 User ID [Signature ...] 3885 [User ID [Signature ...] ...] 3887 Each signature certifies the RSA public key and the preceding User 3888 ID. The RSA public key can have many User IDs and each User ID can 3889 have many signatures. V3 keys are deprecated. Implementations MUST 3890 NOT generate new V3 keys, but MAY continue to use existing ones. 3892 The format of an OpenPGP V4 key that uses multiple public keys is 3893 similar except that the other keys are added to the end as "subkeys" 3894 of the primary key. 3896 Primary-Key 3897 [Revocation Self Signature] 3898 [Direct Key Signature...] 3899 User ID [Signature ...] 3900 [User ID [Signature ...] ...] 3901 [User Attribute [Signature ...] ...] 3902 [[Subkey [Binding-Signature-Revocation] 3903 Primary-Key-Binding-Signature] ...] 3905 A subkey always has a single signature after it that is issued using 3906 the primary key to tie the two keys together. This binding signature 3907 may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can 3908 issue signatures MUST have a V4 binding signature due to the REQUIRED 3909 embedded primary key binding signature. 3911 In the above diagram, if the binding signature of a subkey has been 3912 revoked, the revoked key may be removed, leaving only one key. 3914 In a V4 key, the primary key MUST be a key capable of certification. 3915 The subkeys may be keys of any other type. There may be other 3916 constructions of V4 keys, too. For example, there may be a single- 3917 key RSA key in V4 format, a DSA primary key with an RSA encryption 3918 key, or RSA primary key with an Elgamal subkey, etc. 3920 It is also possible to have a signature-only subkey. This permits a 3921 primary key that collects certifications (key signatures), but is 3922 used only for certifying subkeys that are used for encryption and 3923 signatures. 3925 12.2. Key IDs and Fingerprints 3927 For a V3 key, the eight-octet Key ID consists of the low 64 bits of 3928 the public modulus of the RSA key. 3930 The fingerprint of a V3 key is formed by hashing the body (but not 3931 the two-octet length) of the MPIs that form the key material (public 3932 modulus n, followed by exponent e) with MD5. Note that both V3 keys 3933 and MD5 are deprecated. 3935 A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, 3936 followed by the two-octet packet length, followed by the entire 3937 Public-Key packet starting with the version field. The Key ID is the 3938 low-order 64 bits of the fingerprint. Here are the fields of the 3939 hash material, with the example of a DSA key: 3941 a.1) 0x99 (1 octet) 3943 a.2) two-octet scalar octet count of (b)-(e) 3945 b) version number = 4 (1 octet); 3947 c) timestamp of key creation (4 octets); 3949 d) algorithm (1 octet): 17 = DSA (example); 3951 e) Algorithm-specific fields. 3953 Algorithm-Specific Fields for DSA keys (example): 3955 e.1) MPI of DSA prime p; 3957 e.2) MPI of DSA group order q (q is a prime divisor of p-1); 3959 e.3) MPI of DSA group generator g; 3961 e.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 3963 A V5 fingerprint is the 256-bit SHA2-256 hash of the octet 0x9A, 3964 followed by the four-octet packet length, followed by the entire 3965 Public-Key packet starting with the version field. The Key ID is the 3966 high-order 64 bits of the fingerprint. Here are the fields of the 3967 hash material, with the example of a DSA key: 3969 a.1) 0x9A (1 octet) 3971 a.2) four-octet scalar octet count of (b)-(f) 3972 b) version number = 5 (1 octet); 3974 c) timestamp of key creation (4 octets); 3976 d) algorithm (1 octet): 17 = DSA (example); 3978 e) four-octet scalar octet count for the following key material; 3980 f) algorithm-specific fields. 3982 Algorithm-Specific Fields for DSA keys (example): 3984 f.1) MPI of DSA prime p; 3986 f.2) MPI of DSA group order q (q is a prime divisor of p-1); 3988 f.3) MPI of DSA group generator g; 3990 f.4) MPI of DSA public-key value y (= g**x mod p where x is secret). 3992 Note that it is possible for there to be collisions of Key IDs -- two 3993 different keys with the same Key ID. Note that there is a much 3994 smaller, but still non-zero, probability that two different keys have 3995 the same fingerprint. 3997 Also note that if V3, V4, and V5 format keys share the same RSA key 3998 material, they will have different Key IDs as well as different 3999 fingerprints. 4001 Finally, the Key ID and fingerprint of a subkey are calculated in the 4002 same way as for a primary key, including the 0x99 (V3 and V4 key) or 4003 0x9A (V5 key) as the first octet (even though this is not a valid 4004 packet ID for a public subkey). 4006 13. Elliptic Curve Cryptography 4008 This section descripes algorithms and parameters used with Elliptic 4009 Curve Cryptography (ECC) keys. A thorough introduction to ECC can be 4010 found in [KOBLITZ]. 4012 13.1. Supported ECC Curves 4014 This document references three named prime field curves, defined in 4015 [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521". 4016 Further curve "Curve25519", defined in [RFC7748] is referenced for 4017 use with Ed25519 (EdDSA signing) and X25519 (encryption). 4019 The named curves are referenced as a sequence of bytes in this 4020 document, called throughout, curve OID. Section 9.2 describes in 4021 detail how this sequence of bytes is formed. 4023 13.2. ECDSA and ECDH Conversion Primitives 4025 This document defines the uncompressed point format for ECDSA and 4026 ECDH and a custom compression format for certain curves. The point 4027 is encoded in the Multiprecision Integer (MPI) format. 4029 For an uncompressed point the content of the MPI is: 4031 B = 04 || x || y 4033 where x and y are coordinates of the point P = (x, y), each encoded 4034 in the big-endian format and zero-padded to the adjusted underlying 4035 field size. The adjusted underlying field size is the underlying 4036 field size that is rounded up to the nearest 8-bit boundary. This 4037 encoding is compatible with the definition given in [SEC1]. 4039 For a custom compressed point the content of the MPI is: 4041 B = 40 || x 4043 where x is the x coordinate of the point P encoded to the rules 4044 defined for the specified curve. This format is used for ECDH keys 4045 based on curves expressed in Montgomery form. 4047 Therefore, the exact size of the MPI payload is 515 bits for "Curve 4048 P-256", 771 for "Curve P-384", 1059 for "Curve P-521", and 263 for 4049 Curve25519. 4051 Even though the zero point, also called the point at infinity, may 4052 occur as a result of arithmetic operations on points of an elliptic 4053 curve, it SHALL NOT appear in data structures defined in this 4054 document. 4056 If other conversion methods are defined in the future, a compliant 4057 application MUST NOT use a new format when in doubt that any 4058 recipient can support it. Consider, for example, that while both the 4059 public key and the per-recipient ECDH data structure, respectively 4060 defined in Section 5.6.6 and Section 5.1, contain an encoded point 4061 field, the format changes to the field in Section 5.1 only affect a 4062 given recipient of a given message. 4064 13.3. EdDSA Point Format 4066 The EdDSA algorithm defines a specific point compression format. To 4067 indicate the use of this compression format and to make sure that the 4068 key can be represented in the Multiprecision Integer (MPI) format the 4069 octet string specifying the point is prefixed with the octet 0x40. 4070 This encoding is an extension of the encoding given in [SEC1] which 4071 uses 0x04 to indicate an uncompressed point. 4073 For example, the length of a public key for the curve Ed25519 is 263 4074 bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the 4075 native value of the public key. 4077 13.4. Key Derivation Function 4079 A key derivation function (KDF) is necessary to implement the EC 4080 encryption. The Concatenation Key Derivation Function (Approved 4081 Alternative 1) [SP800-56A] with the KDF hash function that is 4082 SHA2-256 [FIPS180] or stronger is REQUIRED. 4084 For convenience, the synopsis of the encoding method is given below 4085 with significant simplifications attributable to the restricted 4086 choice of hash functions in this document. However, [SP800-56A] is 4087 the normative source of the definition. 4089 // Implements KDF( X, oBits, Param ); 4090 // Input: point X = (x,y) 4091 // oBits - the desired size of output 4092 // hBits - the size of output of hash function Hash 4093 // Param - octets representing the parameters 4094 // Assumes that oBits <= hBits 4095 // Convert the point X to the octet string: 4096 // ZB' = 04 || x || y 4097 // and extract the x portion from ZB' 4098 ZB = x; 4099 MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); 4100 return oBits leftmost bits of MB. 4102 Note that ZB in the KDF description above is the compact 4103 representation of X, defined in Section 4.2 of [RFC6090]. 4105 13.5. EC DH Algorithm (ECDH) 4107 The method is a combination of an ECC Diffie-Hellman method to 4108 establish a shared secret, a key derivation method to process the 4109 shared secret into a derived key, and a key wrapping method that uses 4110 the derived key to protect a session key used to encrypt a message. 4112 The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST 4113 be implemented with the following restrictions: the ECC CDH primitive 4114 employed by this method is modified to always assume the cofactor as 4115 1, the KDF specified in Section 13.4 is used, and the KDF parameters 4116 specified below are used. 4118 The KDF parameters are encoded as a concatenation of the following 5 4119 variable-length and fixed-length fields, compatible with the 4120 definition of the OtherInfo bitstring [SP800-56A]: 4122 * a variable-length field containing a curve OID, formatted as 4123 follows: 4125 - a one-octet size of the following field 4127 - the octets representing a curve OID, defined in Section 9.2 4129 * a one-octet public key algorithm ID defined in Section 9.1 4131 * a variable-length field containing KDF parameters, identical to 4132 the corresponding field in the ECDH public key, formatted as 4133 follows: 4135 - a one-octet size of the following fields; values 0 and 0xff are 4136 reserved for future extensions 4138 - a one-octet value 01, reserved for future extensions 4140 - a one-octet hash function ID used with the KDF 4142 - a one-octet algorithm ID for the symmetric algorithm used to 4143 wrap the symmetric key for message encryption; see Section 13.5 4144 for details 4146 * 20 octets representing the UTF-8 encoding of the string "Anonymous 4147 Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 4148 73 20 53 65 6E 64 65 72 20 20 20 20 4150 * 20 octets representing a recipient encryption subkey or a master 4151 key fingerprint, identifying the key material that is needed for 4152 the decryption. For version 5 keys the 20 leftmost octets of the 4153 fingerprint are used. 4155 The size of the KDF parameters sequence, defined above, is either 54 4156 for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 4157 for Curve25519. 4159 The key wrapping method is described in [RFC3394]. KDF produces a 4160 symmetric key that is used as a key-encryption key (KEK) as specified 4161 in [RFC3394]. Refer to Section 15 for the details regarding the 4162 choice of the KEK algorithm, which SHOULD be one of three AES 4163 algorithms. Key wrapping and unwrapping is performed with the 4164 default initial value of [RFC3394]. 4166 The input to the key wrapping method is the value "m" derived from 4167 the session key, as described in Section 5.1, "Public-Key Encrypted 4168 Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step 4169 is omitted. The result is padded using the method described in 4170 [PKCS5] to the 8-byte granularity. For example, the following 4171 AES-256 session key, in which 32 octets are denoted from k0 to k31, 4172 is composed to form the following 40 octet sequence: 4174 09 k0 k1 ... k31 s0 s1 05 05 05 05 05 4176 The octets s0 and s1 above denote the checksum. This encoding allows 4177 the sender to obfuscate the size of the symmetric encryption key used 4178 to encrypt the data. For example, assuming that an AES algorithm is 4179 used for the session key, the sender MAY use 21, 13, and 5 bytes of 4180 padding for AES-128, AES-192, and AES-256, respectively, to provide 4181 the same number of octets, 40 total, as an input to the key wrapping 4182 method. 4184 The output of the method consists of two fields. The first field is 4185 the MPI containing the ephemeral key used to establish the shared 4186 secret. The second field is composed of the following two fields: 4188 * a one-octet encoding the size in octets of the result of the key 4189 wrapping method; the value 255 is reserved for future extensions; 4191 * up to 254 octets representing the result of the key wrapping 4192 method, applied to the 8-byte padded session key, as described 4193 above. 4195 Note that for session key sizes 128, 192, and 256 bits, the size of 4196 the result of the key wrapping method is, respectively, 32, 40, and 4197 48 octets, unless the size obfuscation is used. 4199 For convenience, the synopsis of the encoding method is given below; 4200 however, this section, [SP800-56A], and [RFC3394] are the normative 4201 sources of the definition. 4203 * Obtain the authenticated recipient public key R 4205 * Generate an ephemeral key pair {v, V=vG} 4206 * Compute the shared point S = vR; 4208 * m = symm_alg_ID || session key || checksum || pkcs5_padding; 4210 * curve_OID_len = (byte)len(curve_OID); 4212 * Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 4213 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous 4214 Sender " || recipient_fingerprint; 4216 * Z_len = the key size for the KEK_alg_ID used with AESKeyWrap 4218 * Compute Z = KDF( S, Z_len, Param ); 4220 * Compute C = AESKeyWrap( Z, m ) as per [RFC3394] 4222 * VB = convert point V to the octet string 4224 * Output (MPI(VB) || len(C) || C). 4226 The decryption is the inverse of the method given. Note that the 4227 recipient obtains the shared secret by calculating 4229 S = rV = rvG, where (r,R) is the recipient's key pair. 4231 Consistent with Section 5.14, Modification Detection Code (MDC) MUST 4232 be used anytime the symmetric key is protected by ECDH. 4234 14. Notes on Algorithms 4236 14.1. PKCS#1 Encoding in OpenPGP 4238 This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and 4239 EMSA-PKCS1-v1_5. However, the calling conventions of these functions 4240 has changed in the past. To avoid potential confusion and 4241 interoperability problems, we are including local copies in this 4242 document, adapted from those in PKCS#1 v2.1 [RFC3447]. [RFC3447] 4243 should be treated as the ultimate authority on PKCS#1 for OpenPGP. 4244 Nonetheless, we believe that there is value in having a self- 4245 contained document that avoids problems in the future with needed 4246 changes in the conventions. 4248 14.1.1. EME-PKCS1-v1_5-ENCODE 4250 Input: 4252 k = the length in octets of the key modulus. 4254 M = message to be encoded, an octet string of length mLen, where 4255 mLen <= k - 11. 4257 Output: 4259 EM = encoded message, an octet string of length k. 4261 Error: "message too long". 4263 1. Length checking: If mLen > k - 11, output "message too long" and 4264 stop. 4266 2. Generate an octet string PS of length k - mLen - 3 consisting of 4267 pseudo-randomly generated nonzero octets. The length of PS will 4268 be at least eight octets. 4270 3. Concatenate PS, the message M, and other padding to form an 4271 encoded message EM of length k octets as 4273 EM = 0x00 || 0x02 || PS || 0x00 || M. 4275 4. Output EM. 4277 14.1.2. EME-PKCS1-v1_5-DECODE 4279 Input: 4281 EM = encoded message, an octet string 4283 Output: 4285 M = message, an octet string. 4287 Error: "decryption error". 4289 To decode an EME-PKCS1_v1_5 message, separate the encoded message EM 4290 into an octet string PS consisting of nonzero octets and a message M 4291 as follows 4293 EM = 0x00 || 0x02 || PS || 0x00 || M. 4295 If the first octet of EM does not have hexadecimal value 0x00, if the 4296 second octet of EM does not have hexadecimal value 0x02, if there is 4297 no octet with hexadecimal value 0x00 to separate PS from M, or if the 4298 length of PS is less than 8 octets, output "decryption error" and 4299 stop. See also the security note in Section 15 regarding differences 4300 in reporting between a decryption error and a padding error. 4302 14.1.3. EMSA-PKCS1-v1_5 4304 This encoding method is deterministic and only has an encoding 4305 operation. 4307 Option: 4309 Hash - a hash function in which hLen denotes the length in octets of 4310 the hash function output. 4312 Input: 4314 M = message to be encoded. 4316 emLen = intended length in octets of the encoded message, at least 4317 tLen + 11, where tLen is the octet length of the DER encoding T of 4318 a certain value computed during the encoding operation. 4320 Output: 4322 EM = encoded message, an octet string of length emLen. 4324 Errors: "message too long"; "intended encoded message length too 4325 short". 4327 Steps: 4329 1. Apply the hash function to the message M to produce a hash value 4330 H: 4332 H = Hash(M). 4334 If the hash function outputs "message too long," output "message 4335 too long" and stop. 4337 2. Using the list in Section 5.2.2, produce an ASN.1 DER value for 4338 the hash function used. Let T be the full hash prefix from the 4339 list, and let tLen be the length in octets of T. 4341 3. If emLen < tLen + 11, output "intended encoded message length too 4342 short" and stop. 4344 4. Generate an octet string PS consisting of emLen - tLen - 3 octets 4345 with hexadecimal value 0xFF. The length of PS will be at least 8 4346 octets. 4348 5. Concatenate PS, the hash prefix T, and other padding to form the 4349 encoded message EM as 4351 EM = 0x00 || 0x01 || PS || 0x00 || T. 4353 6. Output EM. 4355 14.2. Symmetric Algorithm Preferences 4357 The symmetric algorithm preference is an ordered list of algorithms 4358 that the keyholder accepts. Since it is found on a self-signature, 4359 it is possible that a keyholder may have multiple, different 4360 preferences. For example, Alice may have AES-128 only specified for 4361 "alice@work.com" but Camellia-256, Twofish, and AES-128 specified for 4362 "alice@home.org". Note that it is also possible for preferences to 4363 be in a subkey's binding signature. 4365 Since TripleDES is the MUST-implement algorithm, if it is not 4366 explicitly in the list, it is tacitly at the end. However, it is 4367 good form to place it there explicitly. Note also that if an 4368 implementation does not implement the preference, then it is 4369 implicitly a TripleDES-only implementation. 4371 An implementation MUST NOT use a symmetric algorithm that is not in 4372 the recipient's preference list. When encrypting to more than one 4373 recipient, the implementation finds a suitable algorithm by taking 4374 the intersection of the preferences of the recipients. Note that the 4375 MUST-implement algorithm, TripleDES, ensures that the intersection is 4376 not null. The implementation may use any mechanism to pick an 4377 algorithm in the intersection. 4379 If an implementation can decrypt a message that a keyholder doesn't 4380 have in their preferences, the implementation SHOULD decrypt the 4381 message anyway, but MUST warn the keyholder that the protocol has 4382 been violated. For example, suppose that Alice, above, has software 4383 that implements all algorithms in this specification. Nonetheless, 4384 she prefers subsets for work or home. If she is sent a message 4385 encrypted with IDEA, which is not in her preferences, the software 4386 warns her that someone sent her an IDEA-encrypted message, but it 4387 would ideally decrypt it anyway. 4389 14.3. Other Algorithm Preferences 4391 Other algorithm preferences work similarly to the symmetric algorithm 4392 preference, in that they specify which algorithms the keyholder 4393 accepts. There are two interesting cases that other comments need to 4394 be made about, though, the compression preferences and the hash 4395 preferences. 4397 14.3.1. Compression Preferences 4399 Compression has been an integral part of PGP since its first days. 4400 OpenPGP and all previous versions of PGP have offered compression. 4401 In this specification, the default is for messages to be compressed, 4402 although an implementation is not required to do so. Consequently, 4403 the compression preference gives a way for a keyholder to request 4404 that messages not be compressed, presumably because they are using a 4405 minimal implementation that does not include compression. 4406 Additionally, this gives a keyholder a way to state that it can 4407 support alternate algorithms. 4409 Like the algorithm preferences, an implementation MUST NOT use an 4410 algorithm that is not in the preference vector. If the preferences 4411 are not present, then they are assumed to be [ZIP(1), 4412 Uncompressed(0)]. 4414 Additionally, an implementation MUST implement this preference to the 4415 degree of recognizing when to send an uncompressed message. A robust 4416 implementation would satisfy this requirement by looking at the 4417 recipient's preference and acting accordingly. A minimal 4418 implementation can satisfy this requirement by never generating a 4419 compressed message, since all implementations can handle messages 4420 that have not been compressed. 4422 14.3.2. Hash Algorithm Preferences 4424 Typically, the choice of a hash algorithm is something the signer 4425 does, rather than the verifier, because a signer rarely knows who is 4426 going to be verifying the signature. This preference, though, allows 4427 a protocol based upon digital signatures ease in negotiation. 4429 Thus, if Alice is authenticating herself to Bob with a signature, it 4430 makes sense for her to use a hash algorithm that Bob's software uses. 4431 This preference allows Bob to state in his key which algorithms Alice 4432 may use. 4434 Since SHA1 is the MUST-implement hash algorithm, if it is not 4435 explicitly in the list, it is tacitly at the end. However, it is 4436 good form to place it there explicitly. 4438 14.4. Plaintext 4440 Algorithm 0, "plaintext", may only be used to denote secret keys that 4441 are stored in the clear. Implementations MUST NOT use plaintext in 4442 Symmetrically Encrypted Data packets; they must use Literal Data 4443 packets to encode unencrypted or literal data. 4445 14.5. RSA 4447 There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only 4448 keys. These types are deprecated. The "key flags" subpacket in a 4449 signature is a much better way to express the same idea, and 4450 generalizes it to all algorithms. An implementation SHOULD NOT 4451 create such a key, but MAY interpret it. 4453 An implementation SHOULD NOT implement RSA keys of size less than 4454 1024 bits. 4456 14.6. DSA 4458 An implementation SHOULD NOT implement DSA keys of size less than 4459 1024 bits. It MUST NOT implement a DSA key with a q size of less 4460 than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the 4461 q size MUST be a multiple of 8 bits. The Digital Signature Standard 4462 (DSS) [FIPS186] specifies that DSA be used in one of the following 4463 ways: 4465 * 1024-bit key, 160-bit q, SHA-1, SHA2-224, SHA2-256, SHA2-384, or 4466 SHA2-512 hash 4468 * 2048-bit key, 224-bit q, SHA2-224, SHA2-256, SHA2-384, or SHA2-512 4469 hash 4471 * 2048-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4473 * 3072-bit key, 256-bit q, SHA2-256, SHA2-384, or SHA2-512 hash 4475 The above key and q size pairs were chosen to best balance the 4476 strength of the key with the strength of the hash. Implementations 4477 SHOULD use one of the above key and q size pairs when generating DSA 4478 keys. If DSS compliance is desired, one of the specified SHA hashes 4479 must be used as well. [FIPS186] is the ultimate authority on DSS, 4480 and should be consulted for all questions of DSS compliance. 4482 Note that earlier versions of this standard only allowed a 160-bit q 4483 with no truncation allowed, so earlier implementations may not be 4484 able to handle signatures with a different q size or a truncated 4485 hash. 4487 14.7. Elgamal 4489 An implementation SHOULD NOT implement Elgamal keys of size less than 4490 1024 bits. 4492 14.8. EdDSA 4494 Although the EdDSA algorithm allows arbitrary data as input, its use 4495 with OpenPGP requires that a digest of the message is used as input 4496 (pre-hashed). See section Section 5.2.4, "Computing Signatures" for 4497 details. Truncation of the resulting digest is never applied; the 4498 resulting digest value is used verbatim as input to the EdDSA 4499 algorithm. 4501 14.9. Reserved Algorithm Numbers 4503 A number of algorithm IDs have been reserved for algorithms that 4504 would be useful to use in an OpenPGP implementation, yet there are 4505 issues that prevent an implementer from actually implementing the 4506 algorithm. These are marked in Section 9.1 as "reserved for". 4508 The reserved public-key algorithm X9.42 (21) does not have the 4509 necessary parameters, parameter order, or semantics defined. The 4510 same is currently true for reserved public-key algorithms AEDH (23) 4511 and AEDSA (24). 4513 Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures 4514 with a public-key identifier of 20. These are no longer permitted. 4515 An implementation MUST NOT generate such keys. An implementation 4516 MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. 4518 14.10. OpenPGP CFB Mode 4520 OpenPGP does symmetric encryption using a variant of Cipher Feedback 4521 mode (CFB mode). This section describes the procedure it uses in 4522 detail. This mode is what is used for Symmetrically Encrypted Data 4523 Packets; the mechanism used for encrypting secret-key material is 4524 similar, and is described in the sections above. 4526 In the description below, the value BS is the block size in octets of 4527 the cipher. Most ciphers have a block size of 8 octets. The AES and 4528 Twofish have a block size of 16 octets. Also note that the 4529 description below assumes that the IV and CFB arrays start with an 4530 index of 1 (unlike the C language, which assumes arrays start with a 4531 zero index). 4533 OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and 4534 prefixes the plaintext with BS+2 octets of random data, such that 4535 octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB 4536 resynchronization after encrypting those BS+2 octets. 4538 Thus, for an algorithm that has a block size of 8 octets (64 bits), 4539 the IV is 10 octets long and octets 7 and 8 of the IV are the same as 4540 octets 9 and 10. For an algorithm with a block size of 16 octets 4541 (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate 4542 octets 15 and 16. Those extra two octets are an easy check for a 4543 correct key. 4545 Step by step, here is the procedure: 4547 1. The feedback register (FR) is set to the IV, which is all zeros. 4549 2. FR is encrypted to produce FRE (FR Encrypted). This is the 4550 encryption of an all-zero value. 4552 3. FRE is xored with the first BS octets of random data prefixed to 4553 the plaintext to produce C[1] through C[BS], the first BS octets 4554 of ciphertext. 4556 4. FR is loaded with C[1] through C[BS]. 4558 5. FR is encrypted to produce FRE, the encryption of the first BS 4559 octets of ciphertext. 4561 6. The left two octets of FRE get xored with the next two octets of 4562 data that were prefixed to the plaintext. This produces C[BS+1] 4563 and C[BS+2], the next two octets of ciphertext. 4565 7. (The resynchronization step) FR is loaded with C[3] through 4566 C[BS+2]. 4568 8. FR is encrypted to produce FRE. 4570 9. FRE is xored with the first BS octets of the given plaintext, 4571 now that we have finished encrypting the BS+2 octets of prefixed 4572 data. This produces C[BS+3] through C[BS+(BS+2)], the next BS 4573 octets of ciphertext. 4575 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 4576 for an 8-octet block). 4578 11. FR is encrypted to produce FRE. 4580 12. FRE is xored with the next BS octets of plaintext, to produce 4581 the next BS octets of ciphertext. These are loaded into FR, and 4582 the process is repeated until the plaintext is used up. 4584 14.11. Private or Experimental Parameters 4586 S2K specifiers, Signature subpacket types, User Attribute types, 4587 image format types, and algorithms described in Section 9 all reserve 4588 the range 100 to 110 for private and experimental use. Packet types 4589 reserve the range 60 to 63 for private and experimental use. These 4590 are intentionally managed with the PRIVATE USE method, as described 4591 in [RFC8126]. 4593 However, implementations need to be careful with these and promote 4594 them to full IANA-managed parameters when they grow beyond the 4595 original, limited system. 4597 14.12. Extension of the MDC System 4599 As described in the non-normative explanation in Section 5.14, the 4600 MDC system is uniquely unparameterized in OpenPGP. This was an 4601 intentional decision to avoid cross-grade attacks. If the MDC system 4602 is extended to a stronger hash function, care must be taken to avoid 4603 downgrade and cross-grade attacks. 4605 One simple way to do this is to create new packets for a new MDC. 4606 For example, instead of the MDC system using packets 18 and 19, a new 4607 MDC could use 20 and 21. This has obvious drawbacks (it uses two 4608 packet numbers for each new hash function in a space that is limited 4609 to a maximum of 60). 4611 Another simple way to extend the MDC system is to create new versions 4612 of packet 18, and reflect this in packet 19. For example, suppose 4613 that V2 of packet 18 implicitly used SHA-256. This would require 4614 packet 19 to have a length of 32 octets. The change in the version 4615 in packet 18 and the size of packet 19 prevent a downgrade attack. 4617 There are two drawbacks to this latter approach. The first is that 4618 using the version number of a packet to carry algorithm information 4619 is not tidy from a protocol-design standpoint. It is possible that 4620 there might be several versions of the MDC system in common use, but 4621 this untidiness would reflect untidiness in cryptographic consensus 4622 about hash function security. The second is that different versions 4623 of packet 19 would have to have unique sizes. If there were two 4624 versions each with 256-bit hashes, they could not both have 32-octet 4625 packet 19s without admitting the chance of a cross-grade attack. 4627 Yet another, complex approach to extend the MDC system would be a 4628 hybrid of the two above -- create a new pair of MDC packets that are 4629 fully parameterized, and yet protected from downgrade and cross- 4630 grade. 4632 Any change to the MDC system MUST be done through the IETF CONSENSUS 4633 method, as described in [RFC8126]. 4635 14.13. Meta-Considerations for Expansion 4637 If OpenPGP is extended in a way that is not backwards-compatible, 4638 meaning that old implementations will not gracefully handle their 4639 absence of a new feature, the extension proposal can be declared in 4640 the key holder's self-signature as part of the Features signature 4641 subpacket. 4643 We cannot state definitively what extensions will not be upwards- 4644 compatible, but typically new algorithms are upwards-compatible, 4645 whereas new packets are not. 4647 If an extension proposal does not update the Features system, it 4648 SHOULD include an explanation of why this is unnecessary. If the 4649 proposal contains neither an extension to the Features system nor an 4650 explanation of why such an extension is unnecessary, the proposal 4651 SHOULD be rejected. 4653 15. Security Considerations 4655 * As with any technology involving cryptography, you should check 4656 the current literature to determine if any algorithms used here 4657 have been found to be vulnerable to attack. 4659 * This specification uses Public-Key Cryptography technologies. It 4660 is assumed that the private key portion of a public-private key 4661 pair is controlled and secured by the proper party or parties. 4663 * Certain operations in this specification involve the use of random 4664 numbers. An appropriate entropy source should be used to generate 4665 these numbers (see [RFC4086]). 4667 * The MD5 hash algorithm has been found to have weaknesses, with 4668 collisions found in a number of cases. MD5 is deprecated for use 4669 in OpenPGP. Implementations MUST NOT generate new signatures 4670 using MD5 as a hash function. They MAY continue to consider old 4671 signatures that used MD5 as valid. 4673 * SHA2-224 and SHA2-384 require the same work as SHA2-256 and 4674 SHA2-512, respectively. In general, there are few reasons to use 4675 them outside of DSS compatibility. You need a situation where one 4676 needs more security than smaller hashes, but does not want to have 4677 the full 256-bit or 512-bit data length. 4679 * Many security protocol designers think that it is a bad idea to 4680 use a single key for both privacy (encryption) and integrity 4681 (signatures). In fact, this was one of the motivating forces 4682 behind the V4 key format with separate signature and encryption 4683 keys. If you as an implementer promote dual-use keys, you should 4684 at least be aware of this controversy. 4686 * The DSA algorithm will work with any hash, but is sensitive to the 4687 quality of the hash algorithm. Verifiers should be aware that 4688 even if the signer used a strong hash, an attacker could have 4689 modified the signature to use a weak one. Only signatures using 4690 acceptably strong hash algorithms should be accepted as valid. 4692 * As OpenPGP combines many different asymmetric, symmetric, and hash 4693 algorithms, each with different measures of strength, care should 4694 be taken that the weakest element of an OpenPGP message is still 4695 sufficiently strong for the purpose at hand. While consensus 4696 about the strength of a given algorithm may evolve, NIST Special 4697 Publication 800-57 [SP800-57] recommends the following list of 4698 equivalent strengths: 4700 +=====================+===========+====================+ 4701 | Asymmetric key size | Hash size | Symmetric key size | 4702 +=====================+===========+====================+ 4703 | 1024 | 160 | 80 | 4704 +---------------------+-----------+--------------------+ 4705 | 2048 | 224 | 112 | 4706 +---------------------+-----------+--------------------+ 4707 | 3072 | 256 | 128 | 4708 +---------------------+-----------+--------------------+ 4709 | 7680 | 384 | 192 | 4710 +---------------------+-----------+--------------------+ 4711 | 15360 | 512 | 256 | 4712 +---------------------+-----------+--------------------+ 4714 Table 22: Key length equivalences 4716 * There is a somewhat-related potential security problem in 4717 signatures. If an attacker can find a message that hashes to the 4718 same hash with a different algorithm, a bogus signature structure 4719 can be constructed that evaluates correctly. 4721 For example, suppose Alice DSA signs message M using hash 4722 algorithm H. Suppose that Mallet finds a message M' that has the 4723 same hash value as M with H'. Mallet can then construct a 4724 signature block that verifies as Alice's signature of M' with H'. 4725 However, this would also constitute a weakness in either H or H' 4726 or both. Should this ever occur, a revision will have to be made 4727 to this document to revise the allowed hash algorithms. 4729 * If you are building an authentication system, the recipient may 4730 specify a preferred signing algorithm. However, the signer would 4731 be foolish to use a weak algorithm simply because the recipient 4732 requests it. 4734 * Some of the encryption algorithms mentioned in this document have 4735 been analyzed less than others. For example, although CAST5 is 4736 presently considered strong, it has been analyzed less than 4737 TripleDES. Other algorithms may have other controversies 4738 surrounding them. 4740 * In late summer 2002, Jallad, Katz, and Schneier published an 4741 interesting attack on the OpenPGP protocol and some of its 4742 implementations [JKS02]. In this attack, the attacker modifies a 4743 message and sends it to a user who then returns the erroneously 4744 decrypted message to the attacker. The attacker is thus using the 4745 user as a random oracle, and can often decrypt the message. 4747 Compressing data can ameliorate this attack. The incorrectly 4748 decrypted data nearly always decompresses in ways that defeat the 4749 attack. However, this is not a rigorous fix, and leaves open some 4750 small vulnerabilities. For example, if an implementation does not 4751 compress a message before encryption (perhaps because it knows it 4752 was already compressed), then that message is vulnerable. Because 4753 of this happenstance -- that modification attacks can be thwarted 4754 by decompression errors -- an implementation SHOULD treat a 4755 decompression error as a security problem, not merely a data 4756 problem. 4758 This attack can be defeated by the use of Modification Detection, 4759 provided that the implementation does not let the user naively 4760 return the data to the attacker. An implementation MUST treat an 4761 MDC failure as a security problem, not merely a data problem. 4763 In either case, the implementation MAY allow the user access to 4764 the erroneous data, but MUST warn the user as to potential 4765 security problems should that data be returned to the sender. 4767 While this attack is somewhat obscure, requiring a special set of 4768 circumstances to create it, it is nonetheless quite serious as it 4769 permits someone to trick a user to decrypt a message. 4770 Consequently, it is important that: 4772 1. Implementers treat MDC errors and decompression failures as 4773 security problems. 4775 2. Implementers implement Modification Detection with all due 4776 speed and encourage its spread. 4778 3. Users migrate to implementations that support Modification 4779 Detection with all due speed. 4781 * PKCS#1 has been found to be vulnerable to attacks in which a 4782 system that reports errors in padding differently from errors in 4783 decryption becomes a random oracle that can leak the private key 4784 in mere millions of queries. Implementations must be aware of 4785 this attack and prevent it from happening. The simplest solution 4786 is to report a single error code for all variants of decryption 4787 errors so as not to leak information to an attacker. 4789 * Some technologies mentioned here may be subject to government 4790 control in some countries. 4792 * In winter 2005, Serge Mister and Robert Zuccherato from Entrust 4793 released a paper describing a way that the "quick check" in 4794 OpenPGP CFB mode can be used with a random oracle to decrypt two 4795 octets of every cipher block [MZ05]. They recommend as prevention 4796 not using the quick check at all. 4798 Many implementers have taken this advice to heart for any data 4799 that is symmetrically encrypted and for which the session key is 4800 public-key encrypted. In this case, the quick check is not needed 4801 as the public-key encryption of the session key should guarantee 4802 that it is the right session key. In other cases, the 4803 implementation should use the quick check with care. 4805 On the one hand, there is a danger to using it if there is a 4806 random oracle that can leak information to an attacker. In 4807 plainer language, there is a danger to using the quick check if 4808 timing information about the check can be exposed to an attacker, 4809 particularly via an automated service that allows rapidly repeated 4810 queries. 4812 On the other hand, it is inconvenient to the user to be informed 4813 that they typed in the wrong passphrase only after a petabyte of 4814 data is decrypted. There are many cases in cryptographic 4815 engineering where the implementer must use care and wisdom, and 4816 this is one. 4818 * Refer to [FIPS186], B.4.1, for the method to generate a uniformly 4819 distributed ECC private key. 4821 * The curves proposed in this document correspond to the symmetric 4822 key sizes 128 bits, 192 bits, and 256 bits, as described in the 4823 table below. This allows a compliant application to offer 4824 balanced public key security, which is compatible with the 4825 symmetric key strength for each AES algorithm defined here. 4827 The following table defines the hash and the symmetric encryption 4828 algorithm that SHOULD be used with a given curve for ECDSA or 4829 ECDH. A stronger hash algorithm or a symmetric key algorithm MAY 4830 be used for a given ECC curve. However, note that the increase in 4831 the strength of the hash algorithm or the symmetric key algorithm 4832 may not increase the overall security offered by the given ECC 4833 key. 4835 +============+=====+==============+=====================+===========+ 4836 | Curve name | ECC | RSA | Hash size strength, | Symmetric | 4837 | | | strength | informative | key size | 4838 +============+=====+==============+=====================+===========+ 4839 | NIST P-256 | 256 | 3072 | 256 | 128 | 4840 +------------+-----+--------------+---------------------+-----------+ 4841 | NIST P-384 | 384 | 7680 | 384 | 192 | 4842 +------------+-----+--------------+---------------------+-----------+ 4843 | NIST P-521 | 521 | 15360 | 512 | 256 | 4844 +------------+-----+--------------+---------------------+-----------+ 4846 Table 23: Elliptic Curve cryptographic guidance 4848 * Requirement levels indicated elsewhere in this document lead to 4849 the following combinations of algorithms in the OpenPGP profile: 4850 MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD 4851 implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement 4852 NIST curve P-384 / SHA2-384 / AES-256, among other allowed 4853 combinations. 4855 Consistent with the table above, the following table defines the 4856 KDF hash algorithm and the AES KEK encryption algorithm that 4857 SHOULD be used with a given curve for ECDH. A stronger KDF hash 4858 algorithm or AES KEK algorithm MAY be used for a given ECC curve. 4860 +============+=================+======================+ 4861 | Curve name | Recommended KDF | Recommended KEK | 4862 | | hash algorithm | encryption algorithm | 4863 +============+=================+======================+ 4864 | NIST P-256 | SHA2-256 | AES-128 | 4865 +------------+-----------------+----------------------+ 4866 | NIST P-384 | SHA2-384 | AES-192 | 4867 +------------+-----------------+----------------------+ 4868 | NIST P-521 | SHA2-512 | AES-256 | 4869 +------------+-----------------+----------------------+ 4871 Table 24: Elliptic Curve KDF and KEK recommendations 4873 * This document explicitly discourages the use of algorithms other 4874 than AES as a KEK algorithm because backward compatibility of the 4875 ECDH format is not a concern. The KEK algorithm is only used 4876 within the scope of a Public-Key Encrypted Session Key Packet, 4877 which represents an ECDH key recipient of a message. Compare this 4878 with the algorithm used for the session key of the message, which 4879 MAY be different from a KEK algorithm. 4881 Compliant applications SHOULD implement, advertise through key 4882 preferences, and use the strongest algorithms specified in this 4883 document. 4885 Note that the symmetric algorithm preference list may make it 4886 impossible to use the balanced strength of symmetric key 4887 algorithms for a corresponding public key. For example, the 4888 presence of the symmetric key algorithm IDs and their order in the 4889 key preference list affects the algorithm choices available to the 4890 encoding side, which in turn may make the adherence to the table 4891 above infeasible. Therefore, compliance with this specification 4892 is a concern throughout the life of the key, starting immediately 4893 after the key generation when the key preferences are first added 4894 to a key. It is generally advisable to position a symmetric 4895 algorithm ID of strength matching the public key at the head of 4896 the key preference list. 4898 Encryption to multiple recipients often results in an unordered 4899 intersection subset. For example, if the first recipient's set is 4900 {A, B} and the second's is {B, A}, the intersection is an 4901 unordered set of two algorithms, A and B. In this case, a 4902 compliant application SHOULD choose the stronger encryption 4903 algorithm. 4905 Resource constraints, such as limited computational power, is a 4906 likely reason why an application might prefer to use the weakest 4907 algorithm. On the other side of the spectrum are applications 4908 that can implement every algorithm defined in this document. Most 4909 applications are expected to fall into either of two categories. 4910 A compliant application in the second, or strongest, category 4911 SHOULD prefer AES-256 to AES-192. 4913 SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH 4914 method. 4916 MDC MUST be used when a symmetric encryption key is protected by 4917 ECDH. None of the ECC methods described in this document are 4918 allowed with deprecated V3 keys. 4920 Side channel attacks are a concern when a compliant application's 4921 use of the OpenPGP format can be modeled by a decryption or 4922 signing oracle model, for example, when an application is a 4923 network service performing decryption to unauthenticated remote 4924 users. ECC scalar multiplication operations used in ECDSA and 4925 ECDH are vulnerable to side channel attacks. Countermeasures can 4926 often be taken at the higher protocol level, such as limiting the 4927 number of allowed failures or time-blinding of the operations 4928 associated with each network interface. Mitigations at the scalar 4929 multiplication level seek to eliminate any measurable distinction 4930 between the ECC point addition and doubling operations. 4932 16. Implementation Nits 4934 This section is a collection of comments to help an implementer, 4935 particularly with an eye to backward compatibility. Previous 4936 implementations of PGP are not OpenPGP compliant. Often the 4937 differences are small, but small differences are frequently more 4938 vexing than large differences. Thus, this is a non-comprehensive 4939 list of potential problems and gotchas for a developer who is trying 4940 to be backward-compatible. 4942 * The IDEA algorithm is patented, and yet it is required for PGP 2 4943 interoperability. It is also the de-facto preferred algorithm for 4944 a V3 key with a V3 self-signature (or no self-signature). 4946 * When exporting a private key, PGP 2 generates the header "BEGIN 4947 PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". 4948 All previous versions ignore the implied data type, and look 4949 directly at the packet data type. 4951 * PGP versions 2.0 through 2.5 generated V2 Public-Key packets. 4952 These are identical to the deprecated V3 keys except for the 4953 version number. An implementation MUST NOT generate them and may 4954 accept or reject them as it sees fit. Some older PGP versions 4955 generated V2 PKESK packets (Tag 1) as well. An implementation may 4956 accept or reject V2 PKESK packets as it sees fit, and MUST NOT 4957 generate them. 4959 * PGP version 2.6 will not accept key-material packets with versions 4960 greater than 3. 4962 * There are many ways possible for two keys to have the same key 4963 material, but different fingerprints (and thus Key IDs). Perhaps 4964 the most interesting is an RSA key that has been "upgraded" to V4 4965 format, but since a V4 fingerprint is constructed by hashing the 4966 key creation time along with other things, two V4 keys created at 4967 different times, yet with the same key material will have 4968 different fingerprints. 4970 * If an implementation is using zlib to interoperate with PGP 2, 4971 then the "windowBits" parameter should be set to -13. 4973 * The 0x19 back signatures were not required for signing subkeys 4974 until relatively recently. Consequently, there may be keys in the 4975 wild that do not have these back signatures. Implementing 4976 software may handle these keys as it sees fit. 4978 * OpenPGP does not put limits on the size of public keys. However, 4979 larger keys are not necessarily better keys. Larger keys take 4980 more computation time to use, and this can quickly become 4981 impractical. Different OpenPGP implementations may also use 4982 different upper bounds for public key sizes, and so care should be 4983 taken when choosing sizes to maintain interoperability. As of 4984 2007 most implementations have an upper bound of 4096 bits. 4986 * ASCII armor is an optional feature of OpenPGP. The OpenPGP 4987 working group strives for a minimal set of mandatory-to-implement 4988 features, and since there could be useful implementations that 4989 only use binary object formats, this is not a "MUST" feature for 4990 an implementation. For example, an implementation that is using 4991 OpenPGP as a mechanism for file signatures may find ASCII armor 4992 unnecessary. OpenPGP permits an implementation to declare what 4993 features it does and does not support, but ASCII armor is not one 4994 of these. Since most implementations allow binary and armored 4995 objects to be used indiscriminately, an implementation that does 4996 not implement ASCII armor may find itself with compatibility 4997 issues with general-purpose implementations. Moreover, 4998 implementations of OpenPGP-MIME [RFC3156] already have a 4999 requirement for ASCII armor so those implementations will 5000 necessarily have support. 5002 17. References 5004 17.1. Normative References 5006 [AES] NIST, "FIPS PUB 197, Advanced Encryption Standard (AES)", 5007 November 2001, 5008 . 5011 [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 5012 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, 5013 Cambridge Security Workshop Proceedings Springer-Verlag, 5014 1994, pp191-204, December 1993, 5015 . 5017 [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, 5018 . 5020 [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature 5021 Scheme Based on Discrete Logarithms", IEEE Transactions on 5022 Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 5023 1985. 5025 [FIPS180] National Institute of Standards and Technology, U.S. 5026 Department of Commerce, "Secure Hash Standard (SHS), FIPS 5027 180-4", August 2015, 5028 . 5030 [FIPS186] National Institute of Standards and Technology, U.S. 5031 Department of Commerce, "Digital Signature Standard (DSS), 5032 FIPS 186-4", July 2013, 5033 . 5035 [FIPS202] National Institute of Standards and Technology, U.S. 5036 Department of Commerce, "SHA-3 Standard: Permutation-Based 5037 Hash and Extendable-Output Functions, FIPS 202", August 5038 2015, . 5040 [HAC] Menezes, A.J., Oorschot, P.v., and S. Vanstone, "Handbook 5041 of Applied Cryptography", 1996. 5043 [IDEA] Lai, X., "On the design and security of block ciphers", 5044 ETH Series in Information Processing, J.L. Massey 5045 (editor) Vol. 1, Hartung-Gorre Verlag Konstanz, Technische 5046 Hochschule (Zurich), 1992. 5048 [ISO10646] International Organization for Standardization, 5049 "Information Technology - Universal Multiple-octet coded 5050 Character Set (UCS) - Part 1: Architecture and Basic 5051 Multilingual Plane", ISO Standard 10646-1, May 1993. 5053 [JFIF] CA, E.H.M., "JPEG File Interchange Format (Version 5054 1.02).", September 1996. 5056 [PKCS5] RSA Laboratories, "PKCS #5 v2.0: Password-Based 5057 Cryptography Standard", 25 March 1999. 5059 [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data Format 5060 Specification version 3.3", RFC 1950, 5061 DOI 10.17487/RFC1950, May 1996, 5062 . 5064 [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification 5065 version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, 5066 . 5068 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5069 Extensions (MIME) Part One: Format of Internet Message 5070 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 5071 . 5073 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5074 Requirement Levels", BCP 14, RFC 2119, 5075 DOI 10.17487/RFC2119, March 1997, 5076 . 5078 [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC 2144, 5079 DOI 10.17487/RFC2144, May 1997, 5080 . 5082 [RFC2822] Resnick, P., Ed., "Internet Message Format", RFC 2822, 5083 DOI 10.17487/RFC2822, April 2001, 5084 . 5086 [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. Roessler, 5087 "MIME Security with OpenPGP", RFC 3156, 5088 DOI 10.17487/RFC3156, August 2001, 5089 . 5091 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 5092 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 5093 September 2002, . 5095 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 5096 Standards (PKCS) #1: RSA Cryptography Specifications 5097 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 5098 2003, . 5100 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5101 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 5102 2003, . 5104 [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of 5105 the Camellia Encryption Algorithm", RFC 3713, 5106 DOI 10.17487/RFC3713, April 2004, 5107 . 5109 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 5110 "Randomness Requirements for Security", BCP 106, RFC 4086, 5111 DOI 10.17487/RFC4086, June 2005, 5112 . 5114 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 5115 for Security", RFC 7748, DOI 10.17487/RFC7748, January 5116 2016, . 5118 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 5119 Signature Algorithm (EdDSA)", RFC 8032, 5120 DOI 10.17487/RFC8032, January 2017, 5121 . 5123 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 5124 Writing an IANA Considerations Section in RFCs", BCP 26, 5125 RFC 8126, DOI 10.17487/RFC8126, June 2017, 5126 . 5128 [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: 5129 protocols, algorithms, and source code in C", 1996. 5131 [SP800-56A] 5132 Barker, E., Johnson, D., and M. Smid, "Recommendation for 5133 Pair-Wise Key Establishment Schemes Using Discrete 5134 Logarithm Cryptography", NIST Special Publication 800-56A 5135 Revision 1, March 2007. 5137 [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, 5138 C., and N. Ferguson, "The Twofish Encryption Algorithm", 5139 1999. 5141 17.2. Informative References 5143 [BLEICHENBACHER] 5144 Bleichenbacher, D., "Generating ElGamal Signatures Without 5145 Knowing the Secret Key", Lecture Notes in Computer 5146 Science Volume 1070, pp. 10-18, 1996. 5148 [JKS02] Jallad, K., Katz, J., and B. Schneier, "Implementation of 5149 Chosen-Ciphertext Attacks against PGP and GnuPG", 2002, 5150 . 5152 [KOBLITZ] Koblitz, N., "A course in number theory and cryptography, 5153 Chapter VI. Elliptic Curves", ISBN 0-387-96576-9, 1997. 5155 [MZ05] Mister, S. and R. Zuccherato, "An Attack on CFB Mode 5156 Encryption As Used By OpenPGP", IACR ePrint Archive Report 5157 2005/033, 8 February 2005, 5158 . 5160 [REGEX] Friedl, J., "Mastering Regular Expressions", 5161 ISBN 0-596-00289-0, August 2002. 5163 [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message 5164 Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, August 5165 1996, . 5167 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 5168 "OpenPGP Message Format", RFC 2440, DOI 10.17487/RFC2440, 5169 November 1998, . 5171 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 5172 Thayer, "OpenPGP Message Format", RFC 4880, 5173 DOI 10.17487/RFC4880, November 2007, 5174 . 5176 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 5177 Curve Cryptography Algorithms", RFC 6090, 5178 DOI 10.17487/RFC6090, February 2011, 5179 . 5181 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 5182 Elliptic Curve Cryptography", September 2000. 5184 [SP800-57] NIST, "Recommendation on Key Management", NIST Special 5185 Publication 800-57, March 2007, 5186 . 5189 Appendix A. Test vectors 5191 To help implementing this specification a non-normative example for 5192 the EdDSA algorithm is given. 5194 A.1. Sample EdDSA key 5196 The secret key used for this example is: 5198 D: 1a8b1ff05ded48e18bf50166c664ab023ea70003d78d9e41f5758a91d850f8d2 5200 Note that this is the raw secret key used as input to the EdDSA 5201 signing operation. The key was created on 2014-08-19 14:28:27 and 5202 thus the fingerprint of the OpenPGP key is: 5204 C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A 5206 The algorithm specific input parameters without the MPI length 5207 headers are: 5209 oid: 2b06010401da470f01 5211 q: 403f098994bdd916ed4053197934e4a87c80733a1280d62f8010992e43ee3b2406 5213 The entire public key packet is thus: 5215 98 33 04 53 f3 5f 0b 16 09 2b 06 01 04 01 da 47 5216 0f 01 01 07 40 3f 09 89 94 bd d9 16 ed 40 53 19 5217 79 34 e4 a8 7c 80 73 3a 12 80 d6 2f 80 10 99 2e 5218 43 ee 3b 24 06 5220 A.2. Sample EdDSA signature 5222 The signature is created using the sample key over the input data 5223 "OpenPGP" on 2015-09-16 12:24:53 and thus the input to the hash 5224 function is: 5226 m: 4f70656e504750040016080006050255f95f9504ff0000000c 5228 Using the SHA2-256 hash algorithm yields the digest: 5230 d: f6220a3f757814f4c2176ffbb68b00249cd4ccdc059c4b34ad871f30b1740280 5232 Which is fed into the EdDSA signature function and yields this 5233 signature: 5235 r: 56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed3366 5237 s: d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404 5239 The entire signature packet is thus: 5241 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 5242 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 5243 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 5244 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 5245 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e 5246 a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 5248 Appendix B. Document Workflow 5250 This document is built from markdown using ruby-kramdown-rfc2629 5251 (https://rubygems.org/gems/kramdown-rfc2629), and tracked using git 5252 (https://git-scm.com/). The markdown source under development can be 5253 found in the file "crypto-refresh.md" in the "main" branch of the git 5254 repository (https://gitlab.com/openpgp-wg/rfc4880bis). Discussion of 5255 this document should take place on the openpgp@ietf.org mailing list 5256 (https://www.ietf.org/mailman/listinfo/openpgp). 5258 A non-substantive editorial nit can be submitted directly as a merge 5259 request (https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/ 5260 new). A substantive proposed edit may also be submitted as a merge 5261 request, but should simultaneously be sent to the mailing list for 5262 discussion. 5264 An open problem can be recorded and tracked as an issue 5265 (https://gitlab.com/openpgp-wg/rfc4880bis/-/issues) in the gitlab 5266 issue tracker, but discussion of the issue should take place on the 5267 mailing list. 5269 [Note to RFC-Editor: Please remove this section on publication.] 5271 Appendix C. ECC Point compression flag bytes 5273 This specification introduces the new flag byte 0x40 to indicate the 5274 point compression format. The value has been chosen so that the high 5275 bit is not cleared and thus to avoid accidental sign extension. Two 5276 other values might also be interesting for other ECC specifications: 5278 Flag Description 5279 ---- ----------- 5280 0x04 Standard flag for uncompressed format 5281 0x40 Native point format of the curve follows 5282 0x41 Only X coordinate follows. 5283 0x42 Only Y coordinate follows. 5285 Appendix D. Acknowledgements 5287 This memo also draws on much previous work from a number of other 5288 authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc 5289 Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, 5290 Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, 5291 Mark Weaver, and Philip R. Zimmermann. 5293 Authors' Addresses 5295 Werner Koch (editor) 5296 GnuPG e.V. 5297 Rochusstr. 44 5298 40479 Duesseldorf 5299 Germany 5301 Email: wk@gnupg.org 5302 URI: https://gnupg.org/verein 5304 Paul Wouters (editor) 5305 No Hats 5307 Email: paul@nohats.ca