<?xml version='1.0' encoding='UTF-8'?>

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

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-core-oscore-edhoc-11" number="9668" updates="" obsoletes="" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3" xml:lang="en">

  <front>
    <title abbrev="Using EDHOC with CoAP and OSCORE">Using Ephemeral Diffie-Hellman Over COSE (EDHOC) with the Constrained Application Protocol (CoAP) and Object Security for Constrained RESTful Environments (OSCORE)</title>
    <seriesInfo name="RFC" value="9668"/>
    <author initials="F." surname="Palombini" fullname="Francesca Palombini">
      <organization>Ericsson AB</organization>
      <address>
	<postal>
	  <street>Torshamnsgatan 23</street>
	  <city>Kista</city>
	  <code>164 40</code>
	  <country>Sweden</country>
	</postal>
        <email>francesca.palombini@ericsson.com</email>
      </address>
    </author>
    <author initials="M." surname="Tiloca" fullname="Marco Tiloca">
      <organization>RISE AB</organization>
      <address>
        <postal>
          <street>Isafjordsgatan 22</street>
          <city>Kista</city>
          <code>164 40</code>
          <country>Sweden</country>
        </postal>
        <email>marco.tiloca@ri.se</email>
      </address>
    </author>
    <author initials="R." surname="Höglund" fullname="Rikard Höglund">
      <organization>RISE AB</organization>
      <address>
        <postal>
          <street>Isafjordsgatan 22</street>
          <city>Kista</city>
          <code>164 40</code>
          <country>Sweden</country>
        </postal>
        <email>rikard.hoglund@ri.se</email>
      </address>
    </author>
    <author initials="S." surname="Hristozov" fullname="Stefan Hristozov">
      <organization>Eriptic</organization>
      <address>
        <email>stefan.hristozov@eriptic.com</email>
      </address>
    </author>
    <author initials="G." surname="Selander" fullname="Göran Selander">
      <organization>Ericsson</organization>
      <address>
        <email>goran.selander@ericsson.com</email>
      </address>
    </author>
    <date year="2024" month="November"/>
    <area>WIT</area>
    <workgroup>core</workgroup>
<keyword>Security</keyword>
<keyword>Key agreement; Secure communication</keyword>
<keyword>Constrained enviornments</keyword>
<keyword>AKE</keyword>
<keyword>lightweight authenticated key exchange</keyword>
<keyword>IoT security</keyword>
    <abstract>
      <t>The lightweight authenticated key exchange protocol Ephemeral Diffie-Hellman Over COSE (EDHOC) can be run over the Constrained Application Protocol (CoAP) and used by two peers to establish a Security Context for the security protocol Object Security for Constrained RESTful Environments (OSCORE). This document details this use of the EDHOC protocol by specifying a number of additional and optional mechanisms, including an optimization approach for combining the execution of EDHOC with the first OSCORE transaction. This combination reduces the number of round trips required to set up an OSCORE Security Context and to complete an OSCORE transaction using that Security Context.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t>Ephemeral Diffie-Hellman Over COSE (EDHOC) <xref target="RFC9528"/> is a lightweight authenticated key exchange protocol that is specifically intended for use in constrained scenarios. In particular, EDHOC messages can be transported over the Constrained Application Protocol (CoAP) <xref target="RFC7252"/> and used for establishing a Security Context for Object Security for Constrained RESTful Environments (OSCORE) <xref target="RFC8613"/>.</t>
      <t>This document details the use of the EDHOC protocol with CoAP and OSCORE and specifies a number of additional and optional mechanisms. These include an optimization approach that combines the EDHOC execution with the first OSCORE transaction (see <xref target="edhoc-in-oscore"/>). This allows for a minimum number of two round trips necessary to set up the OSCORE Security Context and complete an OSCORE transaction, e.g., when an Internet of Things (IoT) device gets configured in a network for the first time.</t>
      <t>This optimization is desirable since the number of message exchanges can have a substantial impact on the latency of conveying the first OSCORE request when using certain radio technologies.</t>
      <t>Without this optimization, it is not possible to achieve the minimum number of two round trips. This optimization makes it possible since the message_3 of the EDHOC protocol can be made relatively small (see <xref section="1.2" sectionFormat="of" target="RFC9528"/>), thus allowing additional OSCORE-protected CoAP data within target MTU sizes.</t>

<t>The minimum number of two round trips can be achieved only if the default forward message flow of EDHOC is used, i.e., when a CoAP client acts as EDHOC Initiator and a CoAP server acts as EDHOC Responder. The performance advantage of using this optimization can be lost when used in combination with Block-wise transfers <xref target="RFC7959"/> that rely on specific parameter values and block sizes.</t>
<t>Furthermore, this document defines a number of parameters corresponding to
different information elements of an EDHOC application profile (see <xref target="web-linking"/>). These parameters can be specified as target attributes in the link to an
EDHOC resource associated with that application profile, thus enabling an
enhanced discovery of such a resource for CoAP clients.
</t>
      <section anchor="terminology">
        <name>Terminology</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&nbsp;14 <xref target="RFC2119"/> <xref
    target="RFC8174"/> when, and only when, they appear in all capitals, as
    shown here.
        </t>
        <t>The reader is expected to be familiar with terms and concepts defined in CoAP <xref target="RFC7252"/>, Concise Binary Object Representation (CBOR) <xref target="RFC8949"/>, OSCORE <xref target="RFC8613"/>, and EDHOC <xref target="RFC9528"/>.</t>
      </section>
    </section>
    <section anchor="overview">
      <name>EDHOC Overview</name>
      <t>This section is not normative and summarizes what is specified in <xref target="RFC9528"/> (specifically <xref target="RFC9528" sectionFormat="of" section="A.2"></xref>). Thus, it provides a baseline for the enhancements in the subsequent sections.</t>
      <t>The EDHOC protocol specified in <xref target="RFC9528"/> allows two peers to agree on a cryptographic secret in a mutually-authenticated way and achieves forward secrecy by using Diffie-Hellman ephemeral keys. The two peers are denoted as the "Initiator" and "Responder", as the one sending or receiving the initial EDHOC message_1, respectively.</t>
      <t>After successful processing of EDHOC message_3, both peers agree on a cryptographic secret that can be used to derive further security material and establish an OSCORE Security Context <xref target="RFC8613"/>. The Responder can also send an optional EDHOC message_4 in order for the Initiator to achieve key confirmation, e.g., in deployments where no protected application message is sent from the Responder to the Initiator.</t>
      <t><xref section="A.2" sectionFormat="of" target="RFC9528"/> specifies how to transfer EDHOC over CoAP.  That is, the EDHOC data (i.e., the EDHOC message possibly with a prepended connection identifier) is transported in the payload of CoAP requests and responses. The default forward message flow of EDHOC consists in the CoAP client acting as Initiator and the CoAP server acting as Responder (see <xref section="A.2.1" sectionFormat="of" target="RFC9528"/>). Alternatively, the two roles can be reversed as per the reverse message flow of EDHOC (see <xref section="A.2.2" sectionFormat="of" target="RFC9528"/>). In the rest of this document, EDHOC messages are considered to be transferred over CoAP.</t>
      <t><xref target="fig-non-combined"/> shows a successful execution of EDHOC, with a CoAP client and a CoAP server running EDHOC as Initiator and Responder, respectively. In particular, it extends Figure 10 from <xref section="A.2.1" sectionFormat="of" target="RFC9528"/> by highlighting when the two peers perform EDHOC verification and establish the OSCORE Security Context, and by adding an exchange of OSCORE-protected CoAP messages after completing the EDHOC execution.</t>     
      <t>That is, the client sends a POST request to a reserved EDHOC resource at the server, by default at the Uri-Path "/.well-known/edhoc". The request payload consists of the CBOR simple value <tt>true</tt> (0xf5) concatenated with EDHOC message_1, which also includes the EDHOC connection identifier C_I of the client encoded as per <xref section="3.3" sectionFormat="of" target="RFC9528"/>. The request has Content-Format application/cid-edhoc+cbor-seq.</t>
      <t>This triggers the EDHOC execution at the server, which replies with a 2.04 (Changed) response. The response payload consists of EDHOC message_2, which also includes the EDHOC connection identifier C_R of the server encoded as per <xref section="3.3" sectionFormat="of" target="RFC9528"/>. The response has Content-Format application/edhoc+cbor-seq.</t>
      <t>Finally, the client sends a POST request to the same EDHOC resource used earlier when it sent EDHOC message_1. The request payload consists of the EDHOC connection identifier C_R encoded as per <xref section="3.3" sectionFormat="of" target="RFC9528"/> concatenated with EDHOC message_3. The request has Content-Format application/cid-edhoc+cbor-seq.</t>
      <t>After this exchange takes place, and after successful verifications as specified in the EDHOC protocol, the client and server can derive an OSCORE Security Context as defined in <xref section="A.1" sectionFormat="of" target="RFC9528"/>. After that, the client and server can use OSCORE to protect their communications as per <xref target="RFC8613"/>. Note that the EDHOC connection identifier C_R is used as the OSCORE Sender ID of the client (see <xref section="A.1" sectionFormat="of" target="RFC9528"/>). Therefore, C_R is transported in the 'kid' field of the OSCORE option of the OSCORE Request (see <xref section="6.1" sectionFormat="of" target="RFC8613"/>).</t>
      <t>The client and server are required to agree in advance on certain information and parameters describing how they should use EDHOC. These are specified in an application profile associated with the EDHOC resource addressed (see <xref section="3.9" sectionFormat="of" target="RFC9528"/>).</t>
<figure anchor="fig-non-combined">
        <name>Sequential Flow of EDHOC and OSCORE with the Optional message_4
        Included</name>
        <artset>
          <artwork type="svg" align="center"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="768" width="544" viewBox="0 0 544 768" class="diagram" text-anchor="middle" font-family="monospace" font-size="13px">
              <path d="M 64,64 L 64,256" fill="none" stroke="black"/>
              <path d="M 64,288 L 64,544" fill="none" stroke="black"/>
              <path d="M 64,592 L 64,752" fill="none" stroke="black"/>
              <path d="M 488,64 L 488,384" fill="none" stroke="black"/>
              <path d="M 488,464 L 488,752" fill="none" stroke="black"/>
              <path d="M 80,96 L 208,96" fill="none" stroke="black"/>
              <path d="M 336,96 L 472,96" fill="none" stroke="black"/>
              <path d="M 80,192 L 208,192" fill="none" stroke="black"/>
              <path d="M 336,192 L 472,192" fill="none" stroke="black"/>
              <path d="M 80,304 L 208,304" fill="none" stroke="black"/>
              <path d="M 336,304 L 472,304" fill="none" stroke="black"/>
              <path d="M 80,480 L 208,480" fill="none" stroke="black"/>
              <path d="M 336,480 L 472,480" fill="none" stroke="black"/>
              <path d="M 80,608 L 200,608" fill="none" stroke="black"/>
              <path d="M 336,608 L 472,608" fill="none" stroke="black"/>
              <path d="M 80,688 L 200,688" fill="none" stroke="black"/>
              <path d="M 344,688 L 472,688" fill="none" stroke="black"/>
              <polygon class="arrowhead" points="480,608 468,602.4 468,613.6" fill="black" transform="rotate(0,472,608)"/>
              <polygon class="arrowhead" points="480,304 468,298.4 468,309.6" fill="black" transform="rotate(0,472,304)"/>
              <polygon class="arrowhead" points="480,96 468,90.4 468,101.6" fill="black" transform="rotate(0,472,96)"/>
              <polygon class="arrowhead" points="88,688 76,682.4 76,693.6" fill="black" transform="rotate(180,80,688)"/>
              <polygon class="arrowhead" points="88,480 76,474.4 76,485.6" fill="black" transform="rotate(180,80,480)"/>
              <polygon class="arrowhead" points="88,192 76,186.4 76,197.6" fill="black" transform="rotate(180,80,192)"/>
              <g class="text">
                <text x="36" y="36">CoAP</text>
                <text x="84" y="36">client</text>
                <text x="452" y="36">CoAP</text>
                <text x="500" y="36">server</text>
                <text x="28" y="52">(EDHOC</text>
                <text x="100" y="52">Initiator)</text>
                <text x="428" y="52">(EDHOC</text>
                <text x="500" y="52">Responder)</text>
                <text x="240" y="100">EDHOC</text>
                <text x="296" y="100">Request</text>
                <text x="120" y="116">Header:</text>
                <text x="172" y="116">0.02</text>
                <text x="220" y="116">(POST)</text>
                <text x="128" y="132">Uri-Path:</text>
                <text x="252" y="132">"/.well-known/edhoc"</text>
                <text x="152" y="148">Content-Format:</text>
                <text x="340" y="148">application/cid-edhoc+cbor-seq</text>
                <text x="124" y="164">Payload:</text>
                <text x="184" y="164">true,</text>
                <text x="232" y="164">EDHOC</text>
                <text x="296" y="164">message_1</text>
                <text x="240" y="196">EDHOC</text>
                <text x="300" y="196">Response</text>
                <text x="152" y="212">Header:</text>
                <text x="204" y="212">2.04</text>
                <text x="264" y="212">(Changed)</text>
                <text x="184" y="228">Content-Format:</text>
                <text x="356" y="228">application/edhoc+cbor-seq</text>
                <text x="156" y="244">Payload:</text>
                <text x="216" y="244">EDHOC</text>
                <text x="280" y="244">message_2</text>
                <text x="24" y="276">EDHOC</text>
                <text x="100" y="276">verification</text>
                <text x="240" y="308">EDHOC</text>
                <text x="296" y="308">Request</text>
                <text x="120" y="324">Header:</text>
                <text x="172" y="324">0.02</text>
                <text x="220" y="324">(POST)</text>
                <text x="128" y="340">Uri-Path:</text>
                <text x="252" y="340">"/.well-known/edhoc"</text>
                <text x="152" y="356">Content-Format:</text>
                <text x="340" y="356">application/cid-edhoc+cbor-seq</text>
                <text x="124" y="372">Payload:</text>
                <text x="180" y="372">C_R,</text>
                <text x="224" y="372">EDHOC</text>
                <text x="288" y="372">message_3</text>
                <text x="416" y="404">EDHOC</text>
                <text x="492" y="404">verification</text>
                <text x="488" y="420">+</text>
                <text x="444" y="436">OSCORE</text>
                <text x="488" y="436">Sec</text>
                <text x="520" y="436">Ctx</text>
                <text x="468" y="452">Derivation</text>
                <text x="240" y="484">EDHOC</text>
                <text x="300" y="484">Response</text>
                <text x="152" y="500">Header:</text>
                <text x="204" y="500">2.04</text>
                <text x="264" y="500">(Changed)</text>
                <text x="184" y="516">Content-Format:</text>
                <text x="356" y="516">application/edhoc+cbor-seq</text>
                <text x="156" y="532">Payload:</text>
                <text x="216" y="532">EDHOC</text>
                <text x="280" y="532">message_4</text>
                <text x="28" y="564">OSCORE</text>
                <text x="72" y="564">Sec</text>
                <text x="104" y="564">Ctx</text>
                <text x="52" y="580">Derivation</text>
                <text x="236" y="612">OSCORE</text>
                <text x="296" y="612">Request</text>
                <text x="120" y="628">Header:</text>
                <text x="172" y="628">0.02</text>
                <text x="220" y="628">(POST)</text>
                <text x="120" y="644">OSCORE:</text>
                <text x="160" y="644">{</text>
                <text x="184" y="644">...</text>
                <text x="208" y="644">;</text>
                <text x="236" y="644">kid:</text>
                <text x="272" y="644">C_R</text>
                <text x="296" y="644">}</text>
                <text x="124" y="660">Payload:</text>
                <text x="228" y="660">OSCORE-protected</text>
                <text x="316" y="660">data</text>
                <text x="236" y="692">OSCORE</text>
                <text x="300" y="692">Response</text>
                <text x="232" y="708">Header:</text>
                <text x="284" y="708">2.04</text>
                <text x="344" y="708">(Changed)</text>
                <text x="232" y="724">OSCORE:</text>
                <text x="272" y="724">{</text>
                <text x="296" y="724">...</text>
                <text x="320" y="724">}</text>
                <text x="236" y="740">Payload:</text>
                <text x="340" y="740">OSCORE-protected</text>
                <text x="428" y="740">data</text>
              </g>
            </svg>
          </artwork>
          <artwork type="ascii-art" align="center"><![CDATA[
  CoAP client                                         CoAP server
(EDHOC Initiator)                                 (EDHOC Responder)
       |                                                    |
       |                                                    |
       | ----------------- EDHOC Request -----------------> |
       |   Header: 0.02 (POST)                              |
       |   Uri-Path: "/.well-known/edhoc"                   |
       |   Content-Format: application/cid-edhoc+cbor-seq   |
       |   Payload: true, EDHOC message_1                   |
       |                                                    |
       | <---------------- EDHOC Response------------------ |
       |       Header: 2.04 (Changed)                       |
       |       Content-Format: application/edhoc+cbor-seq   |
       |       Payload: EDHOC message_2                     |
       |                                                    |
EDHOC verification                                          |
       |                                                    |
       | ----------------- EDHOC Request -----------------> |
       |   Header: 0.02 (POST)                              |
       |   Uri-Path: "/.well-known/edhoc"                   |
       |   Content-Format: application/cid-edhoc+cbor-seq   |
       |   Payload: C_R, EDHOC message_3                    |
       |                                                    |
       |                                         EDHOC verification
       |                                                    +
       |                                            OSCORE Sec Ctx
       |                                             Derivation
       |                                                    |
       | <---------------- EDHOC Response------------------ |
       |       Header: 2.04 (Changed)                       |
       |       Content-Format: application/edhoc+cbor-seq   |
       |       Payload: EDHOC message_4                     |
       |                                                    |
OSCORE Sec Ctx                                              |
 Derivation                                                 |
       |                                                    |
       | ---------------- OSCORE Request -----------------> |
       |   Header: 0.02 (POST)                              |
       |   OSCORE: { ... ; kid: C_R }                       |
       |   Payload: OSCORE-protected data                   |
       |                                                    |
       | <--------------- OSCORE Response ----------------- |
       |                 Header: 2.04 (Changed)             |
       |                 OSCORE: { ... }                    |
       |                 Payload: OSCORE-protected data     |
       |                                                    |
]]></artwork>
        </artset>
      </figure>
<t>  The sequential flow of EDHOC and OSCORE (where EDHOC runs first and
  OSCORE is used after) takes three round trips to complete, as shown in <xref target="fig-non-combined"/>.</t>
      <t><xref target="edhoc-in-oscore"/> defines an optimization for combining EDHOC with the first OSCORE transaction. This reduces the number of round trips required to set up an OSCORE Security Context and complete an OSCORE transaction using that Security Context.</t>
    </section>
    <section anchor="edhoc-in-oscore">
      <name>EDHOC Combined with OSCORE</name>
      <t>This section defines an optimization for combining the EDHOC message exchange with the first OSCORE transaction, thus minimizing the number of round trips between the two peers to the absolute possible minimum of two round trips.</t>
      <t>To this end, this approach can be used only if the default forward message flow of EDHOC is used, i.e., when the client acts as Initiator and the server acts as Responder. The same is not possible in the case with reversed roles as per the reverse message flow of EDHOC.</t>
      <t>When running the sequential flow of <xref target="overview"/>, the client has all the information to derive the OSCORE Security Context already after receiving EDHOC message_2 and before sending EDHOC message_3.</t>
      <t>Hence, the client can potentially send both EDHOC message_3 and the subsequent OSCORE Request at the same time. On a semantic level, this requires sending two REST requests at once as shown in <xref target="fig-combined"/>.</t>
      <figure anchor="fig-combined">
        <name>EDHOC and OSCORE Combined</name>
        <artset>
          <artwork type="svg" align="center"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="576" width="552" viewBox="0 0 552 576" class="diagram" text-anchor="middle" font-family="monospace" font-size="13px">
              <path d="M 64,64 L 64,240" fill="none" stroke="black"/>
              <path d="M 64,320 L 64,560" fill="none" stroke="black"/>
              <path d="M 496,64 L 496,400" fill="none" stroke="black"/>
              <path d="M 496,480 L 496,560" fill="none" stroke="black"/>
              <path d="M 80,80 L 216,80" fill="none" stroke="black"/>
              <path d="M 344,80 L 480,80" fill="none" stroke="black"/>
              <path d="M 80,176 L 216,176" fill="none" stroke="black"/>
              <path d="M 344,176 L 480,176" fill="none" stroke="black"/>
              <path d="M 80,336 L 184,336" fill="none" stroke="black"/>
              <path d="M 384,336 L 480,336" fill="none" stroke="black"/>
              <path d="M 80,496 L 200,496" fill="none" stroke="black"/>
              <path d="M 344,496 L 480,496" fill="none" stroke="black"/>
              <polygon class="arrowhead" points="488,336 476,330.4 476,341.6" fill="black" transform="rotate(0,480,336)"/>
              <polygon class="arrowhead" points="488,80 476,74.4 476,85.6" fill="black" transform="rotate(0,480,80)"/>
              <polygon class="arrowhead" points="88,496 76,490.4 76,501.6" fill="black" transform="rotate(180,80,496)"/>
              <polygon class="arrowhead" points="88,176 76,170.4 76,181.6" fill="black" transform="rotate(180,80,176)"/>
              <g class="text">
                <text x="36" y="36">CoAP</text>
                <text x="84" y="36">client</text>
                <text x="460" y="36">CoAP</text>
                <text x="508" y="36">server</text>
                <text x="28" y="52">(EDHOC</text>
                <text x="100" y="52">Initiator)</text>
                <text x="436" y="52">(EDHOC</text>
                <text x="508" y="52">Responder)</text>
                <text x="248" y="84">EDHOC</text>
                <text x="304" y="84">Request</text>
                <text x="120" y="100">Header:</text>
                <text x="172" y="100">0.02</text>
                <text x="220" y="100">(POST)</text>
                <text x="128" y="116">Uri-Path:</text>
                <text x="252" y="116">"/.well-known/edhoc"</text>
                <text x="152" y="132">Content-Format:</text>
                <text x="340" y="132">application/cid-edhoc+cbor-seq</text>
                <text x="124" y="148">Payload:</text>
                <text x="184" y="148">true,</text>
                <text x="232" y="148">EDHOC</text>
                <text x="296" y="148">message_1</text>
                <text x="248" y="180">EDHOC</text>
                <text x="308" y="180">Response</text>
                <text x="160" y="196">Header:</text>
                <text x="224" y="196">2.04</text>
                <text x="284" y="196">(Changed)</text>
                <text x="192" y="212">Content-Format:</text>
                <text x="364" y="212">application/edhoc+cbor-seq</text>
                <text x="164" y="228">Payload:</text>
                <text x="224" y="228">EDHOC</text>
                <text x="288" y="228">message_2</text>
                <text x="24" y="260">EDHOC</text>
                <text x="100" y="260">verification</text>
                <text x="64" y="276">+</text>
                <text x="36" y="292">OSCORE</text>
                <text x="80" y="292">Sec</text>
                <text x="112" y="292">Ctx</text>
                <text x="68" y="308">Derivation</text>
                <text x="216" y="340">EDHOC</text>
                <text x="248" y="340">+</text>
                <text x="284" y="340">OSCORE</text>
                <text x="344" y="340">Request</text>
                <text x="120" y="356">Header:</text>
                <text x="172" y="356">0.02</text>
                <text x="220" y="356">(POST)</text>
                <text x="120" y="372">OSCORE:</text>
                <text x="160" y="372">{</text>
                <text x="184" y="372">...</text>
                <text x="208" y="372">;</text>
                <text x="236" y="372">kid:</text>
                <text x="272" y="372">C_R</text>
                <text x="296" y="372">}</text>
                <text x="124" y="388">Payload:</text>
                <text x="184" y="388">EDHOC</text>
                <text x="248" y="388">message_3</text>
                <text x="296" y="388">+</text>
                <text x="372" y="388">OSCORE-protected</text>
                <text x="460" y="388">data</text>
                <text x="424" y="420">EDHOC</text>
                <text x="500" y="420">verification</text>
                <text x="496" y="436">+</text>
                <text x="444" y="452">OSCORE</text>
                <text x="488" y="452">Sec</text>
                <text x="520" y="452">Ctx</text>
                <text x="484" y="468">Derivation</text>
                <text x="236" y="500">OSCORE</text>
                <text x="300" y="500">Response</text>
                <text x="256" y="516">Header:</text>
                <text x="308" y="516">2.04</text>
                <text x="368" y="516">(Changed)</text>
                <text x="256" y="532">OSCORE:</text>
                <text x="296" y="532">{</text>
                <text x="320" y="532">...</text>
                <text x="344" y="532">}</text>
                <text x="260" y="548">Payload:</text>
                <text x="364" y="548">OSCORE-protected</text>
                <text x="452" y="548">data</text>
              </g>
            </svg>
          </artwork>
          <artwork type="ascii-art" align="center"><![CDATA[
  CoAP client                                          CoAP server
(EDHOC Initiator)                                  (EDHOC Responder)
       |                                                     |
       | ------------------ EDHOC Request -----------------> |
       |   Header: 0.02 (POST)                               |
       |   Uri-Path: "/.well-known/edhoc"                    |
       |   Content-Format: application/cid-edhoc+cbor-seq    |
       |   Payload: true, EDHOC message_1                    |
       |                                                     |
       | <----------------- EDHOC Response------------------ |
       |        Header: 2.04 (Changed)                       |
       |        Content-Format: application/edhoc+cbor-seq   |
       |        Payload: EDHOC message_2                     |
       |                                                     |
EDHOC verification                                           |
       +                                                     |
 OSCORE Sec Ctx                                              |
   Derivation                                                |
       |                                                     |
       | -------------- EDHOC + OSCORE Request ------------> |
       |   Header: 0.02 (POST)                               |
       |   OSCORE: { ... ; kid: C_R }                        |
       |   Payload: EDHOC message_3 + OSCORE-protected data  |
       |                                                     |
       |                                          EDHOC verification
       |                                                     +
       |                                            OSCORE Sec Ctx
       |                                               Derivation
       |                                                     |
       | <--------------- OSCORE Response ------------------ |
       |                    Header: 2.04 (Changed)           |
       |                    OSCORE: { ... }                  |
       |                    Payload: OSCORE-protected data   |
       |                                                     |
]]></artwork>
        </artset>
      </figure>      
      <t>To this end, the specific approach defined in this section consists of sending a single EDHOC + OSCORE request, which conveys the pair (C_R, EDHOC message_3) within an OSCORE-protected CoAP message.</t>
      <t>That is, the EDHOC + OSCORE request is composed of the following two
      parts combined together in a single CoAP message. The steps for
      processing the EDHOC + OSCORE request and the two parts combined in the
      request itself are defined in Sections <xref target="client-processing"
      format="counter"/> and <xref target="server-processing"
      format="counter"/>.</t>
      <ul spacing="normal">
        <li>The OSCORE Request from <xref target="fig-non-combined"/>, which, in this case, is also sent to a protected resource with the correct CoAP method and options intended for accessing that resource.</li>
        <li>
          <t>EDHOC data consisting of the pair (C_R, EDHOC message_3) required for completing the EDHOC session transported as follows:  </t>
          <ul spacing="normal">
            <li>C_R is the OSCORE Sender ID of the client; hence, it is transported in the 'kid' field of the OSCORE option (see <xref section="6.1" sectionFormat="of" target="RFC8613"/>). Unlike the sequential workflow shown in <xref target="fig-non-combined"/>, C_R is not transported in the payload of the EDHOC + OSCORE request.</li>
            <li>EDHOC message_3 is transported in the payload of the EDHOC + OSCORE request and prepended to the payload of the OSCORE Request. This is because EDHOC message_3 may be too large to be included in a CoAP option, e.g., when conveying a large public key certificate chain in the ID_CRED_I field (see <xref section="3.5.3" sectionFormat="of" target="RFC9528"/>), or when conveying large External Authorization Data in the EAD_3 field (see <xref section="3.8" sectionFormat="of" target="RFC9528"/>).</li>
          </ul>
        </li>
      </ul>
      <t>The rest of this section specifies how to transport the data in the EDHOC + OSCORE request and their processing order. In particular, the use of this approach is explicitly signalled by including an EDHOC option (<xref target="edhoc-option"/>) in the EDHOC + OSCORE request. The processing of the EDHOC + OSCORE request is specified in <xref target="client-processing-intro"/> for the client side and in <xref target="server-processing-intro"/> for the server side.</t>
      <section anchor="edhoc-option">
        <name>EDHOC Option</name>
        <t>This section defines the EDHOC option. This option is used in a CoAP request to signal that the request payload conveys both an EDHOC message_3 and OSCORE-protected data combined together.</t>
	
	
        <t>The EDHOC option has the properties summarized in <xref target="fig-edhoc-option"/>, which extends Table 4 of <xref target="RFC7252"/>.
The option is Critical, Safe-to-Forward, and part of the Cache-Key.  The option <bcp14>MUST</bcp14> occur at most once and <bcp14>MUST</bcp14> be empty. If any value is sent, the recipient <bcp14>MUST</bcp14> ignore it. (Future documents may update the definition of the option by expanding its semantics and specifying admitted values.) The option is intended only for CoAP requests and is of Class U for OSCORE <xref target="RFC8613"/>.</t>

<table align="center" anchor="fig-edhoc-option">
          <name>The EDHOC Option. C=Critical, U=Unsafe, N=NoCacheKey, R=Repeatable</name>
          <thead>
            <tr>
              <th align="left">No.</th>
              <th align="left">C</th>
              <th align="left">U</th>
              <th align="left">N</th>
              <th align="left">R</th>
              <th align="left">Name</th>
              <th align="left">Format</th>
              <th align="left">Length</th>
              <th align="left">Default</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">21</td>
              <td align="left">x</td>
              <td align="left"> </td>
              <td align="left"> </td>
              <td align="left"> </td>
              <td align="left">EDHOC</td>
              <td align="left">Empty</td>
              <td align="left">0</td>
              <td align="left">(none)</td>
            </tr>
          </tbody>
</table>
        <t>The presence of this option means that the message payload also contains EDHOC data that must be extracted and processed as defined in <xref target="server-processing-intro"/> before the rest of the message can be processed.</t>
        <t><xref target="fig-edhoc-opt"/> shows an example of a CoAP message that is transported over UDP and that contains both the EDHOC data and the OSCORE ciphertext using the newly defined EDHOC option for signalling.</t>
        <figure anchor="fig-edhoc-opt">
          <name>Example of a CoAP Message Containing the Combined EDHOC and OSCORE Data, Signalled by the EDHOC Option and Transported over UDP</name>
          <artwork align="center"><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Ver| T |  TKL  |      Code     |          Message ID           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Token (if any, TKL bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Observe Option| OSCORE Option ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| EDHOC Option  | Other Options (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 1 1 1 1 1 1| Payload ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
        </figure>
      </section>
      <section anchor="client-processing-intro">
        <name>Client Processing</name>
        <t>This section describes the processing on the client side.</t>
        <section anchor="client-processing">
          <name>Processing of the EDHOC + OSCORE Request</name>
          <t>The client prepares an EDHOC + OSCORE request as follows.</t>
          <ol spacing="normal" type="Step %d." indent="9">
<li anchor="L1S1">Compose EDHOC message_3 into EDHOC_MSG_3 as per <xref section="5.4.2" sectionFormat="of" target="RFC9528"/>.</li>
            <li anchor="L1S2">
              <t>Establish the new OSCORE Security Context and use it to encrypt the original CoAP request as per <xref section="8.1" sectionFormat="of" target="RFC8613"/>.  </t>
              <t>
Note that the OSCORE ciphertext is not computed over EDHOC message_3, which is not protected by OSCORE. That is, the result of this step is the OSCORE Request as in <xref target="fig-non-combined"/>.</t>
            </li>
            <li anchor="L1S3">

              <t>Build COMB_PAYLOAD as the concatenation of EDHOC_MSG_3 and OSCORE_PAYLOAD in the order of COMB_PAYLOAD = EDHOC_MSG_3 | OSCORE_PAYLOAD, where | denotes byte string concatenation and:  </t>
              <ul spacing="normal">
                <li>EDHOC_MSG_3 is the binary encoding of EDHOC message_3 resulting from <xref target="L1S1" format="none">Step 1</xref>. As per <xref section="5.4.1" sectionFormat="of" target="RFC9528"/>, EDHOC message_3 consists of one CBOR data item CIPHERTEXT_3, which is a CBOR byte string. Therefore, EDHOC_MSG_3 is the binary encoding of CIPHERTEXT_3.</li>
                <li>OSCORE_PAYLOAD is the OSCORE ciphertext of the OSCORE-protected CoAP request resulting from <xref target="L1S2" format="none">Step 2</xref>.</li>
              </ul>
            </li>
            <li anchor="L1S4">

              <t>Compose the EDHOC + OSCORE request, as the OSCORE-protected CoAP request resulting from <xref target="L1S2" format="none">Step 2</xref>, where the payload is replaced with COMB_PAYLOAD built at <xref target="L1S3" format="none">Step 3</xref>.</t>
              <t>
		Note that the new payload includes EDHOC message_3, but it does not include the EDHOC connection identifier C_R.
   As the client is the EDHOC Initiator, C_R is the OSCORE Sender ID of
   the client, which is already specified as the value of the 'kid' field in the OSCORE option of the
   request from <xref target="L1S2" format="none">Step 2</xref>; hence, C_R is specified as the value of the 'kid' field of the EDHOC + OSCORE request.</t>		
            </li>
            <li anchor="L1S5">
              <t>Include the new EDHOC option defined in <xref target="edhoc-option"/> into the EDHOC + OSCORE request.  </t>
              <t>
The application/cid-edhoc+cbor-seq media type does not apply to this message, whose media type is unnamed.</t>
            </li>
            <li anchor="L1S6">Send the EDHOC + OSCORE request to the server.</li>
          </ol>
          <t>With the same server, the client <bcp14>SHOULD NOT</bcp14> have multiple simultaneous outstanding interactions (see <xref section="4.7" sectionFormat="of" target="RFC7252"/>), such that they consist of an EDHOC + OSCORE request and their EDHOC data pertains to the EDHOC session with the same connection identifier C_R.</t>
          <t>An exception might apply for clients that operate under particular time constraints over particularly unreliable networks, thus raising the chances to promptly complete the EDHOC execution with the server through multiple simultaneous EDHOC + OSCORE requests. As discussed in <xref target="security-considerations"/>, this does not have any impact in terms of security.</t>
        </section>
        <section anchor="client-blockwise">
          <name>Supporting Block-Wise Transfers</name>
          <t>If Block-wise transfers <xref target="RFC7959"/> are supported, the client may fragment the first CoAP application request before protecting it as an original message with OSCORE as defined in <xref section="4.1.3.4.1" sectionFormat="of" target="RFC8613"/>.</t>
          <t>In such a case, the OSCORE processing in <xref target="L1S2" format="none">Step 2</xref> of <xref target="client-processing"/> is performed on each inner block of the first CoAP application request. The following also applies.</t>
          <ul spacing="normal">
            <li>
              <t>The client takes the following additional step between Steps <xref target="L1S2" format="none">2</xref> and <xref target="L1S3" format="none">3</xref> of <xref target="client-processing"/>.  </t>
          <ol spacing='normal' type='Step 2.%d.' indent="10">
<li>If the OSCORE-protected request from <xref target="L1S2" format="none">Step 2</xref> conveys a non-first inner block of the first CoAP application request (i.e., the Block1 option processed at Step 2 had NUM different than 0), then the client skips the following steps and sends the OSCORE-protected request to the server. In particular, the client <bcp14>MUST NOT</bcp14> include the EDHOC option in the OSCORE-protected request.</li></ol>
            </li>
            <li>
              <t>The client takes the following additional step between Steps <xref target="L1S3" format="none">3</xref> and <xref target="L1S4" format="none">4</xref> of <xref target="client-processing"/>.  </t>
              <ol spacing='normal' type='Step 3.%d.' indent="10"><li>
If the size of COMB_PAYLOAD exceeds MAX_UNFRAGMENTED_SIZE (see <xref section="4.1.3.4.2" sectionFormat="of" target="RFC8613"/>), the client <bcp14>MUST</bcp14> stop processing the request and <bcp14>MUST</bcp14> abandon the Block-wise transfer. Then, the client can continue by switching to the sequential workflow shown in <xref target="fig-non-combined"/>. That is, the client first sends EDHOC message_3 prepended by the EDHOC connection identifier C_R encoded as per <xref section="3.3" sectionFormat="of" target="RFC9528"/>. Then, the client sends the OSCORE-protected CoAP request once the EDHOC execution is completed.
            </li>
          </ol>
	    </li>
	  </ul>
          <t>The performance advantage of using the EDHOC + OSCORE request can be lost when used in combination with Block-wise transfers that rely on specific parameter values and block sizes. Application policies at the CoAP client can define when and how to detect whether the performance advantage is lost. If that is the case, they can also define whether to appropriately adjust the parameter values and block sizes or  to fall back on the sequential workflow of EDHOC.</t>
        </section>
      </section>
      <section anchor="server-processing-intro">
        <name>Server Processing</name>
        <t>This section describes the processing on the server side.</t>
        <section anchor="server-processing">
          <name>Processing of the EDHOC + OSCORE Request</name>
          <t>In order to process a request containing the EDHOC option, i.e., an EDHOC + OSCORE request, the server <bcp14>MUST</bcp14> perform the following steps.</t>
          <ol spacing="normal" type="Step %d." indent="9">
<li anchor="L2S1">Check that the EDHOC + OSCORE request includes the OSCORE option and that the request payload has the format defined at <xref target="L1S3" format="none">Step 3</xref> of <xref target="client-processing"/> for COMB_PAYLOAD. If this is not the case, the server <bcp14>MUST</bcp14> stop processing the request and <bcp14>MUST</bcp14> reply with a 4.00 (Bad Request) error response.</li>
            <li anchor="L2S2">Extract EDHOC message_3 from the payload COMB_PAYLOAD of the EDHOC + OSCORE request as the first element EDHOC_MSG_3 (see <xref target="L1S3" format="none">Step 3</xref> of <xref target="client-processing"/>).</li>
            <li anchor="L2S3">Take the value of the 'kid' field from the OSCORE option of the EDHOC + OSCORE request (i.e., the OSCORE Sender ID of the client), and use it as the EDHOC connection identifier C_R.</li>
            <li anchor="L2S4">
              <t>Retrieve the correct EDHOC session by using the connection identifier C_R from <xref target="L2S3" format="none">Step 3</xref>.  </t>
              <t>
If the application profile used in the EDHOC session specifies that EDHOC message_4 shall be sent, the server <bcp14>MUST</bcp14> stop the EDHOC processing and consider it failed due to a client error.  </t>
              <t>
Otherwise, perform the EDHOC processing on the EDHOC message_3 extracted at <xref target="L2S2" format="none">Step 2</xref> as per <xref section="5.4.3" sectionFormat="of" target="RFC9528"/> based on the protocol state of the retrieved EDHOC session.  </t>
              <t>
The application profile used in the EDHOC session is the same one associated with the EDHOC resource where the server received the request conveying EDHOC message_1 that started the session. This is relevant in case the server provides multiple EDHOC resources that  may generally refer to different application profiles.</t>
            </li>
            <li anchor="L2S5">Establish a new OSCORE Security Context associated with the client as per <xref section="A.1" sectionFormat="of" target="RFC9528"/> using the EDHOC output from <xref target="L2S4" format="none">Step 4</xref>.</li>
            <li anchor="L2S6">Extract the OSCORE ciphertext from the payload COMB_PAYLOAD of the EDHOC + OSCORE request as the second element OSCORE_PAYLOAD (see <xref target="L1S3" format="none">Step 3</xref> of <xref target="client-processing"/>).</li>
            <li anchor="L2S7">Rebuild the OSCORE-protected CoAP request as the EDHOC + OSCORE request, where the payload is replaced with the OSCORE ciphertext extracted at <xref target="L2S6" format="none">Step 6</xref>. Then, remove the EDHOC option.</li>
            <li anchor="L2S8">
              <t>Decrypt and verify the OSCORE-protected CoAP request rebuilt at <xref target="L2S7" format="none">Step 7</xref> as per <xref section="8.2" sectionFormat="of" target="RFC8613"/> by using the OSCORE Security Context established at <xref target="L2S5" format="none">Step 5.</xref></t>
              <t>
When the decrypted request is checked for any critical CoAP options (as it is during regular CoAP processing), the presence of an EDHOC option <bcp14>MUST</bcp14> be regarded as an unprocessed critical option unless it is processed by some further mechanism.</t>
            </li>
            <li anchor="L2S9">Deliver the CoAP request resulting from <xref target="L2S8" format="none">Step 8</xref> to the application.</li>
          </ol>
          <t>If Steps <xref target="L2S4" format="none">4</xref> (EDHOC processing) and <xref target="L2S8" format="none">8</xref> (OSCORE processing) are both successfully completed, the server <bcp14>MUST</bcp14> reply with an OSCORE-protected response (see <xref section="5.4.3" sectionFormat="of" target="RFC9528"/>). The usage of EDHOC message_4 as defined in <xref section="5.5" sectionFormat="of" target="RFC9528"/> is not applicable to the approach defined in this document.</t>
          <t>If <xref target="L2S4" format="none">Step 4</xref> (EDHOC processing) fails, the server aborts the session as per <xref section="5.4.3" sectionFormat="of" target="RFC9528"/> and responds with an EDHOC error message with error code 1, which is formatted as defined in <xref section="6.2" sectionFormat="of" target="RFC9528"/>. The server <bcp14>MUST NOT</bcp14> establish a new OSCORE Security Context from the present EDHOC session with the client. The CoAP response conveying the EDHOC error message is not protected with OSCORE. As per <xref section="9.5" sectionFormat="of" target="RFC9528"/>, the server has to make sure that the error message does not reveal sensitive information. The CoAP response conveying the EDHOC error message <bcp14>MUST</bcp14> have Content-Format set to application/edhoc+cbor-seq registered in <xref section="10.9" sectionFormat="of" target="RFC9528"/>.</t>
          <t>If <xref target="L2S4" format="none">Step 4</xref> (EDHOC processing) is successfully completed but <xref target="L2S8" format="none">Step 8</xref> (OSCORE processing) fails, the same OSCORE error handling as defined in <xref section="8.2" sectionFormat="of" target="RFC8613"/> applies.</t>
        </section>
        <section anchor="server-blockwise">
          <name>Supporting Block-Wise Transfers</name>
          <t>If Block-wise transfers <xref target="RFC7959"/> are supported, the server takes the additional following step before any other in <xref target="server-processing"/>.</t>
	  <ol spacing='normal' type='Step %d.' start='0' indent="9">
          <li>If a Block option is present in the request, then process the Outer Block options according to <xref target="RFC7959"/> until all blocks of the request have been received (see <xref section="4.1.3.4" sectionFormat="of" target="RFC8613"/>).</li></ol>
        </section>
      </section>
      <section anchor="example">
        <name>Example of the EDHOC + OSCORE Request</name>
        <t><xref target="fig-edhoc-opt-2"/> shows an example of an EDHOC + OSCORE request transported over UDP. In particular, the example assumes that:</t>
        <ul spacing="normal">
          <li>The OSCORE Partial IV in use is 0 consistently with the first request protected with the new OSCORE Security Context.</li>
          <li>
            <t>The OSCORE Sender ID of the client is 0x01.  </t>
            <t>
As per <xref section="3.3.3" sectionFormat="of" target="RFC9528"/>, this straightforwardly corresponds to the EDHOC connection identifier C_R 0x01.  </t>
            <t>
As per <xref section="3.3.2" sectionFormat="of" target="RFC9528"/>, when using the sequential flow shown in <xref target="fig-non-combined"/>, the same C_R with a value of 0x01 would be encoded on the wire as the CBOR integer 1 (0x01 in CBOR encoding) and prepended to EDHOC message_3 in the payload of the second EDHOC request.</t>
          </li>
        </ul>
        <t>This results in the following components shown in <xref target="fig-edhoc-opt-2"/>:</t>
        <dl spacing="normal">
          <dt>OSCORE option value:</dt><dd>0x090001 (3 bytes)</dd>
          <dt>EDHOC option value:</dt><dd>- (0 bytes)</dd>
          <dt>EDHOC message_3:</dt><dd>0x52d5535f3147e85f1cfacd9e78abf9e0a81bbf (19 bytes)</dd>
          <dt>OSCORE ciphertext:</dt><dd>0x612f1092f1776f1c1668b3825e (13 bytes)</dd></dl>
        <figure anchor="fig-edhoc-opt-2">
          <name>Example of a Protected CoAP Request Combining EDHOC and OSCORE Data</name>
          <sourcecode type="coap"><![CDATA[
   0x44025d1f               ; CoAP 4-byte Header
     00003974               ; Token
     93 090001              ; OSCORE Option
     c0                     ; EDHOC Option
     ff 52d5535f3147e85f1cfacd9e78abf9e0a81bbf
        612f1092f1776f1c1668b3825e
   (46 bytes)
]]></sourcecode>
        </figure>
      </section>
    </section>
    <section anchor="use-of-ids">
      <name>Use of EDHOC Connection Identifiers with OSCORE</name>
      <t>The OSCORE Sender/Recipient IDs are the EDHOC connection identifiers (see <xref section="3.3.3" sectionFormat="of" target="RFC9528"/>). This applies also to the optimized workflow defined in <xref target="edhoc-in-oscore"/> of this document.</t>
      <t>Note that the value of the 'kid' field in the OSCORE option of the EDHOC + OSCORE request is both the server's Recipient ID (i.e., the client's Sender ID) and the EDHOC connection identifier C_R of the server at <xref target="L2S3" format="none">Step 3</xref> of <xref target="server-processing"/>.</t>
      <section anchor="oscore-edhoc-message-processing">
        <name>Additional Processing of EDHOC Messages</name>
        <t>When using EDHOC to establish an OSCORE Security Context, the client and server <bcp14>MUST</bcp14> perform the following additional steps during an EDHOC execution, thus extending <xref section="5" sectionFormat="of" target="RFC9528"/>.</t>
        <section anchor="initiator-processing-of-message-1">
          <name>Initiator Processing of Message 1</name>
          <t>The Initiator selects an EDHOC connection identifier C_I as follows.</t>
          <t>The Initiator <bcp14>MUST</bcp14> choose a C_I that is neither used in any current EDHOC session as this peer's EDHOC connection identifier nor the Recipient ID in a current OSCORE Security Context where the ID Context is not present.</t>
          <t>The chosen C_I <bcp14>SHOULD NOT</bcp14> be the Recipient ID of any current OSCORE Security Context. Note that, unless the two peers concurrently use alternative methods to establish OSCORE Security Contexts, this allows the Responder to always omit the 'kid context' in the OSCORE option of its messages sent to the Initiator when protecting those with an OSCORE Security Context where C_I is the Responder's OSCORE Sender ID (see <xref section="6.1" sectionFormat="of" target="RFC8613"/>).</t>
        </section>
        <section anchor="responder-processing-of-message-2">
          <name>Responder Processing of Message 2</name>
          <t>The Responder selects an EDHOC connection identifier C_R as follows.</t>
          <t>The Responder <bcp14>MUST</bcp14> choose a C_R that is none of the following:</t>

	  <ul><li>used in any current EDHOC session as this peer's EDHOC connection identifier,</li>
	  <li>equal to the EDHOC connection identifier C_I specified in the EDHOC message_1 of the present EDHOC session, or</li>
	  <li>the Recipient ID in a current OSCORE Security Context where the ID Context is not present.</li></ul>
          <t>The chosen C_R <bcp14>SHOULD NOT</bcp14> be the Recipient ID of any current OSCORE Security Context. Note that, for a reason analogous to the one given in <xref target="initiator-processing-of-message-1"/> with C_I, this allows the Initiator to always omit the 'kid context' in the OSCORE option of its messages sent to the Responder when protecting those with an OSCORE Security Context where C_R is the Initiator's OSCORE Sender ID (see <xref section="6.1" sectionFormat="of" target="RFC8613"/>).</t>
        </section>
        <section anchor="initiator-processing-of-message-2">
          <name>Initiator Processing of Message 2</name>
          <t>If the EDHOC connection identifier C_I is equal to the EDHOC connection identifier C_R specified in EDHOC message_2, then the Initiator <bcp14>MUST</bcp14> abort the session and reply with an EDHOC error message with error code 1 formatted as defined in <xref section="6.2" sectionFormat="of" target="RFC9528"/>.</t>
        </section>
      </section>
    </section>
    <section anchor="app-statements">
      <name>Extension and Consistency of Application Profiles</name>
      <t>It is possible to include the information below in the application profile referred by the client and server according to the specified consistency rules.</t>
      <t>If the server supports the EDHOC + OSCORE request within an EDHOC execution started at a certain EDHOC resource, then the application profile associated with that resource <bcp14>SHOULD</bcp14> explicitly specify support for the EDHOC + OSCORE request.</t>
      <t>In the case where the application profile indicates that the server supports the optional EDHOC message_4 (see <xref section="5.5" sectionFormat="of" target="RFC9528"/>), it is still possible to use the optimized workflow based on the EDHOC + OSCORE request. However, this means that the server is not going to send EDHOC message_4 since it is not applicable to the optimized workflow (see <xref target="server-processing"/>).</t>
      <t>Also, in the case where the application profile indicates that the server shall send EDHOC message_4, the application profile <bcp14>MUST NOT</bcp14> specify support for the EDHOC + OSCORE request. There is no point for the client to use the optimized workflow that is bound to fail (see <xref target="server-processing"/>).</t>
    </section>
    <section anchor="web-linking">
      <name>Web Linking</name>
      <t><xref section="10.10" sectionFormat="of" target="RFC9528"/> registers the resource type "core.edhoc", which can be used as target attribute in a web link <xref target="RFC8288"/> to an EDHOC resource, e.g., using a link-format document <xref target="RFC6690"/>. This enables clients to discover the presence of EDHOC resources at a server, possibly using the resource type as a filter criterion.</t>
      <t>At the same time, the application profile associated with an EDHOC resource provides information describing how the EDHOC protocol can be used through that resource. A client may become aware of the application profile, e.g., by obtaining its information elements upon discovering the EDHOC resources at the server. 
This allows the client to discover the EDHOC resources whose associated application profile denotes a way of using EDHOC that is most suitable to the client, e.g., with EDHOC cipher suites or authentication methods that the client also supports or prefers.</t>
      <t>That is, while discovering an EDHOC resource, a client can contextually obtain relevant pieces of information from the application profile associated with that resource. The resource discovery can occur by means of a direct interaction with the server or by means of the CoRE Resource Directory <xref target="RFC9176"/> where the server may have registered the links to its resources.</t>
      <t>In order to enable the above, this section defines a number of parameters, each of which can be optionally specified as a target attribute with the same name in the link to the respective EDHOC resource or as filter criterion in a discovery request from the client. When specifying these parameters in a link to an EDHOC resource, the target attribute rt="core.edhoc" <bcp14>MUST</bcp14> be included and the same consistency rules defined in <xref target="app-statements"/> for the corresponding information elements of an application profile <bcp14>MUST</bcp14> be followed.</t>
      <t>The following parameters are defined.</t>
      <dl spacing="normal">
        <dt>'ed-i':</dt><dd>If present, specifies that the server supports the EDHOC Initiator role, hence the reverse message flow of EDHOC. A value <bcp14>MUST NOT</bcp14> be given to this parameter and any present value <bcp14>MUST</bcp14> be ignored by the recipient.</dd>
        <dt>'ed-r':</dt><dd>If present, specifies that the server supports the EDHOC Responder role, hence the forward message flow of EDHOC. A value <bcp14>MUST NOT</bcp14> be given to this parameter and any present value <bcp14>MUST</bcp14> be ignored by the recipient.</dd>
        <dt>'ed-method':</dt><dd>Specifies an authentication method supported by the server. This parameter <bcp14>MUST</bcp14> specify a single value, which is taken from the 'Value' column of the "EDHOC Method Type" registry defined in <xref section="10.3" sectionFormat="of" target="RFC9528"/>. This parameter <bcp14>MAY</bcp14> occur multiple times, with each occurrence specifying an authentication method.</dd>
        <dt>'ed-csuite':</dt><dd>Specifies an EDHOC cipher suite supported by the server. This parameter <bcp14>MUST</bcp14> specify a single value, which is taken from the 'Value' column of the "EDHOC Cipher Suites" registry defined in <xref section="10.2" sectionFormat="of" target="RFC9528"/>. This parameter <bcp14>MAY</bcp14> occur multiple times, with each occurrence specifying a cipher suite.</dd>
        <dt>'ed-cred-t':</dt><dd>Specifies a type of authentication credential supported by the server. This parameter <bcp14>MUST</bcp14> specify a single value, which is taken from the 'Value' column of the "EDHOC Authentication Credential Types" Registry defined in <xref target="iana-edhoc-auth-cred-types"/> of this document. This parameter <bcp14>MAY</bcp14> occur multiple times, with each occurrence specifying a type of authentication credential.</dd>
          <dt>'ed-idcred-t':</dt><dd><t>Specifies a type of identifier supported by the server for identifying authentication credentials. This parameter <bcp14>MUST</bcp14> specify a single value, which is taken from the 'Label' column of the "COSE Header Parameters" registry <xref target="COSE.Header.Parameters"/>. This parameter <bcp14>MAY</bcp14> occur multiple times, with each occurrence specifying a type of identifier for authentication credentials.</t>
          <t>
Note that the values in the 'Label' column of the "COSE Header Parameters" registry are strongly typed. On the contrary, CoRE Link Format is weakly typed; thus, it does not distinguish between, for instance, the string value "-10" and the integer value -10. Therefore, if responses in CoRE Link Format are returned, string values that look like an integer are not supported. Thus, such values <bcp14>MUST NOT</bcp14> be used in the 'ed-idcred-t' parameter.</t>
        </dd>
        <dt>'ed-ead':</dt><dd>Specifies the support of the server for an External Authorization Data (EAD) item (see <xref section="3.8" sectionFormat="of" target="RFC9528"/>). This parameter <bcp14>MUST</bcp14> specify a single value, which is taken from the 'Label' column of the "EDHOC External Authorization Data" registry defined in <xref section="10.5" sectionFormat="of" target="RFC9528"/>. This parameter <bcp14>MAY</bcp14> occur multiple times, with each occurrence specifying the ead_label of an EAD item that the server supports.</dd>
        <dt>'ed-comb-req':</dt><dd>If present, specifies that the server supports the EDHOC + OSCORE request defined in <xref target="edhoc-in-oscore"/>. A value <bcp14>MUST NOT</bcp14> be given to this parameter and any present value <bcp14>MUST</bcp14> be ignored by the recipient.</dd>
      </dl>
      <t>Future documents may update the definition of the parameters 'ed-i', 'ed-r', and 'ed-comb-req' by expanding their semantics and specifying what they can take as value.</t>
      <t>The example in <xref target="fig-web-link-example"/> shows how a client discovers one EDHOC resource at a server and obtains information elements from the respective application profile. The CoRE Link Format notation from <xref section="5" sectionFormat="of" target="RFC6690"/> is used.</t>
      <figure anchor="fig-web-link-example">
        <name>The Web Link</name>
        <artwork align="center"><![CDATA[
REQ: GET /.well-known/core

RES: 2.05 Content
    </sensors/temp>;osc,
    </sensors/light>;if=sensor,
    </.well-known/edhoc>;rt=core.edhoc;ed-csuite=0;ed-csuite=2;
        ed-method=0;ed-cred-t=0;ed-cred-t=1;ed-idcred-t=4;
        ed-i;ed-r;ed-comb-req
]]></artwork>
      </figure>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>The same security considerations from OSCORE <xref target="RFC8613"/> and EDHOC <xref target="RFC9528"/> hold for this document. In addition, the following considerations apply.</t>
      <t><xref target="client-processing"/> specifies that a client <bcp14>SHOULD NOT</bcp14> have multiple outstanding EDHOC + OSCORE requests pertaining to the same EDHOC session. Even if a client did not fulfill this requirement, it would not have any impact in terms of security. That is, the server would still not process different instances of the same EDHOC message_3 more than once in the same EDHOC session (see <xref section="5.1" sectionFormat="of" target="RFC9528"/>) and would still enforce replay protection of the OSCORE-protected request (see Sections <xref target="RFC8613" section="7.4" sectionFormat="bare"/> and <xref target="RFC8613" section="8.2" sectionFormat="bare"/> of <xref target="RFC8613"/>).</t>
      <t>When using the optimized workflow in <xref target="fig-combined"/>, a minimum of 128-bit security against online brute-force attacks is achieved after the client receives and successfully verifies the first OSCORE-protected response (see Sections <xref target="RFC9528" section="9.1" sectionFormat="bare"/> and <xref target="RFC9528" section="9.4" sectionFormat="bare"/> of <xref target="RFC9528"/>). As an example, if EDHOC is used with method 3 (see <xref section="3.2" sectionFormat="of" target="RFC9528"/>) and cipher suite 2 (see <xref section="3.6" sectionFormat="of" target="RFC9528"/>), then the following holds:</t>
      <ul spacing="normal">
        <li>The Initiator is authenticated with 128-bit security against online attacks. As per <xref section="9.1" sectionFormat="of" target="RFC9528"/>, this results from the combination of the strength of the 64-bit Message Authentication Code (MAC) in EDHOC message_3 and of the 64-bit MAC in the Authenticated Encryption with Associated Data (AEAD) of the first OSCORE-protected CoAP request as rebuilt at <xref target="L2S7" format="none">Step 7</xref> of <xref target="server-processing"/>.</li>
        <li>The Responder is authenticated with 128-bit security against online attacks. As per <xref section="9.1" sectionFormat="of" target="RFC9528"/>, this results from the combination of the strength of the 64-bit MAC in EDHOC message_2 and of the 64-bit MAC in the AEAD of the first OSCORE-protected CoAP response.</li>
      </ul>
      <t>With reference to the sequential workflow in <xref target="fig-non-combined"/>, the OSCORE request might have to undergo access-control checks at the server before being actually executed for accessing the target protected resource. The same <bcp14>MUST</bcp14> hold when the optimized workflow in <xref target="fig-combined"/> is used, i.e., when using the EDHOC + OSCORE request.</t>
      <t>That is, the rebuilt OSCORE-protected application request from <xref target="L2S7" format="none">Step 7</xref> in <xref target="server-processing"/> <bcp14>MUST</bcp14> undergo the same access-control checks that would be performed on a traditional OSCORE-protected application request sent individually as shown in <xref target="fig-non-combined"/>.</t>

<t>To this end, validated information to perform access-control checks (e.g., an access token issued by a trusted party) has to be available at the server before starting to process the rebuilt OSCORE-protected application request. Such information may have been provided to the server separately before starting the EDHOC execution altogether, or instead as External Authorization Data during the EDHOC execution (see <xref section="3.8" sectionFormat="of" target="RFC9528"/>).</t>
      <t>Thus, a successful completion of the EDHOC protocol and the following derivation of the OSCORE Security Context at the server do not play a role in determining whether the rebuilt OSCORE-protected request is authorized to access the target protected resource at the server.</t>
    </section>        
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has the following actions for IANA.</t>
      <section anchor="iana-coap-options">
        <name>CoAP Option Numbers Registry</name>
        <t>IANA has registered the following option number in the "CoAP Option Numbers" registry within the "Constrained RESTful Environments (CoRE) Parameters" registry group.</t>
        <table align="center">
          <name>Registration in the "CoAP Option Numbers" Registry</name>
          <thead>
            <tr>
              <th align="left">Number</th>
              <th align="left">Name</th>
              <th align="left">Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">21</td>
              <td align="left">EDHOC</td>
              <td align="left">RFC 9668</td>
            </tr>
          </tbody>
        </table>
      </section>
      <section anchor="iana-target-attributes">
        <name>Target Attributes Registry</name>
        <t>IANA has registered the following entries in the "Target Attributes" registry <xref target="CORE.Target.Attributes"/> within the "Constrained RESTful Environments (CoRE) Parameters" registry group as per <xref target="RFC9423"/>.
For all entries, the Change Controller is IETF and the reference is RFC 9668.</t>
        <table align="center">
          <name>Registrations in the "Target Attributes" Registry</name>
          <thead>
            <tr>
              <th align="left">Attribute Name</th>
              <th align="left">Brief Description</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">ed-i</td>
              <td align="left">Hint: support for the EDHOC Initiator role</td>
            </tr>
            <tr>
              <td align="left">ed-r</td>
              <td align="left">Hint: support for the EDHOC Responder role</td>
            </tr>
            <tr>
              <td align="left">ed-method</td>
              <td align="left">A supported authentication method for EDHOC</td>
            </tr>
            <tr>
              <td align="left">ed-csuite</td>
              <td align="left">A supported cipher suite for EDHOC</td>
            </tr>
            <tr>
              <td align="left">ed-cred-t</td>
              <td align="left">A supported type of authentication credential for EDHOC</td>
            </tr>
            <tr>
              <td align="left">ed-idcred-t</td>
              <td align="left">A supported type of authentication credential identifier for EDHOC</td>
            </tr>
            <tr>
              <td align="left">ed-ead</td>
              <td align="left">A supported External Authorization Data (EAD) item for EDHOC</td>
            </tr>
            <tr>
              <td align="left">ed-comb-req</td>
              <td align="left">Hint: support for the EDHOC + OSCORE request</td>
            </tr>
          </tbody>
        </table>
      </section>
      <section anchor="iana-edhoc-auth-cred-types">
        <name>EDHOC Authentication Credential Types Registry</name>
        <t>IANA has created the "EDHOC Authentication Credential Types" registry within the "Ephemeral Diffie-Hellman Over COSE (EDHOC)" registry group defined in <xref target="RFC9528"/>.</t>
        <t>The registration policy is either "Private Use", "Standards Action with Expert Review", or "Specification Required" per <xref target="RFC8126"/>. "Expert Review" guidelines are provided in <xref target="review"/>.</t>
        <t>All assignments according to "Standards Action with Expert Review"
        are made on a "Standards Action" basis per <xref section="4.9"
        sectionFormat="of" target="RFC8126"/> with "Expert Review"
        additionally required per <xref section="4.5" sectionFormat="of"
        target="RFC8126"/>. The procedure for early IANA allocation of
        "standards track code points" defined in <xref target="RFC7120"/> also
        applies.  When such a procedure is used, IANA will ask the designated
        expert(s) to approve the early allocation before registration. In
        addition, working group chairs are encouraged to consult the expert(s)
        early during the process outlined in <xref section="3.1"
        sectionFormat="of" target="RFC7120"/>.</t>
        <t>The columns of this registry are:</t>
        <dl spacing="normal">
          <dt>Value:</dt><dd><t>This field contains the value used to identify the type of authentication credential. These values <bcp14>MUST</bcp14> be unique. The value can be an unsigned integer or a negative integer. Different ranges of values use different registration policies:</t>
            <ul spacing="normal">
              <li>Integer values from -24 to 23 are designated as "Standards Action With Expert Review".</li>
              <li>Integer values from -65536 to -25 and from 24 to 65535 are designated as "Specification Required".</li>
              <li>Integer values smaller than -65536 and greater than 65535 are marked as "Private Use".</li>
            </ul>
          </dd>
          <dt>Description:</dt><dd>This field contains a short description of the type of authentication credential.</dd>
          <dt>Reference:</dt><dd>This field contains a pointer to the public specification for the type of authentication credential.</dd>
        </dl>

        <table align="center" anchor="pre-reg">
          <name>Initial Entries in the "EDHOC Authentication Credential Types" Registry</name>
          <thead>
            <tr>
              <th align="left">Value</th>
              <th align="left">Description</th>
              <th align="left">Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">0</td>
              <td align="left">CBOR Web Token (CWT) containing a COSE_Key in a 'cnf' claim and possibly other claims. CWT is defined in RFC 8392.</td>
              <td align="left">
                <xref target="RFC8392"/></td>
            </tr>
            <tr>
              <td align="left">1</td>
              <td align="left">CWT Claims Set (CCS) containing a COSE_Key in a 'cnf' claim and possibly other claims. CCS is defined in RFC 8392.</td>
              <td align="left">
                <xref target="RFC8392"/></td>
            </tr>
            <tr>
              <td align="left">2</td>
              <td align="left">X.509 certificate</td>
              <td align="left">
                <xref target="RFC5280"/></td>
            </tr>
          </tbody>
        </table>
      </section>
      <section anchor="review">
	
        <name>Expert Review Instructions</name>
        <t>"Standards Action with Expert Review" and "Specification Required" are two of the registration policies defined for the IANA registry established in <xref target="iana-edhoc-auth-cred-types"/>.
This section gives some general guidelines for what the experts should be looking for; however, they are being designated as experts for a reason, so they should be given substantial latitude.</t>
        <t>Expert reviewers should take into consideration the following points:</t>
        <ul spacing="normal">
          <li>Clarity and correctness of registrations. Experts are expected to check the clarity of purpose and use of the requested entries. Experts need to make sure that registered identifiers indicate a type of authentication credential whose format and encoding is clearly defined in the corresponding specification. Identifiers of types of authentication credentials that do not meet these objectives of clarity and completeness must not be registered.</li>
          <li>Point squatting should be discouraged. Reviewers are encouraged to get sufficient information for registration requests to ensure that the usage is not going to duplicate one that is already registered and that the point is likely to be used in deployments. The zones tagged as "Private Use" are intended for testing purposes and closed environments. Code points in other ranges should not be assigned for testing.</li>
          <li>Specifications are required for the "Standards Action With Expert Review" range of point assignment. Specifications should exist for "Specification Required" ranges, but early assignment before a specification is available is considered to be permissible. When specifications are not provided, the description provided needs to have sufficient information to identify what the point is being used for.</li>	 	 
          <li>Experts should take into account the expected usage of fields
          when approving point assignment. Documents published via Standards
          Action can also register points outside the Standards Action
          range. The length of the encoded value should be weighed against how
          many code points of that length are left, the size of device it will
          be used on, and the number of code points left that encode to that
          size.</li>
        </ul>
      </section>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>

	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5280.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6690.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7120.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7252.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7959.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8126.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8288.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8392.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8613.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8949.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9176.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9528.xml"/>

        <reference anchor="COSE.Header.Parameters" target="https://www.iana.org/assignments/cose">
          <front>
            <title>COSE Header Parameters</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>

        <reference anchor="CORE.Target.Attributes" target="https://www.iana.org/assignments/core-parameters">
          <front>
            <title>Target Attributes</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>

	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>

      </references>
      <references>
        <name>Informative References</name>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9423.xml"/>

      </references>
    </references>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>The authors sincerely thank <contact fullname="Christian Amsüss"/>, <contact fullname="Emmanuel Baccelli"/>, <contact fullname="Carsten Bormann"/>, <contact fullname="Roman Danyliw"/>, <contact fullname="Esko Dijk"/>, <contact fullname="Joel Halpern"/>, <contact fullname="Wes Hardaker"/>, <contact fullname="Klaus Hartke"/>, <contact fullname="John Preuß Mattsson"/>, <contact fullname="David Navarro"/>, <contact fullname="Shuping Peng"/>, <contact fullname="Jim Schaad"/>, <contact fullname="Jürgen Schönwälder"/>, <contact fullname="John Scudder"/>, <contact fullname="Orie Steele"/>, <contact fullname="Gunter Van de Velde"/>, <contact fullname="Mališa Vučinić"/>, and <contact fullname="Paul Wouters"/> for their feedback and comments.</t>
      <t>The work on this document has been partly supported by the Sweden's Innovation Agency VINNOVA and the Celtic-Next project CRITISEC, and by the H2020 project SIFIS-Home (Grant agreement 952652).</t>
    </section>
  </back>
</rfc>
