Internet-Draft EDHOC for OSCORE with CoAP Transport May 2021
Palombini, et al. Expires 22 November 2021 [Page]
Workgroup:
CoRE Working Group
Internet-Draft:
draft-ietf-core-oscore-edhoc-latest
Published:
Intended Status:
Standards Track
Expires:
Authors:
F. Palombini
Ericsson
M. Tiloca
RISE AB
R. Hoeglund
RISE AB
S. Hristozov
Fraunhofer AISEC
G. Selander
Ericsson

Using EDHOC for OSCORE with CoAP Transport

Abstract

This document defines how the lightweight authenticated key exchange protocol EDHOC is used for establishing an OSCORE Security Context, using CoAP for message transferring. Furthermore, this document defines an optimization approach for combining EDHOC run over CoAP with the first subsequent OSCORE transaction. This reduces the number of round trips required to set up an OSCORE Security Context and to complete an OSCORE transaction using that Security Context.

Discussion Venues

This note is to be removed before publishing as an RFC.

Discussion of this document takes place on the Constrained RESTful Environments Working Group mailing list (core@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/core/.

Source for this draft and an issue tracker can be found at https://github.com/core-wg/oscore-edhoc.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 22 November 2021.

Table of Contents

1. Introduction

Ephemeral Diffie-Hellman Over COSE (EDHOC) [I-D.ietf-lake-edhoc] is a lightweight authenticated key exchange protocol, especially intended for use in constrained scenarios. As defined in Section 7.2 of [I-D.ietf-lake-edhoc], EDHOC messages can be transported over the Constrained Application Protocol (CoAP) [RFC7252].

This document builds on the EDHOC specification [I-D.ietf-lake-edhoc] and defines how EDHOC run over CoAP is used for establishing a Security Context for Object Security for Constrained RESTful Environments (OSCORE) [RFC8613].

In addition, this document defines an optimization approach that combines EDHOC run over CoAP with the first subsequent OSCORE transaction. This allows for a minimum number of round trips necessary to setup the OSCORE Security Context and complete an OSCORE transaction, for example, when an IoT device gets configured in a network for the first time.

This optimization is desirable, since the number of protocol round trips impacts the minimum number of flights, which in turn can have a substantial impact on the latency of conveying the first OSCORE request, when using certain radio technologies.

Without this optimization, it is not possible, not even in theory, to achieve the minimum number of flights. This optimization makes it possible also in practice since the last message of the EDHOC protocol can be made relatively small (see Section 1 of [I-D.ietf-lake-edhoc]), thus allowing additional OSCORE protected CoAP data within target MTU sizes.

1.1. Terminology

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

The reader is expected to be familiar with terms and concepts defined in CoAP [RFC7252], CBOR [RFC8949], CBOR sequences [RFC8742], OSCORE [RFC8613] and EDHOC [I-D.ietf-lake-edhoc].

2. EDHOC Overview

The EDHOC protocol allows two peers to agree on a cryptographic secret, in a mutually-authenticated way and by using Diffie-Hellman ephemeral keys to achieve perfect forward secrecy. The two peers are denoted as Initiator and Responder, as the one sending or receiving the initial EDHOC message_1, respectively.

After successful processing of EDHOC message_3, both peers agree on a cryptographic secret that can be used to derive further security material, and especially to establish an OSCORE Security Context [RFC8613]. The Responder can also send an optional EDHOC message_4 to achieve key confirmation, e.g. in deployments where no protected application message is sent from the Responder to the Initiator.

Section 7.2 of [I-D.ietf-lake-edhoc] specifies how to transport EDHOC over CoAP. That is, the EDHOC data (referred to as "EDHOC messages") are transported in the payload of CoAP requests and responses. The default message flow consists in the CoAP Client acting as Initiator and the CoAP Server acting as Responder. Alternatively, the two roles can be reversed. In the rest of this document, EDHOC messages are considered to be transported over CoAP.

Figure 1 shows a Client and Server running EDHOC as Initiator and Responder, respectively. That is, the Client sends a POST request with payload EDHOC message_1 to a reserved resource at the CoAP Server, by default at Uri-Path "/.well-known/edhoc". This triggers the EDHOC exchange at the Server, which replies with a 2.04 (Changed) Response with payload EDHOC message_2. Finally, the Client sends a CoAP POST request to the same resource used for EDHOC message_1, with payload EDHOC message_3. The Content-Format of these CoAP messages may be set to "application/edhoc".

After this exchange takes place, and after successful verifications as specified in the EDHOC protocol, the Client and Server can derive an OSCORE Security Context, as defined in Section 4 of this document. After that, they can use OSCORE to protect their communications.

   CoAP Client                                  CoAP Server
(EDHOC Initiator)                            (EDHOC Responder)
        | ------------- EDHOC message_1 ------------> |
        |          Header: POST (Code=0.02)           |
        |       Uri-Path: "/.well-known/edhoc"        |
        |      Content-Format: application/edhoc      |
        |                                             |
        | <------------ EDHOC message_2 ------------- |
        |            Header: 2.04 Changed             |
        |      Content-Format: application/edhoc      |
        |                                             |
EDHOC verification                                    |
        |                                             |
        | ------------- EDHOC message_3 ------------> |
        |          Header: POST (Code=0.02)           |
        |        Uri-Path: "/.well-known/edhoc"       |
        |      Content-Format: application/edhoc      |
        |                                             |
        |                                    EDHOC verification
        |                                             +
OSCORE Sec Ctx                                OSCORE Sec Ctx
  Derivation                                     Derivation
        |                                             |
        | ------------- OSCORE Request -------------> |
        |          Header: POST (Code=0.02)           |
        |                                             |
        | <------------ OSCORE Response ------------- |
        |            Header: 2.04 Changed             |
        |                                             |
Figure 1: EDHOC and OSCORE run sequentially

As shown in Figure 1, this purely-sequential way of first running EDHOC and then using OSCORE takes three round trips to complete.

Section 5 defines an optimization for combining EDHOC with the first subsequent OSCORE transaction. This reduces the number of round trips required to set up an OSCORE Security Context and to complete an OSCORE transaction using that Security Context.

3. Transferring EDHOC in CoAP

When using EDHOC over CoAP for establishing an OSCORE Security Context, EDHOC messages are exchanged as defined in Section 7.2 of [I-D.ietf-lake-edhoc], with the following addition.

EDHOC error messages sent as CoAP responses MUST be error responses, i.e. they MUST specify a CoAP error response code. In particular, it is RECOMMENDED that such error responses have response code either 4.00 (Bad Request) in case of client error (e.g. due to a malformed EDHOC message), or 5.00 (Internal Server Error) in case of server error (e.g. due to failure in deriving EDHOC key material).

4. Deriving an OSCORE Security Context from EDHOC

After successful processing of EDHOC message_3 (see Section 5.5 of [I-D.ietf-lake-edhoc]), the Client and Server derive Security Context parameters for OSCORE (see Section 3.2 of [RFC8613]) as follows.

   Master Secret = EDHOC-Exporter( "OSCORE Master Secret", key_length )
   Master Salt   = EDHOC-Exporter( "OSCORE Master Salt", salt_length )

The Client and Server use the parameters above to establish an OSCORE Security Context, as per Section 3.2.1 of [RFC8613].

From then on, the Client and Server MUST be able to retrieve the OSCORE protocol state using its chosen connection identifier, and optionally other information such as the 5-tuple, i.e., the tuple (source IP address, source port, destination IP address, destination port, transport protocol).

5. EDHOC Combined with OSCORE

This section defines an optimization for combining the EDHOC exchange with the first subsequent OSCORE transaction, thus minimizing the number of round trips between the two peers.

This approach can be used only if the default EDHOC message flow is used, i.e., when the Client acts as Initiator and the Server acts as Responder, while it cannot be used in the case with reversed roles.

When running the purely-sequential flow of Section 2, the Client has all the information to derive the OSCORE Security Context already after receiving EDHOC message_2 and before sending EDHOC message_3.

Hence, the Client can potentially send both EDHOC message_3 and the subsequent OSCORE Request at the same time. On a semantic level, this requires sending two REST requests at once, as in Figure 2.

   CoAP Client                                  CoAP Server
(EDHOC Initiator)                            (EDHOC Responder)
        | ------------- EDHOC message_1 ------------> |
        |          Header: POST (Code=0.02)           |
        |       Uri-Path: "/.well-known/edhoc"        |
        |      Content-Format: application/edhoc      |
        |                                             |
        | <------------ EDHOC message_2 ------------- |
        |            Header: 2.04 Changed             |
        |      Content-Format: application/edhoc      |
        |                                             |
EDHOC verification                                    |
        +                                             |
  OSCORE Sec Ctx                                      |
    Derivation                                        |
        |                                             |
        | ---- EDHOC message_3 + OSCORE Request ----> |
        |          Header: POST (Code=0.02)           |
        |                                             |
        |                                    EDHOC verification
        |                                             +
        |                                     OSCORE Sec Ctx
        |                                        Derivation
        |                                             |
        | <------------ OSCORE Response ------------- |
        |            Header: 2.04 Changed             |
        |                                             |
Figure 2: EDHOC and OSCORE combined

To this end, the specific approach defined in this section consists of sending EDHOC message_3 inside an OSCORE protected CoAP message.

The resulting EDHOC + OSCORE request is in practice the OSCORE Request from Figure 1, as still sent to a protected resource and with the correct CoAP method and options, but with the addition that it also transports EDHOC message_3.

As EDHOC message_3 may be too large to be included in a CoAP Option, e.g., if containing a large public key certificate chain, it has to be transported in the CoAP payload of the EDHOC + OSCORE request.

The rest of this section specifies how to transport the data in the EDHOC + OSCORE request and their processing order. In particular, the use of this approach is explicitly signalled by including an EDHOC Option (see Section 5.1) in the EDHOC + OSCORE request. The processing of the EDHOC + OSCORE request is specified in Section 5.2 for the Client side and in Section 5.3 for the Server side.

5.1. EDHOC Option

This section defines the EDHOC Option. The option is used in a CoAP request, to signal that the request payload conveys both an EDHOC message_3 and OSCORE protected data, combined together.

The EDHOC Option has the properties summarized in Figure 3, which extends Table 4 of [RFC7252]. The option is Critical, Safe-to-Forward, and part of the Cache-Key. The option MUST occur at most once and is always empty. If any value is sent, the value is simply ignored. The option is intended only for CoAP requests and is of Class U for OSCORE [RFC8613].

+-------+---+---+---+---+-------+--------+--------+---------+
| No.   | C | U | N | R | Name  | Format | Length | Default |
+-------+---+---+---+---+-------+--------+--------+---------+
| TBD21 | x |   |   |   | EDHOC | Empty  |   0    | (none)  |
+-------+---+---+---+---+-------+--------+--------+---------+
       C=Critical, U=Unsafe, N=NoCacheKey, R=Repeatable
Figure 3: The EDHOC Option.

The presence of this option means that the message payload contains also EDHOC data, that must be extracted and processed as defined in Section 5.3, before the rest of the message can be processed.

Figure 4 shows the format of a CoAP message containing both the EDHOC data and the OSCORE ciphertext, using the newly defined EDHOC option for signalling.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Ver| T |  TKL  |      Code     |          Message ID           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Token (if any, TKL bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  OSCORE option  |   EDHOC option  | other options (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 1 1 1 1 1 1|    Payload
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 4: CoAP message for EDHOC and OSCORE combined - signalled with the EDHOC Option

5.2. Client Processing

The Client prepares an EDHOC + OSCORE request as follows.

  1. Compose EDHOC message_3 as per Section 5.4.2 of [I-D.ietf-lake-edhoc].

    Since the Client is the EDHOC Initiator and the used Correlation Method is 1 (see Section 3.2.4 of [I-D.ietf-lake-edhoc]), the EDHOC message_3 always includes the Connection Identifier C_R and CIPHERTEXT_3. Note that C_R is the OSCORE Sender ID of the Client, encoded as a bstr_identifier (see Section 5.1 of [I-D.ietf-lake-edhoc]).

  2. Encrypt the original CoAP request as per Section 8.1 of [RFC8613], using the new OSCORE Security Context established after receiving EDHOC message_2.

    Note that the OSCORE ciphertext is not computed over EDHOC message_3, which is not protected by OSCORE. That is, the result of this step is the OSCORE Request as in Figure 1.

  3. Build a CBOR sequence [RFC8742] composed of two CBOR byte strings in the following order.

    • The first CBOR byte string is the CIPHERTEXT_3 of the EDHOC message_3 resulting from step 3.
    • The second CBOR byte string has as value the OSCORE ciphertext of the OSCORE protected CoAP request resulting from step 2.
  4. Compose the EDHOC + OSCORE request, as the OSCORE protected CoAP request resulting from step 2, where the payload is replaced with the CBOR sequence built at step 3.
  5. Signal the usage of this approach within the EDHOC + OSCORE request, by including the new EDHOC Option defined in Section 5.1.

5.3. Server Processing

When receiving a request containing the EDHOC option, i.e. an EDHOC + OSCORE request, the Server MUST perform the following steps.

  1. Check that the payload of the EDHOC + OSCORE request is a CBOR sequence composed of two CBOR byte strings. If this is not the case, the Server MUST stop processing the request and MUST respond with a 4.00 (Bad Request) error message.
  2. Extract CIPHERTEXT_3 from the payload of the EDHOC + OSCORE request, as the first CBOR byte string in the CBOR sequence.
  3. Rebuild EDHOC message_3, as a CBOR sequence composed of two CBOR byte strings in the following order.

    • The first CBOR byte string is the 'kid' of the Client indicated in the OSCORE option of the EDHOC + OSCORE request, encoded as a bstr_identifier (see Section 5.1 of [I-D.ietf-lake-edhoc]).
    • The second CBOR byte string is the CIPHERTEXT_3 retrieved at step 2.
  4. Perform the EDHOC processing on the EDHOC message_3 rebuilt at step 3, including verifications, and the OSCORE Security Context derivation, as per Section 5.4.3 and Section 7.2.1 of [I-D.ietf-lake-edhoc], respectively.

    If the applicability statement used in the EDHOC session specifies that EDHOC message_4 shall be sent, the Server MUST stop the EDHOC processing and consider it failed, as due to a client error.

  5. Extract the OSCORE ciphertext from the payload of the EDHOC + OSCORE request, as the value of the second CBOR byte string in the CBOR sequence.
  6. Rebuild the OSCORE protected CoAP request as the EDHOC + OSCORE request, where the payload is replaced with the OSCORE ciphertext resulting from step 5.
  7. Decrypt and verify the OSCORE protected CoAP request resulting from step 6, as per Section 8.2 of [RFC8613], by using the new OSCORE Security Context established at step 4.
  8. Process the CoAP request resulting from step 7.

If steps 4 (EDHOC processing) and 7 (OSCORE processing) are both successfully completed, the Server MUST reply with an OSCORE protected response, in order for the Client to achieve key confirmation (see Section 5.4.2 of [I-D.ietf-lake-edhoc]). The usage of EDHOC message_4 as defined in Section 7.1 of [I-D.ietf-lake-edhoc] is not applicable to the approach defined in this specification.

If step 4 (EDHOC processing) fails, the server discontinues the protocol as per Section 5.4.3 of [I-D.ietf-lake-edhoc] and responds with an EDHOC error message, formatted as defined in Section 6.1 of [I-D.ietf-lake-edhoc]. In particular, the CoAP response conveying the EDHOC error message MUST have Content-Format set to application/edhoc defined in Section 9.5 of [I-D.ietf-lake-edhoc].

If step 4 (EDHOC processing) is successfully completed but step 7 (OSCORE processing) fails, the same OSCORE error handling applies as defined in Section 8.2 of [RFC8613].

5.4. Example of EDHOC + OSCORE Request

Figure 5 shows an example of EDHOC + OSCORE Request, based on the OSCORE test vector from Appendix C.4 of [RFC8613] and the EDHOC test vector from Appendix B.2 of [I-D.ietf-lake-edhoc]. In particular, the example assumes that:

  • The used OSCORE Partial IV is 0, consistently with the first request protected with the new OSCORE Security Context.
  • The OSCORE Sender ID of the Client is 0x00. This corresponds to the numeric EDHOC Connection Identifier C_R, which in EDHOC message_3 is encoded as the CBOR integer 0, hence as 0x00.
  • The EDHOC option is registered with CoAP option number 21.
   o  OSCORE option value: 0x090020 (3 bytes)

   o  EDHOC option value: - (0 bytes)

   o  C_R: 0x00 (1 byte)

   o  CIPHERTEXT_3: 0x52d5535f3147e85f1cfacd9e78abf9e0a81bbf
      (19 bytes)

   o  EDHOC message_3: 0x00 52d5535f3147e85f1cfacd9e78abf9e0a81bbf
      (20 bytes)

   o  OSCORE ciphertext: 0x612f1092f1776f1c1668b3825e (13 bytes)

   From there:

   o  Protected CoAP request (OSCORE message):

      0x44025d1f               ; CoAP 4-byte header
        00003974               ; Token
        39 6c6f63616c686f7374  ; Uri-Host Option: "localhost"
        63 090020              ; OSCORE Option
        C0                     ; EDHOC Option
        ff 52d5535f3147e85f1cfacd9e78abf9e0a81bbf
           4d612f1092f1776f1c1668b3825e
      (57 bytes)
Figure 5: Example of CoAP message with EDHOC and OSCORE combined

6. Security Considerations

The same security considerations from OSCORE [RFC8613] and EDHOC [I-D.ietf-lake-edhoc] hold for this document.

TODO (more considerations)

7. IANA Considerations

RFC Editor: Please replace "[[this Document]]" with the RFC number of this document and delete this paragraph.

This document has the following actions for IANA.

7.1. CoAP Option Numbers Registry

IANA is asked to enter the following option numbers to the "CoAP Option Numbers" registry defined in [RFC7252] within the "CoRE Parameters" registry.

[

The CoAP option numbers 13 and 21 are both consistent with the properties of the EDHOC Option defined in Section 5.1, and they both allow the EDHOC Option to always result in an overall size of 1 byte. This is because:

  • The EDHOC option is always empty, i.e. with zero-length value; and
  • Since the OSCORE option with option number 9 is always present in the CoAP request, the EDHOC option would be encoded with a maximum delta of 4 or 12, depending on its option number being 13 or 21.

At the time of writing, the CoAP option numbers 13 and 21 are both unassigned in the "CoAP Option Numbers" registry, as first available and consistent option numbers for the EDHOC option.

This document suggests 21 (TBD21) as option number to be assigned to the new EDHOC option, since both 13 and 21 are consistent for the use case in question, but different use cases or protocols may make better use of the option number 13.

]

+--------+-------+-------------------+
| Number | Name  |     Reference     |
+--------+-------+-------------------+
| TBD21  | EDHOC | [[this document]] |
+--------+-------+-------------------+

7.2. EDHOC Exporter Label Registry

IANA is asked to enter the following entries to the "EDHOC Exporter Label" registry defined in [I-D.ietf-lake-edhoc].

Label: OSCORE Master Secret
Description: Derived OSCORE Master Secret
Reference: [[this document]]
Label: OSCORE Master Salt
Description: Derived OSCORE Master Salt
Reference: [[this document]]

8. Normative References

[I-D.ietf-lake-edhoc]
Selander, G., Mattsson, J. P., and F. Palombini, "Ephemeral Diffie-Hellman Over COSE (EDHOC)", Work in Progress, Internet-Draft, draft-ietf-lake-edhoc-06, , <https://datatracker.ietf.org/doc/html/draft-ietf-lake-edhoc-06.txt>.
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://datatracker.ietf.org/doc/html/rfc2119>.
[RFC7252]
Shelby, Z., Hartke, K., and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, , <https://datatracker.ietf.org/doc/html/rfc7252>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://datatracker.ietf.org/doc/html/rfc8174>.
[RFC8613]
Selander, G., Mattsson, J., Palombini, F., and L. Seitz, "Object Security for Constrained RESTful Environments (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, , <https://datatracker.ietf.org/doc/html/rfc8613>.
[RFC8742]
Bormann, C., "Concise Binary Object Representation (CBOR) Sequences", RFC 8742, DOI 10.17487/RFC8742, , <https://datatracker.ietf.org/doc/html/rfc8742>.
[RFC8949]
Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", STD 94, RFC 8949, DOI 10.17487/RFC8949, , <https://datatracker.ietf.org/doc/html/rfc8949>.

Appendix A. Document Updates

RFC Editor: Pleare remove this section.

A.1. Version -00 to -01

  • Added explicit rules for converting integer C_x to Sender IDs, following the removal of bstr_identifier from EDHOC.
  • Imported OSCORE-specific content from draft-ietf-lake-edhoc.
  • Expanded scope and revised section organization.
  • Improved error handling for the combined approach.
  • Recommended number for EDHOC option changed to 21.

Acknowledgments

The authors sincerely thank Christian Amsuess, Klaus Hartke, Jim Schaad and Malisa Vucinic for their feedback and comments in the discussion leading up to this draft.

The work on this document has been partly supported by VINNOVA and the Celtic-Next project CRITISEC; and by the H2020 project SIFIS-Home (Grant agreement 952652).

Authors' Addresses

Francesca Palombini
Ericsson
Marco Tiloca
RISE AB
Isafjordsgatan 22
SE-16440 Stockholm Kista
Sweden
Rikard Hoeglund
RISE AB
Isafjordsgatan 22
SE-16440 Stockholm Kista
Sweden
Stefan Hristozov
Fraunhofer AISEC
Goeran Selander
Ericsson