Change:
restructuring for readability adding a section for protocol overview adding examples for each message adding details about updating clients rights (request new token with only scope different) where before there were ref to the framework, explicitly state all the normative text add mechanism during OSCORE Setup for making sure the context is not reused on the server if token is re-posted after it has been lost/removed (nonces) added section about access rights verification between OSCORE layer and CoAP (handling of the resource) layer

Discussion:
resource server.  In order to provide communication security, proof of possession, and server authentication they use Object Security for Constrained RESTful Environments (OSCORE) I-D.ietf-core-object- <del> security.  Optionally the client and the resource server may also use CoAP and OSCORE to communicate with the authorization server. </del> <ins> security. </ins> OSCORE specifies how to use CBOR Object Signing and Encryption (COSE) <del> RFC8152 to secure CoAP messages.  In order to provide replay and reordering protection OSCORE also introduces sequence numbers that are used together with COSE. Note that OSCORE can be used to secure CoAP messages, as well as HTTP and combinations of HTTP and CoAP; a profile of ACE similar to the one described in this document, with the difference of using HTTP instead of CoAP as communication protocol, could be specified analogously to this one. </del> <ins> RFC8152 to secure CoAP messages.  Note that OSCORE can be used to secure CoAP messages, as well as HTTP and combinations of HTTP and CoAP; a profile of ACE similar to the one described in this document, with the difference of using HTTP instead of CoAP as communication protocol, could be specified analogously to this one. </ins> 1.1.

"authorization", "confidentiality", "(data) integrity", "message authentication code", and "verify" are taken from RFC4949. <del> Since we describe exchanges as RESTful protocol interactions HTTP RFC7231 offers useful terminology. </del> <ins> RESTful terminology follows HTTP RFC7231. </ins> Terminology for entities in the architecture is defined in OAuth 2.0 <del> RFC6749 and I-D.ietf-ace-actors, such as client (C), resource server (RS), and authorization server (AS).  It is assumed in this document that a given resource on a specific RS is associated to a unique AS. </del> <ins> RFC6749, such as client (C), resource server (RS), and authorization server (AS).  It is assumed in this document that a given resource on a specific RS is associated to a unique AS. </ins> 2. <del> The use of OSCORE for arbitrary CoAP messages is specified in I- D.ietf-core-object-security.  This section defines the specific uses and their purpose for securing the communication between a client and a resource server, and the parameters needed to negotiate the use of this profile with the token resource at the authorization server as specified in section 5.6 of I-D.ietf-ace-oauth-authz. </del> <ins> This section gives an overview on how to use the ACE Framework I- D.ietf-ace-oauth-authz to secure the communication between a client and a resource server using OSCORE I-D.ietf-core-object-security. The parameters needed to negotiate the use of this profile with the token resource at the authorization server as specified in section 5.6 of I-D.ietf-ace-oauth-authz are described in detail in the following sections. This profile requires a client to retrieve an access token from the AS for the resource it wants to access on a RS, using the token endpoint, as specified in section 5.6.1 of I-D.ietf-ace-oauth-authz. To determine the AS in charge of a resource hosted at the RS, the client C MAY send an initial Unauthorized Resource Request message to the RS.  The RS then denies the request and sends the address of its AS back to the client C as specified in section 5.1 of I-D.ietf-ace- oauth-authz.  The access token request and response MUST be confidentiality-protected and ensure authenticity.  This profile RECOMMENDS the use of OSCORE between client and AS, but TLS or DTLS MAY be used additionally or instead. Once the client has retrieved the access token, it forwards it to the RS using the authz-info endpoint and mechanisms specified in section 5.8.1. of I-D.ietf-ace-oauth-authz.  If the access token is valid, the RS replies to this request with a 2.01 (Created) response, which contains a nonce N1. After receiving the nonce N1, the client generates a nonce N2, concatenates it with N1 and sets the ID Context in its Security Context (see section 3 of I-D.ietf-core-object-security) to N1 concatenated with N2.  The client then derives the complete Security Context from the ID Context plus the parameters received from the AS. Finally, the client sends a request protected with OSCORE to the RS. This message contains the ID Context value.  When receiving this request after the 2.01 (Created) response, the server extract the ID Context from it, verifies that the first part is equal to the nonce N1 it previously sent, and if so, sets its own ID Context and derives the complete Security Context from it plus the parameters received in the AS, following section 3.2 of I-D.ietf-core-object-security.  If the request verifies, then this Security Context is stored in the server, and used in the response, and in further communications with the client, until token expiration.  The client will not include the ID Context value in further requests. An overview of the profile flow for the OSCORE profile is given in prof-overview. 3. </ins> <del> 2.1. </del> <ins> The following subsections describe the details of the POST /token request and response between client and AS.  Section 3.2 of I-D.ietf- core-object-security defines how to derive a security context based on a shared master secret and a set of other parameters, established between client and server, which the client receives from the AS in this exchange.  The proof-of-possession key (pop-key) provisioned from the AS MUST be used as master secret in OSCORE. </ins> <del> A client requests a token at an AS via the /token resource.  This follows the message formats specified in section 5.6.1 of I-D.ietf- </del> <ins> 3.1. The client-to-AS request is specified in Section 5.6.1 of I-D.ietf- </ins> ace-oauth-authz. <del> The AS responding to a successful access token request as defined in section 5.6.2 of I-D.ietf-ace-oauth-authz can signal that the use of OSCORE is REQUIRED for a specific access token by including the "profile" parameter with the value "coap_oscore" in the access token response.  This means that the client MUST use OSCORE towards all resource servers for which this access token is valid, and follow oscore-only to derive the security context to run OSCORE. </del> <ins> If the client wants to update its access rights using the same OSCORE Security Context, it MUST include in its POST /token request a cnf object carrying the Sender ID in the kid field.  This identifier can be used by the AS to determine the shared secret to construct the proof-of-possession token and therefore MUST specify a symmetric key that was previously generated by the AS as a shared secret for the communication between the client and the RS. The client MUST send this POST /token request over a secure channel that guarantees authentication, message integrity and confidentiality (see introsp). An example of such a request, in CBOR diagnostic notation without the tag and value abbreviations is reported in ex0 3.2. After verifying the POST /token request and that the client is authorized to obtain an access token corresponding to its access token request, the AS responds as defined in section 5.6.2 of I- D.ietf-ace-oauth-authz.  It signals that the use of OSCORE is REQUIRED for a specific access token by including the "profile" parameter with the value "coap_oscore" in the access token response. This means that the client MUST use OSCORE towards all resource servers for which this access token is valid, and follow oscore-setup to derive the security context to run OSCORE. </ins> The error response procedures defined in section 5.6.3 of the ACE framework are unchanged by this profile. <del> Note the the client and the authorization server MAY OPTIONALLY use OSCORE to protect the interaction via the /token resource.  See c-as for details. 2.2. Section 3.2 of I-D.ietf-core-object-security defines how to derive a security context based on a shared master secret and a set of other parameters, established between client and server.  The proof-of- possession key (pop-key) provisioned from the AS MAY, in case of pre- shared keys, be used directly as master secret in OSCORE. If OSCORE is used directly with the symmetric pop-key as master secret, then the AS MUST provision the following data, in response to the access token request: </del> <ins> Moreover, the AS MUST provision the following data: </ins> a master secret <del> the sender identifier </del> <ins> a client identifier </ins> <del> the recipient identifier </del> <ins> a server identifier </ins> Additionally, the AS MAY provision the following data, in the same <del> response.  In case these parameters are omitted, the default values are used as described in section 3.2 of I-D.ietf-core-object- security. </del> <ins> response. </ins> an AEAD algorithm <del> a KDF algorithm </del> <ins> an HKDF algorithm </ins> a salt

The master secret MUST be communicated as COSE_Key in the 'cnf' parameter of the access token response as defined in Section 5.6.4.5 of I-D.ietf-ace-oauth-authz.  The AEAD algorithm MAY be included as <del> the 'alg' parameter in the COSE_Key; the KDF algorithm MAY be included as the 'kdf' parameter of the COSE_Key and the salt MAY be included as the 'slt' parameter of the COSE_Key as defined in table 1. </del> <ins> the 'alg' parameter in the COSE_Key; the HKDF algorithm MAY be included as the 'hkdf' parameter of the COSE_Key and the salt MAY be included as the 'slt' parameter of the COSE_Key as defined in tab1. </ins> <del> The same parameters MUST be included as metadata of the access token; if the token is a CWT RFC8392, the same COSE_Key structure MUST be placed in the 'cnf' claim of this token.  If a CWT is used it MUST be encrypted, since the token is transferred from the client to the RS over an unprotected channel. </del> <ins> The same parameters MUST be included as metadata of the access token. This profile RECOMMENDS the use of CBOR web token (CWT) as specified in RFC8392.  If the token is a CWT, the same COSE_Key structure defined above MUST be placed in the 'cnf' claim of this token. </ins> The AS MUST also assign identifiers to both client and RS, which are then used as Sender ID and Recipient ID in the OSCORE context as described in section 3.1 of I-D.ietf-core-object-security.  These identifiers MUST be unique in the set of all clients and RS identifiers for a certain AS.  Moreover, these MUST be included in <del> the COSE_Key as header parameters, as defined in table 1. </del> <ins> the COSE_Key as header parameters, as defined in tab1. </ins> We assume in this document that a resource is associated to one single AS, which makes it possible to assume unique identifiers for

case the RS needs to have a mechanism in place to disambiguate identifiers or mitigate their effect. <del> Note that C should set the Sender ID of its security context to the </del> <ins> Note that C should set the Sender ID of its Security Context to the </ins> clientId value received and the Recipient ID to the serverId value, and RS should do the opposite. <del> Figure 1 shows an example of such an AS response, in CBOR diagnostic </del> <ins> ex1 shows an example of such an AS response, in CBOR diagnostic </ins> notation without the tag and value abbreviations. <del> Figure 2 shows an example CWT, containing the necessary OSCORE parameters in the 'cnf' claim, in CBOR diagnostic notation without tag and value abbreviations. Note that the proof-of-possession required to bind the access token to the client is implicitly performed by generating the shared OSCORE context using the pop-key as master secret, both on the client and RS side.  An attacker using a stolen token will not be able to generate a valid OSCORE context and thus not be able to prove possession of the pop-key. </del> <ins> ex2 shows an example CWT, containing the necessary OSCORE parameters in the 'cnf' claim, in CBOR diagnostic notation without tag and value abbreviations. </ins> <del> 3. </del> <ins> If the client has requested an update to its access rights using the same OSCORE Security Context, and the token associated with it is not expired, the AS MAY omit the master secret and server identifier both in the COSE_Key in the 'cnf' parameter and in the token.  The client identifier needs to be provisioned, in order for the RS to identify the previously generated Security Context. </ins> <del> As specified in the ACE framework (section 5.6 of I-D.ietf-ace-oauth- authz), the Client and AS can also use CoAP instead of HTTP to communicate via the token resource.  This section specifies how to use OSCORE between Client and AS together with CoAP.  The use of OSCORE for this communication is OPTIONAL in this profile, other security protocols (such as DTLS) MAY be used instead. </del> <ins> ex5 shows an example of such an AS response, in CBOR diagnostic notation without the tag and value abbreviations. </ins> <del> The client and the AS are expected to have pre-established security contexts in place.  How these security contexts are established is out of scope for this profile.  Furthermore the client and the AS communicate using OSCORE (I-D.ietf-core-object-security) through the introspection resource as specified in section 5.7 of I-D.ietf-ace- oauth-authz. </del> <ins> ex6 shows an example CWT, containing the necessary OSCORE parameters in the 'cnf' claim for update of access rights, in CBOR diagnostic notation without tag and value abbreviations. </ins> 4. <del> As specified in the ACE framework (section 5.7 of I-D.ietf-ace-oauth- authz), the RS and AS can also use CoAP instead of HTTP to communicate via the introspection resource.  This section specifies how to use OSCORE between RS and AS.  The use of OSCORE for this communication is OPTIONAL in this profile, other security protocols (such as DTLS) MAY be used instead. The RS and the AS are expected to have pre-established security contexts in place.  How these security contexts are established is out of scope for this profile.  Furthermore the RS and the AS communicate using OSCORE (I-D.ietf-core-object-security) through the introspection resource as specified in section 5.7 of I-D.ietf-ace- oauth-authz. </del> <ins> The following subsections describe the details of the POST /authz- info request and response between client and RS.  The client posts the token that includes the materials provisioned by the AS to the RS, which can then use Section 3.2 of I-D.ietf-core-object-security to derive a security context based on a shared master secret and a set of other parameters, established between client and server. Note that the proof-of-possession required to bind the access token to the client is implicitly performed by generating the shared OSCORE Security Context using the pop-key as master secret, for both client and RS.  An attacker using a stolen token will not be able to generate a valid OSCORE context and thus not be able to prove possession of the pop-key. 4.1. The client MUST use CoAP and the Authorization Information endpoint as described in section 5.8.1 of I-D.ietf-ace-oauth-authz to transport the token to the RS. The authz-info endpoint is not protected, nor are the responses from this endpoint. The access token MUST be encrypted, since it is transferred from the client to the RS over an unprotected channel. ex3 shows an example of the request sent from the client to the RS. 4.2. The RS MUST follow the procedures defined in section 5.8.1 of I- D.ietf-ace-oauth-authz: the RS MUST verify the validity of the token. If the token is valid, the RS MUST respond to the POST request with 2.01 (Created).  This response MAY contain an identifier of the token (e.g., the cti for a CWT) as a payload, in order to allow the client to refer to the token.  If the token is valid but is associated to claims that the RS cannot process (e.g., an unknown scope) the RS MUST respond with a response code equivalent to the CoAP code 4.00 (Bad Request).  In the latter case the RS MAY provide additional information in the error response, in order to clarify what went wrong.  The RS MAY make an introspection request to validate the token before responding to the POST request to the authz-info endpoint. Additionally, the RS MUST generate a nonce (N1) with a good amount of randomness, and include it in the payload of the 2.01 (Created) response as a CBOR byte string.  This profile RECOMMENDS to use a nonce of 64 bits.  The RS MUST store this nonce as long as the access token related to it is still valid. ex4 shows an example of the response sent from the RS to the client. As specified in section 5.8.3 of I-D.ietf-ace-oauth-authz, the RS MUST notify the client with an error response with code 4.01 (Unauthorized) for any long running request before terminating the session, when the access token expires. 4.3. Once receiving the 2.01 (Created) response from the RS, following the POST /authz-info request, the client MUST extract the nonce N1 from the CBOR byte string in the payload of the response.  The client MUST generate itself a nonce (N2) with a good amount of randomness.  This profile RECOMMENDS to use a nonce of 64 bits.  Then, the client MUST set the ID Context of the Security Context created to communicate with the RS to the concatenation of N1 and N2, in this order: ID Context = N1 | N2, where | denotes byte string concatenation.  The client MUST set the Master Secret, Sender ID and Recipient ID from the parameters received from the AS in as-c.  The client MUST set the AEAD Algorithm, Master Salt, HKDF and Replay Window from the parameters received from the AS in as-c, if present.  In case these parameters are omitted, the default values are used as described in section 3.2 of I-D.ietf-core-object-security.  After that, the client MUST derive the complete Security Context following section 3.2.1 of I-D.ietf-core-object-security.  From this point on, the client MUST use this Security Context to communicate with the RS when accessing the resources as specified by the authorization information. The client then uses this Security Context to send requests to RS using OSCORE.  In the first request sent to the RS, the client MUST include the kid context, with value ID Context, i.e. N1 concatenated with N2.  The client needs to make sure the RS receives the kid context, possibly adding the kid context to later requests, until it receives a valid OSCORE response from the RS using the same Security Context. When the RS receives this first OSCORE-protected request, it MUST extract the kid context from the message first.  Then, it needs to verify that the first part of the kid context corresponds to the nonce N1 it previously sent, and that it is followed by a non-zero- length byte string.  If that is verified, the RS MUST set the ID Context to the kid context value.  Then, the RS MUST set the Master Secret, Sender ID and Recipient ID from the parameters received from the client in the access token in c-rs.  The RS MUST set the AEAD Algorithm, Master Salt, HKDF and Replay Window from the parameters received from the client in the access token in c-rs, if present.  In case these parameters are omitted, the default values are used as described in section 3.2 of I-D.ietf-core-object-security.  After that, the RS MUST derive the complete Security Context following section 3.2.1 of I-D.ietf-core-object-security, and MUST associate this Security Context with the authorization information from the access token.  Then, the RS MUST delete the nonce N1 from memory. The RS then uses this Security Context to verify the request and send responses to RS using OSCORE.  If OSCORE verification fails, error responses are used, as specified in section 8 of I-D.ietf-core- object-security.  Additionally, if OSCORE verification succeeds, the verification of access rights is performed as described in section tok-ver.  The RS MUST NOT use the Security Context after the related token has expired, and MUST respond with a unprotected 4.01 (Unauthorized) error message. 4.4. The RS MUST follow the procedures defined in section 5.8.2 of I- D.ietf-ace-oauth-authz: if an RS receives a OSCORE-protected request from a client, then it processes according to I-D.ietf-core-object- security.  If OSCORE verification succeeds, and the target resource requires authorization, the RS retrieves the authorization information from the access token associated to the Security Context. The RS then MUST verify that the authorization information covers the resource and the action requested. The response code MUST be 4.01 (Unauthorized) in case the client has not used the Security Context associated with the access token, or if RS has no valid access token for the client.  If RS has an access token for the client but not for the resource that was requested, RS MUST reject the request with a 4.03 (Forbidden).  If RS has an access token for the client but it does not cover the action that was requested on the resource, RS MUST reject the request with a 4.05 (Method Not Allowed). </ins> 5. <ins> As specified in the ACE framework (section 5.7 of I-D.ietf-ace-oauth- authz), the requesting entity (RS and/or client) and the AS communicates via the introspection or token endpoint.  The use of CoAP and OSCORE for this communication is RECOMMENDED in this profile, other protocols (such as HTTP and DTLS or TLS) MAY be used instead. If OSCORE is used, the requesting entity and the AS are expected to have pre-established security contexts in place.  How these security contexts are established is out of scope for this profile. Furthermore the requesting entity and the AS communicate using OSCORE (I-D.ietf-core-object-security) through the introspection endpoint as specified in section 5.7 of I-D.ietf-ace-oauth-authz and through the token endpoint as specified in section 5.6 of I-D.ietf-ace-oauth- authz. 6. </ins> This document specifies a profile for the Authentication and Authorization for Constrained Environments (ACE) framework I-D.ietf- ace-oauth-authz.  Thus the general security considerations from the

expected use of OSCORE, to prevent weakening the security assurances provided by OSCORE. <del> 6. </del> <ins> TODO: explain the rationale for the nonces construction, and the security implications for Man-in-the-Middle attacks. 7. </ins> TBD. <del> 7. </del> <ins> 8. </ins> Note to RFC Editor: Please replace all occurrences of "[[this specification]]" with the RFC number of this specification and delete

Description: Identifies the server in an OSCORE context Reference: [[this specification]] <del> Name: kdf </del> <ins> Name: hkdf </ins> Label: TBD3 (value between 1 and 255) Value Type: bstr Value Registry: COSE Algorithms registry