<?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 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-00.xml">

<!ENTITY I-D.pelov-core-cosol SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-pelov-core-cosol-00.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="exp" docName="draft-marin-ace-wg-coap-eap-02">
    <!-- 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="Raul Sanchez-Sanchez" initials="R." surname="Sanchez">
            <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 92 81</phone>
                <email>raul@um.es</email>
            </address>
        </author>
        
        <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 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 78 82</phone>
                <email>dan.garcia@um.es</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>
        
        <date month="October" year="2015" />
        
        <!-- 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 two purposes:
            </t>
            <t>
                <list style="symbols">
                    <t>
                        Authenticate two CoAP endpoints.
                    </t>
                    <t>
                        Bootstrap key material to protect CoAP messages exchanged 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 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 a new AUTH option that includes an authentication tag generated with the cryptographic material exported during an EAP authentication. This new option is used to protect the integrity of the CoAP message that carries the AUTH option. (NOTE: Encryption will be considered in the future).</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.
                Nevertheless, a model where the EAP peer act as CoAP client and the EAP authenticator as CoAP server will 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 the CoAP protocol as transport layer for EAP. CoAP becomes an EAP lower-layer (in EAP terminology).
                In general, it is assumed that, since the EAP authenticator may need to implement an AAA client to interact with the AAA infrastructure,
                this endpoint will have more resources. We describe two different sequence flow. First, it is shown in <xref target="figure1"></xref> where
                the AUTH option is used at the end of EAP authentication. Second diagram (see <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 the EAP-PSK method <xref target="RFC4764"></xref> as authentication mechanism. (NOTE: any EAP method which is able to export cryptographic material should be valid).
            </t>
            
            <section title="EAP in CoAP with AUTH option">
                
                <t>
                    If the EAP peer discovers the presence of the EAP authenticator and wants to start the authentication, it can send a Confirmable "GET /auth" request to the node (Step 0). If the EAP authenticator implements the authentication service will return a 2.05 in a Acknowledgment with a piggy-backed response (Step 0'). 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 a "GET /auth" message.
                </t>
                
                <t>
                    In any case, to perform the authentication service, the CoAP client (EAP authenticator) sends a Confirmable "POST /auth"
                    request to the CoAP Server (Step 1). POST message indicates to the CoAP server the creation of a resource for the EAP-based authentication service. 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. Moreover if after a period of
                    time (TBD) no further message is received from the CoAP client, the CoAP server will free the created state.
                    
                    In this moment, the CoAP server has started a resource for the EAP authentication, whose resource identifier value will be used
                    together with the Token option value to relate all the EAP conversation between both CoAP endpoints.
                </t>
                
                
                <t>
                    From now on, the EAP authenticator and the EAP peer will exchange EAP packets transported in the CoAP message payload (Steps 3,4,5,6,7,8,9).
                    The EAP authenticator will use PUT method to send EAP requests to the EAP peer. The EAP peer will use a Piggy-backed response
                    in the Acknowledgement 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>
                    If the new defined AUTH option is used, an authentication tag is generated with a new key named COAP_PSK,
                    derived from the MSK. The Acknowledgment message from the CoAP server will
                    also include an AUTH option so that the CoAP client can verify that the CoAP server obtained the MSK.
                    This is shown in Steps 9 and 10. From that point any exchange (for example, Steps 11 and 12) between both CoAP endpoints
                    are protected with the AUTH option. Finally, the CoAP client MAY send a Confirmable DELETE request to remove all the state
                    related with the authentication service in the CoAP server (Steps 13 and 14).
                    The CoAP server may decide to remove the state after period of time in case not receiving a DELETE request.
                    This may be easier if the EAP authenticator sends a session lifetime option (TBD) in the
                    Step 9 (where the EAP Success is sent).
                </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>
                
                <figure align="center" anchor="figure1" title="CoAP-EAP with AUTH option">
                    <!-- maximum wide of the figure                                   -->
                    <artwork align="left"><![CDATA[
                        
                        
                     EAP peer                                  EAP Auth.
                   (COAP server)                             (COAP client)
                   -------------                             -------------
                        |                                         |
                        | CON [0x6af5]                            |
                    0)  | (Token 0xFA5B45FF4723BB43)              |
                        | GET /auth                               |
                        |---------------------------------------->|
                        |                                         |
                        |                                         |
                        |                       ACK 2.05 [0x6af5] |
                        |              (Token 0xFA5B45FF4723BB43) |
                    0') |                           Payload ["OK"]|
                        |<----------------------------------------|
                        |                                         |
                        |                                         |
                        |                           CON [0x73DE]  |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                              POST /auth |
                        |                        Payload nonce_c  |                    
                     1) |<----------------------------------------|
                        |                                         |
                        | ACK [0x73DE]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.01 Created                            |
                        | Uri-Path [auth/5]                       |
                        | Payload nonce_s                         |
                     2) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x7654] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP Req/Id    |
                        |                             PUT /auth/5 |
                     3) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7654]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP Res/Id                      |
                     4) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x7654] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP-PSK MSG 1 |
                        |                             PUT /auth/5 |
                     5) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7654]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP-PSK MSG 2                   |
                     6) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x9869] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP-PSK MSG 3 |
                        |                             PUT /auth/5 |
                     7) |<----------------------------------------|
                        |                                         |
                        | ACK [0x9869]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP-PSK MSG 4                   |
                     8) |---------------------------------------->|
                    MSK |                                         | MSK
                     |  |                            CON [0x7811] |  |
                COAP_PSK|              (Token 0x78728FD4AC3190FF) |COAP_PSK
                        |                             AUTH option |
                        |                     Payload EAP Success | (*)
                        |                             PUT /auth/5 |
                     9) |<----------------------------------------|
                        |                                         |
                    (*) | ACK [0x7811]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | AUTH option                             |
                        | 2.04 Changed                            |
                    10) |---------------------------------------->|
                        
                        .............
                        
                        |                                         |
                        |                            CON [0x7511] |
                        |              (Token 0x55566AF7464646BC) |  (*)
                        |                             AUTH option |
                        |                               GET /temp |
                    11) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7511]                            |
                   (*)  | (Token 0x55566AF7464646BC)              |
                        | AUTH option                             |
                        | 2.05 Content                            |
                        | "22.5C"                                 |                                      
                    12) |---------------------------------------->|
                        ................
                        
                        |                                         |
                        |                            CON [0x7600] |
                        |              (Token 0x678443AA678BC690) | (*)
                        |                             AUTH option |
                        |                          DELETE /auth/5 |
                    13) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7500]                            |
                    (*) | (Token 0x678443AA678BC690)              |
                        | AUTH option                             |
                        | 2.02 Deleted                            |
                    14) |---------------------------------------->|
                        
                        (*) Protected with AUTH option
                        
                        
                        
                    ]]></artwork>
                </figure>
            </section>
            
            <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-8 are the
                    same as the case with AUTH option, however, before continuing with Steps 10 and 11,
                    the EAP authenticator starts the DTLS handshake with the EAP peer (Step 9'). 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, new AUTH option is not needed. 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)
                  -------------                             -------------
                        |                                         |
                        | CON [0x6af5]                            |
                    0)  | (Token 0xFA5B45FF4723BB43)              |
                        | GET /auth                               |
                        |---------------------------------------->|
                        |                                         |
                        |                                         |
                        |                       ACK 2.05 [0x6af5] |
                        |              (Token 0xFA5B45FF4723BB43) |
                    0') |                           Payload ["OK"]|
                        |<----------------------------------------|
                        |                                         |
                        |                           CON [0x73DE]  |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                              POST /auth |
                        |                        Payload nonce_c  |                    
                     1) |<----------------------------------------|
                        |                                         |
                        | ACK [0x73DE]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.01 Created                            |
                        | Uri-Path [auth/5]                       |
                        | Payload nonce_s                         |
                     2) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x7654] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP Req/Id    |
                        |                             PUT /auth/5 |
                     3) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7654]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP Res/Id                      |
                     4) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x7654] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP-PSK MSG 1 |
                        |                             PUT /auth/5 |
                     5) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7654]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP-PSK MSG 2                   |
                     6) |---------------------------------------->|
                        |                                         |
                        |                            CON [0x9869] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                   Payload EAP-PSK MSG 3 |
                        |                             PUT /auth/5 |
                     7) |<----------------------------------------|
                        |                                         |
                        | ACK [0x9869]                            |
                        | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                        | Payload EAP-PSK MSG 4                   |
                     8) |---------------------------------------->|
                    MSK |                                         | MSK
                     |  |                                         |  |
                DTLS_PSK|                                         | DTLS_PSK
                        |                                         |
                        |              DTLS HANDSHAKE             |
                        |          (Initiated by EAP Auth.)       |
                    9') |<--------------------------------------->|
                        |                                         |
                        |                            CON [0x7811] |
                        |              (Token 0x78728FD4AC3190FF) |
                        |                     Payload EAP Success | (*)
                        |                           PUT /auth/5   |
                    10) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7811]                            |
                    (*) | (Token 0x78728FD4AC3190FF)              |
                        | 2.04 Changed                            |
                    11) |---------------------------------------->|
                        
                        .............
                        
                        |                                         |
                        |                            CON [0x7511] |
                        |              (Token 0xAA763D82F623B7FF) | (*)
                        |                               GET /temp |
                    12) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7511]                            |
                   (*)  | (Token 0xAA763D82F623B7FF)              |
                        | 2.05 Content                            |
                        | "22.5C"                                 |
                    13) |---------------------------------------->|
                        ................
                        
                        |                                         |
                        |                            CON [0x7600] |
                        |              (Token 0x678443AA678BC690) | (*)
                        |                          DELETE /auth/5 |
                    14) |<----------------------------------------|
                        |                                         |
                        | ACK [0x7500]                            |
                    (*) | (Token 0x678443AA678BC690)              |
                        | 2.02 Deleted                            |
                    15) |---------------------------------------->|
                        
                        (*) Protected with DTLS
                        
                        
                    ]]></artwork>
                </figure>
                
            </section>
			<section title="Optimization Considerations">
				<t>
        			Here we consider two possible optimizations for reducing the message length: 
        		</t>
	        	<t>
                    <list style="symbols">
	    			<t>
		        		A first optimization would be to reduce the URI of the bootstrapping service. For example, the /auth URI could be reduced to /a.
					</t>	
					<t>
						Another optimization would be to use a zero length CoAP token in the exchange. 
					</t>
		        	</list>
        		</t>

				<t>
					Some use cases as LoRA Networks <xref target="I-D.pelov-core-cosol"></xref> might take advantage of these reductions to improve the performance of the bootstrapping process.
				</t>


        	</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 COAP_PSK or DTLS_PSK.
            </t>
            
            <section title="Deriving COAP_PSK">
                <t>
                    A key COAP_PSK is derived from the MSK to generate the authentication tag included in the AUTH option. COAP_PSK is derived by using AES-CMAC-PRF-128 <xref target="RFC4615"></xref>, which, in turn, uses AES-CMAC-128 <xref target="RFC4493"></xref>. In this case, rest of CoAP exchanges between both entities can be protected with integrity (NOTE: encryption will be considered in the future) with AUTH option without the need of using DTLS. Thus, all CoAP messages MUST include AUTH option from that point. (NOTE: We understand that this would not be the standard way of protecting CoAP but instead a new way of protecting CoAP messages).
                </t>
                <t>
                    COAP_PSK is a 16-byte length key which is computed in the following way:
                </t>
                <t>
                      COAP_PSK = KDF(MSK, "IETF_COAP_PSK" || nonce_c || nonce_s, 64, length)

                </t>
                <t>
                    where:
                </t>
                <t>
                    <list style="symbols">
                        <t>
                            The AES-CMAC-PRF-128 is defined in <xref target="RFC4615"></xref>. This function uses AES-CMAC-128 as building block.
                        </t>
                        <t>
                            The MSK exported by the EAP method.
                        </t>
                        <t>
                            "IETF_COAP_PSK" is the ASCII code representation of the non-NULL terminated string (excluding the double quotes around it). This
                            value is concatenated with the value of the Token Option value.
                        </t>
                        <t>
                            nonce_c is the random value sent by the EAP Authenticator to the EAP Peer in the POST Message.
                        </t>
                        <t>
                            nonce_s is the random value sent by the EAP Peer to the EAP Authenticator in the Acknowledgment to the POST Message.
                        </t>

                        <t>
                            64 is the length of the MSK.
                        </t>
                        <t>
                            length is the length of the label "IETF_COAP_PSK" (13 bytes).
                        </t>
                    </list>
                </t>
            </section>
            
            <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 as follows:
                </t>
                <t>
                       DTLS_PSK = KDF(MSK, "IETF_DTLS_PSK" || nonce_c || nonce_s, 64, length).  


                    This
                    value is concatenated with the value of the Token Option value.
                </t>
                
                <t>
                    where:
                </t>
                <t>
                    <list style="symbols">
                        <t>
                            MSK is exported by the EAP method.
                        </t>
                        <t>
                            "IETF_DTLS_PSK" is the ASCII code representation of the non-NULL terminated string (excluding the double quotes around it).
                        </t>
                        <t>
                            nonce_c is the random value sent by the EAP Authenticator to the EAP Peer in the POST Message.
                        </t>
                        <t>
                            nonce_s is the random value sent by the EAP Peer to the EAP Authenticator in the Acknowledgment to the POST Message.
                        </t>

                        <t>
                            64 is the length of the MSK.
                        </t>
                        <t>
                            length is the length of the label "IETF_DTLS_PSK" (13 bytes).
                        </t>
                    </list>
                </t>
                
                <t>As mentioned in <xref target="RFC4279"></xref>, a PSK identity is needed. We are considering the usage of the Token Option value chosen during the EAP authentication as identity. In any case, this still needs further investigation.</t>
            </section>
        	
        	

        </section>
        
        <section anchor="auth_option" title="Generating AUTH option">
            <t>
                A new AUTH option is defined in this document for authentication purposes. Following guidelines in
                <xref target="RFC7252"></xref> this option is:
            </t>
            
            <t>
                <list style="numbers">
                    <t>Format opaque (sequence of bytes). </t>
                    <t>Elective.</t>
                    <t>Unsafe to Forward.</t>
                    <t>No cacheable.</t>
                </list>
            </t>
            
            <t>
                The number of the option will be determined by this previous decisions.
            </t>
            
            <t>
                <list style="numbers">
                    <t>Elective (C = 0)</t>
                    <t>Unsafe to Forward (0)</t>
                    <t>NoCacheKey (111)</t>
                </list>
            </t>
            
            <t>The number of the AUTH option will fit this pattern: xxx11100</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>
                First available option number is 01011100 (92).
            </t>
            
            <t>
                The resultant AUTH option is:
            </t>
            
            <figure align="center" anchor="auth_option_2" title="AUTH Option">
                
                <artwork align="left"><![CDATA[
                    +-----+----+---+---+---+-----------+--------+--------+---------+
                    | No. | C  | U | N | R | Name      | Format | Length | Default |
                    +-----+----+---+---+---+-----------+--------+--------+---------+
                    |  92 |    |   | x |   | AUTH      | opaque | 128    | (none)  |
                    +-----+----+---+---+---+-----------+--------+--------+---------+
                ]]></artwork>
            </figure>
            
            <t>C, U, N and R columns indicate the properties,
                Critical, UnSafe, NoCacheKey and Repeatable, respectively.</t>
            
            <t>
                To generate the value of the AUTH option, we use AES-CMAC-128 as authentication algorithm. Thus, the AUTH option content
                will have an authentication tag of 16 bytes.
            </t>
            
            
            <t>
                AUTH Option value = AES-CMAC-128(COAP_PSK, MSG, MSG_LENGTH)
            </t>
            <t>
                where:
            </t>
            <t>
                <list style="symbols">
                    <t>
                        COAP_PSK is the key derived in the CoAP Security Association process.
                    </t>
                    <t>
                        MSG is the CoAP message including AUTH option filled with zeros.
                    </t>
                    <t>
                        MSG_LENGTH. Length of the CoAP message.
                    </t>
                </list>
            </t>
            <t>
                After applying AES-CMAC-128 function, the AUTH option value will be set in the AUTH option replacing the zeros.
            </t>
            
        </section>
        
        <section anchor="Implementation" title="Implementation">
            <t>
                At the time of writing this document, we have developed a proof-of-concept based on libcoap (<xref target="libCoAP"></xref>) in PC platform and started the development of a simulation with COOJA network simulator for Contiki (<xref target="Contiki"></xref>).
            </t>
            
            <t>
                So far, we have implemented an authentication tag by using AES-CMAC-128. However this authentication tag has been included in the payload of two final messages after sending the EAP Success. The implementation of the AUTH option will come soon. Moreover, we have used AES-CMAC-128 for COAP_PSK. Since this function does not allow a key longer than 16 bytes, we have used the most significative 16 bytes of the MSK as input key. Since AES-CMAC-PRF-128 eliminates this limitation, we will implement this version instead.
            </t>
            <t>
                We are using (for the PC version) libeap in wpa-supplicant and hostapd open source software (<xref target="hostapd"></xref>) to implement the EAP stack and, in particular, the EAP-PSK method.
            </t>
            
        </section>
        
        <section title="Future Work: CoAP Relay" >
            <t>
                Architecture explained in <xref target="arch"></xref> assumes that EAP peer can communicate with the EAP authenticator.
                In certain scenarios, EAP authenticator may not be reachable from the EAP peer if the EAP authenticator is placed several hops-away. In this scenario, described in <xref target="arch_multihop"></xref>,
                we are considering the usage a new service that assists the authentication. This service acts as a relay of CoAP messages between the EAP peer and EAP authenticator.
                We have called the entity in charge of performing this service CoAP relay. The strategy is similar to the one described in PANA Relay (<xref target="RFC6345"></xref>) or DTLS Relay (<xref target="I-D.kumar-dice-dtls-relay"></xref>). Unlike CoAP proxy, the CoAP relay is not intended to keep any state (stateless behaviour) and the EAP peer is not assumed to be aware of the presence of the CoAP relay. In any case, this part needs further investigation since CoAP already provides the concept of CoAP proxy and, particular, CoAP-to-CoAP proxy that might be used instead.
            </t>
            
            <figure align="center" anchor="arch_multihop" title="CoAP EAP Relay Architecture">
                
                <!-- maximum wide of the figure                                   -->
                <artwork align="left"><![CDATA[
                    
                    
                    +------------+        +------------+        +--------------+
                    | EAP peer/  |        |            |        |  EAP auth    |
                    | CoAP server|+------+| CoAP relay |+------+|  CoaP client |
                    +------------+  CoAP  +------------+  CoAP  +--------------+
                    |
                    AAA |
                    |
                    +--------------+
                    |  EAP server/ |
                    |  AAA server  |
                    +--------------+
                    
                    
                ]]></artwork>
            </figure>
            
            <t>
                Once the EAP peer has been authenticated, CoAP relay service should not be needed anymore for this EAP peer.
            </t>
            
            <t> 
                Development of this new service may modify the "Unsafe to Forward" flag of the AUTH option. 
            </t>
            
        </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 as
      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, however it may have some constrained resources.
                     </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 and CoAP-EAP authentication with the controller C.  This
                authentication, as depicted in Figure 6, 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>
                One use case is the following.  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 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 this 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.
            </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.
            </t>
            <t>
                Another use case is the following.  Node D wants to communicate with
                node A (e.g. to obtain a temperature measurement).  To do that, first
                of all, node D must join the controller C's domain.  To do that it
                performs a CoAP-EAP authentication and authorization with the
                controller C (first phase).  If everything ends with success, the
                node D can request access to node A to C (second phase).  Then if
                node D is authorized can access to node A (third phase).  So, in the
                end, node D also implements CoAP-EAP as any other constrained node.
            </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>
                    
            <t>
                This work has been partly funded by European Commission through the
                FP7-SMARTIE-609062 EU Project.
            </t>
        </section>
        
        <section anchor="Security" title="Security Considerations">
            <t>
                TBD. 
            </t>
        </section>
        
        
        <section anchor="IANA" title="IANA Considerations">
            <t>
                This document has no actions for IANA.
            </t>
        </section>
        
    </middle>
    
    <back>
        <references title="Normative References">
            &RFC2119;
            &RFC5247;
            &RFC5295;
            &RFC4493;
            &RFC4615;
            &RFC3748;
            &RFC4764;
            &RFC4279;
            &RFC6345;
            &RFC7252;
            &I-D.ohba-core-eap-based-bootstrapping;
            &I-D.kumar-dice-dtls-relay;
            &I-D.pelov-core-cosol;
        </references>
        <references title="Informative References">
            <reference anchor="libCoAP">
                <front>
                    <title>C-Implementation of CoAP</title>
                    <author fullname="Olaf Bergmann">
                        <address>
                            <uri>http://libcoap.sourceforge.net/</uri>
                        </address>
                    </author>
                    <date month="January" year="2013" />
                </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>
        
    </back>
</rfc>