<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc version  (Ruby 3.1.2) -->


<!DOCTYPE rfc  [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">

]>


<rfc ipr="trust200902" docName="draft-gallagher-openpgp-literal-metadata-00" category="info" submissionType="IETF" updates="4880" tocInclude="true" sortRefs="true" symRefs="true">
  <front>
    <title>OpenPGP Literal Data Metadata Integrity</title>

    <author fullname="Andrew Gallagher" role="editor">
      <organization>PGPKeys.EU</organization>
      <address>
        <email>andrewg@andrewg.com</email>
      </address>
    </author>

    <date year="2024" month="January" day="02"/>

    <area>int</area>
    <workgroup>openpgp</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


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



    </abstract>

    <note title="About This Document" removeInRFC="true">
      <t>
        The latest revision of this draft can be found at <eref target="https://andrewgdotcom.gitlab.io/draft-gallagher-openpgp-literal-metadata"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-gallagher-openpgp-literal-metadata/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        OpenPGP Working Group mailing list (<eref target="mailto:openpgp@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/openpgp/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/openpgp/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://gitlab.com/andrewgdotcom/draft-gallagher-openpgp-literal-metadata"/>.</t>
    </note>


  </front>

  <middle>


<section anchor="introduction"><name>Introduction</name>

<t>Due to a design oversight in an early version of PGP, the literal data metadata (file type, file name, and file timestamp) were not covered by any integrity-protection mechanisms.
That omission has persisted through subsequent OpenPGP specifications, up to and including <xref target="RFC4880"></xref>.
This document introduces the missing integrity check by adopting and extending the "Literal Data Meta Hash" subpacket from <xref target="LIBREPGP"></xref>, section 5.2.3.33.</t>

</section>
<section anchor="conventions-definitions"><name>Conventions and Definitions</name>

<t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>

</section>
<section anchor="literal-data-meta-subpacket"><name>Literal Data Meta subpacket</name>

<t>This subpacket <bcp14>MAY</bcp14> 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 over a Literal Data Packet, and so it <bcp14>SHOULD NOT</bcp14> appear elsewhere.
The packet <bcp14>SHOULD</bcp14> be marked as critical.</t>

<t>The metadata is always of the same form as it appears in the Literal Data Packet (type 11, <xref target="RFC4880"></xref> section 5.9), i.e.:</t>

<t><list style="symbols">
  <t>A one-octet field that describes how the data is formatted.</t>
  <t>File name as a string (one-octet length, followed by a file name).</t>
  <t>A four-octet number that indicates a date associated with the literal data.</t>
</list></t>

<t>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.</t>

<section anchor="literal-data-meta-hashed"><name>Literal Data Meta (Hashed)</name>

<t>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 <xref target="FIPS180"></xref>.
When an implementation is validating a signature containing a Literal Data Meta (Hashed) subpacket in its hashed-subpackets area, it <bcp14>MUST</bcp14> 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 <bcp14>MUST</bcp14> be deemed as invalid.</t>

</section>
<section anchor="literal-data-meta-verbatim"><name>Literal Data Meta (Verbatim)</name>

<t>The remainder of the packet contains a verbatim copy of the metadata as specified above.
When an implementation has successfully validated a signature containing a Literal Data Meta (Verbatim) subpacket in its hashed-subpackets area, the metadata section of the Literal Data Packet that is signed over <bcp14>MUST</bcp14> be replaced with the copy from the Literal Data Meta subpacket.</t>

</section>
</section>
<section anchor="security-considerations"><name>Security Considerations</name>

<t>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.</t>

<t>It is therefore <bcp14>RECOMMENDED</bcp14> that implementations generate Literal Data Hash subpackets using the Verbatim encoding.</t>

</section>
<section anchor="iana-considerations"><name>IANA Considerations</name>

<t>This document requests that the following entry be added to the OpenPGP Signature Subpacket registry:</t>

<texttable title="Signature Subpacket Registry" anchor="signature-subpacket-registry">
      <ttcol align='left'>Type</ttcol>
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>Specification</ttcol>
      <c>40</c>
      <c>Literal Data Meta</c>
      <c>This document</c>
</texttable>

</section>


  </middle>

  <back>


    <references title='Normative References'>

<reference anchor="FIPS180" target="http://dx.doi.org/10.6028/NIST.FIPS.180-4">
  <front>
    <title>Secure Hash Standard (SHS), FIPS 180-4</title>
    <author >
      <organization>National Institute of Standards and Technology, U.S. Department of Commerce</organization>
    </author>
    <date year="2015" month="August"/>
  </front>
</reference>


<reference anchor='RFC4880'>
  <front>
    <title>OpenPGP Message Format</title>
    <author fullname='J. Callas' initials='J.' surname='Callas'/>
    <author fullname='L. Donnerhacke' initials='L.' surname='Donnerhacke'/>
    <author fullname='H. Finney' initials='H.' surname='Finney'/>
    <author fullname='D. Shaw' initials='D.' surname='Shaw'/>
    <author fullname='R. Thayer' initials='R.' surname='Thayer'/>
    <date month='November' year='2007'/>
    <abstract>
      <t>This document is maintained in order to publish all necessary information needed to develop interoperable applications based on the OpenPGP format. It is not a step-by-step cookbook for writing an application. It describes only the format and methods needed to read, check, generate, and write conforming packets crossing any network. It does not deal with storage and implementation questions. It does, however, discuss implementation issues necessary to avoid security flaws.</t>
      <t>OpenPGP software uses a combination of strong public-key and symmetric cryptography to provide security services for electronic communications and data storage. These services include confidentiality, key management, authentication, and digital signatures. This document specifies the message formats used in OpenPGP. [STANDARDS-TRACK]</t>
    </abstract>
  </front>
  <seriesInfo name='RFC' value='4880'/>
  <seriesInfo name='DOI' value='10.17487/RFC4880'/>
</reference>

<reference anchor='RFC2119'>
  <front>
    <title>Key words for use in RFCs to Indicate Requirement Levels</title>
    <author fullname='S. Bradner' initials='S.' surname='Bradner'/>
    <date month='March' year='1997'/>
    <abstract>
      <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
    </abstract>
  </front>
  <seriesInfo name='BCP' value='14'/>
  <seriesInfo name='RFC' value='2119'/>
  <seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>

<reference anchor='RFC8174'>
  <front>
    <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
    <author fullname='B. Leiba' initials='B.' surname='Leiba'/>
    <date month='May' year='2017'/>
    <abstract>
      <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
    </abstract>
  </front>
  <seriesInfo name='BCP' value='14'/>
  <seriesInfo name='RFC' value='8174'/>
  <seriesInfo name='DOI' value='10.17487/RFC8174'/>
</reference>




    </references>

    <references title='Informative References'>

<reference anchor="LIBREPGP" target="https://datatracker.ietf.org/doc/html/draft-koch-librepgp">
  <front>
    <title>LibrePGP Message Format</title>
    <author initials="W." surname="Koch" fullname="Werner Koch">
      <organization></organization>
    </author>
    <author initials="R. H." surname="Tse" fullname="Ronald Henry Tse">
      <organization></organization>
    </author>
    <date year="2023"/>
  </front>
</reference>


    </references>


<section anchor="acknowledgements"><name>Acknowledgments</name>

<t>The author would like to thank Werner Koch for his earlier work on the Literal Data Meta Hash subpacket.</t>

</section>


  </back>

<!-- ##markdown-source:
H4sIAAAAAAAAA6VYbW/bOBL+rl8x53xJDpZiO+leatwd1tskTbB5uzi5YhEU
B1qiLcKSqCWpuL40/2V/y/6ymyEpyardosXlSySKnBk+88zDocMwDIwwGR9D
77bkxd37O7gShiuWwSkzDK65YQk9XBaGL5Qw614QM3yUaj0GUcxlkMi4YDla
SBSbm3DBsowtUq5CiQbLRRlmzmCYe1vhYBBUJT5xPYbjk5NBIEo1BqMqbUaD
wdvBKGCKMzJvgpVUy4WSVTkGby9Y8jWOJmMbkyq4CU/Jc6CrWS60FrJ4WJcY
z+XZw3nwzIuKjwMAb6TeZg+HjJ3W+4AuRLGA9zSDxnMmMhz3/n4W3MwjqRb0
iak4xU+pMaUeHx7STBoSzzyqpx3SwOFMyZXmh97GIa1VvJQbaxeIO5tFscwP
WZEovlok0tDb9+JINjNC0WxY7ZiKvA8hf8CoNmjjPyyTBYKz5jooxRiejIz7
oKUyis81Pq1zevgYsMqkUiHAIUYDMK+yzLFhYgOB97VH+xnhYYX4LzOYpDFg
Gn7lax2dPdqP3OHud/Cz/08A2c9KEk15IoxUQSFVjlaebWrPL++mw5PB2E4z
TC04IkKAIB7JpyiRwuZlOIh+GoxODm8upw8RrYlwUXjsVrkimPK4UhwumE5h
SjgwlcD+9GJ60LdeoF3RbBz8xsZwY/eFpXNZaDRYGQ5y3tjRtDN44HFayEwu
1n14jKYRnPKSKZPzwtDkdzLPuYq5NUslgkBWCywMGA2Gb3D0/vwdlcw4oNrb
wODq8pf7MwR0GwRiBWXWKBYvuWp5ioV7mJo889xYyjhFOsyQplhkG6D0rmiQ
pOGaa80WHM6t594OHEL/H8Cx4AMVqI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