<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" ipr="trust200902" docName="draft-waite-jws-multi-payload-00" submissionType="IETF" category="info" xml:lang="en" consensus="true">

<front>
<title abbrev="jws-multi-payload">JSON Web Signatures (JWS) Multiple Payload Option</title><seriesInfo value="draft-waite-jws-multi-payload-00" stream="IETF" status="informational" name="Internet-Draft"/>
<author initials="D." surname="Waite" fullname="David Waite"><organization>Ping Identity</organization><address><postal><street/>
</postal><email>dwaite+jose@pingidentity.com</email>
</address></author>
<author initials="J." surname="Miller" fullname="Jeremie Miller"><organization>Ping Identity</organization><address><postal><street/>
</postal><email>jmiller@pingidentity.com</email>
</address></author>
<author initials="M." surname="Jones" fullname="Michael B. Jones"><organization>individual</organization><address><postal><street/>
</postal><email>michael_b_jones@hotmail.com</email>
<uri>https://self-issued.info/</uri>
</address></author>
<date/>
<area>Internet</area>
<workgroup/>
<keyword>jose</keyword>
<keyword>jws</keyword>

<abstract>
<t>The JOSE set of standards established JSON-based container formats for <eref target="https://datatracker.ietf.org/doc/rfc7515/">signatures</eref> over a content payload using  established <eref target="https://datatracker.ietf.org/doc/rfc7518/">algorithms</eref>.</t>
<t>Newer algorithms are emerging which allow for additional operations on content, such as a party (other than the signer) choosing not to disclose some of the integrity-protected content. However, these algorithms often support granularity at the individual message level, creating a need to define a way to support expressing multiple content payloads as part of a single message.</t>
<t>This document defines a new operational mode for JSON Web Signatures that operates on a protected header and multiple binary content payloads to provide the expressivity needed for this class of algorithm. It also describes how multiple content payloads can be expressed in a manner compatible with pre-existing algorithms, albeit without the operational capabilities of newer algorithms.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>The JOSE specifications are very widely deployed and well supported, enabling use of cryptographic primitives with a JSON representation.  JWTs <xref target="RFC7519"/> are one of the most common representations for identity and access claims.  For instance, they are used by the OpenID Connect and Secure Telephony Identity Revisited (STIR) standards.</t>
<t>JWTs are also used by W3C's Verifiable Credentials and are used in many Decentralized Identity systems, where they may represent rich identity claims about a subject as an issued statement, which may be presented at some point in the future to another party for verification, without active participation by the original issuer.</t>
<t>With these new use cases, there is an increased focus on adopting privacy-protecting cryptographic primitives. The privacy-protection focus is largely in two areas: allowing a party to reduce the amount of information from the original document which is presented to a third party, and reducing correlation from the cryptographic algorithms when presenting a single issued statement multiple times.</t>
<t>One commonality across these algorithms is that they either require or are computationally simplified by delineating information items into multiple content payloads (whether the algorithms refer to them as messages, attributes, or slots), which are bound together into a single cryptographic object. They then define transformations in order to modify these individual components to release, omit, or express statements on the value of those components.</t>
<t>This specification defines an operational mode for algorithms which are multi-payload aware, as well as JSON and compact expressions for multiple payloads. It also defines how multiple payloads can be processed by algorithms which do not support the above transformations, and how multiple payloads might be used pre-existing JWS implementations based on such algorithms.</t>
</section>

<section anchor="conventions-and-terminology"><name>Conventions and Terminology</name>
<t>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 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
<t>This specification will use the following conventions to describe expressions for transforms and serializations:</t>

<ol>
<li>A function is a transform or other operation which takes inputs and outputs a value will be described using a capitalized function name, with parameters folling in parenthesis as a comma-separated list, such as <tt>FUNCTION(INPUT1, INPUT2)</tt>. Functions may nest if the input to one function is the output of another.</li>
<li>A constant value is indicated with a capitalized name and no parameterized list, such as <tt>CONSTANT</tt></li>
<li>Constants which are single 7-bit ASCII codes are indicated by the value, surrounded by single quotes, such as <tt>'~'</tt></li>
<li>Multiple values are concatenated into a single serialized form using two vertical line or "pipe" characters, e.g. <tt>A || B</tt></li>
<li>Optionality is indicated by surrounding an expression with square brackets, such as <tt>A || [B || C]</tt></li>
</ol>
<t>The following additional conventions are used for expressing serialization of variable-length lists</t>

<ol>
<li>The values in a list, if needed, is indicated using a 1-based numerical suffix, such as <tt>Payload 1</tt></li>
<li>A loop is indicated by double square brackets, using a suffix of n, such as <tt>Payload 1 || [[ '~' || Payload n]]</tt></li>
</ol>
<t>This specification uses the same terminology as the "JSON Web Signature" [JWS] and "JSON Web Algorithms" [JWA] specifications, as well as the <tt>BASE64URL(OCTETS)</tt>, <tt>UTF8(STRING)</tt>, and <tt>ASCII(STRING)</tt> encoding conventions (here referred to as functions.)</t>
</section>

<section anchor="multiple-payload-aware-algorithms"><name>Multiple Payload Aware Algorithms</name>
<t>Algorithms which support multiple payloads do not operate on the JWS Signing Input. They instead expect to receive information directly and individually as octets:</t>

<ul>
<li>The octets from UTF-8 encoding the protected header</li>
<li>An ordered list of content payloads, each expressed as octets. Note that a single payload may be a zero length octet string, or may be omitted.</li>
</ul>
<blockquote><t>NOTE: Need to decide if zero length and nil are worth representing as distinct, partially as compact representation will not be able to distinguish them.</t>
</blockquote><t>Neither the protected header nor the content payloads are input in their JSON or compact serialized form, and thus are not expected to have a BASE64URL encoding applied when input for signature or validation.</t>
<t>Algorithms which are not aware of multiple payloads are instead expected to operate on the JWS signing input form, described below.</t>
</section>

<section anchor="multi-payload-serializations"><name>Multi Payload Serializations</name>

<section anchor="json-serialization"><name>JSON Serialization</name>
<t>For the JWS JSON serialization, multiple payloads are expressed via the new "payloads" member, which is an array where each entry is either a base64url-encoded content payload value or the JSON value <tt>null</tt>. Implementations MUST verify the "payload" member is absent when "payloads" is present.</t>
</section>

<section anchor="compact-serialization"><name>Compact Serialization</name>
<t>For the JWS Compact serialization, multiple payloads are expressed by base64url-encoding each, then concatenating them into a single textual value with the tilde '~' character. This value is then expressed in lieu of a single base64-url encoded payload.</t>

<artwork>   BASE64URL(UTF8(JWS Protected Header))
   || '.' || BASE64URL(JWS Payload 1) ||
   [[ '~' || BASE64URL(JWS Payload n) ]]
   || '.' || BASE64URL(JWS Signature)
</artwork>
<t>For example, if the protected header coincidentally base64url-encoded to "HEADER", the three payloads base64url-encoded to "PAYLOAD1", "PAYLOAD2", and "PAYLOAD3", and the signature to "SIGN", the compact serialization would be:</t>

<artwork>   HEADER.PAYLOAD1~PAYLOAD2~PAYLOAD3.SIGN
</artwork>
<t>JWS Compact serialization represents omitted payloads as zero length payloads, and both base64url-encode to a zero length character sequence. If the second payload value had been omitted, the representation would have been:</t>

<artwork>   HEADER.PAYLOAD1~~PAYLOAD3.SIGN
</artwork>
</section>
</section>

<section anchor="jws-signing-input"><name>JWS Signing Input</name>
<t>For algorithms which are not multiple payload aware, they are expected to continue to operate on a JWS signing input. When Multiple payloads are used, the JWS signing input is:</t>

<artwork>   BASE64URL(JWS Protected Header)
   || '.' || BASE64URL(JWS Payload 1) ||
   [[ '~' || BASE64URL(JWS Payload n) ]]
</artwork>
</section>

<section anchor="mp-header"><name>The "mp" Header Parameter</name>
<t>This Header Parameter indicates the signature is protecting multiple content payloads.</t>
<t>The value <tt>true</tt> modifies the representation in JSON and compact encodings, as well as the JWS signing input, to to the rules above.</t>
<t>Multi-payload aware algorithms cannot operate on JWS signing input, and MUST be assumed to be operating as if <tt>"mp"</tt> was specified as <tt>true</tt>. A <tt>"mp"</tt> header of <tt>false</tt> is not legal in this scenario, and it is RECOMMENDED that the <tt>"mp"</tt> header not be specified.</t>
<t>Applications which do not specify multi-payload behavior can be assumed to be operating in a mode where <tt>"mp"</tt> is <tt>false</tt>. Applications MAY either indicate this value be specified explicitly, or be assumed by context.</t>
</section>

<section anchor="interactions-with-unencoded-payload-option"><name>Interactions with Unencoded Payload Option</name>
<t>[RFC7797] specifies the unencoded payload option, which allows for payloads that can be expressed without base64url-encoding to skip the payload transformation, altering transforms as well as the JWS signed input. This is done via the <tt>"b64"</tt> protected header being <tt>true</tt>. The payload in such a case can include both the base64url alphabet as well as the tilde character <tt>~</tt>.</t>
<t>As the unencoded payload option describes how to encoded multiple payloads, the <tt>"b64"</tt> protected header does not have an effect on multi-payload processing. That said, the two headers have compatible payloads and JWS signing input, by noting such an unencoded payload input is a <em>combined payload serialization</em> of the multi-payload input, defined as:</t>

<artwork>   BASE64URL(JWS Payload 1) ||
   [[ '~' || BASE64URL(JWS Payload n) ]]
</artwork>

<section anchor="compatibility-mode-with-implementations-without-multi-payload-support"><name>Compatibility mode with implementations without multi-payload support</name>
<t>The unencoded payload option can be used in concert with multi-payload support when using algorithms which are not multi-payload aware, and communicating with compact serialization. This provides compatibility with JWS implementations without multi-payload support, which will fall back to interpreting the payload as a combined payload serialization. For such implementations, another layer of the application would be responsible for decomposing and interpreting the combined payload.</t>
<t>When operating in compatibility mode, the protected header should indicate:</t>

<ul>
<li>a non multi-payload-aware algorithm</li>
<li>a <tt>"mp"</tt> header of <tt>true</tt>, indicating that multiple payloads for JWS implmentations which support such a feature</li>
<li>a <tt>"b64"</tt> header of <tt>false</tt>, indicating that the payload is not encoded</li>
<li>a <tt>"crit"</tt> header including <tt>"b64"</tt> but not including <tt>"mp"</tt>.</li>
</ul>
<t>As this is the only valid combination of <tt>"mp"</tt> with <tt>"b64"</tt> as <tt>false</tt>, a multi-payload aware JWS implementation SHOULD consider that they satisfy the <tt>"crit"</tt> requirement for <tt>"b64"</tt>, even if they otherwise do not support unencoded payloads.</t>
<t>Due to the difference in JSON serialization between the <tt>payloads</tt> value defined for multi-payload support and the <tt>payload</tt> value expected by the unencoded payload option, you MUST NOT use JSON serialization for transmission when operating with this combination of header parameters.</t>
</section>
</section>

<section anchor="indicating-multi-payload-is-required"><name>Indicating Multi-payload is required</name>
<t>When not using the compatibility mode described above, the JWS MUST use existing mechanisms to indicate the requirements of the message, and MUST NOT rely on side effects such as base64url decoding errors to prevent consumption by incompatible implementations.</t>
<t>As such, the following two mechanisms are described to explicitly limit compatibility:</t>

<ol>
<li><t>A multi-payload-aware algorithm MUST only be supported by a multi-payload compatible JWS implementation. Implementations which do not understand multiple payloads will fail when they encounter an algorithm they do not support</t>
</li>
<li><t>When an <tt>"mp"</tt> header of <tt>true</tt> is used with an algorithm that is not multiple payload aware, a <tt>"crit"</tt> header including <tt>"mp"</tt> MUST be supplied.</t>
</li>
</ol>
</section>

<section anchor="detached-payload-content"><name>Detached payload content</name>
<t>Appendix F of [JWS] describes how to represent JWSs with detached content, by applications omitting the payload in the transmitted serialization, and having the application reconsistitute the payload member to do integrity verification.</t>
<t>The steps to detach all payloads from a multi-payload JWS are similar, with the caveat that the JSON serialization would now have the <tt>payloads</tt> key omitted in such a scenario.</t>
<t>It is RECOMMENDED that applications describe when and how the detached content is to be used, taking particular caution around confusion that could result if only <em>some</em> of the payloads have been detached.</t>
</section>

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

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

<section anchor="json-web-signature-and-encryption-header-parameter-registration"><name>JSON Web Signature and Encryption Header Parameter Registration</name>
<t>This specification registers the "mp" Header Parameter defined in Section <xref target="mp-header"/> of this specification in the IANA " JSON Web Signature and Encryption Header Parameters" registry established by [JWS]</t>

<section anchor="registry-contents"><name>Registry Contents</name>

<ul>
<li>Header Parameter Name: "mp"</li>
<li>Header Parameter Description: Multiple Payload Encoding
o  Header Parameter Usage Location(s): JWS
o  Change Controller: IESG
o  Specification Document(s): TBD</li>
</ul>
</section>
</section>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7519.xml"/>
</references>
<references><name>Informative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
</references>

<section anchor="acknowledgments"><name>Acknowledgments</name>
<t>TODO acknowledge.</t>
</section>

</back>

</rfc>
