<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
 which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
There has to be one entity for each item to be referenced.
An alternate method (rfc include) is described in the references. -->

<!ENTITY RFC5295 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5295.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC5247 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5247.xml">
<!ENTITY RFC4493 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4493.xml">
<!ENTITY RFC4615 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4615.xml">
<!ENTITY RFC3748 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3748.xml">
<!ENTITY RFC4764 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4764.xml">
<!ENTITY RFC4279 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4279.xml">
<!ENTITY RFC6345 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6345.xml">
<!ENTITY RFC7252 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7252.xml">
<!ENTITY RFC7967 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7967.xml">
<!ENTITY RFC7833 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7833.xml">
<!ENTITY RFC5191 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5191.xml">
<!ENTITY RFC7228 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7228.xml">
<!ENTITY RFC6696 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6696.xml">

<!ENTITY RFC5869 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5869.xml">




<!ENTITY I-D.ohba-core-eap-based-bootstrapping SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ohba-core-eap-based-bootstrapping-01.xml">

<!ENTITY I-D.kumar-dice-dtls-relay SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-kumar-dice-dtls-relay-02.xml">

<!ENTITY I-D.pelov-core-cosol SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-pelov-core-cosol-01.xml">

<!ENTITY I-D.ietf-ace-oauth-authz SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-ace-oauth-authz-36.xml">

<!ENTITY I-D.ietf-lwig-coap SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-lwig-coap-06.xml">

<!ENTITY I-D.ingles-eap-edhoc SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ingles-eap-edhoc-01.xml">


]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
 please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
 (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
 (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc ipr="trust200902" category="std" docName="draft-marin-ace-wg-coap-eap-07">
    <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN"
     they will automatically be output with "(if approved)" -->
    
    <!-- ***** FRONT MATTER ***** -->
    
    <front>
        <!-- The abbreviated title is used in the page header - it is only necessary if the
         full title is longer than 39 characters -->
        
        <title abbrev="CoAP-EAP">EAP-based Authentication Service for CoAP</title>
        
        <!-- add 'role="editor"' below for the editors if appropriate -->
        
        <!-- Another author who claims to be an editor -->        
        <author fullname="Rafa Marin-Lopez" initials="R." surname="Marin">
            <organization>University of Murcia</organization>
            <address>
                <postal>
                    <street>Campus de Espinardo S/N, Faculty of Computer Science</street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Murcia</city>
                    <region></region>
                    <code>30100</code>
                    <country>Spain</country>
                </postal>
                <phone>+34 868 88 85 01</phone>
                <email>rafa@um.es</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>
        <author fullname="Dan Garcia Carrillo" initials="D." surname="Garcia">
            <organization>University of Oviedo</organization>
            <address>
                <postal>
                    <street>Calle Luis Ortiz Berrocal S/N, Edificio Polivalente </street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Gijon</city>
                    <region>Asturias</region>
                    <code>33203</code>
                    <country>Spain</country>
                </postal>
                <email>garciadan@uniovi.es</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>
        
        <date year="2021" />
        
        <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
         in the current day for you. If only the current year is specified, xml2rfc will fill
         in the current day and month for you. If the year is not the current one, it is
         necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
         purpose of calculating the expiry date).  With drafts it is normally sufficient to
         specify just the year. -->
        
        <!-- Meta-data Declarations -->
        
        <area>General</area>
        
        <workgroup>ACE Working Group</workgroup>
        
        <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.
         If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->
        
        <keyword>template</keyword>
        
        <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->
        
        <abstract>
            <t>
                This document describes an authentication service that uses EAP transported by means of CoAP messages with the following purposes:
            </t>
            <t>
                <list style="symbols">
                    <t>
                        Authenticate a CoAP-enabled device that enters a new security domain against a AAA infrastructure through a domain Controller.
                    </t>
                    <t>
                        Bootstrap key material to protect CoAP messages exchanged between them.
                    </t>
                    <t>
                        Enable the establishment of Security Associations between them.
                    </t>

                </list>
            </t>
            
        </abstract>
    </front>
    
    <middle>
        <section title="Introduction">
            <t>
                The goal of this document is to describe an authentication service that uses the Extensible Authentication Protocol (EAP) 
                <xref target="RFC3748"></xref>. The authentication service is built on top of the Constrained Application Protocol (CoAP) 
                <xref target="RFC7252"></xref> and allows authenticating two CoAP endpoints by using EAP without the need of additional 
                protocols to bootstrap a security association between them.
            </t>
            
            <t> In particular, the document describes how CoAP can be used as a constrained link-layer independent EAP lower-layer <xref target
                ="RFC3748"/> to transport EAP between a CoAP server (EAP peer) and the CoAP client (EAP authenticator) using CoAP
                messages. The CoAP client MAY contact with a backend AAA infrastructure to complete the EAP negotiation
                as described in the EAP specification <xref target="RFC3748"></xref>.
            </t>
            
            <t>
                The assumption is that the EAP method transported in CoAP MUST generate cryptographic material <xref target="RFC5247"></xref> .
                In this way, the CoAP messages can be protected. There are two approaches that we have considered in this document:
                
                <list style="symbols">
                    <t>To define how the OSCORE security association can be established based on the cryptographic material generated from the EAP authentication.
                    </t>
                    <t>To establish a DTLS security association using the exported cryptographic material after a successful EAP authentication.
                        <xref target="I-D.ohba-core-eap-based-bootstrapping"></xref>    
                    </t>
                </list>
                
            </t>
            
            <t> This document also provides some comments about implementation of a proof-of-concept of this preliminary idea </t>
            
            <section title="Requirements Language">
                <t>
                    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
                    "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
                    document are to be interpreted as described in <xref target="RFC2119">RFC 2119</xref>.
                </t>
            </section>
        </section>
        
        <section title="General Architecture">
            <t>
                The <xref target="arch"/> shows the architecture defined in this document. Basically a node acting as the EAP peer wants to be authenticated by using EAP. At the time of writing this document, we have considered a model where the EAP peer will act as CoAP server for this service and the EAP authenticator will act as CoAP client and MAY interact with a backend AAA infrastructure, which will place the EAP server and contain the information required to authenticate the CoAP client. The rationale behind this decision, as we will expand later, is that EAP requests go always from the EAP authenticator and the EAP peer and the EAP responses from the EAP peer to the EAP authenticator. Nevertheless, a model where the EAP peer act as CoAP client and the EAP authenticator as CoAP server can be also analyzed in the future.
            </t>
            
            <figure align="center" anchor="arch" title="CoAP EAP Architecture">
                
                <!-- maximum wide of the figure                                   -->
                <artwork align="left"><![CDATA[
    +------------+        +------------+       +--------------+
    | EAP peer/  |        | EAP auth./ |       |  EAP server/ |
    | CoAP server|+------+| CoAP client|+-----+|  AAA server  |
    +------------+  CoAP  +------------+  AAA  +--------------+
    
                ]]></artwork>
            </figure>
            
            
        </section>
        
        
        
        <section title="General Flow Operation">
            
            <t>
                The authentication service uses CoAP as transport layer for EAP. In other words, CoAP becomes an EAP lower-layer (in EAP terminology). In general, it is assumed that, since the EAP authenticator may implement an AAA client to interact with the AAA infrastructure, this endpoint will have more resources or, at least, it is not a so constrained device. We describe two different sequence flow. First, it is shown in <xref target="figure1"></xref> where the OSCORE is used at the end of EAP authentication. The diagram in <xref target="figuredtls"></xref> shows the flow when DTLS is used to protect CoAP messages at the end of the EAP authentication. As an example, both diagrams show the usage of a generic EAP method that we call EAP-X as authentication mechanism.
                (NOTE: any EAP method which is able to export cryptographic material should be valid).
            </t>
            
            <section title="EAP over CoAP: Running an OSCORE Security Association">
                
                <t>
                    When the EAP peer discovers the presence of the EAP authenticator and wants to start the authentication, it can send a Non-Confirmable "POST /b" request to the node (Step 0). This message, will carry an option developed from the work on  <xref target="RFC7967"></xref> called no response. The rationale of this option is to avoid waiting for a response if it is not needed. So the use of this option will allow signaling the intention of the EAP peer to start the authentication process, as a trigger mechanism.
                    
                    Immediately after that, the EAP authenticator will start the authentication service. It is worth noting that the EAP authenticator MAY decide to start the authentication without waiting for the trigger message if it has knowledge about the presence of the EAP peer, for instance, through a previous authentication (re-authentication).
                </t>
                
                <t>
                    In any case, to perform the authentication service, the CoAP client (EAP authenticator) sends a Confirmable "POST /b" request to the CoAP Server (Step 1). This POST message contains a new option SeqNum that holds a sequence number randomly chosen by the CoAP client. This SeqNum is used to provide ordered and reliable delivery of messages involved during the whole authentication. In general, when a CoAP request with EAP message is received, the CoAP client considers a valid message if only if its sequence number is the expected value. The sequence number is monotonically incremented by 1 so that the CoAP server can know what it is the next expected sequence number.
                 </t>    
                 <!-- If after a period of time no further message is 
                    received from the CoAP client, the CoAP server will free the created state. -->
                 <t> After receiving the first POST, the CoAP server assigns a resource and answers with an Acknowledgment with the piggy-backed resource identifier (Uri-Path) (Step 2). It is assumed that the CoAP server will only have an ongoing authentication and will not process simultaneous EAP authentications in parallel to save resources.  In these two messages, the EAP Req/Id and Rep/ID are exchanged between the EAP authenticator and the EAP peer. The EAP Req/Id message is forwarded by the EAP authenticator, when EAP is in pass-through mode, to the local AAA server that is in charge of steering the conversation, choosing the EAP method to be used (e.g. EAP-X) if the user is local or sending the EAP messages to the home AAA of the EAP peer.

                    At this point, the CoAP server has created a resource for the EAP authentication. The resource identifier value will be used together to relate all the EAP conversation between both CoAP endpoints. Since, only an ongoing EAP authentication is permitted and EAP is a lock-step protocol a Token of a constant value and 1 byte can be used throughout the authentication process. This also allows to save bytes through the link.
                    
                    <!--Rafa : Yo creo que de momento con esta explicacion deberia ser suficiente -->
                    <!--> The implications of the Empty token will
                    be discussed in Section <xref target="security_considerations"></xref>. -->


                </t>
                
                <t>
                    From now on, the EAP authenticator and the EAP peer will exchange EAP packets related to the EAP method, transported in the CoAP message payload (Steps 3,4,5,6). The EAP authenticator will use the POST method to send EAP requests to the EAP peer. The EAP peer will use a Piggy-backed response in the Acknowledgment message to carry the EAP response.
                    
                    At the end of the message exchanges, if everything has gone well, the EAP authenticator is able to send an EAP Success message and both CoAP endpoints will share a Master Session Key (MSK) (<xref target="RFC5295"></xref>)
                </t>
                
                
                <t>
                    To establish a security association that will confirm to the EAP peer that EAP authenticator received the MSK from the AAA sever, as well as to the EAP authenticator that the EAP peer derived the MSK correctly, both entities engage in the establishment of a security association. In
                     the context of constrained devices <xref target="RFC7228"></xref>  and networks we consider protocols that are designed for these cases. Concretely, we show here in the diagram the establishment of the OSCORE security association. This is shown in Steps 7 and 8. From that point any exchange between both CoAP endpoints are protected with OSCORE. Before sending the EAP success to the EAP peer, the EAP authenticator is able to derive the OSCORE Security Context, to confirm the establishment of the security association. The  details of the establishment of the OSCORE Security Context are discussed in 
                     <xref target="oscore"></xref>                   
                </t>
                
                <t>
                    On the contrary, if DTLS is used (see <xref target="figuredtls"></xref>), a DTLS_PSK is derived from the MSK.  
                    Moreover, exchanges between both CoAP endpoints are protected with DTLS from that point.
                </t>
                
                <!-- Rafa: Hay que actualizar la figura con el numero de secuencia -->
                
                <figure align="center" anchor="figure1" title="CoAP-EAP with OSCORE option">
                    <!-- maximum wide of the figure                                   -->
                    <artwork align="left"><![CDATA[
                        
            
         EAP peer                                  EAP Auth.
       (CoAP server)                             (CoAP client)
       -------------                             -------------
            |                                         |
            | NON [0x6af5]                            |
            | POST /b                                 |
            | No-Response                             |
        0)  | Token (0xab)                            |
            |---------------------------------------->|
            |                                         |
            |                            CON [0x7654] |
            |                                 POST /b |
            |                               SeqNum(x) |
            |                            Token (0xac) |
            |                      Payload EAP Req/Id |
         1) |<----------------------------------------|
            |                                         |
            | ACK [0x7654]                            |
            | SeqNum(x)                               |
            | Token (0xac)                            |
            | 2.01 Created                            |
            | Uri-Path [/b/5]                         |
            | Payload EAP Rep/Id                      |
         2) |---------------------------------------->|
            |                                         |
            |                            CON [0x8694] |
            |                               POST /b/5 |
            |                             SeqNum(x+1) |
            |                            Token (0xac) |
            |                     Payload EAP-X MSG 1 |
         3) |<----------------------------------------|
            |                                         |
            | ACK [0x8694]                            |
            | Token (0xac)                           |
            | SeqNum(x+1)                             |
            | 2.04 Changed                            |
            | Payload EAP-X MSG 2                     |
         4) |---------------------------------------->|
                               ....
           
            |                                         |
            |                            CON [0x9869] |
            |                               POST /b/5 |
            |                            SeqNum(x+n/2)|
            |                            Token (0xac) |
            |                 Payload EAP-X MSG (n-1) |
         5) |<----------------------------------------|
            |                                         |
            | ACK [0x9869]                            |
            | SeqNum(x+n/2)                           |
            | Token (0xac)                            |
            | 2.04 Changed                            |
            | Payload EAP-X MSG (n)                   |  MSK
         6) |---------------------------------------->|   |
            |                                         |   V
            |                         CON [0x7811]    | OSCORE
            |                         POST /b/5       | CONTEXT
            |                         SeqNum(x+n/2+1) |
            |                         Token (0xac)    | (*)
            |                         OSCORE Option   |
            |                         EAP success     |
  MSK    7) |<----------------------------------------|
   |        |                                         |
   V    (*) | ACK [0x7811]                            |
 OSCORE     | SeqNum(x+n/2+1)                         |
 CONTEXT    | Token (0xac)                            |
            | OSCORE Option                           |
            | 2.04 Changed                            |
         8) |---------------------------------------->|
            
            (*) Protected with OSCORE

                    ]]></artwork>
                </figure>
            </section>
            

            
            <section anchor="seqnum" title="The SeqNum Option">
                <t>
                    A new SeqNum option is defined in this document for establishing the ordering guarantee of the EAP exchange.
                    Following guidelines in
                    <xref target="RFC7252"></xref> this option is:
                </t>
                <t>
                    <list style="numbers">
                        <t>Format opaque (sequence of bytes). </t>
                        <t>Critical</t>
                        <t>Safe to Forward</t>
                        <t>No cacheable and Not part of the Cache-Key</t>
                        <t>Not repeatable</t>
                    </list>
                </t>

                <t>
                    The number of the option will be determined by this previous decisions.
                </t>
                
                <t>
                    <list style="numbers">
                        <t>Critical (C = 1)</t>
                        <t>Safe to Forward (1)</t>
                        <t>NoCacheKey (111)</t>
                    </list>
                </t>
                
                <t>The number of the SeqNum option will fit this pattern:
                   xxx11111</t>
                
                <figure align="center" anchor="auth_option_fig" title="Auth Option Number Mask">
                    <artwork align="left"><![CDATA[
                        0   1   2   3   4   5   6   7
                        +---+---+---+---+---+---+---+---+
                        |           | NoCacheKey| U | C |
                        +---+---+---+---+---+---+---+---+
                    ]]></artwork>
                </figure>
                
                <t>
                    The option number is TBD.
                </t>
                <t>
                    The resultant SeqNum option is:
                </t>
                <figure align="center" anchor="SeqNum" title="SeqNum option">
                    <!-- maximum wide of the figure                                   -->
                    <artwork align="left"><![CDATA[
                        
                          
   +-----+---+---+---+---+--------+--------+--------+---------+
   | No. | C | U | N | R | Name   | Format | Length | Default |
   +-----+---+---+---+---+--------+--------+--------+---------+
   | TBD | x |   | x |   | SeqNum | uint   |  0-16  | (none)  |
   +-----+---+---+---+---+--------+--------+--------+---------+

   C = Critical,   U = Unsafe,   N = NoCacheKey,   R = Repeatable
                    ]]></artwork>
                </figure>
                
                
            </section>
                
                
          
        
        </section>
        
        <section anchor="key_deriv" title="Key Derivation for protecting CoAP messages">
            <t>
                As a result of a successful EAP authentication, both CoAP
                server and CoAP client share a Master Key Session (MSK).
                The assumption is that MSK is a fresh key so any derived key
                from the MSK will be also fresh. We have considered the
                derivation of either the OSCORE Security Context or pre-shared
                key that can be used for a DTLS negotiation (DTLS_PSK) (in the Appendix)
            </t>
            
            <section anchor="oscore"  title="Deriving the OSCORE Security Context">
                <t>
                    Key material needed to derive the OSCORE Security Context,
                    from the MSK can be done as follows. First,  HKDF SHA-256 <xref target="RFC5869"></xref> is mandatory to implement. We assume the use of the default algorithms HKDF SHA-256 and AES-CCM-16-64-128. The extract phase of HKDF produces a pseudo-random key ( that we refer to here as RK) that is used to generate the OSCORE Security Context in the Expand phase. The derivation is done as follows:

                        
                </t>
                
                 <t>

                     RK = HMAC-SHA-256(MSK)
                     
                </t>
                
                 <t>

                     Where:

                     <list style="symbols">
                         <t>
                             MSK is the Master Session Key derived from the EAP method.
                         </t>

                         <t>
                             RK is the Random Key that is generated from the MSK in the Extract phase.
                         </t>
                     </list>
                     
                 </t>
                 <t>
                     Discussions about the use of the MSK for the key derivation are done in Section <xref target="security_considerations"></xref>.
                 </t>
                <!--Rafa estaria bien que estan haciendo otros protocolos para
                 hacer esta derivacion. Que algoritmos usan por si hay alguno
                 por defecto ya. De hecho, usamos estos porque nuestra mota
                los tenia. -->
                
                <!--
                Segun oscore
                 - HKDF SHA-256 is mandatory to implement.
            
                [...]-Assuming use of the
                default algorithms HKDF SHA-256 and AES-CCM-16-64-128, the extract
                phase of HKDF produces a pseudorandom key (PRK) as follows:
                
                -->
   
               <t>
                   Based on the RK generated from the MSK, we can now generate the Master Secret and Master Salt. The key derivation is performed as follows:
               </t>

   
                <t>
                      Master_Secret = HKDF(RK, "IETF_OSCORE_MASTER_SECRET", length)
                </t>
                <t>
                    where:
                </t>
                <t>
                    <list style="symbols">
                        <t>
                            The RK is exported in the Extract Phase, previously commented.
                        </t>
                        <t>
                            "IETF_OSCORE_MASTER_SECRET" is the ASCII code representation of the non-NULL terminated string (excluding the double quotes around it).
                        </t>
                        <t>
                            length is the length of the Master_Secret. We set the length to 32 bytes
                        </t>
                    </list>
                </t>

                <t>
                  The Master Salt can be derived as follows:
                   
                </t>
                <t>
                      Master_Salt = HKDF(PK, "IETF_OSCORE_MASTER_SALT",  length)
                </t>
                <t>
                    where:
                </t>
                <t>
                    <list style="symbols">

                        <t>
                            The RK is exported in the Extract Phase, previously commented.
                        </t>
                        <t>
                            "IETF_OSCORE_MASTER_SALT" is the ASCII code representation of the non-NULL terminated string (excluding the double quotes around it).
                        </t>
                        <t>
                            length is the length of the Master Salt. We set the length to 8 bytes.
                        </t>
                    </list>
                </t>
                <t>
                  The ID Context can be set to the Identity of the EAP peer.
                </t>


            </section>
        </section>
        
        
        <section title="Use Case Scenario">
            <t>
                In the following, we explain a basic example about the usage of CoAP-EAP.  There are 5 entities involved in the scenario:
            </t>
            <t>

                <list style="symbols">
                     <t>
                        2 nodes (A and B), which are constrained devices.
                     </t>
                     <t>
                         1 node D, which is considered a no so constrained device, such a phone, or a tablet or even a laptop.
                     </t>
                     <t>
                        1 controller (C).  The controller manages a domain where nodes can be deployed.  It can be considered a more powerful machine than the nodes.
                     </t>
                     <t>
                    1 AAA server (AAA).  The AAA is an Authentication, Authorization and Accounting Server, which is not constrained.
                     </t>

                 </list>
            </t>
            <t>
                Any node wanting to join the domain managed by the controller,
                MUST perform an CoAP-EAP authentication with the controller C.
                This authentication may involve an external AAA
                server.  This means that A and B, once deployed, will perform
                this
                CoAP-EAP once as a bootstrapping phase to establish a security
                association with the controller C.  Moreover, any other entity
                (i.e. node D) , which wants to join and establish
                communications with nodes under the controller C's domain must
                also do the same.
            </t>
            <t>
               Let us assume that the node A wants to communicate with
                node B (e.g. to active a light switch).  The overall process is
                divided in three phases.  Let's start with node A.  In the first
                phase, the node A (EAP peer) does not yet belong to the
                controller C's domain.  Then, it communicates with controller C
                (EAP authenticator) and authenticates with CoAP-EAP, which, in
                turn, communicates with the AAA server to complete the
                authentication
                process.  If the authentication is successful, key material is
                distributed to the controller C and derived by node A.  This key
                material allows node A to establish a security association with
                controller C.  Some authorization information coming from the
                AAA infrastructure may be also provided in
                this step.  If authentication and authorization are correct,
                node A
                is enrolled in the controller C's domain during a period of
                time.  In
                particular, <xref target="RFC5247"></xref> recommends 8 hours, though 
                the AAA server can establish a different lifetime.  In the same manner, B needs 
                to perform the same process with CoAP-EAP to be part of the controller C's domain.
            </t>
            <t>
                In the second phase, when node A wants to talk with node B, it
                contacts the controller C for authorization to access node B and
                obtain all the required information to do that in a secure
                manner (e.g. keys, tokens, authorization information, etc.). 
                It does NOT require the usage of CoAP-EAP.  The details of this
                phase are out of
                scope of this document, but ACE framework can be used for this
                purpose <xref target="I-D.ietf-ace-oauth-authz"></xref>
            </t>
            <t>
                In the third phase, the node A can access node B with the credentials
                and information obtained from the controller C in the second phase.
                This access can be repeated without contacting the controller, while
                the credentials given to A are still valid.  The details of this
                phase are out of scope of this document.
            </t>
            <t>
                It is worth noting that first phase with CoAP-EAP is ONLY required to
                join the controller C's domain.  Once it is performed with success,
                the communications are local to the controller C's domain so there is
                no need to contact the external AAA server nor performing EAP authentication.
            </t>

        </section>

				<!-- No se pero igual nos merece anyadir una seccion (por poner el huevo) donde se diga (further re-authentications) por indicar explicitamente que se esto es una unica vez y se podria utilizar ERP para optimizar. -->


    
    <section title="Discussion">
        <section title="CoAP as EAP lower-layer">
            <t> In this section we discuss the suitability of the CoAP protocol as EAP lower layer, and review the requisites imposed by the EAP protocol to any protocol that transports EAP. The assumptions EAP makes about its lower layers can be found in section 3.1 of the rfc <xref target="RFC3748"> </xref>, which are enumerated next:
            </t>

            <t>
                <list style="symbols">
                <t>
                    Unreliable transport. EAP does not assume that lower layers are reliable.
                </t>
                <t>
                    Lower layer error detection. EAP relies on lower layer error detection (e.g., CRC, Checksum, MIC, etc.)
                 </t>
                <t>
                   Lower layer security. EAP does not require security services from the lower layers.
                 </t>
                <t>
                    Minimum MTU.  Lower layers need to provide an EAP MTU size of 1020 octets or greater.
                 </t>
                <t>
                    Possible duplication. EAP stipulates that,  while desirable, it does not require for the lower layers to provide non-duplication.
                 </t>
                 <t>
                    Ordering guarantees. EAP relies on lower layer ordering guarantees for correct operation.
                 </t>
                </list>
            </t>

            <t>
                Regarding the unreliable transport, although EAP assumes a non reliable transport, CoAP does provide a reliability mechanism through the use of Confirmable messages. For the error detection, CoAP goes on top of UDP which provides a checksum mechanism over its payload. Lower layer security services are not required. About the minimum MTU of 1020 octets, CoAP assumes an upper bound of 1024 for its payload which covers the requirements for EAP. Regarding message ordering, we propose the use of a new CoAP option, the SeqNum option described in Section <xref target="seqnum"> </xref>, which will allow keep the order in which the different messages are exchanged.
            </t>
  
            <t>
                Regarding the Token, we consider the use of a constant
            value using a small 1 byte Token. In fact, the EAP
            server will not send a new EAP
            request until it has processed the expected EAP
            response. Additionally, we are under the assumption
            that there will a single EAP authentication between the
            constrained device and the same Controller.
            </t>

 

        </section>
        <section title="Size of the EAP lower-layer vs EAP method size">
        <t>
            Using CoAP as EAP lower layer guarantees a constrained transport for EAP in constrained environments. However, it is a fair to ask about the level of improvement taking into account the overload represented by the EAP method. In fact, if the EAP method is very taxing in the number of messages and the bytes sent over the networks the improvement achieved in the EAP lower-layer may be less significant (<xref target="coap-eap"></xref>). However, if the EAP method is lightweight and suitable for constrained networks (e.g. EAP-PSK, as a representative example of a lightweight EAP method) a constrained EAP lower-layer brings more benefits. This leads to the conclusion that possible next steps in this field could be also improving or designing new EAP methods that can be better adapted to the requirements of constrained devices and networks. Therefore, others EAP methods such as EAP-AKA or new lightweight EAP methods such as EAP-EDHOC <xref target="I-D.ingles-eap-edhoc"></xref> may benefit from a CoAP-based EAP lower-layer, as well as any new lightweight EAP method.
        </t>
				
				
			<!-- Rafa: Deberiamos poner EAP-NOOB no crees como metodo que habla de  IoT
            EAP-NOOB ocupaba bastante en bytes, por lo que dijimos de no incluirlo para no pegarnos el tiro en el pie.
            -->
        </section>
        
        <section title="Controller as the CoAP Client">
         <t>
             Due to the constrained capacities of the devices, to relieve them of the retransmission tasks, we set the Controller as the CoAP client, for the main exchange following the recommendations of the <xref target="I-D.ietf-lwig-coap"></xref> document to simplify the constrained device implementation.
         </t>
        </section>
        <section title="Possible Optimizations">
            <section title="Empty Token">
                <t>
                Assuming that the bootstrapping service runs before any other service, and that no other service will run concurrently until it has finished, we could use an Emtpy Token value to save resources, since there will be no other endpoint or CoAP exchange.
                </t>
            </section>
            <section title="Removing SeqNum Option">
                <t>
                    An alternative to consider would be to try to rely on the Message ID values as a way of achieving the order delivery throughout the authentication exchange. Here we have two approximations: 1) Removing the option from the ACKs and 2) removing the option completely.

                    <list style="numbers">
                    <t>
                        Since the ACKs are piggybacked by design, there is only 1 ongoing authentication process and the EAP exchange is done in a lockstep fashion, when we get a response we will get the same Message ID of the request and we can confirm the SeqNum of the Request.

                    </t>
                    <t>
                        An alternative to consider would be to try to solely rely on the Message ID values as a way of achieving the order delivery throughout the authentication exchange. Here we also have two approaches: A) To expect randomly generated Message IDs and B) set the Message ID to increase monotonically by 1.
                    <list style="letters">
                    <t>
                        Regarding the use of the Message ID, their values in the requests sent by the Controller are generated randomly, as suggested by CoAP. The Controller selects a new Message ID value each time a new request is sent to the CoAP server, until the bootstrapping service finishes. Moreover, the Controller stores the last Message ID sent until correctly receiving the corresponding ACK. The CoAP server keeps track of the last received Message ID to identify retransmissions, and the previous Message IDs during the current bootstrapping to identify old messages. In general, a request is considered valid in terms of the Message ID if either this value matches the last value received, which means a retransmission of the last response is required, or the arrival of a new Message ID, which therefore represents a new message. If these rules do not apply (i.e., an old Message ID has been received), the CoAP server silently discards the request. This is possible because the bootstrapping service is designed as lockstep, i.e. the Controller will not send a new request until it has received the expected response. When the bootstrapping exchange finishes successfully, the CoAP server can free the tracked Message IDs, except for the last received Message ID at the end of the bootstrapping, just in case a retransmission is required.
                    </t>
                    <t>
                        This case would avoid having to keep track of the already used Message IDs, monotonically increasing by 1 the message ID
                        value once the first is randomly picked by the Controller.
                    </t>
                    </list>
                  </t>
                 </list>
                </t>

            </section>

            <section anchor="furth_auth" title="Further re-authentication">
                <t>
                    Since the initial bootstrapping is usually taxing, it is assumed to be done only once over a long period of time. If further re-authentications for refreshing the key material are necessary, there are other methods that can be used to perform these re-authentications. For example, the EAP re-authentication (EAP-ERP)   <xref target="RFC6696"></xref> can be used to avoid repeating the entire EAP exchange in few exchanges.
                </t>
                
            </section>
        </section>
    </section>

    
    
    
    <section anchor="security_considerations" title="Security Considerations">
        <t>
            There are some aspects to be considered such as how authorization is managed, how the cryptographic suite is selected and how the trust in the Controller is established.
        </t>
    <section title="Authorization">
        <t>
            Authorization is part of the bootstrapping. It serves to establish whether the node can join and the set of conditions it has to adhere. The authorization data received from the AAA server can be delivered by the AAA protocol (e.g. Diameter). Providing more fine grained authorization data can be with the transport of SAML in RADIUS <xref target="RFC7833"></xref>

            After bootstrapping, additional authorization to operate in the security domain, e.g., access services offered by other nodes, can be taken care of by the solutions proposed in the ACE WG.
        </t>
    </section>

    <section title="Cryptographic suite selection">
        <t>
            How the cryptographic suit is selected is also important. To reduce the overhead of the protocol we use a default cryptographic suite. As OSCORE is assumed to run after the EAP authentication, the same default crypto-suite is used in this case as explained in the Key Derivation Section <xref target="key_deriv"></xref>
                            
                            <!--Rafa: Te digo lo mismo aqui de los algoritmos-->
                            
            The cryptographic suite is not negotiated. If the cryptographic suite to be used by the node is different from default, the AAA server will send the specific parameters to the Authenticator. If the cryptographic suite is not supported, the key derivation process would result in a security association failure.

        </t>
    </section>
    <section title="Freshness of the key material">
        <t>
            In this design, we do not exchange nonces to provide freshness to the keys derived from the MSK. This is  done under the assumption that the MSK and EMSK keys derived are fresh key material by the specifications of the EAP KMF. Since only one session key is derived from the MSK we do not have to concern ourselves with the generation of additional key material. In case we need to refresh the MSK, a re-authentication can be done, by running process again, using a more lightweight mechanism to derive additional key material such as ERP  <xref target="RFC6696"></xref>. <!--Rafa: Falta la referencia aqui-->

        </t>
    </section>
</section>
    
    
    <section anchor="IANA" title="IANA Considerations">
            <t>
                This document has no actions for IANA.
            </t>
    </section>
    
    <section title="Acknowledgments">
        <t>
            We would like to thank Pedro Moreno-Sanchez and Gabriel
						Lopez-Millan for the first review of this document.
            Also, we would like to thank Ivan Jimenez-Sanchez for the first
						proof-of-concept implementation of this idea.
        </t>
        <t>
            We also thank for their valuables comments to Alexander Pelov and
						Laurent Toutain, specially for the potential optimizations of
						CoAP-EAP.
        </t>
    </section>    

    </middle>

    <back>
        <references title="Normative References">
            &RFC2119;
            &RFC5247;
            &RFC5295;
            &RFC4493;
            &RFC4615;
            &RFC3748;
            &RFC4764;
            &RFC4279;
            &RFC6345;
            &RFC7252;
            &RFC7967;
            &RFC7833;
            &RFC5191;            
            &RFC7228;            
            &RFC6696;
            &RFC5869;

            &I-D.ohba-core-eap-based-bootstrapping;
            &I-D.kumar-dice-dtls-relay;
            &I-D.pelov-core-cosol;
            &I-D.ietf-ace-oauth-authz;
            &I-D.ietf-lwig-coap;
            &I-D.ingles-eap-edhoc;
            
        </references>
        <references title="Informative References">
            <reference anchor="cantcoap">
                <front>
                    <title>Cantcoap implementation of CoAP</title>
                    <author fullname="Ashley Mills">
                        <address>
                            <uri>https://github.com/staropram/cantcoap</uri>
                        </address>
                    </author>
                    <date month="January" year="2013" />
                </front>
            </reference>
            
            <reference anchor="coap-eap">
                <front>
                    <title>Lightweight CoAP-Based Bootstrapping Service for the Internet of Things - https://www.mdpi.com/1424-8220/16/3/358</title>
                    <author fullname="Dan Garcia-Carrillo">
                        <address></address>
                    </author>
                    <author fullname="Rafael Marin-Lopez">
                        <address>
                        </address>
                    </author>
                    <date month="March" year="2016" />
                </front>
            </reference>


            <reference anchor="Contiki">
                <front>
                    <title>Contiki: The Open Source OS for the Internet of Things</title>
                    <author fullname="Contiki">
                        <address>
                            <uri>http://www.contiki-os.org/</uri>
                        </address>
                    </author>
                    <date month="March" year="2014" />
                </front>
            </reference>
            
            <reference anchor="hostapd">
                <front>
                    <title>hostapd: IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator</title>
                    <author fullname="hostapd">
                        <address>
                            <uri>http://w1.fi/hostapd/</uri>
                        </address>
                    </author>
          <date month="March" year="2014" />
                </front>
            </reference>
            
        </references>
        
        
        <section title="CoAP-EAP with DTLS">
                
                <t>
                    Other possibility at our disposal is to do a DTLS handshake after the MSKs generation and continue the communication
                    between endpoints using CoAP through DTLS as we can see at <xref target="figuredtls"></xref>. The Steps 0-6 are the
                    same as the case with OSCORE, however, before continuing with Steps 7 and 8,
                    the EAP authenticator starts the DTLS handshake with the EAP peer (Step 6'). To establish a DTLS Security Association, a
                    key named DTLS-PSK is derived from MSK (see <xref target="key_deriv"></xref> ). In this case the CoAP client can start
                    DTLS before sending the last message containing the EAP Success. Once DTLS is established, any posterior CoAP exchange is protected.
                    Thus, OSCORE in this instance is not needed for key confirmation, since a successful DTLS negotiation confirms the possession of DTLS_PSK that, in turn, corroborates that both entities participated in the EAP authentication.
                </t>
                
                <figure align="center" anchor="figuredtls" title="EAP over CoAP with DTLS">
                    <!-- maximum wide of the figure                                   -->
                    <artwork align="left"><![CDATA[

             EAP peer                                   EAP Auth.
           (COAP server)                             (COAP client)
           -------------                             -------------
                |                                         |
                | NON [0x6af5]                            |
                | POST /b                                 |
                | No-Response                             |
            0)  | Token (0xab)                            |
                |---------------------------------------->|
                |                                         |
                |                            CON [0x7654] |
                |                                 POST /b |
                |                               SeqNum(x) |
                |                            Token (0xac) |
                |                      Payload EAP Req/Id |
             1) |<----------------------------------------|
                |                                         |
                | ACK [0x7654]                            |
                | SeqNum(x)                               |
                | Token (0xac)                            |
                | 2.01 Created                            |
                | Uri-Path [/b/5]                         |
                | Payload EAP Rep/Id                      |
             2) |---------------------------------------->|
                |                                         |
                |                            CON [0x8694] |
                |                               POST /b/5 |
                |                             SeqNum(x+1) |
                |                           Token (0xac)  |
                |                     Payload EAP-X MSG 1 |
             3) |<----------------------------------------|
                |                                         |
                | ACK [0x8694]                            |
                | Token (0xac)                            |
                | SeqNum(x+1)                             |
                | 2.04 Changed                            |
                | Payload EAP-X MSG 2                     |
             4) |---------------------------------------->|
                                   ....
          
                |                                         |
                |                            CON [0x9869] |
                |                               POST /b/5 |
                |                            SeqNum(x+n/2)|
                |                            Token (0xac) |
                |                 Payload EAP-X MSG (n-1) |
             5) |<----------------------------------------|
                |                                         |
                | ACK [0x9869]                            |
                | SeqNum(x+n/2)                           |
                | Token (0xac)                            |
                | 2.04 Changed                            |
                | Payload EAP-X MSG (n)                   |
          MSK 6)|---------------------------------------->| MSK
            |   |                                         |  |
        DTLS_PSK|                                         | DTLS_PSK
                |                                         |
                |              DTLS HANDSHAKE             |
                |          (Initiated by EAP Auth.)       |
            6') |<--------------------------------------->|
                |                                         |
                |                            CON [0x7811] |
                |                            POST /b/5    |
                |                            Token (0xac) |
                |                     Payload EAP Success | (*)
            7)  |<----------------------------------------|
                |                                         |
                | ACK [0x7811]                            |
            (*) | Token (0xac)                            |
                | 2.04 Changed                            |
             8) |---------------------------------------->|
                
                (*) Protected with DTLS
                             

                        
                        
                          
                    ]]></artwork>
                </figure>
                
                    <section title="Deriving DTLS_PSK">
                <t>
                    In the second alternative, a DTLS_PSK is derived from the MSK between both CoAP endpoints. So far, DTLS_PSK will have also 16 byte length and it will derived from the RK (generated as done in Section <xref target="key_deriv"></xref>)  as follows:
                </t>
                <t>
                       DTLS_PSK = HKDF(RK, "IETF_DTLS_PSK" , length).


                    This
                    value is concatenated with the value of the Token Option value.
                </t>
                
                <t>
                    where:
                </t>
                <t>
                    <list style="symbols">
                        <t>
                            RK is the Random Key generated in the Extract phase, from the MSK.
                        </t>
                        <t>
                            "IETF_DTLS_PSK" is the ASCII code representation of the non-NULL terminated string (excluding the double quotes around it).
                        </t>
                        <t>
                            length is the length of the DTLS_PSK (16 bytes).
                        </t>
                    </list>
                </t>
            </section>

        </section>
    </back>
</rfc>
