Internet-Draft OpenPGP Literal Data Metadata Integrity July 2025
Gallagher Expires 15 January 2026 [Page]
Workgroup:
openpgp
Internet-Draft:
draft-gallagher-openpgp-literal-metadata-latest
Updates:
9580 (if approved)
Published:
Intended Status:
Informational
Expires:
Author:
A. Gallagher, Ed.
PGPKeys.EU

OpenPGP Literal Data Metadata Integrity

Abstract

This document specifies a method for ensuring the integrity of file metadata when signed using OpenPGP.

About This Document

This note is to be removed before publishing as an RFC.

The latest revision of this draft can be found at https://andrewgdotcom.gitlab.io/draft-gallagher-openpgp-literal-metadata. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-gallagher-openpgp-literal-metadata/.

Discussion of this document takes place on the OpenPGP Working Group mailing list (mailto:openpgp@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/openpgp/. Subscribe at https://www.ietf.org/mailman/listinfo/openpgp/.

Source for this draft and an issue tracker can be found at https://gitlab.com/andrewgdotcom/draft-gallagher-openpgp-literal-metadata.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

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 15 January 2026.

Table of Contents

1. Introduction

The PGP literal data packet's metadata fields (file type, file name, and file timestamp) are not covered by any integrity-protection mechanisms and are therefore malleable by an attacker. [RFC1991] states that this was intentional, to ensure that attached and detached signatures are calculated identically and can be transformed into one another. Metadata malleability has therefore persisted through subsequent OpenPGP specifications, up to and including [RFC9580]. Although reliance on this metadata is now deprecated, legacy applications may wish to upgrade their cryptographic layer without altering their existing workflow. This document introduces the missing integrity check by adopting and extending the "Literal Data Meta Hash" subpacket from Section 5.2.3.33 of [I-D.koch-librepgp].

2. Conventions and Definitions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

3. Literal Data Meta subpacket

This subpacket MAY be used to protect the metadata of a Literal Data Packet. It is only useful when located in the hashed-subpackets area of a v4 (or later) signature of type 0x00 or 0x01, and so it SHOULD NOT appear elsewhere. The subpacket SHOULD NOT be marked as critical, unless it is known that all recipients can process it.

The metadata is always of the same form as it appears in the Literal Data Packet (Section 5.9 of [RFC9580]), i.e.:

The first octet of the subpacket contents indicates the encoding of the subpacket. A value of 0 indicates Hashed encoding, and a value of 1 indicates Verbatim encoding. The remaining octets of the subpacket are encoding-dependent.

3.1. Literal Data Meta (Hashed)

The remainder of the packet contains a 32 octet fixed-length hash value. The hash is computed over the metadata as specified above, using SHA-256 [FIPS180]. When an implementation is validating a signature containing a Literal Data Meta (Hashed) subpacket in its hashed-subpackets area, it MUST re-create the hash from the metadata section of the Literal Data packet that is signed over. If the calculated hash value does not match the one in the subpacket, the signature MUST be deemed as invalid.

The Hashed encoding cannot be used to recover metadata that has been modified or lost in transit. Hashed encoding is therefore deprecated in favour of Verbatim encoding.

3.2. Literal Data Meta (Verbatim)

The remainder of the packet contains a verbatim copy of the metadata as specified above. When an implementation has successfully validated a signature over a Literal Data packet, and the signature contains a Literal Data Meta (Verbatim) subpacket in its hashed-subpackets area, the metadata section of the Literal Data Packet that is signed over MUST be ignored, and the copy from the Literal Data Meta subpacket SHOULD be used instead.

When a Literal Data Meta (Verbatim) subpacket is present, the metadata section of the corresponding Literal Data packet MAY be empty, i.e. it MAY consist of exactly six octets of zeros (Section 5.9 of [RFC9580]). Otherwise, the Literal Data packet and the Literal Data Meta subpacket SHOULD contain the same metadata, to ensure consistency between receiving implementations.

When an implementation has successfully validated a detached signature that contains a Literal Data Meta (Verbatim) subpacket in its hashed-subpackets area, the metadata from the Literal Data Meta subpacket SHOULD be treated as informational. A mismatch between the Literal Data Metadata and any metadata associated with the data object signed over (such as filesystem metadata) SHOULD NOT be treated as a verification failure.

4. Security Considerations

A signature containing a Literal Data Meta (Verbatim) subpacket can be round-tripped via detached-signature format without loss of integrity. A signature containing a Literal Data Meta (Hashed) subpacket does not have this property, because the metadata cannot be regenerated from the hash and is therefore lost on conversion to a detached signature.

It is therefore RECOMMENDED that implementations generate Literal Data Meta subpackets using the Verbatim encoding.

5. IANA Considerations

This document requests that the following entry be added to the OpenPGP Signature Subpacket registry:

Table 1: OpenPGP Signature Subpacket Registry
Type Name Specification
40 Literal Data Meta This document

6. References

6.1. Normative References

[FIPS180]
National Institute of Standards and Technology, U.S. Department of Commerce, "Secure Hash Standard (SHS), FIPS 180-4", , <http://dx.doi.org/10.6028/NIST.FIPS.180-4>.
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.
[RFC9580]
Wouters, P., Ed., Huigens, D., Winter, J., and Y. Niibe, "OpenPGP", RFC 9580, DOI 10.17487/RFC9580, , <https://www.rfc-editor.org/rfc/rfc9580>.

6.2. Informative References

[I-D.koch-librepgp]
Koch, W. and R. H. Tse, "LibrePGP Message Format", Work in Progress, Internet-Draft, draft-koch-librepgp-03, , <https://datatracker.ietf.org/doc/html/draft-koch-librepgp-03>.
[RFC1991]
Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message Exchange Formats", RFC 1991, DOI 10.17487/RFC1991, , <https://www.rfc-editor.org/rfc/rfc1991>.

Appendix A. Acknowledgments

The author would like to thank Werner Koch for his earlier work on the Literal Data Meta Hash subpacket, and Daniel Kahn Gillmor and Falko Strenzke for subsequent discussions.

Appendix B. Document History

Note to RFC Editor: this section should be removed before publication.

B.1. Changes Between -00 and -01

  • Subpacket now SHOULD NOT be marked as critical, to enable opportunistic upgrades.

  • Subpackets in detached signatures are now explicitly informational.

  • Reworked MUST/SHOULD/MAY in several places for robustness.

  • More explicitly deprecate Hashed encoding.

  • Updated references.

  • Updated preamble to more accurately reflect history.

  • Fixed several typos.

Author's Address

Andrew Gallagher (editor)
PGPKeys.EU