--- 1/draft-ietf-openpgp-crypto-refresh-03.txt 2021-10-18 15:13:11.143644765 -0700 +++ 2/draft-ietf-openpgp-crypto-refresh-04.txt 2021-10-18 15:13:11.387650849 -0700 @@ -1,19 +1,19 @@ Network Working Group W. Koch, Ed. Internet-Draft GnuPG e.V. Obsoletes: 4880, 5581, 6637 (if approved) P. Wouters, Ed. -Intended status: Standards Track No Hats -Expires: 3 November 2021 2 May 2021 +Intended status: Standards Track Aiven +Expires: 21 April 2022 18 October 2021 OpenPGP Message Format - draft-ietf-openpgp-crypto-refresh-03 + draft-ietf-openpgp-crypto-refresh-04 Abstract { Work in progress to update the OpenPGP specification from RFC4880 } This document specifies the message formats used in OpenPGP. OpenPGP provides encryption with public-key or symmetric cryptographic algorithms, digital signatures, compression and key management. This document is maintained in order to publish all necessary @@ -33,230 +33,274 @@ Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on 3 November 2021. + This Internet-Draft will expire on 21 April 2022. Copyright Notice Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 - 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 6 + 1.1. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2. General functions . . . . . . . . . . . . . . . . . . . . . . 7 - 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 7 - 2.2. Authentication via Digital Signature . . . . . . . . . . 8 - 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 8 - 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 9 - 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 9 - 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 9 - 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 9 - 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 9 - 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 10 - 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 10 - 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 10 - 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 11 - 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 11 - 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 11 - 3.7.1.1. Simple S2K . . . . . . . . . . . . . . . . . . . 11 - 3.7.1.2. Salted S2K . . . . . . . . . . . . . . . . . . . 12 - 3.7.1.3. Iterated and Salted S2K . . . . . . . . . . . . . 12 - 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 13 - 3.7.2.1. Secret-Key Encryption . . . . . . . . . . . . . . 13 - 3.7.2.2. Symmetric-Key Message Encryption . . . . . . . . 14 - 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 14 - 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 14 - 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 14 - 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 15 - 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 16 - 4.2.2.1. One-Octet Lengths . . . . . . . . . . . . . . . . 16 - 4.2.2.2. Two-Octet Lengths . . . . . . . . . . . . . . . . 16 - 4.2.2.3. Five-Octet Lengths . . . . . . . . . . . . . . . 16 - 4.2.2.4. Partial Body Lengths . . . . . . . . . . . . . . 17 - 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 17 - 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 18 - 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 19 - 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 20 - 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 21 - 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 21 - 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 24 - 5.2.3. Version 4 and 5 Signature Packet Formats . . . . . . 27 - 5.2.3.1. Signature Subpacket Specification . . . . . . . . 29 - 5.2.3.2. Signature Subpacket Types . . . . . . . . . . . . 32 - 5.2.3.3. Notes on Self-Signatures . . . . . . . . . . . . 32 - 5.2.3.4. Signature Creation Time . . . . . . . . . . . . . 33 - 5.2.3.5. Issuer . . . . . . . . . . . . . . . . . . . . . 34 - 5.2.3.6. Key Expiration Time . . . . . . . . . . . . . . . 34 - 5.2.3.7. Preferred Symmetric Algorithms . . . . . . . . . 34 - 5.2.3.8. Preferred Hash Algorithms . . . . . . . . . . . . 34 - 5.2.3.9. Preferred Compression Algorithms . . . . . . . . 34 - 5.2.3.10. Signature Expiration Time . . . . . . . . . . . . 35 - 5.2.3.11. Exportable Certification . . . . . . . . . . . . 35 - 5.2.3.12. Revocable . . . . . . . . . . . . . . . . . . . . 35 - 5.2.3.13. Trust Signature . . . . . . . . . . . . . . . . . 36 - 5.2.3.14. Regular Expression . . . . . . . . . . . . . . . 36 - 5.2.3.15. Revocation Key . . . . . . . . . . . . . . . . . 36 - 5.2.3.16. Notation Data . . . . . . . . . . . . . . . . . . 37 - 5.2.3.17. Key Server Preferences . . . . . . . . . . . . . 38 - 5.2.3.18. Preferred Key Server . . . . . . . . . . . . . . 38 - 5.2.3.19. Primary User ID . . . . . . . . . . . . . . . . . 38 - 5.2.3.20. Policy URI . . . . . . . . . . . . . . . . . . . 39 - 5.2.3.21. Key Flags . . . . . . . . . . . . . . . . . . . . 39 - 5.2.3.22. Signer's User ID . . . . . . . . . . . . . . . . 41 - 5.2.3.23. Reason for Revocation . . . . . . . . . . . . . . 41 - 5.2.3.24. Features . . . . . . . . . . . . . . . . . . . . 43 - 5.2.3.25. Signature Target . . . . . . . . . . . . . . . . 43 - 5.2.3.26. Embedded Signature . . . . . . . . . . . . . . . 44 - 5.2.3.27. Issuer Fingerprint . . . . . . . . . . . . . . . 44 - 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 44 - 5.2.4.1. Subpacket Hints . . . . . . . . . . . . . . . . . 47 - 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 47 - 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 48 - 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 49 - 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 49 - 5.5.1.1. Public-Key Packet (Tag 6) . . . . . . . . . . . . 49 - 5.5.1.2. Public-Subkey Packet (Tag 14) . . . . . . . . . . 49 - 5.5.1.3. Secret-Key Packet (Tag 5) . . . . . . . . . . . . 49 - 5.5.1.4. Secret-Subkey Packet (Tag 7) . . . . . . . . . . 50 - 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 50 - 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 51 - 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 53 - 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 53 - 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 54 - 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 54 - 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 54 - 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 55 - 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 55 - 5.7. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 56 - 5.8. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 57 - 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 58 - 5.10. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 58 - 5.11. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 59 - 5.12. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 59 - 5.13. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 59 - 5.13.1. The Image Attribute Subpacket . . . . . . . . . . . 60 + 2.1. Confidentiality via Encryption . . . . . . . . . . . . . 8 + 2.2. Authentication via Digital Signature . . . . . . . . . . 9 + 2.3. Compression . . . . . . . . . . . . . . . . . . . . . . . 9 + 2.4. Conversion to Radix-64 . . . . . . . . . . . . . . . . . 10 + 2.5. Signature-Only Applications . . . . . . . . . . . . . . . 10 + 3. Data Element Formats . . . . . . . . . . . . . . . . . . . . 10 + 3.1. Scalar Numbers . . . . . . . . . . . . . . . . . . . . . 10 + 3.2. Multiprecision Integers . . . . . . . . . . . . . . . . . 10 + 3.2.1. Using MPIs to encode other data . . . . . . . . . . . 11 + 3.3. Key IDs . . . . . . . . . . . . . . . . . . . . . . . . . 11 + 3.4. Text . . . . . . . . . . . . . . . . . . . . . . . . . . 11 + 3.5. Time Fields . . . . . . . . . . . . . . . . . . . . . . . 11 + 3.6. Keyrings . . . . . . . . . . . . . . . . . . . . . . . . 12 + 3.7. String-to-Key (S2K) Specifiers . . . . . . . . . . . . . 12 + 3.7.1. String-to-Key (S2K) Specifier Types . . . . . . . . . 12 + 3.7.1.1. Simple S2K . . . . . . . . . . . . . . . . . . . 12 + 3.7.1.2. Salted S2K . . . . . . . . . . . . . . . . . . . 13 + 3.7.1.3. Iterated and Salted S2K . . . . . . . . . . . . . 13 + 3.7.1.4. Argon2 . . . . . . . . . . . . . . . . . . . . . 14 + 3.7.2. String-to-Key Usage . . . . . . . . . . . . . . . . . 15 + 3.7.2.1. Secret-Key Encryption . . . . . . . . . . . . . . 15 + 3.7.2.2. Symmetric-Key Message Encryption . . . . . . . . 16 + 4. Packet Syntax . . . . . . . . . . . . . . . . . . . . . . . . 16 + 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 16 + 4.2. Packet Headers . . . . . . . . . . . . . . . . . . . . . 16 + 4.2.1. Old Format Packet Lengths . . . . . . . . . . . . . . 17 + 4.2.2. New Format Packet Lengths . . . . . . . . . . . . . . 18 + 4.2.2.1. One-Octet Lengths . . . . . . . . . . . . . . . . 18 + 4.2.2.2. Two-Octet Lengths . . . . . . . . . . . . . . . . 18 + 4.2.2.3. Five-Octet Lengths . . . . . . . . . . . . . . . 18 + 4.2.2.4. Partial Body Lengths . . . . . . . . . . . . . . 19 + 4.2.3. Packet Length Examples . . . . . . . . . . . . . . . 19 + 4.3. Packet Tags . . . . . . . . . . . . . . . . . . . . . . . 20 + 5. Packet Types . . . . . . . . . . . . . . . . . . . . . . . . 21 + 5.1. Public-Key Encrypted Session Key Packets (Tag 1) . . . . 22 + 5.1.1. Algorithm Specific Fields for RSA encryption . . . . 22 + 5.1.2. Algorithm Specific Fields for Elgamal encryption . . 22 + 5.1.3. Algorithm-Specific Fields for ECDH encryption . . . . 22 + 5.1.4. Notes on PKESK . . . . . . . . . . . . . . . . . . . 23 + 5.2. Signature Packet (Tag 2) . . . . . . . . . . . . . . . . 23 + 5.2.1. Signature Types . . . . . . . . . . . . . . . . . . . 24 + 5.2.2. Version 3 Signature Packet Format . . . . . . . . . . 26 + 5.2.3. Version 4 and 5 Signature Packet Formats . . . . . . 29 + 5.2.3.1. Algorithm-Specific Fields for RSA signatures . . 30 + 5.2.3.2. Algorithm-Specific Fields for DSA or ECDSA + signatures . . . . . . . . . . . . . . . . . . . . 30 + 5.2.3.3. Algorithm-Specific Fields for EdDSA signatures . 30 + 5.2.3.4. Notes on Signatures . . . . . . . . . . . . . . . 31 + 5.2.3.5. Signature Subpacket Specification . . . . . . . . 32 + 5.2.3.6. Signature Subpacket Types . . . . . . . . . . . . 34 + 5.2.3.7. Notes on Self-Signatures . . . . . . . . . . . . 35 + 5.2.3.8. Signature Creation Time . . . . . . . . . . . . . 36 + 5.2.3.9. Issuer . . . . . . . . . . . . . . . . . . . . . 36 + 5.2.3.10. Key Expiration Time . . . . . . . . . . . . . . . 36 + 5.2.3.11. Preferred Symmetric Algorithms . . . . . . . . . 36 + 5.2.3.12. Preferred Hash Algorithms . . . . . . . . . . . . 37 + 5.2.3.13. Preferred Compression Algorithms . . . . . . . . 37 + 5.2.3.14. Signature Expiration Time . . . . . . . . . . . . 37 + 5.2.3.15. Exportable Certification . . . . . . . . . . . . 37 + 5.2.3.16. Revocable . . . . . . . . . . . . . . . . . . . . 38 + 5.2.3.17. Trust Signature . . . . . . . . . . . . . . . . . 38 + 5.2.3.18. Regular Expression . . . . . . . . . . . . . . . 38 + 5.2.3.19. Revocation Key . . . . . . . . . . . . . . . . . 39 + 5.2.3.20. Notation Data . . . . . . . . . . . . . . . . . . 39 + 5.2.3.21. Key Server Preferences . . . . . . . . . . . . . 40 + 5.2.3.22. Preferred Key Server . . . . . . . . . . . . . . 41 + 5.2.3.23. Primary User ID . . . . . . . . . . . . . . . . . 41 + 5.2.3.24. Policy URI . . . . . . . . . . . . . . . . . . . 41 + 5.2.3.25. Key Flags . . . . . . . . . . . . . . . . . . . . 42 + 5.2.3.26. Signer's User ID . . . . . . . . . . . . . . . . 43 + 5.2.3.27. Reason for Revocation . . . . . . . . . . . . . . 43 + 5.2.3.28. Features . . . . . . . . . . . . . . . . . . . . 45 + 5.2.3.29. Signature Target . . . . . . . . . . . . . . . . 45 + 5.2.3.30. Embedded Signature . . . . . . . . . . . . . . . 46 + 5.2.3.31. Issuer Fingerprint . . . . . . . . . . . . . . . 46 + 5.2.3.32. Intended Recipient Fingerprint . . . . . . . . . 46 + 5.2.4. Computing Signatures . . . . . . . . . . . . . . . . 46 + 5.2.4.1. Subpacket Hints . . . . . . . . . . . . . . . . . 49 + 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) . . . 49 + 5.3.1. No v5 SKESK with SEIPD . . . . . . . . . . . . . . . 51 + 5.4. One-Pass Signature Packets (Tag 4) . . . . . . . . . . . 51 + 5.5. Key Material Packet . . . . . . . . . . . . . . . . . . . 52 + 5.5.1. Key Packet Variants . . . . . . . . . . . . . . . . . 52 + 5.5.1.1. Public-Key Packet (Tag 6) . . . . . . . . . . . . 52 + 5.5.1.2. Public-Subkey Packet (Tag 14) . . . . . . . . . . 52 + 5.5.1.3. Secret-Key Packet (Tag 5) . . . . . . . . . . . . 52 + 5.5.1.4. Secret-Subkey Packet (Tag 7) . . . . . . . . . . 52 + 5.5.2. Public-Key Packet Formats . . . . . . . . . . . . . . 53 + 5.5.3. Secret-Key Packet Formats . . . . . . . . . . . . . . 54 + 5.6. Algorithm-specific Parts of Keys . . . . . . . . . . . . 57 + 5.6.1. Algorithm-Specific Part for RSA Keys . . . . . . . . 57 + 5.6.2. Algorithm-Specific Part for DSA Keys . . . . . . . . 57 + 5.6.3. Algorithm-Specific Part for Elgamal Keys . . . . . . 57 + 5.6.4. Algorithm-Specific Part for ECDSA Keys . . . . . . . 58 + 5.6.5. Algorithm-Specific Part for EdDSA Keys . . . . . . . 58 + 5.6.6. Algorithm-Specific Part for ECDH Keys . . . . . . . . 59 + 5.7. Compressed Data Packet (Tag 8) . . . . . . . . . . . . . 59 + 5.8. Symmetrically Encrypted Data Packet (Tag 9) . . . . . . . 60 + 5.9. Marker Packet (Obsolete Literal Packet) (Tag 10) . . . . 61 + 5.10. Literal Data Packet (Tag 11) . . . . . . . . . . . . . . 61 + 5.11. Trust Packet (Tag 12) . . . . . . . . . . . . . . . . . . 62 + 5.12. User ID Packet (Tag 13) . . . . . . . . . . . . . . . . . 63 + 5.13. User Attribute Packet (Tag 17) . . . . . . . . . . . . . 63 + 5.13.1. The Image Attribute Subpacket . . . . . . . . . . . 64 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag - 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 61 - 5.15. Modification Detection Code Packet (Tag 19) . . . . . . . 64 - 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 65 - 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 65 - 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 66 - 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 69 - 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 71 - 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 71 - 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 72 - 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 72 - 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 73 - 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 74 - 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 74 - 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 75 - 9.2. ECC Curve OID . . . . . . . . . . . . . . . . . . . . . . 76 - 9.3. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 76 - 9.4. Compression Algorithms . . . . . . . . . . . . . . . . . 77 - 9.5. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 78 - 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 79 - 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 79 - 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 79 - 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 79 - 10.2.1.1. Image Format Subpacket Types . . . . . . . . . . 79 - 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 80 - 10.2.2.1. Signature Notation Data Subpackets . . . . . . . 80 + 18) . . . . . . . . . . . . . . . . . . . . . . . . . . 64 + 5.15. Modification Detection Code Packet (Tag 19) . . . . . . . 67 + 5.16. AEAD Encrypted Data Packet (Tag 20) . . . . . . . . . . . 68 + 5.16.1. EAX Mode . . . . . . . . . . . . . . . . . . . . . . 69 + 5.16.2. OCB Mode . . . . . . . . . . . . . . . . . . . . . . 70 + 6. Radix-64 Conversions . . . . . . . . . . . . . . . . . . . . 70 + 6.1. An Implementation of the CRC-24 in "C" . . . . . . . . . 71 + 6.2. Forming ASCII Armor . . . . . . . . . . . . . . . . . . . 71 + 6.3. Encoding Binary in Radix-64 . . . . . . . . . . . . . . . 74 + 6.4. Decoding Radix-64 . . . . . . . . . . . . . . . . . . . . 76 + 6.5. Examples of Radix-64 . . . . . . . . . . . . . . . . . . 76 + 6.6. Example of an ASCII Armored Message . . . . . . . . . . . 77 + 7. Cleartext Signature Framework . . . . . . . . . . . . . . . . 77 + 7.1. Dash-Escaped Text . . . . . . . . . . . . . . . . . . . . 78 + 8. Regular Expressions . . . . . . . . . . . . . . . . . . . . . 79 + 9. Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 79 + 9.1. Public-Key Algorithms . . . . . . . . . . . . . . . . . . 80 + 9.2. ECC Curves for OpenPGP . . . . . . . . . . . . . . . . . 82 + 9.2.1. Curve-Specific Wire Formats . . . . . . . . . . . . . 83 + 9.3. Symmetric-Key Algorithms . . . . . . . . . . . . . . . . 84 + 9.4. Compression Algorithms . . . . . . . . . . . . . . . . . 85 + 9.5. Hash Algorithms . . . . . . . . . . . . . . . . . . . . . 86 + 9.6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . 87 + 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 87 + 10.1. New String-to-Key Specifier Types . . . . . . . . . . . 87 + 10.2. New Packets . . . . . . . . . . . . . . . . . . . . . . 88 + 10.2.1. User Attribute Types . . . . . . . . . . . . . . . . 88 + 10.2.1.1. Image Format Subpacket Types . . . . . . . . . . 88 + 10.2.2. New Signature Subpackets . . . . . . . . . . . . . . 88 + 10.2.2.1. Signature Notation Data Subpackets . . . . . . . 89 10.2.2.2. Signature Notation Data Subpacket Notation - Flags . . . . . . . . . . . . . . . . . . . . . . . 80 - 10.2.2.3. Key Server Preference Extensions . . . . . . . . 81 - 10.2.2.4. Key Flags Extensions . . . . . . . . . . . . . . 81 - 10.2.2.5. Reason for Revocation Extensions . . . . . . . . 81 - 10.2.2.6. Implementation Features . . . . . . . . . . . . 81 - 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 82 - 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 82 - 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 82 - 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 83 - 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 83 - 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 84 - 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 84 - 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 84 - 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 85 - 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 86 - 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 86 - 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 86 - 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 87 - 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 88 - 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 89 - 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 89 - 13.2. ECDSA and ECDH Conversion Primitives . . . . . . . . . . 90 - 13.3. EdDSA Point Format . . . . . . . . . . . . . . . . . . . 91 - 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 91 - 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 91 - 14. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 94 - 14.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 94 - 14.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 94 - 14.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 95 - 14.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 96 - 14.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 97 - 14.3. Other Algorithm Preferences . . . . . . . . . . . . . . 97 - 14.3.1. Compression Preferences . . . . . . . . . . . . . . 98 - 14.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 98 - 14.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 98 - 14.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 99 - 14.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 99 - 14.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 99 - 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 100 - 14.9. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 100 - 14.10. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 100 - 14.11. Private or Experimental Parameters . . . . . . . . . . . 102 - 14.12. Extension of the MDC System . . . . . . . . . . . . . . 102 - 14.13. Meta-Considerations for Expansion . . . . . . . . . . . 103 - 15. Security Considerations . . . . . . . . . . . . . . . . . . . 103 - 16. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 109 - 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 111 - 17.1. Normative References . . . . . . . . . . . . . . . . . . 111 - 17.2. Informative References . . . . . . . . . . . . . . . . . 114 - Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 115 - A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 115 - A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 116 - Appendix B. Document Workflow . . . . . . . . . . . . . . . . . 116 - Appendix C. ECC Point compression flag bytes . . . . . . . . . . 117 - Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 117 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 117 + Flags . . . . . . . . . . . . . . . . . . . . . . . 89 + 10.2.2.3. Key Server Preference Extensions . . . . . . . . 89 + 10.2.2.4. Key Flags Extensions . . . . . . . . . . . . . . 89 + 10.2.2.5. Reason for Revocation Extensions . . . . . . . . 90 + 10.2.2.6. Implementation Features . . . . . . . . . . . . 90 + 10.2.3. New Packet Versions . . . . . . . . . . . . . . . . 90 + 10.3. New Algorithms . . . . . . . . . . . . . . . . . . . . . 90 + 10.3.1. Public-Key Algorithms . . . . . . . . . . . . . . . 91 + 10.3.2. Symmetric-Key Algorithms . . . . . . . . . . . . . . 91 + 10.3.3. Hash Algorithms . . . . . . . . . . . . . . . . . . 91 + 10.3.4. Compression Algorithms . . . . . . . . . . . . . . . 92 + 10.3.5. Elliptic Curve Algorithms . . . . . . . . . . . . . 92 + 10.4. Elliptic Curve Point and Scalar Wire Formats . . . . . . 93 + 10.5. Changes to existing registries . . . . . . . . . . . . . 93 + 11. Packet Composition . . . . . . . . . . . . . . . . . . . . . 93 + 11.1. Transferable Public Keys . . . . . . . . . . . . . . . . 93 + 11.2. Transferable Secret Keys . . . . . . . . . . . . . . . . 95 + 11.3. OpenPGP Messages . . . . . . . . . . . . . . . . . . . . 95 + 11.4. Detached Signatures . . . . . . . . . . . . . . . . . . 96 + 12. Enhanced Key Formats . . . . . . . . . . . . . . . . . . . . 96 + 12.1. Key Structures . . . . . . . . . . . . . . . . . . . . . 96 + 12.2. Key IDs and Fingerprints . . . . . . . . . . . . . . . . 97 + 13. Elliptic Curve Cryptography . . . . . . . . . . . . . . . . . 99 + 13.1. Supported ECC Curves . . . . . . . . . . . . . . . . . . 99 + 13.2. EC Point Wire Formats . . . . . . . . . . . . . . . . . 100 + 13.2.1. SEC1 EC Point Wire Format . . . . . . . . . . . . . 100 + 13.2.2. Prefixed Native EC Point Wire Format . . . . . . . . 100 + 13.2.3. Notes on EC Point Wire Formats . . . . . . . . . . . 101 + 13.3. EC Scalar Wire Formats . . . . . . . . . . . . . . . . . 101 + 13.3.1. EC Octet String Wire Format . . . . . . . . . . . . 102 + 13.3.2. Elliptic Curve Prefixed Octet String Wire Format . . 103 + 13.4. Key Derivation Function . . . . . . . . . . . . . . . . 103 + 13.5. EC DH Algorithm (ECDH) . . . . . . . . . . . . . . . . . 104 + 14. Notes on Algorithms . . . . . . . . . . . . . . . . . . . . . 107 + 14.1. PKCS#1 Encoding in OpenPGP . . . . . . . . . . . . . . . 107 + 14.1.1. EME-PKCS1-v1_5-ENCODE . . . . . . . . . . . . . . . 107 + 14.1.2. EME-PKCS1-v1_5-DECODE . . . . . . . . . . . . . . . 108 + 14.1.3. EMSA-PKCS1-v1_5 . . . . . . . . . . . . . . . . . . 108 + 14.2. Symmetric Algorithm Preferences . . . . . . . . . . . . 109 + 14.3. Other Algorithm Preferences . . . . . . . . . . . . . . 110 + 14.3.1. Compression Preferences . . . . . . . . . . . . . . 110 + 14.3.2. Hash Algorithm Preferences . . . . . . . . . . . . . 111 + + 14.4. Plaintext . . . . . . . . . . . . . . . . . . . . . . . 111 + 14.5. RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 111 + 14.6. DSA . . . . . . . . . . . . . . . . . . . . . . . . . . 112 + 14.7. Elgamal . . . . . . . . . . . . . . . . . . . . . . . . 112 + 14.8. EdDSA . . . . . . . . . . . . . . . . . . . . . . . . . 112 + 14.9. Reserved Algorithm Numbers . . . . . . . . . . . . . . . 113 + 14.10. OpenPGP CFB Mode . . . . . . . . . . . . . . . . . . . . 113 + 14.11. Private or Experimental Parameters . . . . . . . . . . . 115 + 14.12. Extension of the MDC System . . . . . . . . . . . . . . 115 + 14.13. Meta-Considerations for Expansion . . . . . . . . . . . 116 + 15. Security Considerations . . . . . . . . . . . . . . . . . . . 116 + 16. Implementation Nits . . . . . . . . . . . . . . . . . . . . . 122 + 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 124 + 17.1. Normative References . . . . . . . . . . . . . . . . . . 124 + 17.2. Informative References . . . . . . . . . . . . . . . . . 127 + Appendix A. Test vectors . . . . . . . . . . . . . . . . . . . . 128 + A.1. Sample EdDSA key . . . . . . . . . . . . . . . . . . . . 128 + A.2. Sample EdDSA signature . . . . . . . . . . . . . . . . . 129 + A.3. Sample AEAD-EAX encryption and decryption . . . . . . . . 129 + A.3.1. Sample Parameters . . . . . . . . . . . . . . . . . . 129 + A.3.2. Sample symmetric-key encrypted session key packet + (v5) . . . . . . . . . . . . . . . . . . . . . . . . 130 + A.3.3. Starting AEAD-EAX decryption of CEK . . . . . . . . . 130 + A.3.4. Initial Content Encryption Key . . . . . . . . . . . 131 + A.3.5. Sample AEAD encrypted data packet . . . . . . . . . . 131 + A.3.6. Decryption of data . . . . . . . . . . . . . . . . . 131 + A.3.7. Complete AEAD-EAX encrypted packet sequence . . . . . 132 + A.4. Sample AEAD-OCB encryption and decryption . . . . . . . . 132 + A.4.1. Sample Parameters . . . . . . . . . . . . . . . . . . 132 + A.4.2. Sample symmetric-key encrypted session key packet + (v5) . . . . . . . . . . . . . . . . . . . . . . . . 133 + A.4.3. Starting AEAD-OCB decryption of CEK . . . . . . . . . 133 + A.4.4. Initial Content Encryption Key . . . . . . . . . . . 134 + A.4.5. Sample AEAD encrypted data packet . . . . . . . . . . 134 + A.4.6. Decryption of data . . . . . . . . . . . . . . . . . 134 + A.4.7. Complete AEAD-OCB encrypted packet sequence . . . . . 135 + Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 135 + Appendix C. Document Workflow . . . . . . . . . . . . . . . . . 136 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 136 1. Introduction { This is work in progress to update OpenPGP. Editorial notes are enclosed in curly braces. } This document provides information on the message-exchange packet formats used by OpenPGP to provide encryption, decryption, signing, and key management functions. It is a revision of RFC 4880, "OpenPGP Message Format", which is a revision of RFC 2440, which itself replaces RFC 1991, "PGP Message Exchange Formats" [RFC1991] [RFC2440] [RFC4880]. - This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia - cipher) and RFC 6637 (ECC for OpenPGP). + This document obsoletes: RFC 4880 (OpenPGP), RFC 5581 (Camellia in + OpenPGP) and RFC 6637 (Elliptic Curves in OpenPGP). 1.1. Terms * OpenPGP - This is a term for security software that uses PGP 5 as a basis, formalized in this document. * PGP - Pretty Good Privacy. PGP is a family of software systems developed by Philip R. Zimmermann from which OpenPGP is based. * PGP 2 - This version of PGP has many variants; where necessary a @@ -443,20 +486,30 @@ The length field of an MPI describes the length starting from its most significant non-zero bit. Thus, the MPI [00 02 01] is not formed correctly. It should be [00 01 01]. Unused bits of an MPI MUST be zero. Also note that when an MPI is encrypted, the length refers to the plaintext MPI. It may be ill-formed in its ciphertext. +3.2.1. Using MPIs to encode other data + + Note that MPIs are used in some places used to encode non-integer + data, such as an elliptic curve point (see Section 13.2, or an octet + string of known, fixed length (see Section 13.3). The wire + representation is the same: two octets of length in bits counted from + the first non-zero bit, followed by the smallest series of octets + that can represent the value while stripping off any leading zero + octets. + 3.3. Key IDs A Key ID is an eight-octet scalar that identifies a key. Implementations SHOULD NOT assume that Key IDs are unique. Section 12 describes how Key IDs are formed. 3.4. Text Unless otherwise specified, the character set for text is the UTF-8 [RFC3629] encoding of Unicode [ISO10646]. @@ -479,33 +532,38 @@ into symmetric-key encryption/decryption keys. They are used in two places, currently: to encrypt the secret part of private keys in the private keyring, and to convert passphrases to encryption keys for symmetrically encrypted messages. 3.7.1. String-to-Key (S2K) Specifier Types There are three types of S2K specifiers currently supported, and some reserved values: - +============+==========================+ - | ID | S2K Type | - +============+==========================+ - | 0 | Simple S2K | - +------------+--------------------------+ - | 1 | Salted S2K | - +------------+--------------------------+ - | 2 | Reserved value | - +------------+--------------------------+ - | 3 | Iterated and Salted S2K | - +------------+--------------------------+ - | 100 to 110 | Private/Experimental S2K | - +------------+--------------------------+ + +========+==================+==================+=================+ + | ID | S2K Type | Generate? | Reference | + +========+==================+==================+=================+ + | 0 | Simple S2K | N | Section 3.7.1.1 | + +--------+------------------+------------------+-----------------+ + | 1 | Salted S2K | Only when string | Section 3.7.1.2 | + | | | is high entropy | | + +--------+------------------+------------------+-----------------+ + | 2 | Reserved value | N | | + +--------+------------------+------------------+-----------------+ + | 3 | Iterated and | Y | Section 3.7.1.3 | + | | Salted S2K | | | + +--------+------------------+------------------+-----------------+ + | 4 | Argon2 | Y | Section 3.7.1.4 | + +--------+------------------+------------------+-----------------+ + | 100 to | Private/ | As appropriate | | + | 110 | Experimental S2K | | | + +--------+------------------+------------------+-----------------+ Table 1: S2K type registry These are described in the subsections below. 3.7.1.1. Simple S2K This directly hashes the string to produce the key data. See below for how this hashing is done. @@ -577,47 +635,91 @@ Initially, one or more hash contexts are set up as with the other S2K algorithms, depending on how many octets of key data are needed. Then the salt, followed by the passphrase data, is repeatedly hashed until the number of octets specified by the octet count has been hashed. The one exception is that if the octet count is less than the size of the salt plus passphrase, the full salt plus passphrase will be hashed even though that is greater than the octet count. After the hashing is done, the data is unloaded from the hash context(s) as with the other S2K algorithms. +3.7.1.4. Argon2 + + This S2K method hashes the passphrase using Argon2, specified in + [RFC9106]. This provides memory-hardness, further protecting the + passphrase against brute-force attacks. + + Octet 0: 0x04 + Octets 1-16: 16-octet salt value + Octet 17: one-octet number of passes t + Octet 18: one-octet degree of parallelism p + Octet 19: one-octet exponent indicating the memory size m + + The salt SHOULD be unique for each password. + + The number of passes t and the degree of parallelism p MUST be non- + zero. + + The memory size m is 2**encoded_m, where "encoded_m" is the encoded + memory size in Octet 19. The encoded memory size MUST be a value + from 3+ceil(log_2(p)) to 31, such that the decoded memory size m is a + value from 8*p to 2**31. + + Argon2 is invoked with the passphrase as P, the salt as S, the values + of t, p and m as described above, the required key size as the tag + length T, 0x13 as the version v, and Argon2id as the type. + + For the recommended values of t, p and m, see Section 4 of [RFC9106]. + If the recommended value of m for a given application is not a power + of 2, it is RECOMMENDED to round up to the next power of 2 if the + resulting performance would be acceptable, and round down otherwise + (keeping in mind that m must be at least 8*p). + + As an example, with the first recommended option (t=1, p=4, m=2**21), + the full S2K specifier would be: + + 04 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX + XX 01 04 15 + + (where XX represents a random octet of salt). + 3.7.2. String-to-Key Usage - Simple S2K and Salted S2K specifiers are not particularly secure when - used with a low-entropy secret, such as those typically provided by - users. Implementations SHOULD NOT use these methods on encryption of - either keys and messages. + Simple S2K and Salted S2K specifiers can be brute-forced when used + with a low-entropy string, such as those typically provided by users. + In addition, the usage of Simple S2K can lead to key and IV reuse + (see Section 5.3). Therefore, when generating S2K specifiers, + implementations MUST NOT use Simple S2K, and SHOULD NOT use Salted + S2K unless the implementation knows that the string is high-entropy + (e.g., it generated the string itself using a known-good source of + randomness). It is RECOMMENDED that implementations use Argon2. 3.7.2.1. Secret-Key Encryption An S2K specifier can be stored in the secret keyring to specify how to convert the passphrase to a key that unlocks the secret data. - Older versions of PGP just stored a cipher algorithm octet preceding - the secret data or a zero to indicate that the secret data was - unencrypted. The MD5 hash function was always used to convert the - passphrase to a key for the specified cipher algorithm. + Older versions of PGP just stored a symmetric cipher algorithm octet + preceding the secret data or a zero to indicate that the secret data + was unencrypted. The MD5 hash function was always used to convert + the passphrase to a key for the specified cipher algorithm. For compatibility, when an S2K specifier is used, the special value - 254 or 255 is stored in the position where the hash algorithm octet - would have been in the old data structure. This is then followed - immediately by a one-octet algorithm identifier, and then by the S2K - specifier as encoded above. + 253, 254, or 255 is stored in the position where the cipher algorithm + octet would have been in the old data structure. This is then + followed immediately by a one-octet algorithm identifier, and then by + the S2K specifier as encoded above. Therefore, preceding the secret data there will be one of these possibilities: 0: secret data is unencrypted (no passphrase) - 255 or 254: followed by algorithm octet and S2K specifier + 255, 254, or 253: followed by algorithm octet and S2K specifier Cipher alg: use Simple S2K algorithm using MD5 hash This last possibility, the cipher algorithm number with an implicit use of MD5 and IDEA, is provided for backward compatibility; it MAY be understood, but SHOULD NOT be generated, and is deprecated. These are followed by an Initial Vector of the same length as the block size of the cipher for the decryption of the secret values, if they are encrypted, and then the secret-key values themselves. @@ -841,86 +943,90 @@ | 13 | User ID Packet | +----------+----------------------------------------------------+ | 14 | Public-Subkey Packet | +----------+----------------------------------------------------+ | 17 | User Attribute Packet | +----------+----------------------------------------------------+ | 18 | Sym. Encrypted and Integrity Protected Data Packet | +----------+----------------------------------------------------+ | 19 | Modification Detection Code Packet | +----------+----------------------------------------------------+ - | 20 | Reserved (AEAD Encrypted Data) | + | 20 | AEAD Encrypted Data Packet | +----------+----------------------------------------------------+ | 60 to 63 | Private or Experimental Values | +----------+----------------------------------------------------+ Table 2: Packet type registry 5. Packet Types 5.1. Public-Key Encrypted Session Key Packets (Tag 1) - A Public-Key Encrypted Session Key packet holds the session key used - to encrypt a message. Zero or more Public-Key Encrypted Session Key - packets and/or Symmetric-Key Encrypted Session Key packets may - precede a Symmetrically Encrypted Data Packet, which holds an - encrypted message. The message is encrypted with the session key, - and the session key is itself encrypted and stored in the Encrypted - Session Key packet(s). The Symmetrically Encrypted Data Packet is - preceded by one Public-Key Encrypted Session Key packet for each - OpenPGP key to which the message is encrypted. The recipient of the - message finds a session key that is encrypted to their public key, - decrypts the session key, and then uses the session key to decrypt - the message. + Zero or more Public-Key Encrypted Session Key packets and/or + Symmetric-Key Encrypted Session Key packets may precede an encryption + container (i.e. a Symmetrically Encrypted Integrity Protected Data + packet, an AEAD Encrypted Data packet, or -- for historic data -- a + Symmetrically Encrypted Data packet), which holds an encrypted + message. The message is encrypted with the session key, and the + session key is itself encrypted and stored in the Encrypted Session + Key packet(s). The encryption container is preceded by one Public- + Key Encrypted Session Key packet for each OpenPGP key to which the + message is encrypted. The recipient of the message finds a session + key that is encrypted to their public key, decrypts the session key, + and then uses the session key to decrypt the message. The body of this packet consists of: * A one-octet number giving the version number of the packet type. The currently defined value for packet version is 3. * An eight-octet number that gives the Key ID of the public key to which the session key is encrypted. If the session key is encrypted to a subkey, then the Key ID of this subkey is used here instead of the Key ID of the primary key. * A one-octet number giving the public-key algorithm used. * A string of octets that is the encrypted session key. This string takes up the remainder of the packet, and its contents are dependent on the public-key algorithm used. - Algorithm Specific Fields for RSA encryption: +5.1.1. Algorithm Specific Fields for RSA encryption - - Multiprecision integer (MPI) of RSA encrypted value m**e mod n. + * Multiprecision integer (MPI) of RSA-encrypted value m**e mod n. - Algorithm Specific Fields for Elgamal encryption: +5.1.2. Algorithm Specific Fields for Elgamal encryption - - MPI of Elgamal (Diffie-Hellman) value g**k mod p. + * MPI of Elgamal (Diffie-Hellman) value g**k mod p. - - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. + * MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. - Algorithm-Specific Fields for ECDH encryption: +5.1.3. Algorithm-Specific Fields for ECDH encryption - - MPI of an EC point representing an ephemeral public key. + * MPI of an EC point representing an ephemeral public key, in the + point format associated with the curve as specified in + Section 9.2. - - a one-octet size, followed by a symmetric key encoded using the + * A one-octet size, followed by a symmetric key encoded using the method described in Section 13.5. +5.1.4. Notes on PKESK + The value "m" in the above formulas is derived from the session key as follows. First, the session key is prefixed with a one-octet algorithm identifier that specifies the symmetric encryption - algorithm used to encrypt the following Symmetrically Encrypted Data - Packet. Then a two-octet checksum is appended, which is equal to the - sum of the preceding session key octets, not including the algorithm - identifier, modulo 65536. This value is then encoded as described in - PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to - form the "m" value used in the formulas above. See Section 14.1 in - this document for notes on OpenPGP's use of PKCS#1. + algorithm used to encrypt the following encryption container. Then a + two-octet checksum is appended, which is equal to the sum of the + preceding session key octets, not including the algorithm identifier, + modulo 65536. This value is then encoded as described in PKCS#1 + block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to form + the "m" value used in the formulas above. See Section 14.1 in this + document for notes on OpenPGP's use of PKCS#1. Note that when an implementation forms several PKESKs with one session key, forming a message that can be decrypted by several keys, the implementation MUST make a new PKCS#1 encoding for each key. An implementation MAY accept or use a Key ID of zero as a "wild card" or "speculative" Key ID. In this case, the receiving implementation would try all available private keys, checking for a valid decrypted session key. This format helps reduce traffic analysis of messages. @@ -1213,60 +1319,83 @@ unhashed subpackets; a pointer incremented by this number will skip over the unhashed subpackets. * Unhashed subpacket data set (zero or more subpackets). * Two-octet field holding the left 16 bits of the signed hash value. * One or more multiprecision integers comprising the signature. This portion is algorithm specific: - Algorithm-Specific Fields for RSA signatures: - - - Multiprecision integer (MPI) of RSA signature value m**d mod n. +5.2.3.1. Algorithm-Specific Fields for RSA signatures - Algorithm-Specific Fields for DSA or ECDSA signatures: + * Multiprecision integer (MPI) of RSA signature value m**d mod n. - - MPI of DSA or ECDSA value r. +5.2.3.2. Algorithm-Specific Fields for DSA or ECDSA signatures - - MPI of DSA or ECDSA value s. + * MPI of DSA or ECDSA value r. - Algorithm-Specific Fields for EdDSA signatures: + * MPI of DSA or ECDSA value s. - - MPI of an EC point r. +5.2.3.3. Algorithm-Specific Fields for EdDSA signatures - - EdDSA value s, in MPI, in the little endian representation. + * Two MPI-encoded values, whose contents and formatting depend on + the choice of curve used (see Section 9.2.1). - The format of R and S for use with EdDSA is described in [RFC8032]. A version 3 signature MUST NOT be created and MUST NOT be used with EdDSA. +5.2.3.3.1. Algorithm-Specific Fields for Ed25519 signatures + + The two MPIs for Ed25519 use octet strings R and S as described in + [RFC8032]. + + * MPI of an EC point R, represented as a (non-prefixed) native + (little-endian) octet string up to 32 octets. + + * MPI of EdDSA value S, also in (non-prefixed) native little-endian + format with a length up to 32 octets. + +5.2.3.3.2. Algorithm-Specific Fields for Ed448 signatures + + For Ed448 signatures, the native signature format is used as + described in [RFC8032]. The two MPIs are composed as follows: + + * The first MPI has a body of 58 octets: a prefix 0x40 octet, + followed by 57 octets of the native signature. + + * The second MPI is set to 0 (this is a placeholder, and is unused). + Note that an MPI with a value of 0 is encoded on the wire as a + pair of zero octets: "00 00". + +5.2.3.4. Notes on Signatures + The concatenation of the data being signed and the signature data from the version number through the hashed subpacket data (inclusive) is hashed. The resulting hash value is what is signed. The high 16 bits (first two octets) of the hash are included in the Signature packet to provide a way to reject some invalid signatures without performing a signature verification. There are two fields consisting of Signature subpackets. The first field is hashed with the rest of the signature data, while the second is unhashed. The second set of subpackets is not cryptographically protected by the signature and should include only advisory information. The difference between a V4 and V5 signature is that the latter includes additional meta data. The algorithms for converting the hash function result to a signature are described in a section below. -5.2.3.1. Signature Subpacket Specification +5.2.3.5. Signature Subpacket Specification A subpacket data set consists of zero or more Signature subpackets. In Signature packets, the subpacket data set is preceded by a two- octet scalar count of the length in octets of all the subpackets. A pointer incremented by this number will skip over the subpacket data set. Each subpacket consists of a subpacket header and a body. The header consists of: @@ -1287,93 +1416,93 @@ if the 1st octet >= 192 and < 255, then lengthOfLength = 2 subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 if the 1st octet = 255, then lengthOfLength = 5 subpacket length = [four-octet scalar starting at 2nd_octet] The value of the subpacket type octet may be: - +============+===========================================+ + +============+========================================+ | Type | Description | - +============+===========================================+ + +============+========================================+ | 0 | Reserved | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 1 | Reserved | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 2 | Signature Creation Time | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 3 | Signature Expiration Time | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 4 | Exportable Certification | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 5 | Trust Signature | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 6 | Regular Expression | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 7 | Revocable | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 8 | Reserved | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 9 | Key Expiration Time | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 10 | Placeholder for backward compatibility | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 11 | Preferred Symmetric Algorithms | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 12 | Revocation Key | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 13 to 15 | Reserved | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 16 | Issuer | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 17 to 19 | Reserved | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 20 | Notation Data | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 21 | Preferred Hash Algorithms | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 22 | Preferred Compression Algorithms | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 23 | Key Server Preferences | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 24 | Preferred Key Server | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 25 | Primary User ID | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 26 | Policy URI | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 27 | Key Flags | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 28 | Signer's User ID | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 29 | Reason for Revocation | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 30 | Features | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 31 | Signature Target | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 32 | Embedded Signature | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 33 | Issuer Fingerprint | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 34 | Reserved (Preferred AEAD Algorithms) | - +------------+-------------------------------------------+ - | 35 | Reserved (Intended Recipient Fingerprint) | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ + | 35 | Intended Recipient Fingerprint | + +------------+----------------------------------------+ | 37 | Reserved (Attested Certifications) | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 38 | Reserved (Key Block) | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ | 100 to 110 | Private or experimental | - +------------+-------------------------------------------+ + +------------+----------------------------------------+ Table 6: Subpacket type registry An implementation SHOULD ignore any subpacket of a type that it does not recognize. Bit 7 of the subpacket type is the "critical" bit. If set, it denotes that the subpacket is one that is critical for the evaluator of the signature to recognize. If a subpacket is encountered that is marked critical but is unknown to the evaluating software, the @@ -1384,35 +1513,35 @@ evaluator that it would prefer a new, unknown feature to generate an error than be ignored. Implementations SHOULD implement the three preferred algorithm subpackets (11, 21, and 22), as well as the "Reason for Revocation" subpacket. Note, however, that if an implementation chooses not to implement some of the preferences, it is required to behave in a polite manner to respect the wishes of those users who do implement these preferences. -5.2.3.2. Signature Subpacket Types +5.2.3.6. Signature Subpacket Types A number of subpackets are currently defined. Some subpackets apply to the signature itself and some are attributes of the key. Subpackets that are found on a self-signature are placed on a certification made by the key itself. Note that a key may have more than one User ID, and thus may have more than one self-signature, and differing subpackets. A subpacket may be found either in the hashed or unhashed subpacket sections of a signature. If a subpacket is not hashed, then the information in it cannot be considered definitive because it is not part of the signature proper. -5.2.3.3. Notes on Self-Signatures +5.2.3.7. Notes on Self-Signatures A self-signature is a binding signature made by the key to which the signature refers. There are three types of self-signatures, the certification signatures (types 0x10-0x13), the direct-key signature (type 0x1F), and the subkey binding signature (type 0x18). For certification self-signatures, each User ID may have a self- signature, and thus different subpackets in those self-signatures. For subkey binding signatures, each subkey in fact has a self- signature. Subpackets that appear in a certification self-signature apply to the user name, and subpackets that appear in the subkey @@ -1433,102 +1562,102 @@ meaning that varies with the signature type. Revoking the self- signature on a User ID effectively retires that user name. The self- signature is a statement, "My name X is tied to my signing key K" and is corroborated by other users' certifications. If another user revokes their certification, they are effectively saying that they no longer believe that name and that key are tied together. Similarly, if the users themselves revoke their self-signature, then the users no longer go by that name, no longer have that email address, etc. Revoking a binding signature effectively retires that subkey. Revoking a direct-key signature cancels that signature. Please see - Section 5.2.3.23 for more relevant detail. + Section 5.2.3.27 for more relevant detail. Since a self-signature contains important information about the key's use, an implementation SHOULD allow the user to rewrite the self- signature, and important information in it, such as preferences and key expiration. It is good practice to verify that a self-signature imported into an implementation doesn't advertise features that the implementation doesn't support, rewriting the signature as appropriate. An implementation that encounters multiple self-signatures on the same object may resolve the ambiguity in any way it sees fit, but it is RECOMMENDED that priority be given to the most recent self- signature. -5.2.3.4. Signature Creation Time +5.2.3.8. Signature Creation Time (4-octet time field) The time the signature was made. MUST be present in the hashed area. -5.2.3.5. Issuer +5.2.3.9. Issuer (8-octet Key ID) The OpenPGP Key ID of the key issuing the signature. If the version of that key is greater than 4, this subpacket MUST NOT be included in the signature. -5.2.3.6. Key Expiration Time +5.2.3.10. Key Expiration Time (4-octet time field) The validity period of the key. This is the number of seconds after the key creation time that the key expires. If this is not present or has a value of zero, the key never expires. This is found only on a self-signature. -5.2.3.7. Preferred Symmetric Algorithms +5.2.3.11. Preferred Symmetric Algorithms (array of one-octet values) Symmetric algorithm numbers that indicate which algorithms the key holder prefers to use. The subpacket body is an ordered list of octets with the most preferred listed first. It is assumed that only algorithms listed are supported by the recipient's software. Algorithm numbers are in Section 9.3. This is only found on a self- signature. -5.2.3.8. Preferred Hash Algorithms +5.2.3.12. Preferred Hash Algorithms (array of one-octet values) Message digest algorithm numbers that indicate which algorithms the key holder prefers to receive. Like the preferred symmetric algorithms, the list is ordered. Algorithm numbers are in Section 9.5. This is only found on a self-signature. -5.2.3.9. Preferred Compression Algorithms +5.2.3.13. Preferred Compression Algorithms (array of one-octet values) Compression algorithm numbers that indicate which algorithms the key holder prefers to use. Like the preferred symmetric algorithms, the list is ordered. Algorithm numbers are in Section 9.4. If this subpacket is not included, ZIP is preferred. A zero denotes that uncompressed data is preferred; the key holder's software might have no compression software in that implementation. This is only found on a self-signature. -5.2.3.10. Signature Expiration Time +5.2.3.14. Signature Expiration Time (4-octet time field) The validity period of the signature. This is the number of seconds after the signature creation time that the signature expires. If this is not present or has a value of zero, it never expires. -5.2.3.11. Exportable Certification +5.2.3.15. Exportable Certification (1 octet of exportability, 0 for not, 1 for exportable) This subpacket denotes whether a certification signature is "exportable", to be used by other users than the signature's issuer. The packet body contains a Boolean flag indicating whether the signature is exportable. If this packet is not present, the certification is exportable; it is equivalent to a flag containing a 1. @@ -1543,61 +1672,60 @@ any local certifications. In normal operation, there won't be any, assuming the import is performed on an exported key. However, there are instances where this can reasonably happen. For example, if an implementation allows keys to be imported from a key database in addition to an exported key, then this situation can arise. Some implementations do not represent the interest of a single user (for example, a key server). Such implementations always trim local certifications from any key they handle. -5.2.3.12. Revocable +5.2.3.16. Revocable (1 octet of revocability, 0 for not, 1 for revocable) Signature's revocability status. The packet body contains a Boolean flag indicating whether the signature is revocable. Signatures that are not revocable have any later revocation signatures ignored. They represent a commitment by the signer that he cannot revoke his signature for the life of his key. If this packet is not present, the signature is revocable. -5.2.3.13. Trust Signature +5.2.3.17. Trust Signature (1 octet "level" (depth), 1 octet of trust amount) Signer asserts that the key is not only valid but also trustworthy at the specified level. Level 0 has the same meaning as an ordinary validity signature. Level 1 means that the signed key is asserted to be a valid trusted introducer, with the 2nd octet of the body specifying the degree of trust. Level 2 means that the signed key is asserted to be trusted to issue level 1 trust signatures, i.e., that it is a "meta introducer". Generally, a level n trust signature asserts that a key is trusted to issue level n-1 trust signatures. The trust amount is in a range from 0-255, interpreted such that values less than 120 indicate partial trust and values of 120 or greater indicate complete trust. Implementations SHOULD emit values of 60 for partial trust and 120 for complete trust. -5.2.3.14. Regular Expression +5.2.3.18. Regular Expression (null-terminated regular expression) - Used in conjunction with trust Signature packets (of level > 0) to limit the scope of trust that is extended. Only signatures by the target key on User IDs that match the regular expression in the body of this packet have trust extended by the trust Signature subpacket. The regular expression uses the same syntax as the Henry Spencer's "almost public domain" regular expression [REGEX] package. A description of the syntax is found in Section 8. -5.2.3.15. Revocation Key +5.2.3.19. Revocation Key (1 octet of class, 1 octet of public-key algorithm ID, 20 or 32 octets of fingerprint) V4 keys use the full 20 octet fingerprint; V5 keys use the full 32 octet fingerprint Authorizes the specified key to issue revocation signatures for this key. Class octet must have bit 0x80 set. If the bit 0x40 is set, then this means that the revocation information is sensitive. Other @@ -1608,21 +1736,21 @@ If the "sensitive" flag is set, the keyholder feels this subpacket contains private trust information that describes a real-world sensitive relationship. If this flag is set, implementations SHOULD NOT export this signature to other users except in cases where the data needs to be available: when the signature is being sent to the designated revoker, or when it is accompanied by a revocation signature from that revoker. Note that it may be appropriate to isolate this subpacket within a separate signature so that it is not combined with other subpackets that need to be exported. -5.2.3.16. Notation Data +5.2.3.20. Notation Data (4 octets of flags, 2 octets of name length (M), 2 octets of value length (N), M octets of name data, N octets of value data) This subpacket describes a "notation" on the signature that the issuer wishes to make. The notation has a name and a value, each of which are strings of octets. There may be more than one notation in a signature. Notations can be used for any extension the issuer of the signature cares to make. The "flags" field holds four octets of flags. @@ -1659,21 +1787,21 @@ Since the user namespace is in the form of an email address, implementers MAY wish to arrange for that address to reach a person who can be consulted about the use of the named tag. Note that due to UTF-8 encoding, not all valid user space name tags are valid email addresses. If there is a critical notation, the criticality applies to that specific notation and not to notations in general. -5.2.3.17. Key Server Preferences +5.2.3.21. Key Server Preferences (N octets of flags) This is a list of one-bit flags that indicate preferences that the key holder has about how the key is handled on a key server. All undefined flags MUST be zero. First octet: +======+===========+============================================+ @@ -1681,58 +1809,58 @@ +======+===========+============================================+ | 0x80 | No-modify | The key holder requests that this key only | | | | be modified or updated by the key holder | | | | or an administrator of the key server. | +------+-----------+--------------------------------------------+ Table 8: Key server preferences flag registry (first octet) This is found only on a self-signature. -5.2.3.18. Preferred Key Server +5.2.3.22. Preferred Key Server (String) This is a URI of a key server that the key holder prefers be used for updates. Note that keys with multiple User IDs can have a preferred key server for each User ID. Note also that since this is a URI, the key server can actually be a copy of the key retrieved by ftp, http, finger, etc. -5.2.3.19. Primary User ID +5.2.3.23. Primary User ID (1 octet, Boolean) This is a flag in a User ID's self-signature that states whether this User ID is the main User ID for this key. It is reasonable for an implementation to resolve ambiguities in preferences, etc. by referring to the primary User ID. If this flag is absent, its value is zero. If more than one User ID in a key is marked as primary, the implementation may resolve the ambiguity in any way it sees fit, but it is RECOMMENDED that priority be given to the User ID with the most recent self-signature. When appearing on a self-signature on a User ID packet, this subpacket applies only to User ID packets. When appearing on a self- signature on a User Attribute packet, this subpacket applies only to User Attribute packets. That is to say, there are two different and independent "primaries" -- one for User IDs, and one for User Attributes. -5.2.3.20. Policy URI +5.2.3.24. Policy URI (String) This subpacket contains a URI of a document that describes the policy under which the signature was issued. -5.2.3.21. Key Flags +5.2.3.25. Key Flags (N octets of flags) This subpacket contains a list of binary flags that hold information about a key. It is a string of octets, and an implementation MUST NOT assume a fixed size. This is so it can grow over time. If a list is shorter than an implementation expects, the unstated flags are considered to be zero. The defined flags are as follows: First octet: @@ -1785,34 +1913,34 @@ decision is left wholly up to the implementation; the authors of this document do not claim any special wisdom on the issue and realize that accepted opinion may change. The "split key" (0x10) and "group key" (0x80) flags are placed on a self-signature only; they are meaningless on a certification signature. They SHOULD be placed only on a direct-key signature (type 0x1F) or a subkey signature (type 0x18), one that refers to the key the flag applies to. -5.2.3.22. Signer's User ID +5.2.3.26. Signer's User ID (String) This subpacket allows a keyholder to state which User ID is responsible for the signing. Many keyholders use a single key for different purposes, such as business communications as well as personal communications. This subpacket allows such a keyholder to state which of their roles is making a signature. This subpacket is not appropriate to use to refer to a User Attribute packet. -5.2.3.23. Reason for Revocation +5.2.3.27. Reason for Revocation (1 octet of revocation code, N octets of reason string) This subpacket is used only in key revocation and certification revocation signatures. It describes the reason why the key or certificate was revoked. The first octet contains a machine-readable code that denotes the reason for the revocation: @@ -1854,21 +1982,21 @@ revoked signature is the self-signature for certifying a User ID, a revocation denotes that that user name is no longer in use. Such a revocation SHOULD include a 0x20 code. Note that any signature may be revoked, including a certification on some other person's key. There are many good reasons for revoking a certification signature, such as the case where the keyholder leaves the employ of a business with an email address. A revoked certification is no longer a part of validity calculations. -5.2.3.24. Features +5.2.3.28. Features (N octets of flags) The Features subpacket denotes which advanced OpenPGP features a user's implementation supports. This is so that as features are added to OpenPGP that cannot be backwards-compatible, a user can state that they can use that feature. The flags are single bits that indicate that a given feature is supported. This subpacket is similar to a preferences subpacket, and only @@ -1879,69 +2007,82 @@ Defined features are as follows: First octet: +=========+============================================+ | feature | definition | +=========+============================================+ | 0x01 | Modification Detection (packets 18 and 19) | +---------+--------------------------------------------+ - | 0x02 | Reserved (AEAD Data & v5 SKESK) | + | 0x02 | AEAD Encrypted Data (packet 20) | +---------+--------------------------------------------+ - | 0x04 | Version 5 Public-Key Packet format and | - | | corresponding new fingerprint format | + | 0x04 | Reserved | +---------+--------------------------------------------+ Table 12: Features registry If an implementation implements any of the defined features, it SHOULD implement the Features subpacket, too. An implementation may freely infer features from other suitable implementation-dependent mechanisms. -5.2.3.25. Signature Target +5.2.3.29. Signature Target (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) This subpacket identifies a specific target signature to which a signature refers. For revocation signatures, this subpacket provides explicit designation of which signature is being revoked. For a third-party or timestamp signature, this designates what signature is signed. All arguments are an identifier of that target signature. The N octets of hash data MUST be the size of the hash of the signature. For example, a target signature with a SHA-1 hash MUST have 20 octets of hash data. -5.2.3.26. Embedded Signature +5.2.3.30. Embedded Signature (1 signature packet body) This subpacket contains a complete Signature packet body as specified in Section 5.2. It is useful when one signature needs to refer to, or be incorporated in, another signature. -5.2.3.27. Issuer Fingerprint +5.2.3.31. Issuer Fingerprint (1 octet key version number, N octets of fingerprint) The OpenPGP Key fingerprint of the key issuing the signature. This subpacket SHOULD be included in all signatures. If the version of the issuing key is 4 and an Issuer subpacket is also included in the signature, the key ID of the Issuer subpacket MUST match the low 64 bits of the fingerprint. Note that the length N of the fingerprint for a version 4 key is 20 octets; for a version 5 key N is 32. +5.2.3.32. Intended Recipient Fingerprint + + (1 octet key version number, N octets of fingerprint) + + The OpenPGP Key fingerprint of the intended recipient primary key. + If one or more subpackets of this type are included in a signature, + it SHOULD be considered valid only in an encrypted context, where the + key it was encrypted to is one of the indicated primary keys, or one + of their subkeys. This can be used to prevent forwarding a signature + outside of its intended, encrypted context. + + Note that the length N of the fingerprint for a version 4 key is 20 + octets; for a version 5 key N is 32. + 5.2.4. Computing Signatures All signatures are formed by producing a hash over the signature data, and then using the resulting hash in the signature algorithm. For binary document signatures (type 0x00), the document data is hashed directly. For text document signatures (type 0x01), the document is canonicalized by converting line endings to , and the resulting data is hashed. @@ -1998,21 +2138,21 @@ - the hashed subpacket body, - the two octets 0x04 and 0xFF, - a four-octet big-endian number that is the length of the hashed data from the Signature packet stopping right before the 0x04, 0xff octets. The four-octet big-endian number is considered to be an - unsigned integer modulo 2^32. + unsigned integer modulo 2**32. * A V5 signature hashes the packet body starting from its first field, the version number, through the end of the hashed subpacket data and a final extra trailer. Thus, the hashed fields are: - the signature version (0x05), - the signature type, - the public-key algorithm, @@ -2034,21 +2174,21 @@ o a four-octet number that indicates a date, - the two octets 0x05 and 0xFF, - a eight-octet big-endian number that is the length of the hashed data from the Signature packet stopping right before the 0x05, 0xff octets. The three data items hashed for document signatures need to mirror the values of the Literal Data packet. For detached and - cleartext signatures 6 zero bytes are hashed instead. + cleartext signatures 6 zero octets are hashed instead. After all this has been hashed in a single hash context, the resulting hash field is used in the signature algorithm and placed at the end of the Signature packet. 5.2.4.1. Subpacket Hints It is certainly possible for a signature to contain conflicting information in subpackets. For example, a signature may contain multiple copies of a preference or multiple expiration times. In @@ -2062,67 +2202,106 @@ Some apparent conflicts may actually make sense -- for example, suppose a keyholder has a V3 key and a V4 key that share the same RSA key material. Either of these keys can verify a signature created by the other, and it may be reasonable for a signature to contain an issuer subpacket for each key, as a way of explicitly tying those keys to the signature. 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) - The Symmetric-Key Encrypted Session Key packet holds the symmetric- - key encryption of a session key used to encrypt a message. Zero or - more Public-Key Encrypted Session Key packets and/or Symmetric-Key - Encrypted Session Key packets may precede a Symmetrically Encrypted - Data packet that holds an encrypted message. The message is - encrypted with a session key, and the session key is itself encrypted - and stored in the Encrypted Session Key packet or the Symmetric-Key - Encrypted Session Key packet. + The Symmetric-Key Encrypted Session Key (SKESK) packet holds the + symmetric-key encryption of a session key used to encrypt a message. + Zero or more Public-Key Encrypted Session Key packets and/or + Symmetric-Key Encrypted Session Key packets may precede a an + encryption container (i.e. a Symmetrically Encrypted Integrity + Protected Data packet, an AEAD Encrypted Data packet, or -- for + historic data -- a Symmetrically Encrypted Data packet) that holds an + encrypted message. The message is encrypted with a session key, and + the session key is itself encrypted and stored in the Encrypted + Session Key packet or the Symmetric-Key Encrypted Session Key packet. - If the Symmetrically Encrypted Data packet is preceded by one or more - Symmetric-Key Encrypted Session Key packets, each specifies a - passphrase that may be used to decrypt the message. This allows a - message to be encrypted to a number of public keys, and also to one - or more passphrases. This packet type is new and is not generated by - PGP 2 or PGP version 5.0. + If the encryption container is preceded by one or more Symmetric-Key + Encrypted Session Key packets, each specifies a passphrase that may + be used to decrypt the message. This allows a message to be + encrypted to a number of public keys, and also to one or more + passphrases. This packet type is new and is not generated by PGP 2 + or PGP version 5.0. - The body of this packet consists of: + A version 4 Symmetric-Key Encrypted Session Key packet consists of: - * A one-octet version number. The only currently defined version is - 4. + * A one-octet version number with value 4. * A one-octet number describing the symmetric algorithm used. * A string-to-key (S2K) specifier, length as defined above. * Optionally, the encrypted session key itself, which is decrypted with the string-to-key object. If the encrypted session key is not present (which can be detected on the basis of packet length and S2K specifier size), then the S2K algorithm applied to the passphrase produces the session key for decrypting the message, using the symmetric cipher algorithm from the Symmetric-Key Encrypted Session Key packet. If the encrypted session key is present, the result of applying the S2K algorithm to the passphrase is used to decrypt just that encrypted session key field, using CFB mode with an IV of all zeros. The decryption result consists of a one-octet algorithm identifier that specifies the symmetric-key encryption algorithm used to encrypt - the following Symmetrically Encrypted Data packet, followed by the - session key octets themselves. + the following encryption container, followed by the session key + octets themselves. Note: because an all-zero IV is used for this decryption, the S2K specifier MUST use a salt value, either a Salted S2K or an Iterated- Salted S2K. The salt value will ensure that the decryption key is not repeated even if the passphrase is reused. + A version 5 Symmetric-Key Encrypted Session Key packet consists of: + + * A one-octet version number with value 5. + + * A one-octet cipher algorithm. + + * A one-octet AEAD algorithm. + + * A string-to-key (S2K) specifier, length as defined above. + + * A starting initialization vector of size specified by the AEAD + algorithm. + + * The encrypted session key itself, which is decrypted with the + string-to-key object using the given cipher and AEAD mode. + + * An authentication tag for the AEAD mode. + + The encrypted session key is encrypted using one of the AEAD + algorithms specified for the AEAD Encrypted Data Packet. Note that + no chunks are used and that there is only one authentication tag. + The Packet Tag in new format encoding (bits 7 and 6 set, bits 5-0 + carry the packet tag), the packet version number, the cipher + algorithm octet, and the AEAD algorithm octet are given as additional + data. For example, the additional data used with EAX and AES-128 + consists of the octets 0xC3, 0x05, 0x07, and 0x01. + +5.3.1. No v5 SKESK with SEIPD + + Note that unlike the AEAD Encrypted Data Packet (AED, see + Section 5.16), the Symmetrically Encrypted Integrity Protected Data + Packet (SEIPD, see Section 5.14) does not internally indicate what + cipher algorithm to use to decrypt it. Since the v5 SKESK packet's + encrypted payload only indicates the key used, not the choice of + cipher algorithm used for the subsequent encrypted data, a v5 SKESK + packet can only provide a session key for an AED packet, and MUST NOT + be used to provide a session key for a SEIPD Packet. + 5.4. One-Pass Signature Packets (Tag 4) The One-Pass Signature packet precedes the signed data and contains enough information to allow the receiver to begin calculating any hashes needed to verify the signature. It allows the Signature packet to be placed at the end of the message, so that the signer can compute the entire signed message in one pass. A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. @@ -2242,21 +2421,21 @@ * A four-octet number denoting the time that the key was created. * A one-octet number denoting the public-key algorithm of this key. * A series of multiprecision integers comprising the key material. This is algorithm-specific and described in Section 5.6. The version 5 format is similar to the version 4 format except for the addition of a count for the key material. This count helps parsing secret key packets (which are an extension of the public key - packet format) in the case of an unknown algoritm. In addition, + packet format) in the case of an unknown algorithm. In addition, fingerprints of version 5 keys are calculated differently from version 4 keys, as described in the section "Enhanced Key Formats". A version 5 packet contains: * A one-octet version number (5). * A four-octet number denoting the time that the key was created. * A one-octet number denoting the public-key algorithm of this key. @@ -2279,83 +2458,115 @@ * One octet indicating string-to-key usage conventions. Zero indicates that the secret-key data is not encrypted. 255 or 254 indicates that a string-to-key specifier is being given. Any other value is a symmetric-key encryption algorithm identifier. A version 5 packet MUST NOT use the value 255. * Only for a version 5 packet, a one-octet scalar octet count of the next 4 optional fields. - * [Optional] If string-to-key usage octet was 255 or 254, a one- - octet symmetric encryption algorithm. + * [Optional] If string-to-key usage octet was 255, 254, or 253, a + one-octet symmetric encryption algorithm. - * [Optional] If string-to-key usage octet was 255 or 254, a string- - to-key specifier. The length of the string-to-key specifier is - implied by its type, as described above. + * [Optional] If string-to-key usage octet was 253, a one-octet AEAD + algorithm. - * [Optional] If secret data is encrypted (string-to-key usage octet - not zero), an Initial Vector (IV) of the same length as the - cipher's block size. + * [Optional] If string-to-key usage octet was 255, 254, or 253, a + string-to-key specifier. The length of the string-to-key + specifier is implied by its type, as described above. + + * [Optional] If string-to-key usage octet was 253 (i.e. the secret + data is AEAD-encrypted), an initialization vector (IV) of size + specified by the AEAD algorithm (see Section 5.16), which is used + as the nonce for the AEAD algorithm. + + * [Optional] If string-to-key usage octet was 255, 254, or a cipher + algorithm identifier (i.e. the secret data is CFB-encrypted), an + initialization vector (IV) of the same length as the cipher's + block size. * Only for a version 5 packet, a four-octet scalar octet count for the following secret key material. This includes the encrypted SHA-1 hash or AEAD tag if the string-to-key usage octet is 254 or 253. * Plain or encrypted multiprecision integers comprising the secret key data. This is algorithm-specific and described in section - Section 5.6. + Section 5.6. If the string-to-key usage octet is 253, then an + AEAD authentication tag is part of that data. If the string-to- + key usage octet is 254, a 20-octet SHA-1 hash of the plaintext of + the algorithm-specific portion is appended to plaintext and + encrypted with it. If the string-to-key usage octet is 255 or + another nonzero value (i.e., a symmetric-key encryption algorithm + identifier), a two-octet checksum of the plaintext of the + algorithm-specific portion (sum of all octets, mod 65536) is + appended to plaintext and encrypted with it. (This is deprecated + and SHOULD NOT be used, see below.) - * If the string-to-key usage octet is zero or 255, then a two-octet - checksum of the plaintext of the algorithm-specific portion (sum - of all octets, mod 65536). If the string-to-key usage octet was - 254, then a 20-octet SHA-1 hash of the plaintext of the algorithm- - specific portion. This checksum or hash is encrypted together - with the algorithm-specific fields (if string-to-key usage octet - is not zero). Note that for all other values, a two-octet - checksum is required. + * If the string-to-key usage octet is zero, then a two-octet + checksum of the algorithm-specific portion (sum of all octets, mod + 65536). Note that the version 5 packet format adds two count values to help parsing packets with unknown S2K or public key algorithms. Secret MPI values can be encrypted using a passphrase. If a string- to-key specifier is given, that describes the algorithm for converting the passphrase to a key, else a simple MD5 hash of the passphrase is used. Implementations MUST use a string-to-key specifier; the simple hash is for backward compatibility and is deprecated, though implementations MAY continue to use existing private keys in the old format. The cipher for encrypting the MPIs is specified in the Secret-Key packet. - Encryption/decryption of the secret data is done in CFB mode using - the key created from the passphrase and the Initial Vector from the - packet. A different mode is used with V3 keys (which are only RSA) + Encryption/decryption of the secret data is done using the key + created from the passphrase and the initialization vector from the + packet. If the string-to-key usage octet is not 253, CFB mode is + used. A different mode is used with V3 keys (which are only RSA) than with other key formats. With V3 keys, the MPI bit count prefix (i.e., the first two octets) is not encrypted. Only the MPI non- prefix data is encrypted. Furthermore, the CFB state is resynchronized at the beginning of each new MPI value, so that the CFB block boundary is aligned with the start of the MPI data. With V4 and V5 keys, a simpler method is used. All secret MPI values - are encrypted in CFB mode, including the MPI bitcount prefix. + are encrypted, including the MPI bitcount prefix. + + If the string-to-key usage octet is 253, the encrypted MPI values are + encrypted as one combined plaintext using one of the AEAD algorithms + specified for the AEAD Encrypted Data Packet. Note that no chunks + are used and that there is only one authentication tag. As + additional data, the Packet Tag in new format encoding (bits 7 and 6 + set, bits 5-0 carry the packet tag), followed by the public key + packet fields, starting with the packet version number, are passed to + the AEAD algorithm. For example, the additional data used with a + Secret-Key Packet of version 4 consists of the octets 0xC5, 0x04, + followed by four octets of creation time, one octet denoting the + public-key algorithm, and the algorithm-specific public-key + parameters. For a Secret-Subkey Packet, the first octet would be + 0xC7. For a version 5 key packet, the second octet would be 0x05, + and the four-octet octet count of the public key material would be + included as well (see Section 5.5.2). The two-octet checksum that follows the algorithm-specific portion is the algebraic sum, mod 65536, of the plaintext of all the algorithm- specific octets (including MPI prefix and data). With V3 keys, the checksum is stored in the clear. With V4 keys, the checksum is encrypted like the algorithm-specific data. This value is used to check that the passphrase was correct. However, this checksum is deprecated; an implementation SHOULD NOT use it, but should rather use the SHA-1 hash denoted with a usage octet of 254. The reason for this is that there are some attacks that involve undetectably - modifying the secret key. + modifying the secret key. If the string-to-key usage octet is 253 no + checksum or SHA-1 hash is used but the authentication tag of the AEAD + algorithm follows. 5.6. Algorithm-specific Parts of Keys The public and secret key format specifies algorithm-specific parts of a key. The following sections describe them in detail. 5.6.1. Algorithm-Specific Part for RSA Keys The public key is this series of multiprecision integers: @@ -2400,89 +2611,94 @@ secret). The secret key is this single multiprecision integer: * MPI of Elgamal secret exponent x. 5.6.4. Algorithm-Specific Part for ECDSA Keys The public key is this series of values: - * a variable-length field containing a curve OID, formatted as - follows: + * A variable-length field containing a curve OID, which is formatted + as follows: - - a one-octet size of the following field; values 0 and 0xFF are + - A one-octet size of the following field; values 0 and 0xFF are reserved for future extensions, - - the octets representing a curve OID, defined in Section 9.2; + - The octets representing a curve OID (defined in Section 9.2); - * a MPI of an EC point representing a public key. + * MPI of an EC point representing a public key. The secret key is this single multiprecision integer: * MPI of an integer representing the secret key, which is a scalar of the public EC point. 5.6.5. Algorithm-Specific Part for EdDSA Keys The public key is this series of values: - * a variable-length field containing a curve OID, formatted as + * A variable-length field containing a curve OID, formatted as follows: - - a one-octet size of the following field; values 0 and 0xFF are + - A one-octet size of the following field; values 0 and 0xFF are reserved for future extensions, - - the octets representing a curve OID, defined in Section 9.2; + - The octets representing a curve OID, defined in Section 9.2; - * a MPI of an EC point representing a public key Q as described - under EdDSA Point Format below. + * An MPI of an EC point representing a public key Q in prefixed + native form (see Section 13.2.2). The secret key is this single multiprecision integer: - * MPI of an integer representing the secret key, which is a scalar - of the public EC point. + * An MPI-encoded octet string representing the native form of the + secret key, in the curve-specific format described in + Section 9.2.1. + + See [RFC8032] for more details about the native octet strings. 5.6.6. Algorithm-Specific Part for ECDH Keys The public key is this series of values: - * a variable-length field containing a curve OID, formatted as - follows: + * A variable-length field containing a curve OID, which is formatted + as follows: - - a one-octet size of the following field; values 0 and 0xFF are + - A one-octet size of the following field; values 0 and 0xFF are reserved for future extensions, - - the octets representing a curve OID, defined in Section 9.2; + - Octets representing a curve OID, defined in Section 9.2; - * a MPI of an EC point representing a public key; + * MPI of an EC point representing a public key, in the point format + associated with the curve as specified in Section 9.2.1 - * a variable-length field containing KDF parameters, formatted as - follows: + * A variable-length field containing KDF parameters, which is + formatted as follows: - - a one-octet size of the following fields; values 0 and 0xff are - reserved for future extensions; + - A one-octet size of the following fields; values 0 and 0xFF are + reserved for future extensions, - - a one-octet value 1, reserved for future extensions; - - a one-octet hash function ID used with a KDF; + - A one-octet value 1, reserved for future extensions, - - a one-octet algorithm ID for the symmetric algorithm used to + - A one-octet hash function ID used with a KDF, + + - A one-octet algorithm ID for the symmetric algorithm used to wrap the symmetric key used for the message encryption; see Section 13.5 for details. Observe that an ECDH public key is composed of the same sequence of - fields that define an ECDSA key, plus the KDF parameters field. + fields that define an ECDSA key plus the KDF parameters field. The secret key is this single multiprecision integer: - * MPI of an integer representing the secret key, which is a scalar - of the public EC point. + * An MPI representing the secret key, in the curve-specific format + described in Section 9.2.1. 5.7. Compressed Data Packet (Tag 8) The Compressed Data packet contains compressed data. Typically, this packet is found as the contents of an encrypted packet, or following a Signature or One-Pass Signature packet, and contains a literal data packet. The body of this packet consists of: @@ -2715,28 +2931,23 @@ 5.14. Sym. Encrypted Integrity Protected Data Packet (Tag 18) The Symmetrically Encrypted Integrity Protected Data packet is a variant of the Symmetrically Encrypted Data packet. It is a new feature created for OpenPGP that addresses the problem of detecting a modification to encrypted data. It is used in combination with a Modification Detection Code packet. There is a corresponding feature in the features Signature subpacket that denotes that an implementation can properly use this packet - type. An implementation MUST support decrypting these packets and - SHOULD prefer generating them to the older Symmetrically Encrypted - Data packet when possible. Since this data packet protects against - modification attacks, this standard encourages its proliferation. - While blanket adoption of this data packet would create - interoperability problems, rapid adoption is nevertheless important. - An implementation SHOULD specifically denote support for this packet, - but it MAY infer it from other mechanisms. + type. An implementation MUST support decrypting and generating these + packets. An implementation SHOULD specifically denote support for + this packet, but it MAY infer it from other mechanisms. For example, an implementation might infer from the use of a cipher such as Advanced Encryption Standard (AES) or Twofish that a user supports this feature. It might place in the unhashed portion of another user's key signature a Features subpacket. It might also present a user with an opportunity to regenerate their own self- signature with a Features subpacket. This packet contains data encrypted with a symmetric-key algorithm and protected against modification by the SHA-1 hash algorithm. When @@ -2749,23 +2960,23 @@ * A one-octet version number. The only currently defined value is 1. * Encrypted data, the output of the selected symmetric-key cipher operating in Cipher Feedback mode with shift amount equal to the block size of the cipher (CFB-n where n is the block size). The symmetric cipher used MUST be specified in a Public-Key or Symmetric-Key Encrypted Session Key packet that precedes the - Symmetrically Encrypted Data packet. In either case, the cipher - algorithm octet is prefixed to the session key before it is - encrypted. + Symmetrically Encrypted Integrity Protected Data packet. In either + case, the cipher algorithm octet is prefixed to the session key + before it is encrypted. The data is encrypted in CFB mode, with a CFB shift size equal to the cipher's block size. The Initial Vector (IV) is specified as all zeros. Instead of using an IV, OpenPGP prefixes an octet string to the data before it is encrypted. The length of the octet string equals the block size of the cipher in octets, plus two. The first octets in the group, of length equal to the block size of the cipher, are random; the last two octets are each copies of their 2nd preceding octet. For example, with a cipher whose block size is 128 bits or 16 octets, the prefix data will contain 16 random octets, @@ -2884,20 +3095,113 @@ prefix data, the tag octet, and length octet of the Modification Detection Code packet. Note that the Modification Detection Code packet MUST always use a new format encoding of the packet tag, and a one-octet encoding of the packet length. The reason for this is that the hashing rules for modification detection include a one-octet tag and one-octet length in the data hash. While this is a bit restrictive, it reduces complexity. +5.16. AEAD Encrypted Data Packet (Tag 20) + + This packet contains data encrypted with an authenticated encryption + and additional data (AEAD) construction. When it has been decrypted, + it will typically contain other packets (often a Literal Data packet + or Compressed Data packet). + + The body of this packet starts with: + + * A one-octet version number. The only currently defined value is + 1. + + When the version is 1, it is followed by the following fields: + + * A one-octet cipher algorithm. + + * A one-octet AEAD algorithm. + + * A one-octet chunk size. + + * A initialization vector of size specified by the AEAD algorithm. + + * Encrypted data, the output of the selected symmetric-key cipher + operating in the given AEAD mode. + + * A final, summary authentication tag for the AEAD mode. + + An AEAD encrypted data packet consists of one or more chunks of data. + The plaintext of each chunk is of a size specified using the chunk + size octet using the method specified below. + + The encrypted data consists of the encryption of each chunk of + plaintext, followed immediately by the relevant authentication tag. + If the last chunk of plaintext is smaller than the chunk size, the + ciphertext for that data may be shorter; it is nevertheless followed + by a full authentication tag. + + For each chunk, the AEAD construction is given the Packet Tag in new + format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag), + version number, cipher algorithm octet, AEAD algorithm octet, chunk + size octet, and an eight-octet, big-endian chunk index as additional + data. The index of the first chunk is zero. For example, the + additional data of the first chunk using EAX and AES-128 with a chunk + size of 2**16 octets consists of the octets 0xD4, 0x01, 0x07, 0x01, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, and 0x00. + + After the final chunk, the AEAD algorithm is used to produce a final + authentication tag encrypting the empty string. This AEAD instance + is given the additional data specified above, plus an eight-octet, + big-endian value specifying the total number of plaintext octets + encrypted. This allows detection of a truncated ciphertext. Please + note that the big-endian number representing the chunk index in the + additional data is increased accordingly, although it's not really a + chunk. + + The chunk size octet specifies the size of chunks using the following + formula (in C), where c is the chunk size octet: + + chunk_size = ((uint64_t)1 << (c + 6)) + + An implementation MUST accept chunk size octets with values from 0 to + 16. An implementation MUST NOT create data with a chunk size octet + value larger than 16 (4 MiB chunks). + + A unique, random, unpredictable initialization vector MUST be used + for each message. Failure to do so for each message can lead to a + catastrophic failure depending on the choice of AEAD mode and + symmetric key reuse. + +5.16.1. EAX Mode + + The EAX AEAD Algorithm used in this document is defined in [EAX]. + + The EAX algorithm can only use block ciphers with 16-octet blocks. + The initialization vector is 16 octets long. EAX authentication tags + are 16 octets long. + + The nonce for EAX mode is computed by treating the initialization + vector as a 16-octet, big-endian value and exclusive-oring the low + eight octets of it with the chunk index. + +5.16.2. OCB Mode + + The OCB AEAD Algorithm used in this document is defined in [RFC7253]. + + The OCB algorithm can only use block ciphers with 16-octet blocks. + The initialization vector is 15 octets long. OCB authentication tags + are 16 octets long. + + The nonce for OCB mode is computed by the exclusive-oring of the + initialization vector as a 15-octet, big endian value, against the + chunk index. + 6. Radix-64 Conversions As stated in the introduction, OpenPGP's underlying native representation for objects is a stream of arbitrary octets, and some systems desire these objects to be immune to damage caused by character set translation, data conversions, etc. In principle, any printable encoding scheme that met the requirements of the unsafe channel would suffice, since it would not change the underlying binary bit streams of the native OpenPGP data structures. @@ -3015,30 +3319,31 @@ The format of an Armor Header is that of a key-value pair. A colon (":" 0x38) and a single space (0x20) separate the key and value. OpenPGP should consider improperly formatted Armor Headers to be corruption of the ASCII Armor. Unknown keys should be reported to the user, but OpenPGP should continue to process the message. Note that some transport methods are sensitive to line length. While there is a limit of 76 characters for the Radix-64 data (Section 6.3), there is no limit to the length of Armor Headers. - Care should be taken that the Armor Headers are short enough to survive transport. One way to do this is to repeat an Armor Header Key multiple times with different values for each so that no one line is overly long. Currently defined Armor Header Keys are as follows: * "Version", which states the OpenPGP implementation and version - used to encode the message. + used to encode the message. To minimize metadata, implementations + SHOULD NOT emit this key and its corresponding value except for + debugging purposes with explicit user consent. * "Comment", a user-defined comment. OpenPGP defines all text to be in UTF-8. A comment may be any UTF-8 string. However, the whole point of armoring is to provide seven-bit-clean data. Consequently, if a comment has characters that are outside the US- ASCII range of UTF, they may very well not survive transport. * "MessageID", a 32-character string of printable characters. The string must be the same for all parts of a multi-part message that uses the "PART X" Armor Header. MessageID strings should be @@ -3190,21 +3495,20 @@ 8-bit: 00010100 11111011 10011100 | 00000011 pad with 0000 6-bit: 000101 001111 101110 011100 | 000000 110000 Decimal: 5 15 46 28 0 48 pad with = = Output: F P u c A w = = 6.6. Example of an ASCII Armored Message -----BEGIN PGP MESSAGE----- - Version: OpenPrivacy 0.99 yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS vBSFjNSiVHsuAA== =njUN -----END PGP MESSAGE----- Note that this example has extra indenting; an actual armored message would have no leading whitespace. 7. Cleartext Signature Framework @@ -3245,27 +3549,27 @@ An implementation SHOULD add a line break after the cleartext, but MAY omit it if the cleartext ends with a line break. This is for visual clarity. 7.1. Dash-Escaped Text The cleartext content of the message must also be dash-escaped. Dash-escaped cleartext is the ordinary cleartext where every line - starting with a dash "-" (0x2D) is prefixed by the sequence dash "-" - (0x2D) and space ` ` (0x20). This prevents the parser from - recognizing armor headers of the cleartext itself. An implementation - MAY dash-escape any line, SHOULD dash-escape lines commencing "From" - followed by a space, and MUST dash-escape any line commencing in a - dash. The message digest is computed using the cleartext itself, not - the dash-escaped form. + starting with a "-" (HYPHEN-MINUS, U+002D) is prefixed by the + sequence "-" (HYPHEN-MINUS, U+002D) and " " (SPACE, U+0020). This + prevents the parser from recognizing armor headers of the cleartext + itself. An implementation MAY dash-escape any line, SHOULD dash- + escape lines commencing "From" followed by a space, and MUST dash- + escape any line commencing in a dash. The message digest is computed + using the cleartext itself, not the dash-escaped form. As with binary signatures on text documents, a cleartext signature is calculated on the text using canonical line endings. The line ending (i.e., the ) before the "-----BEGIN PGP SIGNATURE-----" line that terminates the signed text is not considered part of the signed text. When reversing dash-escaping, an implementation MUST strip the string "-" if it occurs at the beginning of a line, and SHOULD warn on "-" and any character other than a space at the beginning of a line. @@ -3312,143 +3616,258 @@ Note that these tables are not exhaustive lists; an implementation MAY implement an algorithm not on these lists, so long as the algorithm numbers are chosen from the private or experimental algorithm range. See Section 14 for more discussion of the algorithms. 9.1. Public-Key Algorithms - +========+===================================================+ - | ID | Algorithm | - +========+===================================================+ - | 1 | RSA (Encrypt or Sign) [HAC] | - +--------+---------------------------------------------------+ - | 2 | RSA Encrypt-Only [HAC] | - +--------+---------------------------------------------------+ - | 3 | RSA Sign-Only [HAC] | - +--------+---------------------------------------------------+ - | 16 | Elgamal (Encrypt-Only) [ELGAMAL] [HAC] | - +--------+---------------------------------------------------+ - | 17 | DSA (Digital Signature Algorithm) [FIPS186] [HAC] | - +--------+---------------------------------------------------+ - | 18 | ECDH public key algorithm | - +--------+---------------------------------------------------+ - | 19 | ECDSA public key algorithm [FIPS186] | - +--------+---------------------------------------------------+ - | 20 | Reserved (formerly Elgamal Encrypt or Sign) | - +--------+---------------------------------------------------+ - | 21 | Reserved for Diffie-Hellman (X9.42, as defined | - | | for IETF-S/MIME) | - +--------+---------------------------------------------------+ - | 22 | EdDSA [RFC8032] | - +--------+---------------------------------------------------+ - | 23 | Reserved (AEDH) | - +--------+---------------------------------------------------+ - | 24 | Reserved (AEDSA) | - +--------+---------------------------------------------------+ - | 100 to | Private/Experimental algorithm | - | 110 | | - +--------+---------------------------------------------------+ + +===+==============+==========+=============+===========+===========+ + | ID|Algorithm |Public Key|Secret Key | Signature |PKESK | + | | |Format |Format | Format |Format | + +===+==============+==========+=============+===========+===========+ + | 1|RSA (Encrypt |MPI(n), |MPI(d), | MPI(m**d |MPI(m**e | + | |or Sign) [HAC]|MPI(e) |MPI(p), | mod n) |mod n) | + | | |[Section |MPI(q), | [Section |[Section | + | | |5.6.1] |MPI(u) | 5.2.3.1] |5.1.1] | + +---+--------------+----------+-------------+-----------+-----------+ + | 2|RSA Encrypt- |MPI(n), |MPI(d), | N/A |MPI(m**e | + | |Only [HAC] |MPI(e) |MPI(p), | |mod n) | + | | |[Section |MPI(q), | |[Section | + | | |5.6.1] |MPI(u) | |5.1.1] | + +---+--------------+----------+-------------+-----------+-----------+ + | 3|RSA Sign-Only |MPI(n), |MPI(d), | MPI(m**d |N/A | + | |[HAC] |MPI(e) |MPI(p), | mod n) | | + | | |[Section |MPI(q), | [Section | | + | | |5.6.1] |MPI(u) | 5.2.3.1] | | + +---+--------------+----------+-------------+-----------+-----------+ + | 16|Elgamal |MPI(p), |MPI(x) | N/A |MPI(g**k | + | |(Encrypt-Only)|MPI(g), | | |mod p), MPI| + | |[ELGAMAL] |MPI(y) | | |(m * y**k | + | |[HAC] |[Section | | |mod p) | + | | |5.6.3] | | |[Section | + | | | | | |5.1.2] | + +---+--------------+----------+-------------+-----------+-----------+ + | 17|DSA (Digital |MPI(p), |MPI(x) | MPI(r), |N/A | + | |Signature |MPI(q), | | MPI(s) | | + | |Algorithm) |MPI(g), | | [Section | | + | |[FIPS186] |MPI(y) | | 5.2.3.2] | | + | |[HAC] |[Section | | | | + | | |5.6.2] | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 18|ECDH public |OID, |MPI(secret) | N/A |MPI(point | + | |key algorithm |MPI(point | | |in curve- | + | | |in curve- | | |specific | + | | |specific | | |point | + | | |point | | |format), | + | | |format), | | |size octet,| + | | |KDFParams | | |encoded key| + | | |[see | | |[Section | + | | |Section | | |9.2.1, | + | | |9.2.1, | | |Section | + | | |Section | | |5.1.3, | + | | |5.6.6] | | |Section | + | | | | | |13.5] | + +---+--------------+----------+-------------+-----------+-----------+ + | 19|ECDSA public |OID, |MPI(secret) | MPI(r), |N/A | + | |key algorithm |MPI(point | | MPI(s) | | + | |[FIPS186] |in SEC1 | | [Section | | + | | |format) | | 5.2.3.2] | | + | | |[Section | | | | + | | |5.6.4] | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 20|Reserved | | | | | + | |(formerly | | | | | + | |Elgamal | | | | | + | |Encrypt or | | | | | + | |Sign) | | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 21|Reserved for | | | | | + | |Diffie-Hellman| | | | | + | |(X9.42, as | | | | | + | |defined for | | | | | + | |IETF-S/MIME) | | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 22|EdDSA |OID, |MPI(value in | MPI, MPI |N/A | + | |[RFC8032] |MPI(point |curve- | [see | | + | | |in |specific | Section | | + | | |prefixed |format) [see | 9.2.1, | | + | | |native |Section | Section | | + | | |format) |9.2.1] | 5.2.3.3] | | + | | |[Section | | | | + | | |5.6.5] | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 23|Reserved | | | | | + | |(AEDH) | | | | | + +---+--------------+----------+-------------+-----------+-----------+ + | 24|Reserved | | | | | + | |(AEDSA) | | | | | + +---+--------------+----------+-------------+-----------+-----------+ + |100|Private/ | | | | | + | to|Experimental | | | | | + |110|algorithm | | | | | + +---+--------------+----------+-------------+-----------+-----------+ Table 15: Public-key algorithm registry Implementations MUST implement DSA for signatures, and Elgamal for encryption. Implementations SHOULD implement RSA keys (1). RSA Encrypt-Only (2) and RSA Sign-Only (3) are deprecated and SHOULD NOT be generated, but may be interpreted. See Section 14.5. See Section 14.9 for notes on Elgamal Encrypt or Sign (20), and X9.42 (21). Implementations MAY implement any other algorithm. A compatible specification of ECDSA is given in [RFC6090] as "KT-I - Signatures" and in [SEC1]; ECDH is defined in Section 13.5 this + Signatures" and in [SEC1]; ECDH is defined in Section 13.5 of this document. -9.2. ECC Curve OID +9.2. ECC Curves for OpenPGP The parameter curve OID is an array of octets that define a named - curve. The table below specifies the exact sequence of bytes for - each named curve referenced in this document: + curve. - +========================+=====+=================+============+ - | ASN.1 Object | OID | Curve OID bytes | Curve name | - | Identifier | len | in hexadecimal | | - | | | representation | | - +========================+=====+=================+============+ - | 1.2.840.10045.3.1.7 | 8 | 2A 86 48 CE 3D | NIST P-256 | - | | | 03 01 07 | | - +------------------------+-----+-----------------+------------+ - | 1.3.132.0.34 | 5 | 2B 81 04 00 22 | NIST P-384 | - +------------------------+-----+-----------------+------------+ - | 1.3.132.0.35 | 5 | 2B 81 04 00 23 | NIST P-521 | - +------------------------+-----+-----------------+------------+ - | 1.3.6.1.4.1.11591.15.1 | 9 | 2B 06 01 04 01 | Ed25519 | - | | | DA 47 0F 01 | | - +------------------------+-----+-----------------+------------+ - | 1.3.6.1.4.1.3029.1.5.1 | 10 | 2B 06 01 04 01 | Curve25519 | - | | | 97 55 01 05 01 | | - +------------------------+-----+-----------------+------------+ + The table below specifies the exact sequence of octets for each named + curve referenced in this document. It also specifies which public + key algorithms the curve can be used with, as well as the size of + expected elements in octets: - Table 16: ECC Curve OID registry + +======================+===+==============+==========+======+=======+ + |ASN.1 Object |OID|Curve OID |Curve name|Usage |Field | + |Identifier |len|octets in | | |Size | + | | |hexadecimal | | |(fsize)| + | | |representation| | | | + +======================+===+==============+==========+======+=======+ + |1.2.840.10045.3.1.7 |8 |2A 86 48 CE 3D|NIST P-256|ECDSA,|32 | + | | |03 01 07 | |ECDH | | + +----------------------+---+--------------+----------+------+-------+ + |1.3.132.0.34 |5 |2B 81 04 00 22|NIST P-384|ECDSA,|48 | + | | | | |ECDH | | + +----------------------+---+--------------+----------+------+-------+ + |1.3.132.0.35 |5 |2B 81 04 00 23|NIST P-521|ECDSA,|66 | + | | | | |ECDH | | + +----------------------+---+--------------+----------+------+-------+ + |1.3.6.1.4.1.11591.15.1|9 |2B 06 01 04 01|Ed25519 |EdDSA |32 | + | | |DA 47 0F 01 | | | | + +----------------------+---+--------------+----------+------+-------+ + |1.3.101.113 |3 |2B 65 71 |Ed448 |EdDSA |57 | + +----------------------+---+--------------+----------+------+-------+ + |1.3.6.1.4.1.3029.1.5.1|10 |2B 06 01 04 01|Curve25519|ECDH |32 | + | | |97 55 01 05 01| | | | + +----------------------+---+--------------+----------+------+-------+ + |1.3.101.111 |3 |2B 65 6F |X448 |ECDH |56 | + +----------------------+---+--------------+----------+------+-------+ + + Table 16: ECC Curve OID and usage registry + + The "Field Size (fsize)" column represents the field size of the + group in number of octets, rounded up, such that x or y coordinates + for a point on the curve, native point representations, or scalars + with high enough entropy for the curve can be represented in that + many octets. The sequence of octets in the third column is the result of applying the Distinguished Encoding Rules (DER) to the ASN.1 Object Identifier with subsequent truncation. The truncation removes the two fields of encoded Object Identifier. The first omitted field is one octet representing the Object Identifier tag, and the second omitted field is the length of the Object Identifier body. For example, the complete ASN.1 DER encoding for the NIST P-256 curve OID is "06 08 2A 86 48 CE 3D 03 01 07", from which the first entry in the table above is constructed by omitting the first two octets. Only the truncated sequence of octets is the valid representation of a curve OID. +9.2.1. Curve-Specific Wire Formats + + Some Elliptic Curve Public Key Algorithms use different conventions + for specific fields depending on the curve in use. Each field is + always formatted as an MPI, but with a curve-specific framing. This + table summarizes those distinctions. + + +============+========+========+=========+===========+==============+ + | Curve |ECDH |ECDH |EdDSA |EdDSA |EdDSA | + | |Point |Secret |Secret |Signature |Signature | + | |Format |Key MPI |Key MPI |first MPI |second MPI | + +============+========+========+=========+===========+==============+ + | NIST P-256 |SEC1 |integer |N/A |N/A |N/A | + +------------+--------+--------+---------+-----------+--------------+ + | NIST P-384 |SEC1 |integer |N/A |N/A |N/A | + +------------+--------+--------+---------+-----------+--------------+ + | NIST P-521 |SEC1 |integer |N/A |N/A |N/A | + +------------+--------+--------+---------+-----------+--------------+ + | Ed25519 |N/A |N/A |32 octets|32 octets |32 octets of S| + | | | |of secret|of R | | + +------------+--------+--------+---------+-----------+--------------+ + | Ed448 |N/A |N/A |prefixed |prefixed |0 [this is an | + | | | |57 octets|114 octets |unused | + | | | |of secret|of |placeholder] | + | | | | |signature | | + +------------+--------+--------+---------+-----------+--------------+ + | Curve25519 |prefixed|integer |N/A |N/A |N/A | + | |native | | | | | + +------------+--------+--------+---------+-----------+--------------+ + | X448 |prefixed|prefixed|N/A |N/A |N/A | + | |native |56 | | | | + | | |octets | | | | + | | |of | | | | + | | |secret | | | | + +------------+--------+--------+---------+-----------+--------------+ + + Table 17: Curve-specific wire formats + + For the native octet-string forms of EdDSA values, see [RFC8032]. + For the native octet-string forms of ECDH secret scalars and points, + see [RFC7748]. + 9.3. Symmetric-Key Algorithms - +========+=======================================+ + +==========+====================================================+ | ID | Algorithm | - +========+=======================================+ + +==========+====================================================+ | 0 | Plaintext or unencrypted data | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 1 | IDEA [IDEA] | - +--------+---------------------------------------+ - | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] | - | | - 168 bit key derived from 192) | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ + | 2 | TripleDES (DES-EDE, [SCHNEIER], [HAC] - 168 bit | + | | key derived from 192) | + +----------+----------------------------------------------------+ | 3 | CAST5 (128 bit key, as per [RFC2144]) | - +--------+---------------------------------------+ - | 4 | Blowfish (128 bit key, 16 rounds) | - | | [BLOWFISH] | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ + | 4 | Blowfish (128 bit key, 16 rounds) [BLOWFISH] | + +----------+----------------------------------------------------+ | 5 | Reserved | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 6 | Reserved | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 7 | AES with 128-bit key [AES] | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 8 | AES with 192-bit key | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 9 | AES with 256-bit key | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 10 | Twofish with 256-bit key [TWOFISH] | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 11 | Camellia with 128-bit key [RFC3713] | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 12 | Camellia with 192-bit key | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 13 | Camellia with 256-bit key | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ | 100 to | Private/Experimental algorithm | | 110 | | - +--------+---------------------------------------+ + +----------+----------------------------------------------------+ + | 253, 254 | Reserved to avoid collision with Secret Key | + | and 255 | Encryption (see Section 3.7.2.1 and Section 5.5.3) | + +----------+----------------------------------------------------+ - Table 17: Symmetric-key algorithm registry + Table 18: Symmetric-key algorithm registry Implementations MUST implement TripleDES. Implementations SHOULD implement AES-128 and CAST5. Implementations that interoperate with PGP 2.6 or earlier need to support IDEA, as that is the only symmetric cipher those versions use. Implementations MAY implement any other algorithm. 9.4. Compression Algorithms +============+================================+ @@ -3458,21 +3877,21 @@ +------------+--------------------------------+ | 1 | ZIP [RFC1951] | +------------+--------------------------------+ | 2 | ZLIB [RFC1950] | +------------+--------------------------------+ | 3 | BZip2 [BZ2] | +------------+--------------------------------+ | 100 to 110 | Private/Experimental algorithm | +------------+--------------------------------+ - Table 18: Compression algorithm registry + Table 19: Compression algorithm registry Implementations MUST implement uncompressed data. Implementations SHOULD implement ZIP. Implementations MAY implement any other algorithm. 9.5. Hash Algorithms +============+================================+=============+ | ID | Algorithm | Text Name | +============+================================+=============+ @@ -3500,42 +3919,65 @@ +------------+--------------------------------+-------------+ | 12 | SHA3-256 [FIPS202] | "SHA3-256" | +------------+--------------------------------+-------------+ | 13 | Reserved | | +------------+--------------------------------+-------------+ | 14 | SHA3-512 [FIPS202] | "SHA3-512" | +------------+--------------------------------+-------------+ | 100 to 110 | Private/Experimental algorithm | | +------------+--------------------------------+-------------+ - Table 19: Hash algorithm registry + Table 20: Hash algorithm registry Implementations MUST implement SHA-1. Implementations MAY implement other algorithms. MD5 is deprecated. +9.6. AEAD Algorithms + + +========+======================+===========+====================+ + | ID | Algorithm | IV length | authentication tag | + | | | (octets) | length (octets) | + +========+======================+===========+====================+ + | 1 | EAX [EAX] | 16 | 16 | + +--------+----------------------+-----------+--------------------+ + | 2 | OCB [RFC7253] | 15 | 16 | + +--------+----------------------+-----------+--------------------+ + | 100 to | Private/Experimental | | | + | 110 | algorithm | | | + +--------+----------------------+-----------+--------------------+ + + Table 21: AEAD algorithm registry + 10. IANA Considerations + Because this document obsoletes [RFC4880], IANA is requested to + update all registration information that references [RFC4880] to + instead reference this RFC. + OpenPGP is highly parameterized, and consequently there are a number of considerations for allocating parameters for extensions. This section describes how IANA should look at extensions to the protocol as described in this document. 10.1. New String-to-Key Specifier Types OpenPGP S2K specifiers contain a mechanism for new algorithms to turn a string into a key. This specification creates a registry of S2K specifier types. The registry includes the S2K type, the name of the S2K, and a reference to the defining specification. The initial values for this registry can be found in Section 3.7.1. Adding a new S2K specifier MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. + IANA should add a column "Generate?" to the S2K type registry, with + initial values taken from Section 3.7.1. + 10.2. New Packets Major new features of OpenPGP are defined through new packet types. This specification creates a registry of packet types. The registry includes the packet type, the name of the packet, and a reference to the defining specification. The initial values for this registry can be found in Section 4.3. Adding a new packet type MUST be done through the RFC REQUIRED method, as described in [RFC8126]. 10.2.1. User Attribute Types @@ -3550,99 +3992,98 @@ [RFC8126]. 10.2.1.1. Image Format Subpacket Types Within User Attribute packets, there is an extensible mechanism for other types of image-based User Attributes. This specification creates a registry of Image Attribute subpacket types. The registry includes the Image Attribute subpacket type, the name of the Image Attribute subpacket, and a reference to the defining specification. The initial values for this registry can be found in Section 5.13.1. - Adding a new Image Attribute subpacket type MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2. New Signature Subpackets OpenPGP signatures contain a mechanism for signed (or unsigned) data to be added to them for a variety of purposes in the Signature - subpackets as discussed in Section 5.2.3.1. This specification + subpackets as discussed in Section 5.2.3.5. This specification creates a registry of Signature subpacket types. The registry includes the Signature subpacket type, the name of the subpacket, and a reference to the defining specification. The initial values for - this registry can be found in Section 5.2.3.1. Adding a new + this registry can be found in Section 5.2.3.5. Adding a new Signature subpacket MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.1. Signature Notation Data Subpackets OpenPGP signatures further contain a mechanism for extensions in signatures. These are the Notation Data subpackets, which contain a key/value pair. Notations contain a user space that is completely unmanaged and an IETF space. This specification creates a registry of Signature Notation Data types. The registry includes the Signature Notation Data type, the name of the Signature Notation Data, its allowed values, and a reference to the defining specification. The initial values for this - registry can be found in Section 5.2.3.16. Adding a new Signature + registry can be found in Section 5.2.3.20. Adding a new Signature Notation Data subpacket MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.2. Signature Notation Data Subpacket Notation Flags This specification creates a new registry of Signature Notation Data Subpacket Notation Flags. The registry includes the columns "Flag", "Description", "Security Recommended", "Interoperability Recommended", and "Reference". The initial values for this registry - can be found in Section 5.2.3.16. Adding a new item MUST be done + can be found in Section 5.2.3.20. Adding a new item MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.3. Key Server Preference Extensions OpenPGP signatures contain a mechanism for preferences to be specified about key servers. This specification creates a registry of key server preferences. The registry includes the key server preference, the name of the preference, and a reference to the defining specification. The initial values for this registry can be - found in Section 5.2.3.17. Adding a new key server preference MUST + found in Section 5.2.3.21. Adding a new key server preference MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.4. Key Flags Extensions OpenPGP signatures contain a mechanism for flags to be specified about key usage. This specification creates a registry of key usage flags. The registry includes the key flags value, the name of the flag, and a reference to the defining specification. The initial - values for this registry can be found in Section 5.2.3.21. Adding a + values for this registry can be found in Section 5.2.3.25. Adding a new key usage flag MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.5. Reason for Revocation Extensions OpenPGP signatures contain a mechanism for flags to be specified about why a key was revoked. This specification creates a registry of "Reason for Revocation" flags. The registry includes the "Reason for Revocation" flags value, the name of the flag, and a reference to the defining specification. The initial values for this registry can - be found in Section 5.2.3.23. Adding a new feature flag MUST be done + be found in Section 5.2.3.27. Adding a new feature flag MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. 10.2.2.6. Implementation Features OpenPGP signatures contain a mechanism for flags to be specified stating which optional features an implementation supports. This specification creates a registry of feature-implementation flags. The registry includes the feature-implementation flags value, the name of the flag, and a reference to the defining specification. The - initial values for this registry can be found in Section 5.2.3.24. + initial values for this registry can be found in Section 5.2.3.28. Adding a new feature-implementation flag MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. Also see Section 14.13 for more information about when feature flags are needed. 10.2.3. New Packet Versions The core OpenPGP packets all have version numbers, and can be revised by introducing a new version of an existing packet. This @@ -3677,21 +4118,21 @@ This document requests IANA register the following new public-key algorithm: +====+============================+========================+ | ID | Algorithm | Reference | +====+============================+========================+ | 22 | EdDSA public key algorithm | This doc, Section 14.8 | +----+----------------------------+------------------------+ - Table 20: New public-Key algorithms registered + Table 22: New public-Key algorithms registered [ Note to RFC-Editor: Please remove the table above on publication. ] 10.3.2. Symmetric-Key Algorithms OpenPGP specifies a number of symmetric-key algorithms. This specification creates a registry of symmetric-key algorithm identifiers. The registry includes the algorithm name, its key sizes and block size, and a reference to the defining specification. The initial values for this registry can be found in Section 9.3. Adding @@ -3715,39 +4156,89 @@ +====+===========+===========+ | ID | Algorithm | Reference | +====+===========+===========+ | 12 | SHA3-256 | This doc | +----+-----------+-----------+ | 13 | Reserved | | +----+-----------+-----------+ | 14 | SHA3-512 | This doc | +----+-----------+-----------+ - Table 21: New hash + Table 23: New hash algorithms registered [Notes to RFC-Editor: Please remove the table above on publication. It is desirable not to reuse old or reserved algorithms because some existing tools might print a wrong description. The ID 13 has been reserved so that the SHA3 algorithm IDs align nicely with their SHA2 counterparts.] 10.3.4. Compression Algorithms OpenPGP specifies a number of compression algorithms. This specification creates a registry of compression algorithm identifiers. The registry includes the algorithm name and a reference to the defining specification. The initial values for this registry can be found in Section 9.4. Adding a new compression key algorithm MUST be done through the SPECIFICATION REQUIRED method, as described in [RFC8126]. +10.3.5. Elliptic Curve Algorithms + + This document requests IANA add a registry of elliptic curves for use + in OpenPGP. + + Each curve is identified on the wire by OID, and is acceptable for + use in certain OpenPGP public key algorithms. The table's initial + headings and values can be found in Section 9.2. Adding a new + elliptic curve algorithm to OpenPGP MUST be done through the + SPECIFICATION REQUIRED method, as described in [RFC8126]. If the new + curve can be used for ECDH or EdDSA, it must also be added to the + "Curve-specific wire formats" table described in Section 9.2.1. + +10.4. Elliptic Curve Point and Scalar Wire Formats + + This document requests IANA add a registry of wire formats that + represent elliptic curve points. The table's initial headings and + values can be found in Section 13.2. Adding a new EC point wire + format MUST be done through the SPECIFICATION REQUIRED method, as + described in [RFC8126]. + + This document also requests IANA add a registry of wire formats that + represent scalars for use with elliptic curve cryptography. The + table's initial headings and values can be found in Section 13.3. + Adding a new EC scalar wire format MUST be done through the + SPECIFICATION REQUIRED method, as described in [RFC8126]. + + This document also requests that IANA add a registry mapping curve- + specific MPI octet-string encoding conventions for ECDH and EdDSA. + The table's initial headings and values can be found in + Section 9.2.1. Adding a new elliptic curve algorithm to OpenPGP MUST + be done through the SPECIFICATION REQUIRED method, as described in + [RFC8126], and requires adding an entry to this table if the curve is + to be used with either EdDSA or ECDH. + +10.5. Changes to existing registries + + This document requests IANA add the following wire format columns to + the OpenPGP public-key algorithm registry: + + * Public Key Format + + * Secret Key Format + + * Signature Format + + * PKESK Format + + And populate them with the values found in Section 9.1. + 11. Packet Composition OpenPGP packets are assembled into sequences in order to create messages and to transfer keys. Not all possible packet sequences are meaningful and correct. This section describes the rules for how packets should be placed into sequences. 11.1. Transferable Public Keys OpenPGP users may transfer public keys. The essential elements of a @@ -3843,34 +4334,42 @@ Compressed Message :- Compressed Data Packet. Literal Message :- Literal Data Packet. ESK :- Public-Key Encrypted Session Key Packet | Symmetric-Key Encrypted Session Key Packet. ESK Sequence :- ESK | ESK Sequence, ESK. Encrypted Data :- Symmetrically Encrypted Data Packet | - Symmetrically Encrypted Integrity Protected Data Packet + Symmetrically Encrypted Integrity Protected Data Packet | AEAD + Encrypted Data Packet Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. One-Pass Signed Message :- One-Pass Signature Packet, OpenPGP Message, Corresponding Signature Packet. Signed Message :- Signature Packet, OpenPGP Message | One-Pass Signed Message. - In addition, decrypting a Symmetrically Encrypted Data packet or a - Symmetrically Encrypted Integrity Protected Data packet as well as - decompressing a Compressed Data packet must yield a valid OpenPGP - Message. + In addition, decrypting a Symmetrically Encrypted and Integrity + Protected Data packet, an AEAD Encrypted Data packet, or -- for + historic data -- a Symmetrically Encrypted Data packet must yield a + valid OpenPGP Message. Decompressing a Compressed Data packet must + also yield a valid OpenPGP Message. + + Note that some subtle combinations that are formally acceptable by + this grammar are nonetheless unacceptable. For example, a v5 SKESK + packet cannot effectively precede a SEIPD packet, since that + combination does not include any information about the choice of + symmetric cipher used for SEIPD (see Section 5.3.1 for more details). 11.4. Detached Signatures Some OpenPGP applications use so-called "detached signatures". For example, a program bundle may contain a file, and with it a second file that is a detached signature of the first file. These detached signatures are simply a Signature packet stored separately from the data for which they are a signature. 12. Enhanced Key Formats @@ -3892,31 +4392,28 @@ The format of an OpenPGP V4 key that uses multiple public keys is similar except that the other keys are added to the end as "subkeys" of the primary key. Primary-Key [Revocation Self Signature] [Direct Key Signature...] User ID [Signature ...] [User ID [Signature ...] ...] [User Attribute [Signature ...] ...] - [[Subkey [Binding-Signature-Revocation] - Primary-Key-Binding-Signature] ...] - - A subkey always has a single signature after it that is issued using - the primary key to tie the two keys together. This binding signature - may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can - issue signatures MUST have a V4 binding signature due to the REQUIRED - embedded primary key binding signature. + [[Subkey [Binding-Signature-Revocation ...] + Subkey-Binding-Signature ...] ...] - In the above diagram, if the binding signature of a subkey has been - revoked, the revoked key may be removed, leaving only one key. + A subkey always has at least one subkey binding signature after it + that is issued using the primary key to tie the two keys together. + These binding signatures may be in either V3 or V4 format, but SHOULD + be V4. Subkeys that can issue signatures MUST have a V4 binding + signature due to the REQUIRED embedded primary key binding signature. In a V4 key, the primary key MUST be a key capable of certification. The subkeys may be keys of any other type. There may be other constructions of V4 keys, too. For example, there may be a single- key RSA key in V4 format, a DSA primary key with an RSA encryption key, or RSA primary key with an Elgamal subkey, etc. It is also possible to have a signature-only subkey. This permits a primary key that collects certifications (key signatures), but is used only for certifying subkeys that are used for encryption and @@ -3933,21 +4430,21 @@ and MD5 are deprecated. A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, followed by the two-octet packet length, followed by the entire Public-Key packet starting with the version field. The Key ID is the low-order 64 bits of the fingerprint. Here are the fields of the hash material, with the example of a DSA key: a.1) 0x99 (1 octet) - a.2) two-octet scalar octet count of (b)-(e) + a.2) two-octet, big-endian scalar octet count of (b)-(e) b) version number = 4 (1 octet); c) timestamp of key creation (4 octets); d) algorithm (1 octet): 17 = DSA (example); e) Algorithm-specific fields. Algorithm-Specific Fields for DSA keys (example): @@ -3998,92 +4496,188 @@ material, they will have different Key IDs as well as different fingerprints. Finally, the Key ID and fingerprint of a subkey are calculated in the same way as for a primary key, including the 0x99 (V3 and V4 key) or 0x9A (V5 key) as the first octet (even though this is not a valid packet ID for a public subkey). 13. Elliptic Curve Cryptography - This section descripes algorithms and parameters used with Elliptic + This section describes algorithms and parameters used with Elliptic Curve Cryptography (ECC) keys. A thorough introduction to ECC can be found in [KOBLITZ]. 13.1. Supported ECC Curves - This document references three named prime field curves, defined in - [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521". - Further curve "Curve25519", defined in [RFC7748] is referenced for - use with Ed25519 (EdDSA signing) and X25519 (encryption). + This document references three named prime field curves defined in + [FIPS186] as "Curve P-256", "Curve P-384", and "Curve P-521". These + three [FIPS186] curves can be used with ECDSA and ECDH public key + algorithms. Additionally, curve "Curve25519" and "Curve448" are + referenced for use with Ed25519 and Ed448 (EdDSA signing, see + [RFC8032]); and X25519 and X448 (ECDH encryption, see [RFC7748]). - The named curves are referenced as a sequence of bytes in this + The named curves are referenced as a sequence of octets in this document, called throughout, curve OID. Section 9.2 describes in - detail how this sequence of bytes is formed. + detail how this sequence of octets is formed. -13.2. ECDSA and ECDH Conversion Primitives +13.2. EC Point Wire Formats - This document defines the uncompressed point format for ECDSA and - ECDH and a custom compression format for certain curves. The point - is encoded in the Multiprecision Integer (MPI) format. + A point on an elliptic curve will always be represented on the wire + as an MPI. Each curve uses a specific point format for the data + within the MPI itself. Each format uses a designated prefix octet to + ensure that the high octet has at least one bit set to make the MPI a + constant size. - For an uncompressed point the content of the MPI is: + +=================+================+================+ + | Name | Wire Format | Reference | + +=================+================+================+ + | SEC1 | 0x04 || x || y | Section 13.2.1 | + +-----------------+----------------+----------------+ + | Prefixed native | 0x40 || native | Section 13.2.2 | + +-----------------+----------------+----------------+ + + Table 24: Elliptic Curve Point Wire Formats + +13.2.1. SEC1 EC Point Wire Format + + For a SEC1-encoded (uncompressed) point the content of the MPI is: B = 04 || x || y - where x and y are coordinates of the point P = (x, y), each encoded - in the big-endian format and zero-padded to the adjusted underlying - field size. The adjusted underlying field size is the underlying - field size that is rounded up to the nearest 8-bit boundary. This - encoding is compatible with the definition given in [SEC1]. + where x and y are coordinates of the point P = (x, y), and each is + encoded in the big-endian format and zero-padded to the adjusted + underlying field size. The adjusted underlying field size is the + underlying field size rounded up to the nearest 8-bit boundary, as + noted in the "fsize" column in Section 9.2. This encoding is + compatible with the definition given in [SEC1]. + +13.2.2. Prefixed Native EC Point Wire Format For a custom compressed point the content of the MPI is: - B = 40 || x + B = 40 || p - where x is the x coordinate of the point P encoded to the rules + where p is the public key of the point encoded using the rules defined for the specified curve. This format is used for ECDH keys - based on curves expressed in Montgomery form. + based on curves expressed in Montgomery form, and for points when + using EdDSA. - Therefore, the exact size of the MPI payload is 515 bits for "Curve - P-256", 771 for "Curve P-384", 1059 for "Curve P-521", and 263 for - Curve25519. +13.2.3. Notes on EC Point Wire Formats + + Given the above definitions, the exact size of the MPI payload for an + encoded point is 515 bits for "Curve P-256", 771 for "Curve P-384", + 1059 for "Curve P-521", 263 for both "Curve25519" and "Ed25519", 463 + for "Ed448", and 455 for "X448". For example, the length of a EdDSA + public key for the curve Ed25519 is 263 bits: 7 bits to represent the + 0x40 prefix octet and 32 octets for the native value of the public + key. Even though the zero point, also called the point at infinity, may occur as a result of arithmetic operations on points of an elliptic curve, it SHALL NOT appear in data structures defined in this document. - If other conversion methods are defined in the future, a compliant - application MUST NOT use a new format when in doubt that any - recipient can support it. Consider, for example, that while both the - public key and the per-recipient ECDH data structure, respectively - defined in Section 5.6.6 and Section 5.1, contain an encoded point - field, the format changes to the field in Section 5.1 only affect a - given recipient of a given message. + Each particular curve uses a designated wire format for the point + found in its public key or ECDH data structure. An implementation + MUST NOT use a different wire format for a point than the wire format + associated with the curve. -13.3. EdDSA Point Format +13.3. EC Scalar Wire Formats - The EdDSA algorithm defines a specific point compression format. To - indicate the use of this compression format and to make sure that the - key can be represented in the Multiprecision Integer (MPI) format the - octet string specifying the point is prefixed with the octet 0x40. - This encoding is an extension of the encoding given in [SEC1] which - uses 0x04 to indicate an uncompressed point. + Some non-curve values in elliptic curve cryptography (e.g. secret + keys and signature components) are not points on a curve, but are + also encoded on the wire in OpenPGP as an MPI. - For example, the length of a public key for the curve Ed25519 is 263 - bit: 7 bit to represent the 0x40 prefix octet and 32 octets for the - native value of the public key. + Because of different patterns of deployment, some curves treat these + values as opaque bit strings with the high bit set, while others are + treated as actual integers, encoded in the standard OpenPGP big- + endian form. The choice of encoding is specific to the public key + algorithm in use. + + +==========+=====================================+===========+ + | Type | Description | Reference | + +==========+=====================================+===========+ + | integer | An integer, big-endian encoded as a | Section | + | | standard OpenPGP MPI | 3.2 | + +----------+-------------------------------------+-----------+ + | octet | An octet string of fixed length, | Section | + | string | that may be shorter on the wire due | 13.3.1 | + | | to leading zeros being stripped by | | + | | the MPI encoding, and may need to | | + | | be zero-padded before usage | | + +----------+-------------------------------------+-----------+ + | prefixed | An octet string of fixed length N, | Section | + | N octets | prefixed with octet 0x40 to ensure | 13.3.2 | + | | no leading zero octet | | + +----------+-------------------------------------+-----------+ + + Table 25: Elliptic Curve Scalar Encodings + +13.3.1. EC Octet String Wire Format + + Some opaque strings of octets are represented on the wire as an MPI + by simply stripping the leading zeros and counting the remaining + bits. These strings are of known, fixed length. They are + represented in this document as "MPI(N octets of X)" where "N" is the + expected length in octets of the octet string. + + For example, a five-octet opaque string ("MPI(5 octets of X)") where + "X" has the value "00 02 ee 19 00" would be represented on the wire + as an MPI like so: "00 1a 02 ee 19 00". + + To encode "X" to the wire format, we set the MPI's two-octet bit + counter to the value of the highest set bit (bit 26, or 0x001a), and + do not transfer the leading all-zero octet to the wire. + + To reverse the process, an implementation that knows this value has + an expected length of 5 octets can take the following steps: + + * ensure that the MPI's two-octet bitcount is less than or equal to + 40 (5 octets of 8 bits) + + * allocate 5 octets, setting all to zero initially + + * copy the MPI data octets (without the two count octets) into the + lower octets of the allocated space + +13.3.2. Elliptic Curve Prefixed Octet String Wire Format + + Another way to ensure that a fixed-length bytestring is encoded + simply to the wire while remaining in MPI format is to prefix the + bytestring with a dedicated non-zero octet. This specification uses + 0x40 as the prefix octet. This is represented in this standard as + "MPI(prefixed N octets of X)", where "N" is the known bytestring + length. + + For example, a five-octet opaque string using "MPI(prefixed 5 octets + of X)" where "X" has the value "00 02 ee 19 00" would be written to + the wire form as: "00 2f 40 00 02 ee 19 00". + + To encode the string, we prefix it with the octet 0x40 (whose 7th bit + is set), then set the MPI's two-octet bit counter to 47 (0x002f, 7 + bits for the prefix octet and 40 bits for the string). + + To decode the string from the wire, an implementation that knows that + the variable is formed in this way can: + + * ensure that the first three octets of the MPI (the two bit-count + octets plus the prefix octet) are "00 2f 40", and + + * use the remainder of the MPI directly off the wire. + + Note that this is a similar approach to that used in the EC point + encodings found in Section 13.2.2. 13.4. Key Derivation Function - A key derivation function (KDF) is necessary to implement the EC + A key derivation function (KDF) is necessary to implement EC encryption. The Concatenation Key Derivation Function (Approved Alternative 1) [SP800-56A] with the KDF hash function that is SHA2-256 [FIPS180] or stronger is REQUIRED. For convenience, the synopsis of the encoding method is given below with significant simplifications attributable to the restricted choice of hash functions in this document. However, [SP800-56A] is the normative source of the definition. // Implements KDF( X, oBits, Param ); @@ -4093,150 +4687,152 @@ // Param - octets representing the parameters // Assumes that oBits <= hBits // Convert the point X to the octet string: // ZB' = 04 || x || y // and extract the x portion from ZB' ZB = x; MB = Hash ( 00 || 00 || 00 || 01 || ZB || Param ); return oBits leftmost bits of MB. Note that ZB in the KDF description above is the compact - representation of X, defined in Section 4.2 of [RFC6090]. + representation of X as defined in Section 4.2 of [RFC6090]. 13.5. EC DH Algorithm (ECDH) The method is a combination of an ECC Diffie-Hellman method to establish a shared secret, a key derivation method to process the shared secret into a derived key, and a key wrapping method that uses the derived key to protect a session key used to encrypt a message. The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST be implemented with the following restrictions: the ECC CDH primitive - employed by this method is modified to always assume the cofactor as + employed by this method is modified to always assume the cofactor is 1, the KDF specified in Section 13.4 is used, and the KDF parameters specified below are used. The KDF parameters are encoded as a concatenation of the following 5 - variable-length and fixed-length fields, compatible with the - definition of the OtherInfo bitstring [SP800-56A]: + variable-length and fixed-length fields, which are compatible with + the definition of the OtherInfo bitstring [SP800-56A]: - * a variable-length field containing a curve OID, formatted as - follows: + * A variable-length field containing a curve OID, which is formatted + as follows: - - a one-octet size of the following field + - A one-octet size of the following field, - - the octets representing a curve OID, defined in Section 9.2 + - The octets representing a curve OID defined in Section 9.2; - * a one-octet public key algorithm ID defined in Section 9.1 + * A one-octet public key algorithm ID defined in Section 9.1; - * a variable-length field containing KDF parameters, identical to - the corresponding field in the ECDH public key, formatted as - follows: + * A variable-length field containing KDF parameters, which are + identical to the corresponding field in the ECDH public key, and + are formatted as follows: - - a one-octet size of the following fields; values 0 and 0xff are - reserved for future extensions + - A one-octet size of the following fields; values 0 and 0xFF are + reserved for future extensions, - - a one-octet value 01, reserved for future extensions + - A one-octet value 0x01, reserved for future extensions, - - a one-octet hash function ID used with the KDF + - A one-octet hash function ID used with the KDF, - - a one-octet algorithm ID for the symmetric algorithm used to + - A one-octet algorithm ID for the symmetric algorithm used to wrap the symmetric key for message encryption; see Section 13.5 - for details + for details; * 20 octets representing the UTF-8 encoding of the string "Anonymous Sender ", which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 - 73 20 53 65 6E 64 65 72 20 20 20 20 + 73 20 53 65 6E 64 65 72 20 20 20 20; - * 20 octets representing a recipient encryption subkey or a master - key fingerprint, identifying the key material that is needed for - the decryption. For version 5 keys the 20 leftmost octets of the - fingerprint are used. + * 20 octets representing a recipient encryption subkey or a primary + key fingerprint identifying the key material that is needed for + decryption (for version 5 keys the 20 leftmost octets of the + fingerprint are used). The size of the KDF parameters sequence, defined above, is either 54 - for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 - for Curve25519. + for the NIST curve P-256, 51 for the curves P-384 and P-521, 56 for + Curve25519, or 49 for X448. - The key wrapping method is described in [RFC3394]. KDF produces a - symmetric key that is used as a key-encryption key (KEK) as specified - in [RFC3394]. Refer to Section 15 for the details regarding the - choice of the KEK algorithm, which SHOULD be one of three AES - algorithms. Key wrapping and unwrapping is performed with the - default initial value of [RFC3394]. + The key wrapping method is described in [RFC3394]. The KDF produces + a symmetric key that is used as a key-encryption key (KEK) as + specified in [RFC3394]. Refer to Section 15 for the details + regarding the choice of the KEK algorithm, which SHOULD be one of + three AES algorithms. Key wrapping and unwrapping is performed with + the default initial value of [RFC3394]. The input to the key wrapping method is the value "m" derived from the session key, as described in Section 5.1, "Public-Key Encrypted Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step is omitted. The result is padded using the method described in - [PKCS5] to the 8-byte granularity. For example, the following + [PKCS5] to an 8-octet granularity. For example, the following AES-256 session key, in which 32 octets are denoted from k0 to k31, is composed to form the following 40 octet sequence: 09 k0 k1 ... k31 s0 s1 05 05 05 05 05 The octets s0 and s1 above denote the checksum. This encoding allows the sender to obfuscate the size of the symmetric encryption key used to encrypt the data. For example, assuming that an AES algorithm is - used for the session key, the sender MAY use 21, 13, and 5 bytes of + used for the session key, the sender MAY use 21, 13, and 5 octets of padding for AES-128, AES-192, and AES-256, respectively, to provide the same number of octets, 40 total, as an input to the key wrapping method. The output of the method consists of two fields. The first field is the MPI containing the ephemeral key used to establish the shared - secret. The second field is composed of the following two fields: + secret. The second field is composed of the following two subfields: - * a one-octet encoding the size in octets of the result of the key + * One octet encoding the size in octets of the result of the key wrapping method; the value 255 is reserved for future extensions; - * up to 254 octets representing the result of the key wrapping - method, applied to the 8-byte padded session key, as described + * Up to 254 octets representing the result of the key wrapping + method, applied to the 8-octet padded session key, as described above. Note that for session key sizes 128, 192, and 256 bits, the size of the result of the key wrapping method is, respectively, 32, 40, and - 48 octets, unless the size obfuscation is used. + 48 octets, unless size obfuscation is used. For convenience, the synopsis of the encoding method is given below; however, this section, [SP800-56A], and [RFC3394] are the normative sources of the definition. * Obtain the authenticated recipient public key R * Generate an ephemeral key pair {v, V=vG} + * Compute the shared point S = vR; * m = symm_alg_ID || session key || checksum || pkcs5_padding; - * curve_OID_len = (byte)len(curve_OID); + * curve_OID_len = (octet)len(curve_OID); * Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous Sender " || recipient_fingerprint; * Z_len = the key size for the KEK_alg_ID used with AESKeyWrap * Compute Z = KDF( S, Z_len, Param ); * Compute C = AESKeyWrap( Z, m ) as per [RFC3394] * VB = convert point V to the octet string * Output (MPI(VB) || len(C) || C). The decryption is the inverse of the method given. Note that the recipient obtains the shared secret by calculating S = rV = rvG, where (r,R) is the recipient's key pair. - Consistent with Section 5.14, Modification Detection Code (MDC) MUST - be used anytime the symmetric key is protected by ECDH. + Consistent with Section 5.16 and Section 5.14, AEAD encryption or a + Modification Detection Code (MDC) MUST be used anytime the symmetric + key is protected by ECDH. 14. Notes on Algorithms 14.1. PKCS#1 Encoding in OpenPGP This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and EMSA-PKCS1-v1_5. However, the calling conventions of these functions has changed in the past. To avoid potential confusion and interoperability problems, we are including local copies in this document, adapted from those in PKCS#1 v2.1 [RFC3447]. [RFC3447] @@ -4491,20 +5087,29 @@ 14.8. EdDSA Although the EdDSA algorithm allows arbitrary data as input, its use with OpenPGP requires that a digest of the message is used as input (pre-hashed). See section Section 5.2.4, "Computing Signatures" for details. Truncation of the resulting digest is never applied; the resulting digest value is used verbatim as input to the EdDSA algorithm. + For clarity: while [RFC8032] describes different variants of EdDSA, + OpenPGP uses the "pure" variant (PureEdDSA). The hashing that + happens with OpenPGP is done as part of the standard OpenPGP + signature process, and that hash itself is fed as the input message + to the PureEdDSA algorithm. + + As specified in [RFC8032], Ed448 also expects a "context string". In + OpenPGP, Ed448 is used with the empty string as a context string. + 14.9. Reserved Algorithm Numbers A number of algorithm IDs have been reserved for algorithms that would be useful to use in an OpenPGP implementation, yet there are issues that prevent an implementer from actually implementing the algorithm. These are marked in Section 9.1 as "reserved for". The reserved public-key algorithm X9.42 (21) does not have the necessary parameters, parameter order, or semantics defined. The same is currently true for reserved public-key algorithms AEDH (23) @@ -4704,21 +5309,21 @@ +---------------------+-----------+--------------------+ | 2048 | 224 | 112 | +---------------------+-----------+--------------------+ | 3072 | 256 | 128 | +---------------------+-----------+--------------------+ | 7680 | 384 | 192 | +---------------------+-----------+--------------------+ | 15360 | 512 | 256 | +---------------------+-----------+--------------------+ - Table 22: Key length equivalences + Table 26: Key length equivalences * There is a somewhat-related potential security problem in signatures. If an attacker can find a message that hashes to the same hash with a different algorithm, a bogus signature structure can be constructed that evaluates correctly. For example, suppose Alice DSA signs message M using hash algorithm H. Suppose that Mallet finds a message M' that has the same hash value as M with H'. Mallet can then construct a signature block that verifies as Alice's signature of M' with H'. @@ -4836,21 +5441,21 @@ | Curve name | ECC | RSA | Hash size strength, | Symmetric | | | | strength | informative | key size | +============+=====+==============+=====================+===========+ | NIST P-256 | 256 | 3072 | 256 | 128 | +------------+-----+--------------+---------------------+-----------+ | NIST P-384 | 384 | 7680 | 384 | 192 | +------------+-----+--------------+---------------------+-----------+ | NIST P-521 | 521 | 15360 | 512 | 256 | +------------+-----+--------------+---------------------+-----------+ - Table 23: Elliptic Curve cryptographic guidance + Table 27: Elliptic Curve cryptographic guidance * Requirement levels indicated elsewhere in this document lead to the following combinations of algorithms in the OpenPGP profile: MUST implement NIST curve P-256 / SHA2-256 / AES-128, SHOULD implement NIST curve P-521 / SHA2-512 / AES-256, MAY implement NIST curve P-384 / SHA2-384 / AES-256, among other allowed combinations. Consistent with the table above, the following table defines the KDF hash algorithm and the AES KEK encryption algorithm that @@ -4861,78 +5466,78 @@ | Curve name | Recommended KDF | Recommended KEK | | | hash algorithm | encryption algorithm | +============+=================+======================+ | NIST P-256 | SHA2-256 | AES-128 | +------------+-----------------+----------------------+ | NIST P-384 | SHA2-384 | AES-192 | +------------+-----------------+----------------------+ | NIST P-521 | SHA2-512 | AES-256 | +------------+-----------------+----------------------+ - Table 24: Elliptic Curve KDF and KEK recommendations + Table 28: Elliptic Curve KDF and KEK recommendations * This document explicitly discourages the use of algorithms other than AES as a KEK algorithm because backward compatibility of the ECDH format is not a concern. The KEK algorithm is only used within the scope of a Public-Key Encrypted Session Key Packet, which represents an ECDH key recipient of a message. Compare this with the algorithm used for the session key of the message, which MAY be different from a KEK algorithm. Compliant applications SHOULD implement, advertise through key preferences, and use the strongest algorithms specified in this document. Note that the symmetric algorithm preference list may make it impossible to use the balanced strength of symmetric key algorithms for a corresponding public key. For example, the presence of the symmetric key algorithm IDs and their order in the key preference list affects the algorithm choices available to the encoding side, which in turn may make the adherence to the table above infeasible. Therefore, compliance with this specification - is a concern throughout the life of the key, starting immediately + is a concern throughout the life of the key starting immediately after the key generation when the key preferences are first added to a key. It is generally advisable to position a symmetric algorithm ID of strength matching the public key at the head of the key preference list. Encryption to multiple recipients often results in an unordered intersection subset. For example, if the first recipient's set is {A, B} and the second's is {B, A}, the intersection is an unordered set of two algorithms, A and B. In this case, a compliant application SHOULD choose the stronger encryption algorithm. - Resource constraints, such as limited computational power, is a - likely reason why an application might prefer to use the weakest + Resource constraints, such as limited computational power, are a + reason why an application might prefer to use the weakest algorithm. On the other side of the spectrum are applications that can implement every algorithm defined in this document. Most - applications are expected to fall into either of two categories. - A compliant application in the second, or strongest, category - SHOULD prefer AES-256 to AES-192. + applications are expected to fall into either of these two + categories. A compliant application in the second, or strongest, + category SHOULD prefer AES-256 to AES-192. SHA-1 MUST NOT be used with the ECDSA or the KDF in the ECDH method. MDC MUST be used when a symmetric encryption key is protected by ECDH. None of the ECC methods described in this document are allowed with deprecated V3 keys. Side channel attacks are a concern when a compliant application's use of the OpenPGP format can be modeled by a decryption or - signing oracle model, for example, when an application is a - network service performing decryption to unauthenticated remote - users. ECC scalar multiplication operations used in ECDSA and - ECDH are vulnerable to side channel attacks. Countermeasures can - often be taken at the higher protocol level, such as limiting the - number of allowed failures or time-blinding of the operations - associated with each network interface. Mitigations at the scalar + signing oracle, for example, when an application is a network + service performing decryption to unauthenticated remote users. + ECC scalar multiplication operations used in ECDSA and ECDH are + vulnerable to side channel attacks. Countermeasures can often be + taken at the higher protocol level, such as limiting the number of + allowed failures or time-blinding of the operations associated + with each network interface. Mitigations at the scalar multiplication level seek to eliminate any measurable distinction between the ECC point addition and doubling operations. 16. Implementation Nits This section is a collection of comments to help an implementer, particularly with an eye to backward compatibility. Previous implementations of PGP are not OpenPGP compliant. Often the differences are small, but small differences are frequently more vexing than large differences. Thus, this is a non-comprehensive @@ -5010,20 +5615,23 @@ [BLOWFISH] Schneier, B., "Description of a New Variable-Length Key, 64-Bit Block Cipher (Blowfish)", Fast Software Encryption, Cambridge Security Workshop Proceedings Springer-Verlag, 1994, pp191-204, December 1993, . [BZ2] Seward, J., "The Bzip2 and libbzip2 home page", 2010, . + [EAX] Bellare, M., Rogaway, P., and D. Wagner, "A Conventional + Authenticated-Encryption Mode", April 2003. + [ELGAMAL] Elgamal, T., "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms", IEEE Transactions on Information Theory v. IT-31, n. 4, 1985, pp. 469-472, 1985. [FIPS180] National Institute of Standards and Technology, U.S. Department of Commerce, "Secure Hash Standard (SHS), FIPS 180-4", August 2015, . @@ -5104,34 +5712,44 @@ [RFC3713] Matsui, M., Nakajima, J., and S. Moriai, "A Description of the Camellia Encryption Algorithm", RFC 3713, DOI 10.17487/RFC3713, April 2004, . [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086, DOI 10.17487/RFC4086, June 2005, . + [RFC7253] Krovetz, T. and P. Rogaway, "The OCB Authenticated- + Encryption Algorithm", RFC 7253, DOI 10.17487/RFC7253, May + 2014, . + [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves for Security", RFC 7748, DOI 10.17487/RFC7748, January 2016, . [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital Signature Algorithm (EdDSA)", RFC 8032, DOI 10.17487/RFC8032, January 2017, . [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, June 2017, . + [RFC9106] Biryukov, A., Dinu, D., Khovratovich, D., and S. + Josefsson, "Argon2 Memory-Hard Function for Password + Hashing and Proof-of-Work Applications", RFC 9106, + DOI 10.17487/RFC9106, September 2021, + . + [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: protocols, algorithms, and source code in C", 1996. [SP800-56A] Barker, E., Johnson, D., and M. Smid, "Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography", NIST Special Publication 800-56A Revision 1, March 2007. [TWOFISH] Schneier, B., Kelsey, J., Whiting, D., Wagner, D., Hall, @@ -5238,21 +5855,319 @@ The entire signature packet is thus: 88 5e 04 00 16 08 00 06 05 02 55 f9 5f 95 00 0a 09 10 8c fd e1 21 97 96 5a 9a f6 22 01 00 56 f9 0c ca 98 e2 10 26 37 bd 98 3f db 16 c1 31 df d2 7e d8 2b f4 dd e5 60 6e 0d 75 6a ed 33 66 01 00 d0 9c 4f a1 15 27 f0 38 e0 f5 7f 22 01 d8 2f 2e a2 c9 03 32 65 fa 6c eb 48 9e 85 4b ae 61 b4 04 -Appendix B. Document Workflow +A.3. Sample AEAD-EAX encryption and decryption + + Encryption is performed with the string "Hello, world!", using + AES-128 with AEAD-EAX encryption. + +A.3.1. Sample Parameters + + S2K: + + type 3 + + Iterations: + + 524288 (144), SHA2-256 + + Salt: + + cd5a9f70fbe0bc65 + +A.3.2. Sample symmetric-key encrypted session key packet (v5) + + Packet header: + + c3 3e + + Version, algorithms, S2K fields: + + 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 + + AEAD IV: + + bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 + + AEAD encrypted CEK: + + 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb + + Authentication tag: + + 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 + +A.3.3. Starting AEAD-EAX decryption of CEK + + The derived key is: + + b2 55 69 b9 54 32 45 66 45 27 c4 97 6e 7a 5d 6e + + Authenticated Data: + + c3 05 07 01 + + Nonce: + + bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 + + Decrypted CEK: + + 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d + +A.3.4. Initial Content Encryption Key + + This key would typically be extracted from an SKESK or PKESK. In + this example, it is extracted from an SKESK packet, as described + above. + + CEK: + + 86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d + +A.3.5. Sample AEAD encrypted data packet + + Packet header: + + d4 4a + + Version, AES-128, EAX, Chunk bits (14): + + 01 07 01 0e + + IV: + + b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 + + AEAD-EAX Encrypted data chunk #0: + + 5d c1 1a 81 dc 0c b8 a2 f6 f3 d9 00 16 38 4a 56 + fc 82 1a e1 1a e8 + + Chunk #0 authentication tag: + + db cb 49 86 26 55 de a8 8d 06 a8 14 86 80 1b 0f + + Final (zero-size chunk #1) authentication tag: + + f3 87 bd 2e ab 01 3d e1 25 95 86 90 6e ab 24 76 + +A.3.6. Decryption of data + + Starting AEAD-EAX decryption of data, using the CEK. + + Chunk #0: + + Authenticated data: + + d4 01 07 01 0e 00 00 00 00 00 00 00 00 + + Nonce: + + b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10 + + Decrypted chunk #0. + + Literal data packet with the string contents "Hello, world!\n". + + cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 + 6f 72 6c 64 21 0a + + Authenticating final tag: + + Authenticated data: + + d4 01 07 01 0e 00 00 00 00 00 00 00 01 00 00 00 + 00 00 00 00 16 + + Nonce: + + b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 11 + +A.3.7. Complete AEAD-EAX encrypted packet sequence + + Symmetric-key encrypted session key packet (v5): + + c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90 + bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35 + 9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb + 7e 92 8e a5 b4 fa 80 12 bd 45 6d 17 38 c6 3c 36 + + AEAD encrypted data packet: + + d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f + ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3 + d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86 + 26 55 de a8 8d 06 a8 14 86 80 1b 0f f3 87 bd 2e + ab 01 3d e1 25 95 86 90 6e ab 24 76 + +A.4. Sample AEAD-OCB encryption and decryption + + Encryption is performed with the string "Hello, world!" using AES-128 + with AEAD-OCB encryption. + +A.4.1. Sample Parameters + + S2K: + + type 3 + + Iterations: + + 524288 (144), SHA2-256 + + Salt: + + 9f0b7da3e5ea6477 + +A.4.2. Sample symmetric-key encrypted session key packet (v5) + + Packet header: + + c3 3d + + Version, algorithms, S2K fields: + + 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 + + AEAD IV: + + 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c + + AEAD encrypted CEK: + + 67 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da + + Authentication tag: + + c5 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed + +A.4.3. Starting AEAD-OCB decryption of CEK + + The derived key is: + + eb 9d a7 8a 9d 5d f8 0e c7 02 05 96 39 9b 65 08 + + Authenticated Data: + + c3 05 07 02 + + Nonce: + + 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c + + Decrypted CEK: + + d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 + +A.4.4. Initial Content Encryption Key + + This key would typically be extracted from an SKESK or PKESK. In + this example, it is extracted from an SKESK packet, as described + above. + + Decrypted CEK: + + d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44 + +A.4.5. Sample AEAD encrypted data packet + + Packet header: + + d4 49 + + Version, AES-128, OCB, Chunk bits (14): + + 01 07 02 0e + + IV: + + 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 + + AEAD-OCB Encrypted data chunk #0: + + 7b 0f 77 01 19 66 11 a1 54 ba 9c 25 74 cd 05 62 + 84 a8 ef 68 03 5c + + Chunk #0 authentication tag: + + 62 3d 93 cc 70 8a 43 21 1b b6 ea f2 b2 7f 7c 18 + + Final (zero-size chunk #1) authentication tag: + + d5 71 bc d8 3b 20 ad d3 a0 8b 73 af 15 b9 a0 98 + +A.4.6. Decryption of data + + Starting AEAD-OCB decryption of data, using the CEK. + + Chunk #0: + + Authenticated data: + + d4 01 07 02 0e 00 00 00 00 00 00 00 00 + + Nonce: + + 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56 + + Decrypted chunk #0. + + Literal data packet with the string contents "Hello, world!\n". + + cb 14 62 00 00 00 00 00 48 65 6c 6c 6f 2c 20 77 + 6f 72 6c 64 21 0a + + Authenticating final tag: + + Authenticated data: + + d4 01 07 02 0e 00 00 00 00 00 00 00 01 00 00 00 + 00 00 00 00 16 + + Nonce: + + 5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 57 + +A.4.7. Complete AEAD-OCB encrypted packet sequence + + Symmetric-key encrypted session key packet (v5): + + c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90 + 99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67 + 73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5 + 29 d3 de 31 e1 5b 4a eb 72 9e 33 00 33 db ed + + AEAD encrypted data packet: + + d4 49 01 07 02 0e 5e d2 bc 1e 47 0a be 8f 1d 64 + 4c 7a 6c 8a 56 7b 0f 77 01 19 66 11 a1 54 ba 9c + 25 74 cd 05 62 84 a8 ef 68 03 5c 62 3d 93 cc 70 + 8a 43 21 1b b6 ea f2 b2 7f 7c 18 d5 71 bc d8 3b + 20 ad d3 a0 8b 73 af 15 b9 a0 98 + +Appendix B. Acknowledgements + + This memo also draws on much previous work from a number of other + authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc + Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, + Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, + Mark Weaver, and Philip R. Zimmermann. + +Appendix C. Document Workflow This document is built from markdown using ruby-kramdown-rfc2629 (https://rubygems.org/gems/kramdown-rfc2629), and tracked using git (https://git-scm.com/). The markdown source under development can be found in the file "crypto-refresh.md" in the "main" branch of the git repository (https://gitlab.com/openpgp-wg/rfc4880bis). Discussion of this document should take place on the openpgp@ietf.org mailing list (https://www.ietf.org/mailman/listinfo/openpgp). A non-substantive editorial nit can be submitted directly as a merge @@ -5261,47 +6176,25 @@ request, but should simultaneously be sent to the mailing list for discussion. An open problem can be recorded and tracked as an issue (https://gitlab.com/openpgp-wg/rfc4880bis/-/issues) in the gitlab issue tracker, but discussion of the issue should take place on the mailing list. [Note to RFC-Editor: Please remove this section on publication.] -Appendix C. ECC Point compression flag bytes - - This specification introduces the new flag byte 0x40 to indicate the - point compression format. The value has been chosen so that the high - bit is not cleared and thus to avoid accidental sign extension. Two - other values might also be interesting for other ECC specifications: - - Flag Description - ---- ----------- - 0x04 Standard flag for uncompressed format - 0x40 Native point format of the curve follows - 0x41 Only X coordinate follows. - 0x42 Only Y coordinate follows. - -Appendix D. Acknowledgements - - This memo also draws on much previous work from a number of other - authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc - Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, - Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, - Mark Weaver, and Philip R. Zimmermann. - Authors' Addresses Werner Koch (editor) GnuPG e.V. Rochusstr. 44 40479 Duesseldorf Germany Email: wk@gnupg.org URI: https://gnupg.org/verein Paul Wouters (editor) - No Hats + Aiven - Email: paul@nohats.ca + Email: paul.wouters@aiven.io