<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.17 (Ruby 3.2.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-kleidl-digest-fields-problem-types-00" category="info" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.22.0 -->
  <front>
    <title>HTTP Problem Types for Digest Fields</title>
    <seriesInfo name="Internet-Draft" value="draft-kleidl-digest-fields-problem-types-00"/>
    <author fullname="Marius Kleidl">
      <organization>Transloadit</organization>
      <address>
        <email>marius@transloadit.com</email>
      </address>
    </author>
    <author fullname="Lucas Pardue">
      <organization>Cloudflare</organization>
      <address>
        <email>lucas@lucaspardue.com</email>
      </address>
    </author>
    <date year="2024" month="July" day="08"/>
    <keyword>next generation</keyword>
    <keyword>unicorn</keyword>
    <keyword>sparkling distributed ledger</keyword>
    <abstract>
      <?line 43?>

<t>This document specifies problem types that servers can use in responses to problems encountered while dealing with a request carrying integrity fields and integrity preference fields.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://tus.github.io/draft-digest-fields-problem-types/draft-kleidl-digest-fields-problem-types.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-kleidl-digest-fields-problem-types/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/tus/draft-digest-fields-problem-types"/>.</t>
    </note>
  </front>
  <middle>
    <?line 47?>

<section anchor="introduction">
      <name>Introduction</name>
      <t><xref target="DIGEST"/> by design does not define, require or recommend any specific behavior for error handling relating to integrity. The responsibility is instead delegated to applications. This draft defines a set of problem types <xref target="PROBLEM"/> that can be used by server applications to indicate that a problem was encountered while dealing with a request carrying integrity fields and integrity preference fields.</t>
      <t>For example, a request message may include content alongside <tt>Content-Digest</tt> and <tt>Repr-Digest</tt> header fields that use a digest algorithm the server does not support. An application could decide to reject this request because it cannot validate the integrity. Using a problem type, the server can provide machine-readable error details to aid debugging or error reporting, as shown in the following example.</t>
      <sourcecode type="http-message"><![CDATA[
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
Want-Content-Digest: sha-512=3, sha-256=10

{
  "type": "https://iana.org/assignments/http-problem-types#unsupported-hashing-algorithm",
  "title": "hashing algorithm is not supported",
  "unsupported-algorithm": "foo"
}
]]></sourcecode>
    </section>
    <section anchor="conventions-and-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>
      <?line -18?>

<t>The terms "integrity fields" and "integrity preference fields" are from <xref target="DIGEST"/>.</t>
    </section>
    <section anchor="problem-types">
      <name>Problem Types</name>
      <section anchor="unsupported-hashing-algorithm">
        <name>Unsupported Hashing Algorithm</name>
        <t>This section defines the "https://iana.org/assignments/http-problem-types#unsupported-hashing-algorithm" problem type <xref target="PROBLEM"/>. A server <bcp14>MAY</bcp14> use this problem type when responding to a request, whose integrity or integrity preference fields reference a hashing algorithm that the server can not or does not want to support for this request, and if the server wants to indicate this problem to the sender.</t>
        <t>For this problem type, the <tt>unsupported-algorithm</tt> is defined as the only extension member. It <bcp14>SHOULD</bcp14> be populated in a response using this problem type, with its value being the algorithm key of the unsupported algorithm from the request. The response <bcp14>SHOULD</bcp14> include the corresponding integrity preference field to indicate the server's algorithm support and preference.</t>
        <t>The following example shows a response for a request with an integrity field utilizing an unsupported hashing algorithm <tt>foo</tt>. The response also includes a list of supported algorithms.</t>
        <sourcecode type="http-message"><![CDATA[
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
Want-Content-Digest: sha-512=3, sha-256=10

{
  "type": "https://iana.org/assignments/http-problem-types#unsupported-hashing-algorithm",
  "title": "hashing algorithm is not supported",
  "unsupported-algorithm": "foo"
}
]]></sourcecode>
        <t>This problem type is a hint to the client about algorithm support, which the client could use to retry the request with a different algorithm supported by the server.</t>
      </section>
      <section anchor="invalid-digest-value">
        <name>Invalid Digest Value</name>
        <t>This section defines the "https://iana.org/assignments/http-problem-types#invalid-digest-value" problem type <xref target="PROBLEM"/>. A server <bcp14>MAY</bcp14> use this problem type when responding to a request, whose integrity fields include a digest value, that cannot be generated by the corresponding hashing algorithm. For example, if the digest value of the <tt>sha-512</tt> hashing algorithm is not 64 bytes long, it cannot be a valid digest value and the server can skip computing the digest value. This problem type <bcp14>MUST NOT</bcp14> be used if the server is not able to parse the integrity fields according to <xref section="4.5" sectionFormat="of" target="STRUCTURED-FIELDS"/>, for example because of a syntax error in the field value.</t>
        <t>The server <bcp14>SHOULD</bcp14> include a human-readable description why the value is considered invalid in the <tt>title</tt> member.</t>
        <t>The following example shows a response for a request with an invalid digest value.</t>
        <sourcecode type="http-message"><![CDATA[
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json

{
  "type": "https://iana.org/assignments/http-problem-types#invalid-digest-value",
  "title": "digest value for sha-512 is not 64 bytes long"
}
]]></sourcecode>
        <t>This problem type indicates a fault in the sender's calculation or encoding of the digest value. A retry of the same request without modification will likely not yield a successful response.</t>
      </section>
      <section anchor="mismatching-digest-value">
        <name>Mismatching Digest Value</name>
        <t>This section defines the "https://iana.org/assignments/http-problem-types#mismatching-digest-value" problem type <xref target="PROBLEM"/>. A server <bcp14>MAY</bcp14> use this problem type when responding to a request, whose integrity fields include a digest value that does not match the digest value that the server calculated for the request content or representation.</t>
        <t>Three problem type extension members are defined: the <tt>algorithm</tt>, <tt>provided-digest</tt>, and <tt>calculated-digest</tt> members. A response using this problem type <bcp14>SHOULD</bcp14> populate all members, with the value of <tt>algorithm</tt> being the algorithm key of the used hashing algorithm, with the value of <tt>provided-digest</tt> being the digest value taken from the request's integrity fields, and the value of <tt>calculated-digest</tt> being the calculated digest. The digest values <bcp14>MUST</bcp14> BE serialized as byte sequences as described in <xref section="4.1.8" sectionFormat="of" target="STRUCTURED-FIELDS"/>.</t>
        <t>The following example shows a response for a request with a mismatching SHA-256 digest value.</t>
        <sourcecode type="http-message"><![CDATA[
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json

{
  "type": "https://iana.org/assignments/http-problem-types#mismatching-digest-value",
  "title": "digest value fromr request does not match expected value",
  "algorithm": "sha-256",
  "provided-digest": ":RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:",
  "calculated-digest": ":d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:"
}
]]></sourcecode>
        <t>If the sender receives this problem type, the request might be modified unintentionally by an intermediary. The sender could use this information to retry the request without modification to address temporary transmission issues.</t>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>Although an error appeared while handling the digest fields, the server may choose to not disclose this error to the sender to avoid lacking implementation details. Similar, the server may choose a general problem type for the response even in a more specific problem type is defined if it prefers to hide the details of the error from the sender.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>IANA is asked to register the following entry in the "HTTP Problem Types" registry:</t>
      <dl>
        <dt>Type URI:</dt>
        <dd>
          <t>https://iana.org/assignments/http-problem-types#unsupported-hashing-algorithm</t>
        </dd>
        <dt>Title:</dt>
        <dd>
          <t>Unsupported Hashing Algorithm</t>
        </dd>
        <dt>Recommended HTTP status code:</dt>
        <dd>
          <t>400</t>
        </dd>
        <dt>Reference:</dt>
        <dd>
          <t>This document</t>
        </dd>
      </dl>
      <t>IANA is asked to register the following entry in the "HTTP Problem Types" registry:</t>
      <dl>
        <dt>Type URI:</dt>
        <dd>
          <t>https://iana.org/assignments/http-problem-types#invalid-digest-value</t>
        </dd>
        <dt>Title:</dt>
        <dd>
          <t>Invalid Digest Value</t>
        </dd>
        <dt>Recommended HTTP status code:</dt>
        <dd>
          <t>400</t>
        </dd>
        <dt>Reference:</dt>
        <dd>
          <t>This document</t>
        </dd>
      </dl>
      <t>IANA is asked to register the following entry in the "HTTP Problem Types" registry:</t>
      <dl>
        <dt>Type URI:</dt>
        <dd>
          <t>https://iana.org/assignments/http-problem-types#mismatching-digest-value</t>
        </dd>
        <dt>Title:</dt>
        <dd>
          <t>Mismatching Digest Value</t>
        </dd>
        <dt>Recommended HTTP status code:</dt>
        <dd>
          <t>400</t>
        </dd>
        <dt>Reference:</dt>
        <dd>
          <t>This document</t>
        </dd>
      </dl>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references">
      <name>Normative References</name>
      <reference anchor="DIGEST">
        <front>
          <title>Digest Fields</title>
          <author fullname="R. Polli" initials="R." surname="Polli"/>
          <author fullname="L. Pardue" initials="L." surname="Pardue"/>
          <date month="February" year="2024"/>
          <abstract>
            <t>This document defines HTTP fields that support integrity digests. The Content-Digest field can be used for the integrity of HTTP message content. The Repr-Digest field can be used for the integrity of HTTP representations. Want-Content-Digest and Want-Repr-Digest can be used to indicate a sender's interest and preferences for receiving the respective Integrity fields.</t>
            <t>This document obsoletes RFC 3230 and the Digest and Want-Digest HTTP fields.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="9530"/>
        <seriesInfo name="DOI" value="10.17487/RFC9530"/>
      </reference>
      <reference anchor="PROBLEM">
        <front>
          <title>Problem Details for HTTP APIs</title>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
          <author fullname="E. Wilde" initials="E." surname="Wilde"/>
          <author fullname="S. Dalal" initials="S." surname="Dalal"/>
          <date month="July" year="2023"/>
          <abstract>
            <t>This document defines a "problem detail" to carry machine-readable details of errors in HTTP response content to avoid the need to define new error response formats for HTTP APIs.</t>
            <t>This document obsoletes RFC 7807.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="9457"/>
        <seriesInfo name="DOI" value="10.17487/RFC9457"/>
      </reference>
      <reference anchor="STRUCTURED-FIELDS">
        <front>
          <title>Structured Field Values for HTTP</title>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
          <author fullname="P-H. Kamp" surname="P-H. Kamp"/>
          <date month="February" year="2021"/>
          <abstract>
            <t>This document describes a set of data types and associated algorithms that are intended to make it easier and safer to define and handle HTTP header and trailer fields, known as "Structured Fields", "Structured Headers", or "Structured Trailers". It is intended for use by specifications of new HTTP fields that wish to use a common syntax that is more restrictive than traditional HTTP field values.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8941"/>
        <seriesInfo name="DOI" value="10.17487/RFC8941"/>
      </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>
    <?line 207?>

<section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>This document is based on ideas from a discussion with Roberto Polli, so thanks to him for his valuable input and feedback on this topic.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA+1a727bOBL/rqfgqR8KXG0nbpM2Nba7df41RpMmdZwW28MB
piXaYkORKikldYP0WfZZ7sluhqRkyXbSw7W7KA73JbVIcTj8zcxvZqi22+0g
57lgPRIejUZn5EyriWApGc0zZshUabLPZ8zk5JAzEZswiGjOZkrPe4TLqQqC
WEWSprA+1nSaty8F47Fox3ZRe2oXtTMntJ2j0PbmZmCKScqN4UriUI8MDkaH
hDwgVBgFmnAZs4zBH5mHLRKymOdKcyrwYdDfhX9Ar3AwHB2GgSzSCdO9IAa9
ekGkpGHSFKZHcl2w4KpHngQgVzPaI/3hQR8erpW+nGlVZD3y/hV5D09czsgr
HAku2Rym415A2kSyzzmZMck0zUFTHCokj5S2P01G9aXAlTE3ueaTImcxESye
MR1cMVmANg8IqTbCB3fY5o4wnFIu8JWX7DNNM8E6kUpxnOoo6ZEkzzPT29io
TW6AOBDN86SYAFx5YTYc+vfAHsIKARiZHFaUMmFlx4npcPVtGRv/qY07SZ6K
MAhokSdKI5qwOyHTQgjnLOEJ1bww5LUVFdpZpWdU8i8W7B4ZaSqNUBRsb2eZ
QylM7cKX+WIaEQnXbHFcRNSQM6rjgq3bYU+oIp4K8I3GBgKXvbR/M7vWyQ+k
0imsvAK7ErI/eHVwPuqR4eHe8+0nmzByNjzdPT44cUNb289g6Hw0vNgbXQwP
9tuHg4Pj/XM7ufN8qxsEGDyVvCBot9uETsCPaJQHwSjhhkBgFSlEAHgaizig
bIjH2PqRIXlCYZLpK6YNiagkhWEQlEQzk2EYwBuqXGIIk5EqZM40eOl1w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