<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-mahy-mimi-content-01" submissionType="IETF" category="info" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true" consensus="true">

<front>
<title abbrev="MIMI Content">More Instant Messaging Interoperability (MIMI) message content</title><seriesInfo value="draft-mahy-mimi-content-01" stream="IETF" status="informational" name="Internet-Draft"></seriesInfo>
<author initials="R." surname="Mahy" fullname="Rohan Mahy"><organization>Wire</organization><address><postal><street></street>
</postal><email>rohan.mahy@wire.com</email>
</address></author><date/>
<area>art</area>
<workgroup>MIMI BoF</workgroup>
<keyword>mimi</keyword>
<keyword>content</keyword>
<keyword>mls</keyword>
<keyword>mime</keyword>

<abstract>
<t>This document describes content semantics common in Instant Messaging (IM)
systems and describes an example
profile suitable for instant messaging interoperability
of messages end-to-end encrypted inside the MLS
(Message Layer Security)
Protocol. It adapts prior work (CPIM) to work well in the MLS context.</t>
</abstract>

</front>

<middle>

<section anchor="terminology"><name>Terminology</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;, &quot;SHOULD&quot;,
&quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to
be interpreted as described in RFC 2119 <xref target="RFC2219"></xref>.</t>
<t>The terms MLS client, MLS group, and KeyPackage have the same meanings as in
the MLS protocol <xref target="I-D.ietf-mls-protocol"></xref>.</t>
</section>

<section anchor="introduction"><name>Introduction</name>
<t>MLS <xref target="I-D.ietf-mls-protocol"></xref> is a group key establishment protocol
motivated by the desire for group chat with efficient end-to-end encryption.
While one of the motivations of MLS is interoperable standards-based secure
messaging, the MLS protocol does not define or prescribe any format for the
encrypted &quot;application messages&quot; encoded by MLS.  The development of MLS
was strongly motivated by the needs of a number of Instant Messaging (IM)
systems, which encrypt messages end-to-end using variations of the
Double Ratchet protocol <xref target="DoubleRatchet"></xref>.</t>
<t>End-to-end encrypted instant messaging was also a motivator for the Common
Protocol for Instant Messaging (CPIM) <xref target="RFC3862"></xref>, however the model used at the time
assumed standalone encryption of each message using a protocol such as S/MIME
<xref target="RFC8551"></xref> or PGP <xref target="RFC3156"></xref> to interoperate between IM protocols such as
SIP <xref target="RFC3261"></xref> and XMPP <xref target="RFC6120"></xref>.  For a variety of practical reasons, interoperable
end-to-end encryption between IM systems was never deployed commercially.</t>
<t>There are now several instant messaging vendors implementing MLS.
In order to enable
interoperable messaging conveyed &quot;inside&quot; MLS application messages, some
additional specification and some minor changes are required. Also, the
expectation of what constitutes basic features common across multiple IM
systems has grown. It would be beneficial to provide an interoperable format
for these additional features as well.  Most of these features could be
implemented using a profile which describes how to use already-defined
URIs, message headers, and MIME types.</t>
<t>This document explores issues and example solutions consistent with the
More Instant Messaging Interoperability (MIMI) problem outline
<xref target="I-D.mahy-mimi-problem-outline"></xref>.</t>
<t>This proposal assumes that MLS clients can advertise media types they support
and that MLS clients can determine what media types are required to join a
specific MLS group. Specifically, <xref target="I-D.mahy-mls-content-adv"></xref> defines
two MLS extensions which
meet this requirement. It would allow implementations to define groups
with different MIME type requirements and it would allow MLS clients to send
extended or proprietary messages that would be interpreted by some members
of the group while assuring that an interoperable end-to-end encrypted
baseline is available to all members, even when the group spans multiple
systems or vendors.</t>
<t>Below is a list of some features commonly found in IM group chat systems:</t>

<ul spacing="compact">
<li>plain text and rich text messaging</li>
<li>delivery notifications</li>
<li>read receipts</li>
<li>replies</li>
<li>reactions</li>
<li>edit or delete previously sent messages</li>
<li>expiring messages</li>
<li>knock / ping</li>
<li>shared files/audio/videos</li>
<li>calling / conferencing</li>
</ul>
</section>

<section anchor="overview"><name>Overview</name>

<section anchor="naming-schemes"><name>Naming schemes</name>
<t>IM systems have a number of types of identifiers. These are described in detail
in <xref target="I-D.mahy-mimi-identity"></xref>. A few of these used in this document are:</t>

<ul spacing="compact">
<li>handle identifier (external, friendly representation). This is the type
of identifier in the From header in the examples.</li>
<li>client/device identifier (internal representation). This is the type
of identifier in the implied Sender header in the examples.</li>
<li>group or conversation or channel name (either internal or external representation).
. This is the type of identifier in the implied To header in the examples.</li>
</ul>
<t>This proposal relies on URIs for naming and identifiers. All the example use
the <tt>im:</tt> URI scheme (defined in <xref target="RFC3862"></xref>), but any instant messaging scheme
could be used.</t>
</section>

<section anchor="detection-of-suitable-media-types"><name>Detection of suitable media types</name>
<t>As most IM systems are proprietary, standalone systems, it is useful to allow
clients to send and receive proprietary formats among themselves. Using the
multipart/alternative MIME wrapper (or the container syntax in Appendix A of
this document), clients can send a message using the basic
functionality described in this document AND a proprietary format for
same-vendor clients simultaneously over the same group with end-to-end
encryption.</t>
<t>Example sending this profile and proprietary messaging protocol simultaneously.</t>

<artwork>Content-type: multipart/alternative; boundary=XcrSXMwuRwk9

--XcrSXMwuRwk9
Content-type: message/cpim

From: &lt;im:alice-smith@example.com&gt;
DateTime: 2022-02-08T22:13:45-00:00
Message-ID: &lt;28fd19857ad7@example.com&gt;

Content-Type: text/plain; charset=utf-8

Test Message
--XcrSXMwuRwk9
Content-type: application/vnd.examplevendor-fancy-im-message

&lt;content of example vendor's fancy proprietary format&gt;
--XcrSXMwuRwk9
</artwork>
<t><xref target="I-D.mahy-mls-content-adv"></xref> contains the actual MLS extensions useful for
advertising the relevant media types.  The profile in this document requires
support for receiving:</t>

<ul spacing="compact">
<li>message/cpim</li>
<li>text/plain</li>
<li>text/markdown</li>
<li>multipart/mixed</li>
<li>multipart/alternative</li>
</ul>
<t>All other mime types (including some recommended in this profile) are optional.</t>
</section>

<section anchor="cpim-and-mime-headers"><name>CPIM and MIME headers</name>
<t>Note that while the <strong>syntax</strong> used in this document is based on CPIM, the
semantics of these messages could be translated into any number of formats,
for example JSON, XML, CBOR, etc.</t>
<t>We assume that an MLS group is already established and that either out-of-band
or using the MLS protocol or MLS extensions that the following is known to every
member of the group:</t>

<ul spacing="compact">
<li>The membership of the group (via MLS).</li>
<li>The identity of any MLS client which sends an application message (via MLS).</li>
<li>The MLS group ID (via MLS)</li>
<li>The human readable name(s) of the MLS group, if any (out-of-band or extension).</li>
<li>Which media types are mandatory to implement (proposed extension).</li>
<li>For each member, the media types each supports (proposed extension).</li>
</ul>
<t>For all messages the message header equivalent of To (the MLS group) and
Sender fields (MLS sender) is already
known and is therefore redundant. Every message contains a message/cpim header which
includes the From, DateTime, and Message-ID fields. The From field contains the
external, user-friendly representation of the Sender.</t>
<t>Messages sent to an MLS group are delivered to every member of the group active during
the epoch in which the message was sent.</t>
<t>It is also mandatory to understand are the following MIME headers:</t>

<ul spacing="compact">
<li>Content-Type</li>
<li>Content-Disposition</li>
<li>Content-Length</li>
</ul>
</section>
</section>

<section anchor="example"><name>Example</name>

<section anchor="original-message"><name>Original Message</name>
<t>In this example, Alice Smith sends a rich-text (Markdown) <xref target="RFC7763"></xref>
message to the Engineering Team MLS group. The following values are
implied as if headers were present:</t>

<ul spacing="compact">
<li>Implied Sender header from MLS sender:
<eref target="im:3b52249d-68f9-45ce-8bf5-c799f3cad7ec/0003@example.com">im:3b52249d-68f9-45ce-8bf5-c799f3cad7ec/0003@example.com</eref></li>
<li>Implied To header from MLS group: &quot;Engineering Team&quot;
<eref target="im:#engineering_team@example.com">im:#engineering_team@example.com</eref></li>
</ul>

<artwork>Content-type: message/cpim

From: &lt;im:alice-smith@example.com&gt;
DateTime: 2022-02-08T22:13:45-00:00
Message-ID: &lt;28fd19857ad7@example.com&gt;

Content-Type: text/markdown;charset=utf-8

Hi everyone, we just shipped release 2.0. __Good work__!
</artwork>
</section>

<section anchor="reply"><name>Reply</name>
<t>A reply message looks similar, but contains an In-Reply-To CPIM header with
the ID of the original message. The implied To header is the same all
example messages in this section. The implied Sender header is always the
MLS sender, and will not be shown in subsequent example messages.</t>

<artwork>Content-type: message/cpim

From: &lt;im:bob-jones@example.com&gt;
DateTime: 2022-02-08T22:13:57-00:00
Message-ID: &lt;e701beee59f9@example.com&gt;
In-Reply-To: &lt;28fd19857ad7@example.com&gt;

Content-Type: text/markdown;charset=utf-8

Right on! _Congratulations_ 'all!
</artwork>
</section>

<section anchor="reaction"><name>Reaction</name>
<t>A reaction, uses the reaction Content-Disposition token defined in <xref target="RFC9078"></xref>.
This Content-Disposition token indicates that the intended disposition of the
contents of the message is a reaction.</t>
<t>The content in the sample message is a single Unicode heart character (U+2665).
Discovering the range of characters each implementation could render as a
reaction can occur out-of-band and is not within the scope of this proposal.
However, an implementation which receives a reaction character string it
does not recognize could render the reaction as a reply, possibly prefixing
with a localized string such as &quot;Reaction: &quot;.  Note that a reaction could
theoretically even be another media type (ex: image, audio, or video), although
not currently implemented in major instant messaging systems.</t>

<artwork>Content-type: message/cpim

From: &lt;im:cathy-washington@example.com&gt;
DateTime: 2022-02-08T22:13:57-00:00
Message-ID: &lt;1a771ca1d84f@example.com&gt;
In-Reply-To: &lt;28fd19857ad7@example.com&gt;

Content-Type: text/plain;charset=utf-8
Content-Disposition: reaction

♥
</artwork>
</section>

<section anchor="mentions"><name>Mentions</name>
<t>In instant messaging systems and social media, a mention allows special
formatting and behavior when a name, handle, or tag associated with a
known group is encountered, often when prefixed with a commercial-at &quot;@&quot;
character for mentions of users or a hash &quot;#&quot; character for groups or tags.
A message which contains a mention may trigger distinct notifications on
the IM client.</t>
<t>We can convey a mention by linking the user, handle, or tag URI in Markdown
or HTML rich content. For example, a mention using Markdown is indicated below.</t>

<artwork>Content-type: message/cpim

From: &lt;im:cathy-washington@example.com&gt;
DateTime: 2022-02-08T22:14:03-00:00
Message-ID: &lt;4dcab7711a77@example.com&gt;

Content-Type: text/markdown;charset=utf-8

Kudos to [@Alice Smith](im:alice-smith@example.com)
for making the release happen!
</artwork>
<t>The same mention using HTML <xref target="W3C.CR-html52-20170808"></xref> is indicated below.</t>

<artwork>Content-type: message/cpim

From: &lt;im:cathy-washington@example.com&gt;
DateTime: 2022-02-08T22:14:03-00:00
Message-ID: &lt;4dcab7711a77@example.com&gt;

Content-Type: text/html;charset=utf-8

&lt;p&gt;Kudos to &lt;a href=&quot;im:alice-smith@example.com&quot;&gt;@Alice
Smith&lt;/a&gt; for making the release happen!&lt;/p&gt;
</artwork>
</section>

<section anchor="edit"><name>Edit</name>
<t>Unlike with email messages, it is common in IM systems to allow the sender of
a message to edit or delete the message after the fact. Typically the message
is replaced in the user interface of the receivers (even after the original
message is read) but shows a visual indication that it has been edited.</t>
<t>We reuse the Supersedes header from MIXER <xref target="RFC2156"></xref>, because the semantics
are correct: the message included in the body is a replacement for the message
with the superseded message ID.</t>
<t>Here Bob Jones corrects a typo in his original message:</t>

<artwork>Content-type: message/cpim

From: &lt;im:bob-jones@example.com&gt;
DateTime: 2022-02-08T22:13:57-00:00
Message-ID: &lt;89d3472622a4@example.com&gt;
Supersedes: &lt;e701beee59f9@example.com&gt;

Content-Type: text/markdown;charset=utf-8

Right on! _Congratulations_ y'all!
</artwork>
</section>

<section anchor="delete"><name>Delete</name>
<t>In IM systems, a delete means that the author of a specific message has
retracted the message, regardless if other users have read the message
or not. Typically a placeholder remains in the user interface showing
that a message was deleted. Replies which reference a deleted message
typically hide the quoted portion and reflect that the original message
was deleted.</t>
<t>If Bob deleted his message instead of modifying it, we would represent it
using the Supersedes header with an empty body, as shown below.</t>

<artwork>Content-type: message/cpim

From: &lt;im:bob-jones@example.com&gt;
DateTime: 2022-02-08T22:13:57-00:00
Message-ID: &lt;89d3472622a4@example.com&gt;
Supersedes: &lt;e701beee59f9@example.com&gt;

Content-Length: 0
</artwork>
</section>

<section anchor="unlike"><name>Unlike</name>
<t>In most IM systems, not only is it possible to react to a message (&quot;Like&quot;),
but it is possible to remove a previous reaction (&quot;Unlike&quot;). This can be
accomplished by deleting the message which creates the original reaction</t>
<t>If Cathy removes her reaction, we would represent the removal using a
Supercedes header with an empty body, referring to the message which
created the reaction, as shown below.</t>

<artwork>Content-type: message/cpim

From: &lt;im:cathy-washington@example.com&gt;
DateTime: 2022-02-08T22:14:14-00:00
Message-ID: &lt;d052cace46f8@example.com&gt;
Supercedes: &lt;1a771ca1d84f@example.com&gt;

Content-Length: 0
</artwork>
</section>

<section anchor="expiring"><name>Expiring</name>
<t>Expiring messages are designed to be deleted automatically by the receiving
client at a certain time whether they have been read or not.  As with manually
deleted messages, there is no guarantee that a uncooperative client or a
determined user will not save the content of the message, however most clients
respect the convention.</t>
<t>MIXER defines an Expires header which is also used
 sent simply by including an Expires header in the CPIM message body.</t>
<t>To avoid using two different date header syntaxes, we define an
ExpiresDateTime header, which uses the same date/time format as
CPIM's DateTime header. The semantics of the header are that the message
is automatically deleted by the receiving clients at the indicated time
without user interaction or network connectivity necessary.</t>

<artwork>Content-type: message/cpim

From: &lt;im:alice-smith@example.com&gt;
DateTime: 2022-02-08T22:49:03-00:00
Message-ID: &lt;5c95a4dfddab@example.com&gt;
ExpiresDateTime: 2022-02-08T22:59:03-00:00

Content-Type: text/markdown;charset=utf-8

__*VPN GOING DOWN*__
I'm rebooting the VPN in ten minutes unless anyone objects.
</artwork>
</section>

<section anchor="knock"><name>Knock</name>
<t>A knock or ping is message sent to get the attention of a user or a
group of users.  It might be sent when a user has not responded to
direct messages or mentions, or in a group when something requires
the attention of everyone quickly (ex: a serious unusual situation
like a major system outage).</t>
<t>We represent a knock as a text/plain body containing a single CRLF
with the alert Content-Disposition token (defined in <xref target="RFC3261"></xref>).</t>

<artwork>Content-type: message/cpim

From: &lt;im:alice-smith@example.com&gt;
DateTime: 2022-02-08T22:13:45-00:00
Message-ID: &lt;c1a3375bfe3f@example.com&gt;

Content-Type: text/plain
Content-Disposition: alert


</artwork>
</section>

<section anchor="read-receipt"><name>Read Receipt</name>
<t>In instant messaging systems, read receipts typically generate a distinct
indicator for each message. In some systems, the number of users in a group
who have read the message is subtly displayed and the list of users who
read the message is available on further inspection.</t>
<t>Of course, Internet mail has support for read receipts as well, but
the existing message disposition notification mechanism defined for email
in <xref target="RFC8098"></xref> is unfortunately inappropriate in this context.</t>

<ul spacing="compact">
<li>notifications can be sent by intermediaries</li>
<li>only one notification can be sent about a single message per recipient</li>
<li>a human-readable version of the notification is expected</li>
<li>each notification can refer to only one message</li>
<li>it is extremely verbose</li>
</ul>
<t>The proposed format below, message/immi-disposition-notification is sent
by one member of an MLS group to the entire group and can refer to multiple messages. There
is one IMMI-Disposition line per message, with the disposition of the original
message in a parameter. As the disposition at the recipient changes, the disposition
can be updated in a subsequent notification.</t>

<artwork>Content-type: message/cpim

From: &lt;im:bob-jones@example.com&gt;
DateTime: 2022-02-09T07:57:13-00:00
Message-ID: &lt;7e924c2e6ee5@example.com&gt;

Content-Disposition: notification
Content-type: message/immi-disposition-notification

IMMI-Disposition: &lt;4dcab7711a77@example.com&gt;;dispo=read
IMMI-Disposition: &lt;285f75c46430@example.com&gt;;dispo=read
IMMI-Disposition: &lt;c5e0cd6140e6@example.com&gt;;dispo=read
IMMI-Disposition: &lt;5c95a4dfddab@example.com&gt;;dispo=expired
</artwork>
</section>

<section anchor="attachments"><name>Attachments</name>
<t>The message/external-body MIME Type is a convenient way to present a
URL to download an attachment which should not be rendered inline.</t>

<artwork>Content-Type: message/external-body; access-type=&quot;URL&quot;;
 URL=&quot;https://example.com/storage/bigfile.m4v&quot;;
 size=708234961
</artwork>
</section>

<section anchor="conferencing"><name>Conferencing</name>
<t>Joining a conference via URL is also possible. The link could be
rendered to the user, requiring a click. Alternatively another
Content-Disposition could be specified to more automatic actions.
However further calling and conferencing functionality is out-of-scope
of this document.</t>

<artwork>Content-Type: message/external-body; access-type=&quot;URL&quot;;
 URL=&quot;https://example.com/join/12345&quot;
</artwork>
</section>
</section>

<section anchor="immi-cpim-profile"><name>IMMI CPIM profile</name>
<t>We define a profile of CPIM for instant messaging within MLS.
The grammar uses Augmented Backus-Naur Form (BNF) <xref target="RFC5234"></xref>.</t>

<section anchor="cpim-headers"><name>CPIM headers</name>
<t>The following CPIM headers are required:</t>

<ul spacing="compact">
<li>From: the identity of message sender. for example im:alice@example.com
this identity could be pseudonymous or anonymous if the group policy allows.</li>
<li>DateTime: the date and time in a reasonable format, as specified in CPIM.</li>
<li>Message-ID: a message ID which is unique across domains.</li>
<li>Content-type: As is from CPIM.</li>
<li>In-Reply-To: Refers to the previous Message-ID. Same semantics as in
<xref target="RFC5322"></xref>.</li>
<li>Supersedes: Refers to the previous Messsage-ID. Similar semantics to
header of the same name in MIXER.
Content-Disposition:  The intended handling of the message. The two required
dispositions are render and reaction.</li>
<li>Content-Length:</li>
</ul>
<t>For clarity the grammar for the headers not already included in CPIM are
formulated below.</t>

<artwork>msg-id-header-line = msg-id-header &quot;:&quot; SP msg-id CRLF
msg-id-header = &quot;Message-ID&quot;   ; case-sensitive

in-reply-to-header-line = in-reply-to-header &quot;:&quot; SP msg-id CRLF
in-reply-to-header = &quot;In-Reply-To&quot;   ; case-sensitive

supersedes-header-line = supersedes-header &quot;:&quot; SP msg-id CRLF
supersedes-header = &quot;Supersedes&quot;   ; case-sensitive


msg-id = &quot;&lt;&quot; id-left &quot;@&quot; id-right &quot;&gt;&quot;

id-left  = dot-atom-text
id-right = dot-atom-text / no-fold-literal

dot-atom-text   =   1*atext *(&quot;.&quot; 1*atext)

atext = ALPHA / DIGIT / atom-symbol

atom-symbol = &quot;!&quot; / &quot;#&quot; / &quot;$&quot; / &quot;%&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;*&quot; / &quot;+&quot; / &quot;-&quot; /
              &quot;/&quot; / &quot;=&quot; / &quot;?&quot; / &quot;^&quot; / &quot;_&quot; / &quot;`&quot; / &quot;{&quot; / &quot;|&quot; / &quot;}&quot; / &quot;~&quot;

no-fold-literal = &quot;[&quot; *dtext &quot;]&quot;

dtext = %d33-90 / %d94-126 ; Printable US-ASCII
                           ; excluding &quot;[&quot;, &quot;]&quot;, and &quot;\&quot;
</artwork>
</section>

<section anchor="definition-of-message-immi-disposition-notification"><name>Definition of message/immi-disposition-notification</name>
<t>The grammar below defines the syntax.</t>

<artwork>immi-disposition-notification-body = 1*immi-header-line

immi-header-line = immi-header &quot;:&quot; SP msg-id &quot;;&quot; status CRLF

imm-header = &quot;IMMI-Disposition&quot; ; case-sensitive

status = &quot;dispo&quot; &quot;=&quot; status-value

status-value = &quot;read&quot; /
               &quot;error&quot; /
               &quot;delivered&quot; /
               &quot;expired&quot; /
               &quot;deleted&quot; /
               &quot;hidden&quot;
</artwork>
</section>

<section anchor="required-and-recommended-mime-types"><name>Required and Recommended MIME types</name>
<t>The following MIME types are REQUIRED:</t>

<ul spacing="compact">
<li>message/cpim</li>
<li>multipart/alternative</li>
<li>multipart/mixed</li>
<li>multipart/parallel</li>
<li>text/plain</li>
<li>text/markdown</li>
</ul>
<t>The following MIME types are RECOMMENDED:</t>

<ul spacing="compact">
<li>text/html</li>
<li>message/external-body</li>
<li>message/immi-disposition-notification</li>
<li>image/jpeg</li>
<li>image/png</li>
</ul>
</section>
</section>

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

<section anchor="mime-subtype-registration-of-message-immi-disposition-notification"><name>MIME subtype registration of message/immi-disposition-notification</name>
<t>This document proposes registration of a MIME subtype with IANA.</t>

<artwork>TBC
</artwork>
</section>
</section>

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

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.mahy-mimi-problem-outline.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.mahy-mls-content-adv.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2156.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2219.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3261.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3862.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5234.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7763.xml"/>
</references>
<references><name>Informative References</name>
<reference anchor="DoubleRatchet" target="https://signal.org/docs/specifications/doubleratchet/">
  <front>
    <title>The Double Ratchet Algorithm</title>
    <author fullname="Trevor Perrin">
      <organization>Signal</organization>
    </author>
    <author fullname="Moxie Marlinspike">
      <organization>Signal</organization>
    </author>
    <date year="2016" month="November" day="20"></date>
  </front>
</reference>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-mls-protocol.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.mahy-mimi-identity.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2046.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3156.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5322.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6120.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8098.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8551.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9078.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-w3c/reference.W3C.CR-html52-20170808.xml"/>
</references>

<section anchor="tls-presentation-language-multipart-container-format"><name>TLS Presentation Language multipart container format</name>
<t>In a heterogenous group of IM clients, it is often desirable to send more than one
media type as alternatives, such that IM clients have a choice of which media
type to render. For example, imagine an IM group containing a set of clients
which support a common video format and a subset which only support animated GIFs.
The sender could send a <tt>multipart/alternative</tt> <xref target="RFC2046"></xref> container containing
both media types. Every client in the group chat could render something resembling the
media sent.</t>
<t>Likewise it is often desirable to send more than one media type intended to be
rendered together as in (for example a rich text document with embedded images),
which can be represented using the <tt>multipart/mixed</tt> <xref target="RFC2046"></xref> media type.</t>
<t>Some implementors complain that the multipart types are unnatural to use inside a
binary protocol which requires explicit lengths such as MLS
<xref target="I-D.ietf-mls-protocol"></xref>. Concretely, an implementation has to scan through the
entire content to construct a boundary token which is not contained in the content.</t>
<t>While the author does not care about the specific syntax used, for comparison
purposes presents a multipart container format using the TLS presentation language
syntax used by the MLS protocol.</t>
<t>Note that there is a minor semantic difference between multipart/alternative and
the proposal below. In multipart/alternative, the parts are presented in
preference order by the sender. The receiver is support to render the first type
which it supports. This container includes an ordering flag. As well, even if the
flag is ordered, it is up to the IETF community to decide if it is acceptable for
the receiver to choose its &quot;best&quot; format to render among an ordered preference list
provided by the sender, or if the receiver must respect the ordered preference of
the sender.</t>

<sourcecode type="tls">struct {
    /* a valid &quot;Language-tag&quot; as defined in RFC 5646 */
    opaque language_tag&lt;1..52&gt;;
} LanguageTag;

struct {
  ContentType content_type;
  LanguageTag content_languages&lt;V&gt;;
  opaque&lt;V&gt; body;
} Part;

enum {
  reserved(0),
  multipart_container_v1(1),
  (255)
} MultipartVersion;

enum {
  reserved(0),
  mixed(1),
  alternative(2),
  (255)
} MultipartSemantics;

enum {
  reserved(0),
  unordered(1),
  ordered(2),
  (255)
} MultipartOrdering;

struct {
    uint8 container_version;
    uint16 number_of_parts;
    MultipartSemantics semantics;
    MultipartOrdering ordering;
    Part parts&lt;V&gt;;
} MultipartContainer;
</sourcecode>
</section>

</back>

</rfc>
