ACE Working Group                                           F. Palombini
Internet-Draft                                                  Ericsson
Intended status: Standards Track                          March 13, 2017
Expires: September 14, 2017


     CoAP Pub-Sub Profile for Authentication and Authorization for
                     Constrained Environments (ACE)
               draft-palombini-ace-coap-pubsub-profile-00

Abstract

   This specification defines a profile for authentication and
   authorization for publishers and subscribers in a pub-sub setting
   scenario in a constrained environment, using the ACE framework.  This
   profile relies on transport layer or application layer security to
   authorize the publisher to the broker.  Moreover, it relies on
   application layer security for publisher-broker and subscriber-broker
   communication.

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 http://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 September 14, 2017.

Copyright Notice

   Copyright (c) 2017 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must



Palombini              Expires September 14, 2017               [Page 1]


Internet-Draft             coap-pubsub-profile                March 2017


   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
     1.1.  Terminology . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Overview  . . . . . . . . . . . . . . . . . . . . . . . . . .   2
   3.  Publisher Profile . . . . . . . . . . . . . . . . . . . . . .   4
     3.1.  Retrieval of COSE Key for protection of content . . . . .   5
     3.2.  AS1, AS2 Information  . . . . . . . . . . . . . . . . . .   7
   4.  Subscriber Profile  . . . . . . . . . . . . . . . . . . . . .   8
   5.  Pub-Sub Protected Communication . . . . . . . . . . . . . . .   9
     5.1.  Using COSE Objects to protect the resource representation  10
   6.  Security Considerations . . . . . . . . . . . . . . . . . . .  12
   7.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  12
   8.  Acknowledgments . . . . . . . . . . . . . . . . . . . . . . .  12
   9.  References  . . . . . . . . . . . . . . . . . . . . . . . . .  12
     9.1.  Normative References  . . . . . . . . . . . . . . . . . .  13
     9.2.  Informative References  . . . . . . . . . . . . . . . . .  13
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .  14

1.  Introduction

   This specification defines a way to authorize nodes in a CoAP pub-sub
   type of setting, using the ACE framework [I-D.ietf-ace-oauth-authz].
   The pub-sub scenario is described in [I-D.ietf-core-coap-pubsub].

1.1.  Terminology

   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 RFC 2119 [RFC2119].

   Readers are expected to be familiar with the terms and concepts
   described in [I-D.ietf-ace-oauth-authz] and
   [I-D.ietf-core-coap-pubsub].

2.  Overview

   The objective of this specification is to specify how to protect a
   CoAP pub-sub communication, as described in
   [I-D.ietf-core-coap-pubsub], using Ace framework
   ([I-D.ietf-ace-oauth-authz]) and profiles
   ([I-D.gerdes-ace-dtls-authorize], [I-D.seitz-ace-oscoap-profile]).

   The architecture of the scenario is shown in Figure 1.



Palombini              Expires September 14, 2017               [Page 2]


Internet-Draft             coap-pubsub-profile                March 2017


                +----------------+   +----------------+
                |                |   |                |
                | Authorization  |   | Authorization  |
                |    Server 1    |   |    Server 2    |
                |                |   |                |
                +----------------+   +----------------+
                         ^                  ^  ^
                         |                  |  |
        +---------(A)----+                  |  +-----(E)------+
        |   +--------------------(B)--------+                 |
        v   v                                                 v
   +------------+             +------------+              +------------+
   |   CoAP     | ----(C)---> |   CoAP     |              |    CoAP    |
   |  Client -  | [<--(D)-->] |  Server -  |              |  Client -  |
   |            | ----(F)---> |            |              |            |
   | Publisher  |             |   Broker   | <----(G)---- | Subscriber |
   |            |             |            | -----(H)---> |            |
   +------------+             +------------+              +------------+

       Figure 1: Architecture CoAP pubsub with Authorization Servers

   The RS is the broker, which contains the topic.  The AS1 hosts the
   policies about the Broker: what endpoints are allowed to Publish on
   the Broker.  The AS2 hosts the policies about the topic: what
   endpoints are allowed to access what topic.  There are four phases,
   the first three can be done in parallel.

   1.  The Publisher requests publishing access to a broker at the AS1,
       and communicates with the Broker to set up security.

   2.  The Publisher requests access to a specific topic at the AS2

   3.  The Subscriber requests access to a specific topic at the AS2.

   4.  The Publisher and the Subscriber securely post to and get
       publications from the Broker.

   This scenario requires the setup of 2 different security
   associations: on the one hand, the Publisher has a security
   association with the Broker, to protect the communication and
   securely authorize the Publisher to publish on a topic (Security
   Association 1).  On the other hand, the Publisher has a security
   association with the Subscriber, to protect the publication content
   itself (Security Association 2).  The Security Association 1 is set
   up using AS1, the Security Association 2 is set up using AS2.






Palombini              Expires September 14, 2017               [Page 3]


Internet-Draft             coap-pubsub-profile                March 2017


   +------------+             +------------+              +------------+
   |   CoAP     |             |   CoAP     |              |    CoAP    |
   |  Client -  |             |  Server -  |              |  Client -  |
   |            |             |            |              |            |
   | Publisher  |             |   Broker   |              | Subscriber |
   +------------+             +------------+              +------------+
         :   :                       :                           :
         :   '------ Security -------'                           :
         :         Association 1                                 :
         '------------------------------- Security --------------'
                                        Association 2

3.  Publisher Profile

   In this section, it is specified how the Publisher requests, obtains
   and communicates to the Broker the access token, as well as the
   retrieval of the keying material to protect the publication.

                        +----------------+   +----------------+
                        |                |   |                |
                        | Authorization  |   | Authorization  |
                        |    Server 1    |   |    Server 2    |
                        |                |   |                |
                        +----------------+   +----------------+
                                 ^                  ^
                                 |                  |
                +---------(A)----+                  |
                |   +--------------------(B)--------+
                v   v
           +------------+             +------------+
           |   CoAP     | ----(C)---> |   CoAP     |
           |  Client -  | [<--(D)-->] |  Server -  |
           |            |             |            |
           | Publisher  |             |   Broker   |
           |            |             |            |
           +------------+             +------------+

                     Figure 2: Phase 1: Publisher side

   This is a combination of two independent phases:

   o  one is the establishment of a secure connection between Publisher
      and Broker, using an ACE profile such as DTLS
      [I-D.gerdes-ace-dtls-authorize] or OSCOAP
      [I-D.seitz-ace-oscoap-profile].  (A)(C)(D)

   o  the other is the Publisher's retrieval of keying material to
      protect the publication.  (B)



Palombini              Expires September 14, 2017               [Page 4]


Internet-Draft             coap-pubsub-profile                March 2017


   In detail:

   (A) corresponds to the Access Token Request and Response between
   Publisher and Authorization Server to retrieve the Access Token and
   RS (Broker) Information.  As specified, the Publisher has the role of
   a CoAP client, the Broker has the role of the CoAP server.

   (C) corresponds to the exchange between Publisher and Broker, where
   the Publisher sends its access token to the Broker.

   (D) corresponds to the exchange where the Publisher establishes a
   secure connection with the Broker.  Depending on the Information
   received in (A), this can be for example DTLS handshake, or other
   protocols such as EDHOC.  Depending on the application, there may not
   be the need for this set up phase: for example, if OSCOAP is used
   directly and not without EDHOC first.

   (A), (C) and (D) details are specified in the profile used.

   (B) corresponds to the retrieval of the keying material to protect
   the publication.  The detailed message flow is defined below.

3.1.  Retrieval of COSE Key for protection of content

   This phase is common to both Publisher and Subscriber.  To maintain
   the generality, the Publisher or Subscriber is referred as Client in
   this section.

           Client                            Broker             AS2
              | [----- Resource Request ---->] |                 |
              |                                |                 |
              | [<-- AS1, AS2 Information ---] |                 |
              |                                                  |
              | ------- Topic Keying Material Request ---------> |
              |                                                  |
              | <------------ Keying Material ------------------ |
              |                                                  |

                  Figure 3: B: Access request - response

   Complementary to what is defined in the DTLS profile (section 2.), to
   determine the AS2 in charge of a topic hosted at the broker, the
   Broker MAY send the address of both the AS in charge of the topic
   back to the Client, as a response to a Resource Request
   (Section 2.1).  Analogously to the DTLS profile, instead of the
   initial Unauthorized Resource Request message, the Client MAY look up
   the desired topic in a resource directory (see
   [I-D.ietf-core-resource-directory]).



Palombini              Expires September 14, 2017               [Page 5]


Internet-Draft             coap-pubsub-profile                March 2017


   After retrieving the AS2 address, the Client sends a Topic Keying
   Material Request, which is a token-less authorization as described in
   [I-D.seitz-ace-oauth-authz], section 6.5.  More specifically, the
   Client sends a POST request to the /token endpoint on AS2, that MUST
   contain in the payload:

   o  the grant type set to "client_credentials",

   o  the audience parameter set to the Broker,

   o  the scope parameter set to the topic,

   o  the cnf parameter containing the Client's COSE key, if the Client
      is a publisher, and

   o  OPTIONALLY, other additional parameters such as the client id or
      the algorithm.

   Note that, if present, the algorithm MUST be a Content Encryption
   Algorithm, as defined in Section 10 of [I-D.ietf-cose-msg].  An
   example of the payload of a Topic Keying Material Request for a
   Publisher is specified in Figure 4.

   {
     "grant_type" : "client_credentials",
     "aud" : "Broker1",
     "scope" : "Temp",
     "client_id" : "publisher1",
     "cnf" :
       { / COSE_Key /
         / type / 1 : 2, / EC2 /
         / kid / 2 : h'11',
         / alg / 3 : -7, / ECDSA with SHA-256 /
         / crv / -1 : 1 , / P-256 /
         / x / -2 : h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de1
         08de439c08551d',
         / y /-3 : h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e
         9eecd0084d19c'
       }
   }

     Figure 4: Example of Topic Keying Material Request payload for a
                                 Publisher

   The AS2 verifies that the Client is authorized to access the topic
   and, if the "cnf" parameter is present, stores the public key of the
   Client.




Palombini              Expires September 14, 2017               [Page 6]


Internet-Draft             coap-pubsub-profile                March 2017


   The AS2 response contains an empty token and the keying material to
   protect the publication ("key" field in the payload).  Moreover, the
   payload MUST contain the "profile" parameter, set to value "OSCON",
   and the "token_type" set to "none".

   TODO: define "key" parameter following ACE framework

   The "key" parameter value MUST be a serialized COSE Key (see
   Section 7 of [I-D.ietf-cose-msg]), with the following values:

   o  kty with value 4 (symmetric)

   o  alg with value defined by the AS2 (Content Encryption Algorithm)

   o  k with value the symmetric key value

   o  OPTIONALLY, kid with an identifier for the key value

   An example for the response is detailed in Figure 5.

   {
     "access_token" : NULL,
     "token_type" : "none",
     "profile" : "OSCON",
     "key" : h'a4010402421234030c205002e2cc3a9b92855220f255fff1c615bc'
    /{1: 4, 2: h'1234', 3: 12, -1: h'02e2cc3a9b92855220f255fff1c615bc'}/
   }

     Figure 5: Example of Topic Keying Material response payload for a
                                 Publisher

3.2.  AS1, AS2 Information

   The Client MUST be able to process the following response message
   from the Broker, in order to retrieve the correct AS1 and AS2
   addresses.

   This CoAP message MUST have the following characteristics: the CoAP
   Code MUST be 4.01 "Unauthorized", the payload MUST be present and
   MUST include the full URI of both AS.  An example using CBOR
   diagnostic notation is given below:

                 4.01 Unauthorized
                 Content-Format: application/ace+cbor
                 {"AS1": "coaps://as1.example.com/token",
                  "AS2": "coaps://as2.example.com/pubsubkey"}

                  Figure 6: AS1, AS2 Information example



Palombini              Expires September 14, 2017               [Page 7]


Internet-Draft             coap-pubsub-profile                March 2017


4.  Subscriber Profile

   In this section, it is specified how the Subscriber retrieves the
   keying material to protect the publication.

                                     +----------------+
                                     |                |
                                     | Authorization  |
                                     |    Server 2    |
                                     |                |
                                     +----------------+
                                               ^
                                               |
                                               +-----(E)------+
                                                              |
                                                              v
                                                          +------------+
                                                          |    CoAP    |
                                                          |  Client -  |
                                                          |            |
                                                          | Subscriber |
                                                          |            |
                                                          +------------+

                    Figure 7: Phase 2: Subscriber side

   Step (E) between Subscriber and AS2 corresponds to the retrieval of
   the keying material to verify the publication, and is the same as (B)
   between Publisher and AS2 (Section 3.1), with the following
   differences:

   o  The POST request to the /token endpoint on AS2, does not contain
      the cnf parameter containing the Client's COSE key.

   o  The AS2 response contains a "cnf" parameter whose value is set to
      a COSE Key Set, (Section 7 of [I-D.ietf-cose-msg]) i.e. an array
      of COSE Keys, which contains the public keys of all authorized
      Publishers

   An example of the payload of a Topic Keying Material Request and
   corresponding response for a Subscriber is specified in Figure 8 and
   Figure 9.









Palombini              Expires September 14, 2017               [Page 8]


Internet-Draft             coap-pubsub-profile                March 2017


                  {
                    "grant_type" : "client_credentials",
                    "aud" : "Broker1",
                    "scope" : "Temp",
                    "client_id" : "subscriber1"
                  }

     Figure 8: Example of Topic Keying Material Request payload for a
                                Subscriber

   {
     "access_token" : NULL,
     "token_type" : "none",
     "profile" : "OSCON",
     "key" : h'a4010402421234030c205002e2cc3a9b92855220f255fff1c615bc',
    /{1: 4, 2: h'1234', 3: 12, -1: h'02e2cc3a9b92855220f255fff1c615bc'}/
     "cnf" : [
      {
         1 : 2, / type EC2 /
         2 : h'11', / kid /
         3 : -7, / alg ECDSA with SHA-256 /
         -1 : 1 , / crv P-256 /
         -2 : h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de43
         9c08551d', / x /
         -3 : h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd
         0084d19c' / y /
       }
     ]
   }

     Figure 9: Example of Topic Keying Material response payload for a
                                Subscriber

5.  Pub-Sub Protected Communication

   This section specifies the communication Publisher-Broker and
   Subscriber-Broker, after the previous phases have taken place.

   +------------+             +------------+              +------------+
   |   CoAP     |             |   CoAP     |              |    CoAP    |
   |  Client -  |             |  Server -  |              |  Client -  |
   |            | ----(F)---> |            |              |            |
   | Publisher  |             |   Broker   | <----(G)---- | Subscriber |
   |            |             |            | -----(H)---> |            |
   +------------+             +------------+              +------------+

      Figure 10: Phase 3: Secure communication between Publisher and
                                Subscriber



Palombini              Expires September 14, 2017               [Page 9]


Internet-Draft             coap-pubsub-profile                March 2017


   The (F) message corresponds to the publication of a topic on the
   Broker.  The publication (the resource representation) is protected
   with COSE ([I-D.ietf-cose-msg]).  The (G) message is the subscription
   of the Subscriber, which is unprotected.  The (H) message is the
   response from the Broker, where the publication is protected with
   COSE.

   The flow graph is presented below.

          Publisher                Broker               Subscriber
              | --- PUT /topic ----> |                       |
              |  protected with COSE |                       |
              |                      | <--- GET /topic ----- |
              |                      |                       |
              |                      | ---- response ------> |
              |                      |  protected with COSE  |

       Figure 11: (F), (G), (H): Example of protected communication

5.1.  Using COSE Objects to protect the resource representation

   The Publisher uses the symmetric COSE Key received from AS2 in
   exchange B (Section 3.1) to protect the payload of the PUBLISH
   operation (Section 4.3 of [I-D.ietf-core-coap-pubsub]).
   Specifically, the COSE Key is used to create a COSE_Encrypt0 with
   algorithm specified by AS2.  The Publisher uses the private key
   corresponding to the public key sent to the AS2 in exchange B
   (Section 3.1) to countersign the COSE Object as specified in
   Section 4.5 of [I-D.ietf-cose-msg].  The CoAP payload is replaced by
   the COSE object before the publication is sent to the Broker.

   The Subscriber uses the kid in the countersignature field in the COSE
   object to retrieve the right public key to verify the
   countersignature.  It then uses the symmetric key received from AS2
   to verify and decrypt the publication received in the payload of the
   CoAP Notification from the Broker.

   The COSE object is constructed in the following way:

   o  The protected Headers (as described in Section 3 of
      [I-D.ietf-cose-msg]) MAY contain the kid parameter, with value the
      kid of the symmetric COSE Key received in Section 3.1 and MUST
      contain the content encryption algorithm

   o  The unprotected Headers MUST contain the IV and the counter
      signature that includes:





Palombini              Expires September 14, 2017              [Page 10]


Internet-Draft             coap-pubsub-profile                March 2017


      *  the algorithm (same value as in the asymmetric COSE Key
         received in (B)) in the protected header

      *  the kid (same value as the kid of the asymmetric COSE Key
         received in (B)) in the unprotected header

      *  the signature computed as specified in Section 4.5 of
         [I-D.ietf-cose-msg]

   o  The ciphertext, computed over the plaintext that MUST contain the
      CoAP payload.

   The external_aad, when using AEAD, is an empty string.

   An example is given in Figure 12

        16(
          [
            / protected / h'a2010c04421234' / {
                \ alg \ 1:12, \ AES-CCM-64-64-128 \
                \ kid \ 4: h'1234'
              } / ,
            / unprotected / {
              / iv / 5:h'89f52f65a1c580',
              / countersign / 7:[
                / protected / h'a10126' / {
                  \ alg \ 1:-7
                } / ,
                / unprotected / {
                  / kid / 4:h'11'
                },
                / signature / SIG / 64 bytes signature /
              ]
            },
            / ciphertext / h'8df0a3b62fccff37aa313c8020e971f8aC8d'
          ]
        )

    Figure 12: Example of COSE Object sent in the payload of a PUBLISH
                                 operation

   The encryption and decryption operations are described in sections
   5.3 and 5.4 of [I-D.ietf-cose-msg].








Palombini              Expires September 14, 2017              [Page 11]


Internet-Draft             coap-pubsub-profile                March 2017


6.  Security Considerations

   In the profile described above, the Publisher and Subscriber use
   asymmetric crypto, which would make the message exchange quite heavy
   for small constrained devices.  Moreover, all Subscribers must be
   able to access the public keys of all the Publishers to a specific
   topic to be able to verify the publications.  Such a database could
   be set up and managed by the same entity having control of the topic,
   i.e. AS2.

   An application where it is not critical that only authorized
   Publishers can publish on a topic may decide not to make use of the
   asymmetric crypto and only use symmetric encryption/MAC to
   confidentiality and integrity protect the publication, but this is
   not recommended since, as a result, any authorized Subscribers with
   access to the Broker may forge unauthorized publications without
   being detected.  In this symmetric case the Subscribers would only
   need one symmetric key per topic, and would not need to know any
   information about the Publishers, that can be anonymous to it and the
   Broker.

   Subscribers can be excluded from future publications through re-
   keying for a certain topic.  This could be set up to happen on a
   regular basis, for certain applications.  How this could be done is
   out of scope for this work.

   The Broker is only trusted with verifying that the Publisher is
   authorized to publish, but is not trusted with the publications
   itself, which it cannot read nor modify.  In this setting, caching of
   publications on the Broker is still allowed.

   TODO: expand on security and Privacy considerations

7.  IANA Considerations

   TODO: "key" parameter, OSCON profile identifier

8.  Acknowledgments

   The author wishes to thank John Mattsson, Ludwig Seitz and Goeran
   Selander for the useful discussion that helped shape this document.

9.  References








Palombini              Expires September 14, 2017              [Page 12]


Internet-Draft             coap-pubsub-profile                March 2017


9.1.  Normative References

   [I-D.ietf-ace-oauth-authz]
              Seitz, L., Selander, G., Wahlstroem, E., Erdtman, S., and
              H. Tschofenig, "Authentication and Authorization for
              Constrained Environments (ACE)", draft-ietf-ace-oauth-
              authz-05 (work in progress), February 2017.

   [I-D.ietf-core-coap-pubsub]
              Koster, M., Keranen, A., and J. Jimenez, "Publish-
              Subscribe Broker for the Constrained Application Protocol
              (CoAP)", draft-ietf-core-coap-pubsub-00 (work in
              progress), October 2016.

   [I-D.ietf-cose-msg]
              Schaad, J., "CBOR Object Signing and Encryption (COSE)",
              draft-ietf-cose-msg-24 (work in progress), November 2016.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <http://www.rfc-editor.org/info/rfc2119>.

9.2.  Informative References

   [I-D.gerdes-ace-dtls-authorize]
              Gerdes, S., Bergmann, O., Bormann, C., Selander, G., and
              L. Seitz, "Datagram Transport Layer Security (DTLS)
              Profile for Authentication and Authorization for
              Constrained Environments (ACE)", draft-gerdes-ace-dtls-
              authorize-01 (work in progress), March 2017.

   [I-D.ietf-core-resource-directory]
              Shelby, Z., Koster, M., Bormann, C., and P. Stok, "CoRE
              Resource Directory", draft-ietf-core-resource-directory-09
              (work in progress), October 2016.

   [I-D.seitz-ace-oauth-authz]
              Seitz, L., Selander, G., Wahlstroem, E., Erdtman, S., and
              H. Tschofenig, "Authorization for the Internet of Things
              using OAuth 2.0", draft-seitz-ace-oauth-authz-00 (work in
              progress), October 2015.

   [I-D.seitz-ace-oscoap-profile]
              Seitz, L. and F. Palombini, "OSCOAP profile of ACE",
              draft-seitz-ace-oscoap-profile-01 (work in progress),
              October 2016.




Palombini              Expires September 14, 2017              [Page 13]


Internet-Draft             coap-pubsub-profile                March 2017


Author's Address

   Francesca Palombini
   Ericsson

   Email: francesca.palombini@ericsson.com













































Palombini              Expires September 14, 2017              [Page 14]