<?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.30 (Ruby 3.4.7) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-robert-mimi-attachments-05" category="info" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.31.0 -->
  <front>
    <title abbrev="MIMI">MIMI Attachments</title>
    <seriesInfo name="Internet-Draft" value="draft-robert-mimi-attachments-05"/>
    <author initials="R." surname="Robert" fullname="Raphael Robert">
      <organization>Phoenix R&amp;D</organization>
      <address>
        <email>ietf@raphaelrobert.com</email>
      </address>
    </author>
    <author initials="K." surname="Kohbrok" fullname="Konrad Kohbrok">
      <organization>Phoenix R&amp;D</organization>
      <address>
        <email>konrad.kohbrok@datashrine.de</email>
      </address>
    </author>
    <date year="2026" month="January" day="05"/>
    <area>Security</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <?line 24?>

<t>This document describes MIMI Attachments.</t>
    </abstract>
  </front>
  <middle>
    <?line 28?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>Attachments are known from email, where they are used to attach files to an
email message. Attachments are also used in instant messaging, where they are
used to attach files, images, videos, etc.</t>
      <t>The main difference between attachments and other messages is that attachments
are bigger in size and their content is typically saved in files on the client
side. Since downloading attachments can be expensive for instant messaging
clients, it is common to download attachments only on demand, e.g. when the user
clicks on the attachment.</t>
      <t>draft-mimi-content defines various message content formats that can be used in
either MLS application messages or attachments. This document describes how
attachments are used in MIMI.</t>
      <section anchor="change-log">
        <name>Change Log</name>
        <t>draft-01</t>
        <ul spacing="normal">
          <li>
            <t>Version bump to prevent expiration</t>
          </li>
        </ul>
        <t>draft-02</t>
        <ul spacing="normal">
          <li>
            <t>Version bump to prevent expiration</t>
          </li>
        </ul>
        <t>draft-03</t>
        <ul spacing="normal">
          <li>
            <t>Version bump to prevent expiration</t>
          </li>
        </ul>
        <t>draft-04</t>
        <ul spacing="normal">
          <li>
            <t>Version bump to prevent expiration</t>
          </li>
        </ul>
        <t>draft-05</t>
        <ul spacing="normal">
          <li>
            <t>Version bump to prevent expiration</t>
          </li>
        </ul>
      </section>
    </section>
    <section anchor="access-control-quotas">
      <name>Access control &amp; quotas</name>
      <t>Attachments are bound to a specific MLS group. Only members of the group can
access the attachment. The Delivery Service enforces this access control.</t>
      <t>The Delivery Service can keep track of the size of attachments for each group,
its total number, who uploaded them, etc. This information can be used to
enforce quotas on the size of attachments, the number of attachments, etc.</t>
    </section>
    <section anchor="distribution">
      <name>Distribution</name>
      <t>Since attachments are not directly distributed as messages, they are distributed
over the MIMI Delivery Service.</t>
      <section anchor="uploading-attachments">
        <name>Uploading attachments</name>
        <t>When a client wants to send an attachment, it first uploads the attachment to
the Delivery Service. The Delivery Service returns a token that can be used to
download the attachment. The client then sends a message that contains the URL
and cryptographic key material to the intended recipients.</t>
        <t>TODO: This probably become part of <em>draft-robert-mimi-delivery-service</em>.</t>
        <t>The client first encrypts the attachment as descibed in <xref target="encryption"/> and then
uploads it to the DS using the following message:</t>
        <sourcecode type="tls"><![CDATA[
struct {
  opaque group_id<V>;
  opaque content<V>;
} UploadAttachmentRequest;
]]></sourcecode>
        <t>Upon succes, the Delivery Service returns the following message:</t>
        <sourcecode type="tls"><![CDATA[
struct {
  opaque token<V>;
} UploadAttachmentResponse;
]]></sourcecode>
      </section>
      <section anchor="sending-attachments">
        <name>Sending attachments</name>
        <t>Once clients have uploaded an attachment to the Delivery Service, they can send
messages that contain a reference to the attachment. The client sets the
contentType of the body as follows:</t>
        <sourcecode type="tls"><![CDATA[
body.contentType = "message/external-body; access-type=token;" +
  "token=<token>; nonce=<nonce>; hash=<hash>";
]]></sourcecode>
        <t>The token is the token that was received from the Delivery Service as part of
the UploadAttachmentResponse message. The nonce is a random byte sequence that
is used in the key derivation descibed in <xref target="encryption"/>. The hash is the hash
of the plaintext attachment content, as defined in <xref target="encryption"/>. The hash acts
as a commitment hash for the attachment content.</t>
        <t>TODO: This needs to be better aligned with draft-ietf-mimi-content.</t>
      </section>
      <section anchor="receiving-attachments">
        <name>Receiving attachments</name>
        <t>When a client receives a message that contains a reference to an attachment, it
first downloads the attachment from the Delivery Service using the following
message:</t>
        <sourcecode type="tls"><![CDATA[
struct {
  opaque group_id<V>;
  opaque token<V>;
} DownloadAttachmentRequest;
]]></sourcecode>
        <t>Upon succes, the Delivery Service returns the following message:</t>
        <sourcecode type="tls"><![CDATA[
struct {
  opaque content<V>;
} DownloadAttachmentResponse;
]]></sourcecode>
        <t>The client then decrypts the attachment using the nonce for the key derivation
 described in <xref target="encryption"/>.</t>
      </section>
      <section anchor="deleting-attachments">
        <name>Deleting attachments</name>
        <t>Attachments can either be deleted by members of the group (according to a
predefined policy), or by the Delivery Service after a predefined time.</t>
      </section>
      <section anchor="access-control">
        <name>Access control</name>
        <t>Attachments are bound to a specific MLS group. Only members of the group can
access the attachment. The Delivery Service enforces this access control.</t>
        <t>Attachments can however be shared between groups by either re-uploading the
attachment to the Delivery Service or by asking the Delivery Service to copy an
attachment to another group. Copying an attachment to another group is only
possible if both groups are located on the same Delivery Service, and the user
has access to both groups. It is an optimization to avoid re-uploading the same
attachment multiple times, but otherwise follows the same rules as uploading a
new attachment.</t>
      </section>
      <section anchor="encryption">
        <name>Encryption</name>
        <t>Attachments are encrypted using a nonce/key pair that is exported from the MLS
group exporter and combined with a randomly generated byte sequence on the
sender's side, and context data.</t>
        <artwork><![CDATA[
struct {
   opaque attachment_hash;
   uint64 sender_index;
} AttachmentContext;
]]></artwork>
        <t>Since attachments are specific to an MLS group, we reuse components the cipher
suite of the group:</t>
        <ul spacing="normal">
          <li>
            <t>KDF</t>
          </li>
          <li>
            <t>Hash</t>
          </li>
          <li>
            <t>AEAD</t>
          </li>
          <li>
            <t>ExpandWithLabel</t>
          </li>
        </ul>
        <t>The sender encrypts the attachment as follows:</t>
        <ul spacing="normal">
          <li>
            <t>Compute the hash of the attachment data:</t>
          </li>
        </ul>
        <artwork><![CDATA[
attachment_hash = Hash(plaintext)
]]></artwork>
        <ul spacing="normal">
          <li>
            <t>Generate a random byte sequence <tt>nonce</tt> of length <tt>KDF.Nh</tt> bytes.</t>
          </li>
          <li>
            <t>Set the context to the following values: <tt>AttachmentContext.hash</tt>
to the previously computed <tt>attachment_hash</tt> and
<tt>AttachmentContext.sender_index</tt> to the leaf index of the sender in the group.</t>
          </li>
          <li>
            <t>Compute a secret <tt>attachment_exporter_secret</tt> from the MLS group
exporter using the previously computed context and extracts
<tt>attachment_secret</tt> from it and the nonce:</t>
          </li>
        </ul>
        <artwork><![CDATA[
attachment_exporter_secret =
   MLS-Exporter("MIMI attachment", context, KDF.Nh)

attachment_secret =
   KDF.Extract(attachment_exporter_secret, nonce)
]]></artwork>
        <ul spacing="normal">
          <li>
            <t>Compute the nonce/key pair:</t>
          </li>
        </ul>
        <artwork><![CDATA[
attachment_nonce =
   ExpandWithLabel(attachment_secret, "nonce", "", AEAD.Nn)

attachment_key =
   ExpandWithLabel(attachment_secret, "key", "", AEAD.Nk)
]]></artwork>
        <ul spacing="normal">
          <li>
            <t>Encrypt the attachment using the key/nonce pair.</t>
          </li>
        </ul>
      </section>
    </section>
  </middle>
  <back>








  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA81Ya28buRX9zl9B2MDW2UqKm+4WqBwHa0RuGyTZFHay+6Eo
LM4MJRGaGc6SHMnaIPntPZfkvPTYTfqlDRCPJJL3ee65lzMej5lTLpdT/vbV
21f8xjmRrgpZOstEkhi5CQss02kpCmzLjFi4sdGJNG5cqEKNRXdmfPk9S4WT
S212U67KhWZMVWbKnamte3Z5+dfLZ0wYKab8Xqa1UW7H1nK31Sab8lelk6aU
bjwjFYxZJ8rsQeS6hNqdtKxSU/4vp9MR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