idnits 2.17.00 (12 Aug 2021) /tmp/idnits9420/draft-ietf-lpwan-coap-static-context-hc-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([I-D.ietf-lpwan-ipv6-static-context-hc]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 342 has weird spacing: '... equal not...' == Line 344 has weird spacing: '... ignore valu...' == Line 367 has weird spacing: '... ignore val...' == Line 1043 has weird spacing: '...tkn piv kid...' == Line 1060 has weird spacing: '... mid tkn...' -- The document date (February 05, 2019) is 1201 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'CON' is mentioned on line 240, but not defined == Missing Reference: 'NON' is mentioned on line 240, but not defined == Missing Reference: 'ACK' is mentioned on line 240, but not defined == Missing Reference: 'RST' is mentioned on line 240, but not defined -- Looks like a reference, but probably isn't: '69' on line 1084 -- Looks like a reference, but probably isn't: '132' on line 1084 == Outdated reference: draft-ietf-core-object-security has been published as RFC 8613 == Outdated reference: draft-ietf-lpwan-ipv6-static-context-hc has been published as RFC 8724 Summary: 1 error (**), 0 flaws (~~), 12 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 lpwan Working Group A. Minaburo 3 Internet-Draft Acklio 4 Intended status: Informational L. Toutain 5 Expires: August 9, 2019 Institut MINES TELECOM; IMT Atlantique 6 R. Andreasen 7 Universidad de Buenos Aires 8 February 05, 2019 10 LPWAN Static Context Header Compression (SCHC) for CoAP 11 draft-ietf-lpwan-coap-static-context-hc-06 13 Abstract 15 This draft defines the way SCHC header compression can be applied to 16 CoAP headers. The CoAP header structure differs from IPv6 and UDP 17 protocols since CoAP 18 use a flexible header with a variable number of options themselves of 19 a variable length. The CoAP protocol is asymmetric in its format 20 messages, the format of the header packet in the request messages is 21 different than in the response messages. Most of the compression 22 mechanisms have been introduced in 23 [I-D.ietf-lpwan-ipv6-static-context-hc], this document explains how 24 to use the SCHC compression for CoAP. 26 Status of This Memo 28 This Internet-Draft is submitted in full conformance with the 29 provisions of BCP 78 and BCP 79. 31 Internet-Drafts are working documents of the Internet Engineering 32 Task Force (IETF). Note that other groups may also distribute 33 working documents as Internet-Drafts. The list of current Internet- 34 Drafts is at https://datatracker.ietf.org/drafts/current/. 36 Internet-Drafts are draft documents valid for a maximum of six months 37 and may be updated, replaced, or obsoleted by other documents at any 38 time. It is inappropriate to use Internet-Drafts as reference 39 material or to cite them other than as "work in progress." 41 This Internet-Draft will expire on August 9, 2019. 43 Copyright Notice 45 Copyright (c) 2019 IETF Trust and the persons identified as the 46 document authors. All rights reserved. 48 This document is subject to BCP 78 and the IETF Trust's Legal 49 Provisions Relating to IETF Documents 50 (https://trustee.ietf.org/license-info) in effect on the date of 51 publication of this document. Please review these documents 52 carefully, as they describe your rights and restrictions with respect 53 to this document. Code Components extracted from this document must 54 include Simplified BSD License text as described in Section 4.e of 55 the Trust Legal Provisions and are provided without warranty as 56 described in the Simplified BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 61 2. SCHC Compression Process . . . . . . . . . . . . . . . . . . 3 62 3. CoAP Compression with SCHC . . . . . . . . . . . . . . . . . 4 63 4. Compression of CoAP header fields . . . . . . . . . . . . . . 6 64 4.1. CoAP version field . . . . . . . . . . . . . . . . . . . 6 65 4.2. CoAP type field . . . . . . . . . . . . . . . . . . . . . 6 66 4.3. CoAP code field . . . . . . . . . . . . . . . . . . . . . 6 67 4.4. CoAP Message ID field . . . . . . . . . . . . . . . . . . 6 68 4.5. CoAP Token fields . . . . . . . . . . . . . . . . . . . . 7 69 5. CoAP options . . . . . . . . . . . . . . . . . . . . . . . . 7 70 5.1. CoAP Content and Accept options. . . . . . . . . . . . . 7 71 5.2. CoAP option Max-Age field, CoAP option Uri-Host and Uri- 72 Port fields . . . . . . . . . . . . . . . . . . . . . . . 7 73 5.3. CoAP option Uri-Path and Uri-Query fields . . . . . . . . 8 74 5.3.1. Variable length Uri-Path and Uri-Query . . . . . . . 8 75 5.3.2. Variable number of path or query elements . . . . . . 9 76 5.4. CoAP option Size1, Size2, Proxy-URI and Proxy-Scheme 77 fields . . . . . . . . . . . . . . . . . . . . . . . . . 9 78 5.5. CoAP option ETag, If-Match, If-None-Match, Location-Path 79 and Location-Query fields . . . . . . . . . . . . . . . . 9 80 6. Other RFCs . . . . . . . . . . . . . . . . . . . . . . . . . 9 81 6.1. Block . . . . . . . . . . . . . . . . . . . . . . . . . . 9 82 6.2. Observe . . . . . . . . . . . . . . . . . . . . . . . . . 10 83 6.3. No-Response . . . . . . . . . . . . . . . . . . . . . . . 10 84 6.4. Time Scale . . . . . . . . . . . . . . . . . . . . . . . 10 85 6.5. OSCORE . . . . . . . . . . . . . . . . . . . . . . . . . 10 86 7. Examples of CoAP header compression . . . . . . . . . . . . . 12 87 7.1. Mandatory header with CON message . . . . . . . . . . . . 12 88 7.2. OSCORE Compression . . . . . . . . . . . . . . . . . . . 13 89 7.3. Example OSCORE Compression . . . . . . . . . . . . . . . 17 90 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 27 91 9. Security considerations . . . . . . . . . . . . . . . . . . . 27 92 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 27 93 11. Normative References . . . . . . . . . . . . . . . . . . . . 27 94 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 28 96 1. Introduction 98 CoAP [rfc7252] is an implementation of the REST architecture for 99 constrained devices. Nevertheless, if limited, the size of a CoAP 100 header may be too large for LPWAN constraints and some compression 101 may be needed to reduce the header size. 103 [I-D.ietf-lpwan-ipv6-static-context-hc] defines a header compression 104 mechanism for LPWAN network based on a static context. The context 105 is said static since the field description composing the Rules and 106 the context are not learned during the packet exchanges but are 107 previously defined. The context(s) is(are) known by both ends before 108 transmission. 110 A context is composed of a set of rules that are referenced by Rule 111 IDs (identifiers). A rule contains an ordered list of the fields 112 descriptions containing a field ID (FID), its length (FL) and its 113 position (FP), a direction indicator (DI) (upstream, downstream and 114 bidirectional) and some associated Target Values (TV). Target Value 115 indicates the value that can be expected. TV can also be a list of 116 values. A Matching Operator (MO) is associated to each header field 117 description. The rule is selected if all the MOs fit the TVs for all 118 fields. In that case, a Compression/Decompression Action (CDA) 119 associated to each field defines the link between the compressed and 120 decompressed value for each of the header fields. Compression 121 results mainly in 4 actions: send the field value, send nothing, send 122 less significant bits of a field, send an index. Values sent are 123 called Compression Residues and follows the rule ID. 125 2. SCHC Compression Process 127 The SCHC Compression rules can be applied to CoAP flows. SCHC 128 Compression of the CoAP header may be done in conjunction with the 129 above layers (IPv6/UDP) or independently. The SCHC adaptation layers 130 as described in [I-D.ietf-lpwan-ipv6-static-context-hc] may be used 131 as as shown in the Figure 1. 133 ^ +------------+ ^ +------------+ ^ +------------+ 134 | | CoAP | | | CoAP | inner | | CoAP | 135 | +------------+ v +------------+ x | OSCORE | 136 | | UDP | | DTLS | outer | +------------+ 137 | +------------+ +------------+ | | UDP | 138 | | IPv6 | | UDP | | +------------+ 139 v +------------+ +------------+ | | IPv6 | 140 | IPv6 | v +------------+ 141 +------------+ 143 Figure 1: rule scope for CoAP 145 Figure 1 shows some examples for CoAP architecture and the SCHC 146 rule's scope. A rule can covers all headers from IPv6 to CoAP, SCHC 147 C/D is done in the device and at the LPWAN boundary. If an end-to- 148 end encryption mechanisms is used between the device and the 149 application. CoAP must be compressed independently of the other 150 layers. The rule ID and the compression residue are encrypted using 151 a mechanism such as DTLS. Only the other end can decipher the 152 information. 153 Layers below may also be compressed using other SCHC rules (this is 154 out of the scope of this document). OSCORE 155 [I-D.ietf-core-object-security] can also define 2 rules to compress 156 the CoAP message. A first rule focuses on the inner header and is 157 end to end, a second rule may compress the outer header and the layer 158 above. SCHC C/D for inner header is done by both ends, SCHC C/D for 159 outer header and other headers is done between the device and the 160 LPWAN boundary. 162 3. CoAP Compression with SCHC 164 CoAP differs from IPv6 and UDP protocols on the following aspects: 166 o IPv6 and UDP are symmetrical protocols. The same fields are found 167 in the request and in the response, only the location in the 168 header may vary (e.g. source and destination fields). A CoAP 169 request is different from a response. For example, the URI-path 170 option is mandatory in the request and is not found in the 171 response, a request may contain an Accept option and the response 172 a Content option. 174 [I-D.ietf-lpwan-ipv6-static-context-hc] defines the use of a 175 message direction (DI) when processing the rule which allows the 176 description of message header format in both directions. 178 o Even when a field is "symmetric" (i.e. found in both directions) 179 the values carried in each direction are different. Combined with 180 a matching list in the TV, this will allow to reduce the range of 181 expected values in a particular direction and therefore reduce the 182 size of a compression residue. For instance, if a client sends 183 only CON request, the type can be elided by compression and the 184 answer may use one bit to carry either the ACK or RST type. Same 185 behavior can be applied to the CoAP Code field (0.0X code are 186 present in the request and Y.ZZ in the answer). The direction 187 allows to split in two parts the possible values for each 188 direction. 190 o In IPv6 and UDP header fields have a fixed size. In CoAP, Token 191 size may vary from 0 to 8 bytes, length is given by a field in the 192 header. More systematically, the CoAP options are described using 193 the Type-Length-Value. 195 [I-D.ietf-lpwan-ipv6-static-context-hc] offers the possibility to 196 define a function for the Field Length in the Field Description. 198 o In CoAP headers, a field can be duplicated several times, for 199 instances, elements of an URI (path or queries). The position 200 defined in a rule, associated to a Field ID, can be used to 201 identify the proper element. 203 [I-D.ietf-lpwan-ipv6-static-context-hc] allows a Field id to 204 appears several times in the rule, the Field Position (FP) removes 205 ambiguities for the matching operation. 207 o Field size defined in the CoAP protocol can be too large regarding 208 LPWAN traffic constraints. This is particularly true for the 209 message ID field or Token field. The use of MSB MO can be used to 210 reduce the information carried on LPWANs. 212 o CoAP also obeys to the client/server paradigm and the compression 213 rate can be different if the request is issued from an LPWAN node 214 or from an non LPWAN device. For instance a Device (Dev) aware of 215 LPWAN constraints can generate a 1 byte token, but a regular CoAP 216 client will certainly send a larger token to the Thing. SCHC 217 compression will not modify the values to offer a better 218 compression rate. Nevertheless a proxy placed before the 219 compressor may change some field values to offer a better 220 compression rate and maintain the necessary context for 221 interoperability with existing CoAP implementations. 223 4. Compression of CoAP header fields 225 This section discusses of the compression of the different CoAP 226 header fields. 228 4.1. CoAP version field 230 This field is bidirectional and must be elided during the SCHC 231 compression, since it always contains the same value. In the future, 232 if new version of CoAP are defined, new rules ID will be defined 233 avoiding ambiguities between versions. 235 4.2. CoAP type field 237 [rfc7252] defines 4 types of messages: CON, NON, ACK and RST. The 238 latter two ones are a response of the two first ones. If the device 239 plays a specific role, a rule can exploit these property with the 240 mapping list: [CON, NON] for one direction and [ACK, RST] for the 241 other direction. Compression residue is reduced to 1 bit. 243 The field must be elided if for instance a client is sending only NON 244 or CON messages. 246 In any case, a rule must be defined to carry RST to a client. 248 4.3. CoAP code field 250 The compression of the CoAP code field follows the same principle as 251 for the CoAP type field. If the device plays a specific role, the 252 set of code values can be split in two parts, the request codes with 253 the 0 class and the response values. 255 If the device implement only a CoAP client, the request code can be 256 reduced to the set of request the client is able to process. 258 All the response codes should be compressed with a SCHC rule. 260 4.4. CoAP Message ID field 262 This field is bidirectional and is used to manage acknowledgments. 263 Server memorizes the value for a EXCHANGE_LIFETIME period (by default 264 247 seconds) for CON messages and a NON_LIFETIME period (by default 265 145 seconds) for NON messages. During that period, a server 266 receiving the same Message ID value will process the message as a 267 retransmission. After this period, it will be processed as a new 268 messages. 270 In case the Device is a client, the size of the message ID field may 271 the too large regarding the number of messages sent. Client may use 272 only small message ID values, for instance 4 bit long. Therefore a 273 MSB can be used to limit the size of the compression residue. 275 In case the Device is a server, client may be located outside of the 276 LPWAN area and view the device as a regular device connected to the 277 internet. The client will generate Message ID using the 16 bits 278 space offered by this field. A CoAP proxy can be set before the SCHC 279 C/D to reduce the value of the Message ID, to allow its compression 280 with the MSB matching operator and LSB CDA. 282 4.5. CoAP Token fields 284 Token is defined through two CoAP fields, Token Length in the 285 mandatory header and Token Value directly following the mandatory 286 CoAP header. 288 Token Length is processed as any protocol field. If the value 289 remains the same during all the transaction, the size can be stored 290 in the context and elided during the transmission. Otherwise it will 291 have to the send as a compression residue. 293 Token Value size should not be defined directly in the rule in the 294 Field Length (FL). Instead a specific function designed as "TKL" 295 must be used and length do not have to the sent with the residue. 296 During the decompression, this function returns the value contained 297 in the Token Length field. 299 5. CoAP options 301 5.1. CoAP Content and Accept options. 303 These field are both unidirectional and must not be set to 304 bidirectional in a rule entry. 306 If single value is expected by the client, it can be stored in the TV 307 and elided during the transmission. Otherwise, if several possible 308 values are expected by the client, a matching-list should be used to 309 limit the size of the residue. If is not possible, the value has to 310 be sent as a residue (fixed or variable length). 312 5.2. CoAP option Max-Age field, CoAP option Uri-Host and Uri-Port 313 fields 315 This field is unidirectional and must not be set to bidirectional in 316 a rule entry. It is used only by the server to inform of the caching 317 duration and is never found in client requests. 319 If the duration is known by both ends, value can be elided on the 320 LPWAN. 322 A matching list can be used if some well-known values are defined. 324 Otherwise these options should be sent as a residue (fixed or 325 variable length). 327 5.3. CoAP option Uri-Path and Uri-Query fields 329 This fields are unidirectional and must not be set to bidirectional 330 in a rule entry. They are used only by the client to access to a 331 specific resource and are never found in server responses. 333 Uri-Path and Uri-Query elements are a repeatable options, the Field 334 Position (FP) gives the position in the path. 336 A Mapping list can be used to reduce size of variable Paths or 337 Queries. In that case, to optimize the compression, several elements 338 can be regrouped into a single entry. Numbering of elements do not 339 change, MO comparison is set with the first element of the matching. 341 FID FL FP DI TV MO CDA 342 URI-Path 1 up ["/a/b", equal not-sent 343 "/c/d"] 344 URI-Path 3 up ignore value-sent 346 Figure 2: complex path example 348 In Figure 2 a single bit residue can be used to code one of the 2 349 paths. If regrouping was not allowed, a 2 bits residue is needed. 351 5.3.1. Variable length Uri-Path and Uri-Query 353 When the length is known at the rule creation, the Field Length must 354 be set to variable, and the unit is set to bytes. 356 The MSB MO can be apply to a Uri-Path or Uri-Query element. Since 357 MSB value is given in bit, the size must always be a multiple of 8 358 bits and the LSB CDA must not carry any value. 360 The length sent at the beginning of a variable length residue 361 indicates the size of the LSB in bytes. 363 For instance for a CoMi path /c/X6?k="eth0" the rule can be set to: 365 FID FL FP DI TV MO CDA 366 URI-Path 1 up "c" equal not-sent 367 URI-Path 2 up ignore value-sent 368 URI-Query 1 up "k=" MSB (16) LSB 370 Figure 3: CoMi URI compression 372 Figure 3 shows the parsing and the compression of the URI. where c is 373 not sent. The second element is sent with the length (i.e. 0x2 X 6) 374 followed by the query option (i.e. 0x05 "eth0"). 376 5.3.2. Variable number of path or query elements 378 The number of Uri-path or Uri-Query element in a rule is fixed at the 379 rule creation time. If the number varies, several rules should be 380 created to cover all the possibilities. Another possibilities is to 381 define the length of Uri-Path to variable and send a compression 382 residue with a length of 0 to indicate that this Uri-Path is empty. 383 This add 4 bits to the compression residue. 385 5.4. CoAP option Size1, Size2, Proxy-URI and Proxy-Scheme fields 387 These fields are unidirectional and must not be set to bidirectional 388 in a rule entry. They are used only by the client to access to a 389 specific resource and are never found in server response. 391 If the field value must be sent, TV is not set, MO is set to "ignore" 392 and CDA is set to "value-sent. A mapping can also be used. 394 Otherwise the TV is set to the value, MO is set to "equal" and CDA is 395 set to "not-sent" 397 5.5. CoAP option ETag, If-Match, If-None-Match, Location-Path and 398 Location-Query fields 400 These fields are unidirectional. 402 These fields values cannot be stored in a rule entry. They must 403 always be sent with the compression residues. 405 6. Other RFCs 407 6.1. Block 409 Block [rfc7959] allows a fragmentation at the CoAP level. SCHC 410 includes also a fragmentation protocol. They are compatible. If a 411 block option is used, its content must be sent as a compression 412 residue. 414 6.2. Observe 416 [rfc7641] defines the Observe option. The TV is not set, MO is set 417 to "ignore" and the CDA is set to "value-sent". SCHC does not limit 418 the maximum size for this option (3 bytes). To reduce the 419 transmission size either the device implementation should limit the 420 delta between two consecutive value or a proxy can modify the 421 incrementation. 423 Since RST message may be sent to inform a server that the client does 424 not require Observe response, a rule must allow the transmission of 425 this message. 427 6.3. No-Response 429 [rfc7967] defines an No-Response option limiting the responses made 430 by a server to a request. If the value is not known by both ends, 431 then TV is set to this value, MO is set to "equal" and CDA is set to 432 "not-sent". 434 Otherwise, if the value is changing over time, TV is not set, MO is 435 set to "ignore" and CDA to "value-sent". A matching list can also be 436 used to reduce the size. 438 6.4. Time Scale 440 Time scale [I-D.toutain-core-time-scale] option allows a client to 441 inform the server that it is in a slow network and that message ID 442 should be kept for a duration given by the option. 444 If the value is not known by both ends, then TV is set to this value, 445 MO is set to "equal" and CDA is set to "not-sent". 447 Otherwise, if the value is changing over time, TV is not set, MO is 448 set to "ignore" and CDA to "value-sent". A matching list can also be 449 used to reduce the size. 451 6.5. OSCORE 453 OSCORE [I-D.ietf-core-object-security] defines end-to-end protection 454 for CoAP messages. This section describes how SCHC rules can be 455 applied to compress OSCORE-protected messages. 457 0 1 2 3 4 5 6 7 <--------- n bytes -------------> 458 +-+-+-+-+-+-+-+-+--------------------------------- 459 |0 0 0|h|k| n | Partial IV (if any) ... 460 +-+-+-+-+-+-+-+-+--------------------------------- 461 | | | 462 |<-- CoAP -->|<------ CoAP OSCORE_piv ------> | 463 OSCORE_flags 465 <- 1 byte -> <------ s bytes -----> 466 +------------+----------------------+-----------------------+ 467 | s (if any) | kid context (if any) | kid (if any) ... | 468 +------------+----------------------+-----------------------+ 469 | | | 470 | <------ CoAP OSCORE_kidctxt ----->|<-- CoAP OSCORE_kid -->| 472 Figure 4: OSCORE Option 474 The encoding of the OSCORE Option Value defined in Section 6.1 of 475 [I-D.ietf-core-object-security] is repeated in Figure 4. 477 The first byte is used for flags that specify the contents of the 478 OSCORE option. The 3 most significant bits are reserved and always 479 set to 0. Bit h, when set, indicates the presence of the kid context 480 field in the option. Bit k, when set, indicates the presence of a 481 kid field. The 3 least significant bits n indicate the length of the 482 piv field in bytes. When n = 0, no piv is present. 484 After the flag byte follow the piv field, kid context field and kid 485 field in order and if present; the length of the kid context field is 486 encoded in the first byte denoting by s the length of the kid context 487 in bytes. 489 This draft recommends to implement a parser that is able to identify 490 the OSCORE Option and the fields it contains. 492 Conceptually, it discerns up to 4 distinct pieces of information 493 within the OSCORE option: the flag bits, the piv, the kid context, 494 and the kid. It is thus recommended that the parser split the OSCORE 495 option into the 4 subsequent fields: 497 o CoAP OSCORE_flags, 499 o CoAP OSCORE_piv, 501 o CoAP OSCORE_kidctxt, 503 o CoAP OSCORE_kid. 505 These fields are superposed on the OSCORE Option format in Figure 4, 506 the CoAP OSCORE_kidctxt field including the size bits s. Their size 507 may be reduced using the MSB matching operator. 509 7. Examples of CoAP header compression 511 7.1. Mandatory header with CON message 513 In this first scenario, the LPWAN compressor receives from outside 514 client a POST message, which is immediately acknowledged by the 515 Device. For this simple scenario, the rules are described Figure 5. 517 Rule ID 1 518 +-------------+--+--+--+------+---------+-------------++------------+ 519 | Field. |FL|FP|DI|Target| Match | CDA || Sent | 520 | | | | |Value | Opera. | || [bits] | 521 +-------------+--+--+--+------+---------+-------------++------------+ 522 |CoAP version | | |bi| 01 |equal |not-sent || | 523 |CoAP version | | |bi| 01 |equal |not-sent || | 524 |CoAP Type | | |dw| CON |equal |not-sent || | 525 |CoAP Type | | |up|[ACK, | | || | 526 | | | | | RST] |match-map|matching-sent|| T | 527 |CoAP TKL | | |bi| 0 |equal |not-sent || | 528 |CoAP Code | | |bi| ML1 |match-map|matching-sent|| CC CCC | 529 |CoAP MID | | |bi| 0000 |MSB(7 ) |LSB(9) || M-ID| 530 |CoAP Uri-Path| | |dw| path |equal 1 |not-sent || | 531 +-------------+--+--+--+------+---------+-------------++------------+ 533 Figure 5: CoAP Context to compress header without token 535 The version and Token Length fields are elided. Code has shrunk to 5 536 bits using a matching list. Uri-Path contains a single element 537 indicated in the matching operator. 539 Figure 6 shows the time diagram of the exchange. A client in the 540 Application Server sends a CON request. It can go through a proxy 541 which reduces the message ID to a smallest value, with at least the 9 542 most significant bits equal to 0. SCHC Compression reduces the 543 header sending only the Type, a mapped code and the least 9 544 significant bits of Message ID. 546 Device LPWAN SCHC C/D 547 | | 548 | rule id=1 |<-------------------- 549 |<-------------------| +-+-+--+----+------+ 550 <------------------- | CCCCCMMMMMMMMM | |1|0| 4|0.01|0x0034| 551 +-+-+--+----+-------+ | 00001000110100 | | 0xb4 p a t| 552 |1|0| 1|0.01|0x0034 | | | | h | 553 | 0xb4 p a t | | | +------+ 554 | h | | | 555 +------+ | | 556 | | 557 | | 558 ---------------------->| rule id=1 | 559 +-+-+--+----+--------+ |------------------->| 560 |1|2| 0|2.05| 0x0034 | | TCCCCCMMMMMMMMM |---------------------> 561 +-+-+--+----+--------+ | 001100000110100 | +-+-+--+----+------+ 562 | | |1|2| 0|2.05|0x0034| 563 v v +-+-+--+----+------+ 565 Figure 6: Compression with global addresses 567 7.2. OSCORE Compression 569 OSCORE aims to solve the problem of end-to-end encryption for CoAP 570 messages. The goal, therefore, is to hide as much of the message as 571 possible while still enabling proxy operation. 573 Conceptually this is achieved by splitting the CoAP message into an 574 Inner Plaintext and Outer OSCORE Message. The Inner Plaintext 575 contains sensible information which is not necessary for proxy 576 operation. This, in turn, is the part of the message which can be 577 encrypted until it reaches its end destination. The Outer Message 578 acts as a shell matching the format of a regular CoAP message, and 579 includes all Options and information needed for proxy operation and 580 caching. This decomposition is illustrated in Figure 7. 582 CoAP options are sorted into one of 3 classes, each granted a 583 specific type of protection by the protocol: 585 o Class E: Encrypted options moved to the Inner Plaintext, 587 o Class I: Integrity-protected options included in the AAD for the 588 encryption of the Plaintext but otherwise left untouched in the 589 Outer Message, 591 o Class U: Unprotected options left untouched in the Outer Message. 593 Additionally, the OSCORE Option is added as an Outer option, 594 signaling that the message is OSCORE protected. This option carries 595 the information necessary to retrieve the Security Context with which 596 the message was encrypted so that it may be correctly decrypted at 597 the other end-point. 599 Original CoAP Message 600 +-+-+---+-------+---------------+ 601 |v|t|tkl| code | Msg Id. | 602 +-+-+---+-------+---------------+....+ 603 | Token | 604 +-------------------------------.....+ 605 | Options (IEU) | 606 . . 607 . . 608 +------+-------------------+ 609 | 0xFF | 610 +------+------------------------+ 611 | | 612 | Payload | 613 | | 614 +-------------------------------+ 615 / \ 616 / \ 617 / \ 618 / \ 619 Outer Header v v Plaintext 620 +-+-+---+--------+---------------+ +-------+ 621 |v|t|tkl|new code| Msg Id. | | code | 622 +-+-+---+--------+---------------+....+ +-------+-----......+ 623 | Token | | Options (E) | 624 +--------------------------------.....+ +-------+------.....+ 625 | Options (IU) | | OxFF | 626 . . +-------+-----------+ 627 . OSCORE Option . | | 628 +------+-------------------+ | Payload | 629 | 0xFF | | | 630 +------+ +-------------------+ 632 Figure 7: OSCORE inner and outer header form a CoAP message 634 Figure 7 shows the message format for the OSCORE Message and 635 Plaintext. 637 In the Outer Header, the original message code is hidden and replaced 638 by a default dummy value. As seen in sections 4.1.3.5 and 4.2 of 640 [I-D.ietf-core-object-security], the message code is replaced by POST 641 for requests and Changed for responses when Observe is not used. If 642 Observe is used, the message code is replaced by FETCH for requests 643 and Content for responses. 645 The original message code is put into the first byte of the 646 Plaintext. Following the message code, the class E options comes and 647 if present the original message Payload is preceded by its payload 648 marker. 650 The Plaintext is now encrypted by an AEAD algorithm which integrity 651 protects Security Context parameters and eventually any class I 652 options from the Outer Header. Currently no CoAP options are marked 653 class I. The resulting Ciphertext becomes the new Payload of the 654 OSCORE message, as illustrated in Figure 8. 656 This Ciphertext is, as defined in RFC 5116, the concatenation of the 657 encrypted Plaintext and its authentication tag. Note that Inner 658 Compression only affects the Plaintext before encryption, thus we can 659 only aim to reduce this first, variable length component of the 660 Ciphertext. The authentication tag is fixed in length and considered 661 part of the cost of protection. 663 Outer Header 664 +-+-+---+--------+---------------+ 665 |v|t|tkl|new code| Msg Id. | 666 +-+-+---+--------+---------------+....+ 667 | Token | 668 +--------------------------------.....+ 669 | Options (IU) | 670 . . 671 . OSCORE Option . 672 +------+-------------------+ 673 | 0xFF | 674 +------+-------------------------+ 675 | | 676 | Encrypted Inner Header and | 677 | Payload | 678 | | 679 +--------------------------------+ 681 Figure 8: OSCORE message 683 The SCHC Compression scheme consists of compressing both the 684 Plaintext before encryption and the resulting OSCORE message after 685 encryption, see Figure 9. 687 This translates into a segmented process where SCHC compression is 688 applied independently in 2 stages, each with its corresponding set of 689 rules, with the Inner SCHC Rules and the Outer SCHC Rules. This way 690 compression is applied to all fields of the original CoAP message. 692 Note that since the Inner part of the message can only be decrypted 693 by the corresponding end-point, this end-point will also have to 694 implement Inner SCHC Compression/Decompression. 696 Outer Message OSCORE Plaintext 697 +-+-+---+--------+---------------+ +-------+ 698 |v|t|tkl|new code| Msg Id. | | code | 699 +-+-+---+--------+---------------+....+ +-------+-----......+ 700 | Token | | Options (E) | 701 +--------------------------------.....+ +-------+------.....+ 702 | Options (IU) | | OxFF | 703 . . +-------+-----------+ 704 . OSCORE Option . | | 705 +------+-------------------+ | Payload | 706 | 0xFF | | | 707 +------+------------+ +-------------------+ 708 | Ciphertext |<---------\ | 709 | | | v 710 +-------------------+ | +-----------------+ 711 | | | Inner SCHC | 712 v | | Compression | 713 +-----------------+ | +-----------------+ 714 | Outer SCHC | | | 715 | Compression | | v 716 +-----------------+ | +-------+ 717 | | |Rule ID| 718 v | +-------+--+ 719 +--------+ +------------+ | Residue | 720 |Rule ID'| | Encryption | <--- +----------+--------+ 721 +--------+--+ +------------+ | | 722 | Residue' | | Payload | 723 +-----------+-------+ | | 724 | Ciphertext | +-------------------+ 725 | | 726 +-------------------+ 728 Figure 9: OSCORE Compression Diagram 730 7.3. Example OSCORE Compression 732 An example is given with a GET Request and its consequent CONTENT 733 Response. A possible set of rules for the Inner and Outer SCHC 734 Compression is shown. A dump of the results and a contrast between 735 SCHC + OSCORE performance with SCHC + COAP performance is also 736 listed. This gives an approximation to the cost of security with 737 SCHC-OSCORE. 739 Our first example CoAP message is the GET Request in Figure 10 741 Original message: 742 ================= 743 0x4101000182bb74656d7065726174757265 745 Header: 746 0x4101 747 01 Ver 748 00 CON 749 0001 tkl 750 00000001 Request Code 1 "GET" 752 0x0001 = mid 753 0x82 = token 755 Options: 756 0xbb74656d7065726174757265 757 Option 11: URI_PATH 758 Value = temperature 760 Original msg length: 17 bytes. 762 Figure 10: CoAP GET Request 764 Its corresponding response is the CONTENT Response in Figure 11. 766 Original message: 767 ================= 768 0x6145000182ff32332043 770 Header: 771 0x6145 772 01 Ver 773 10 ACK 774 0001 tkl 775 01000101 Successful Response Code 69 "2.05 Content" 777 0x0001 = mid 778 0x82 = token 780 0xFF Payload marker 781 Payload: 782 0x32332043 784 Original msg length: 10 786 Figure 11: CoAP CONTENT Response 788 The SCHC Rules for the Inner Compression include all fields that are 789 already present in a regular CoAP message, what is important is the 790 order of appearance and inclusion of only those CoAP fields that go 791 into the Plaintext, Figure 12. 793 Rule ID 0 794 +---------------+--+--+-----------+-----------+-----------++------+ 795 | Field |FP|DI| Target | MO | CDA || Sent | 796 | | | | Value | | ||[bits]| 797 +---------------+--+--+-----------+-----------+-----------++------+ 798 |CoAP Code | |up| 1 | equal |not-sent || | 799 |CoAP Code | |dw|[69,132] | match-map |match-sent || c | 800 |CoAP Uri-Path | |up|temperature| equal |not-sent || | 801 |COAP Option-End| |dw| 0xFF | equal |not-sent || | 802 +---------------+--+--+-----------+-----------+-----------++------+ 804 Figure 12: Inner SCHC Rules 806 Figure 13 shows the Plaintext obtained for our example GET Request 807 and follows the process of Inner Compression and Encryption until we 808 end up with the Payload to be added in the outer OSCORE Message. 810 In this case the original message has no payload and its resulting 811 Plaintext can be compressed up to only 1 byte (size of the Rule ID). 812 The AEAD algorithm preserves this length in its first output, but 813 also yields a fixed-size tag which cannot be compressed and must be 814 included in the OSCORE message. This translates into an overhead in 815 total message length, which limits the amount of compression that can 816 be achieved and plays into the cost of adding security to the 817 exchange. 819 ________________________________________________________ 820 | | 821 | OSCORE Plaintext | 822 | | 823 | 0x01bb74656d7065726174757265 (13 bytes) | 824 | | 825 | 0x01 Request Code GET | 826 | | 827 | bb74656d7065726174757265 Option 11: URI_PATH | 828 | Value = temperature | 829 |________________________________________________________| 831 | 832 | 833 | Inner SCHC Compression 834 | 835 v 836 _________________________________ 837 | | 838 | Compressed Plaintext | 839 | | 840 | 0x00 | 841 | | 842 | Rule ID = 0x00 (1 byte) | 843 | (No residue) | 844 |_________________________________| 846 | 847 | AEAD Encryption 848 | (piv = 0x04) 849 v 850 _________________________________________________ 851 | | 852 | encrypted_plaintext = 0xa2 (1 byte) | 853 | tag = 0xc54fe1b434297b62 (8 bytes) | 854 | | 855 | ciphertext = 0xa2c54fe1b434297b62 (9 bytes) | 856 |_________________________________________________| 858 Figure 13: Plaintext compression and encryption for GET Request 860 In Figure 14 we repeat the process for the example CONTENT Response. 861 In this case the misalignment produced by the compression residue (1 862 bit) makes it so that 7 bits of padding must be applied after the 863 payload, resulting in a compressed Plaintext that is the same size as 864 before compression. This misalignment also causes the hexcode from 865 the payload to differ from the original, even though it has not been 866 compressed. On top of this, the overhead from the tag bytes is 867 incurred as before. 869 ________________________________________________________ 870 | | 871 | OSCORE Plaintext | 872 | | 873 | 0x45ff32332043 (6 bytes) | 874 | | 875 | 0x45 Successful Response Code 69 "2.05 Content" | 876 | | 877 | ff Payload marker | 878 | | 879 | 32332043 Payload | 880 |________________________________________________________| 882 | 883 | 884 | Inner SCHC Compression 885 | 886 v 887 __________________________________________ 888 | | 889 | Compressed Plaintext | 890 | | 891 | 0x001919902180 (6 bytes) | 892 | | 893 | 00 Rule ID | 894 | | 895 | 0b0 (1 bit match-map residue) | 896 | 0x32332043 >> 1 (shifted payload) | 897 | 0b0000000 Padding | 898 |__________________________________________| 900 | 901 | AEAD Encryption 902 | (piv = 0x04) 903 v 904 _________________________________________________________ 905 | | 906 | encrypted_plaintext = 0x10c6d7c26cc1 (6 bytes) | 907 | tag = 0xe9aef3f2461e0c29 (8 bytes) | 908 | | 909 | ciphertext = 0x10c6d7c26cc1e9aef3f2461e0c29 (14 bytes) | 910 |_________________________________________________________| 912 Figure 14: Plaintext compression and encryption for CONTENT Response 914 The Outer SCHC Rules (Figure 17) must process the OSCORE Options 915 fields. In Figure 15 and Figure 16 we show a dump of the OSCORE 916 Messages generated from our example messages once they have been 917 provided with the Inner Compressed Ciphertext in the payload. These 918 are the messages that are to go through Outer SCHC Compression. 920 Protected message: 921 ================== 922 0x4102000182d7080904636c69656e74ffa2c54fe1b434297b62 923 (25 bytes) 925 Header: 926 0x4102 927 01 Ver 928 00 CON 929 0001 tkl 930 00000010 Request Code 2 "POST" 932 0x0001 = mid 933 0x82 = token 935 Options: 936 0xd7080904636c69656e74 (10 bytes) 937 Option 21: OBJECT_SECURITY 938 Value = 0x0904636c69656e74 939 09 = 000 0 1 001 Flag byte 940 h k n 941 04 piv 942 636c69656e74 kid 944 0xFF Payload marker 945 Payload: 946 0xa2c54fe1b434297b62 (9 bytes) 948 Figure 15: Protected and Inner SCHC Compressed GET Request 950 Protected message: 951 ================== 952 0x6144000182d008ff10c6d7c26cc1e9aef3f2461e0c29 953 (22 bytes) 955 Header: 956 0x6144 957 01 Ver 958 10 ACK 959 0001 tkl 960 01000100 Successful Response Code 68 "2.04 Changed" 962 0x0001 = mid 963 0x82 = token 965 Options: 966 0xd008 (2 bytes) 967 Option 21: OBJECT_SECURITY 968 Value = b'' 970 0xFF Payload marker 971 Payload: 972 0x10c6d7c26cc1e9aef3f2461e0c29 (14 bytes) 974 Figure 16: Protected and Inner SCHC Compressed CONTENT Response 976 For the flag bits, a number of compression methods could prove to be 977 useful depending on the application. The simplest alternative is to 978 provide a fixed value for the flags, combining MO equal and CDA not- 979 sent. This saves most bits but could hinder flexibility. Otherwise, 980 match-mapping could allow to choose from a number of configurations 981 of interest to the exchange. If neither of these alternatives is 982 desirable, MSB could be used to mask off the 3 hard-coded most 983 significant bits. 985 Note that fixing a flag bit will limit the choice of CoAP Options 986 that can be used in the exchange, since their values are dependent on 987 certain options. 989 The piv field lends itself to having a number of bits masked off with 990 MO MSB and CDA LSB. This could prove useful in applications where 991 the message frequency is low such as that found in LPWAN 992 technologies. Note that compressing the sequence numbers effectively 993 reduces the maximum amount of sequence numbers that can be used in an 994 exchange. Once this amount is exceeded, the SCHC Context would need 995 to be re-established. 997 The size s included in the kid context field may be masked off with 998 CDA MSB. The rest of the field could have additional bits masked 999 off, or have the whole field be fixed with MO equal and CDA not-sent. 1000 The same holds for the kid field. 1002 Figure 17 shows a possible set of Outer Rules to compress the Outer 1003 Header. 1005 Rule ID 0 1006 +-------------------+--+--+--------------+--------+---------++------+ 1007 | Field |FP|DI| Target | MO | CDA || Sent | 1008 | | | | Value | | ||[bits]| 1009 +-------------------+--+--+--------------+--------+---------++------+ 1010 |CoAP version | |bi| 01 |equal |not-sent || | 1011 |CoAP Type | |up| 0 |equal |not-sent || | 1012 |CoAP Type | |dw| 2 |equal |not-sent || | 1013 |CoAP TKL | |bi| 1 |equal |not-sent || | 1014 |CoAP Code | |up| 2 |equal |not-sent || | 1015 |CoAP Code | |dw| 68 |equal |not-sent || | 1016 |CoAP MID | |bi| 0000 |MSB(12) |LSB ||MMMM | 1017 |CoAP Token | |bi| 0x80 |MSB(5) |LSB ||TTT | 1018 |CoAP OSCORE_flags | |up| 0x09 |equal |not-sent || | 1019 |CoAP OSCORE_piv | |up| 0x00 |MSB(4) |LSB ||PPPP | 1020 |COAP OSCORE_kid | |up|0x636c69656e70|MSB(52) |LSB ||KKKK | 1021 |COAP OSCORE_kidctxt| |bi| b'' |equal |not-sent || | 1022 |CoAP OSCORE_flags | |dw| b'' |equal |not-sent || | 1023 |CoAP OSCORE_piv | |dw| b'' |equal |not-sent || | 1024 |CoAP OSCORE_kid | |dw| b'' |equal |not-sent || | 1025 |COAP Option-End | |dw| 0xFF |equal |not-sent || | 1026 +-------------------+--+--+--------------+--------+---------++------+ 1028 Figure 17: Outer SCHC Rules 1030 These Outer Rules are applied to the example GET Request and CONTENT 1031 Response. The resulting messages are shown in Figure 18 and 1032 Figure 19. 1034 Compressed message: 1035 ================== 1036 0x001489458a9fc3686852f6c4 (12 bytes) 1037 0x00 Rule ID 1038 1489 Compression Residue 1039 458a9fc3686852f6c4 Padded payload 1041 Compression residue: 1042 0b 0001 010 0100 0100 (15 bits -> 2 bytes with padding) 1043 mid tkn piv kid 1045 Payload 1046 0xa2c54fe1b434297b62 (9 bytes) 1048 Compressed message length: 12 bytes 1050 Figure 18: SCHC-OSCORE Compressed GET Request 1052 Compressed message: 1053 ================== 1054 0x0014218daf84d983d35de7e48c3c1852 (16 bytes) 1055 0x00 Rule ID 1056 14 Compression residue 1057 218daf84d983d35de7e48c3c1852 Padded payload 1058 Compression residue: 1059 0b0001 010 (7 bits -> 1 byte with padding) 1060 mid tkn 1062 Payload 1063 0x10c6d7c26cc1e9aef3f2461e0c29 (14 bytes) 1065 Compressed msg length: 16 bytes 1067 Figure 19: SCHC-OSCORE Compressed CONTENT Response 1069 For contrast, we compare these results with what would be obtained by 1070 SCHC compressing the original CoAP messages without protecting them 1071 with OSCORE. To do this, we compress the CoAP messages according to 1072 the SCHC rules in Figure 20. 1074 Rule ID 1 1075 +---------------+--+--+-----------+---------+-----------++--------+ 1076 | Field |FP|DI| Target | MO | CDA || Sent | 1077 | | | | Value | | || [bits] | 1078 +---------------+--+--+-----------+---------+-----------++--------+ 1079 |CoAP version | |bi| 01 |equal |not-sent || | 1080 |CoAP Type | |up| 0 |equal |not-sent || | 1081 |CoAP Type | |dw| 2 |equal |not-sent || | 1082 |CoAP TKL | |bi| 1 |equal |not-sent || | 1083 |CoAP Code | |up| 2 |equal |not-sent || | 1084 |CoAP Code | |dw| [69,132] |equal |not-sent || | 1085 |CoAP MID | |bi| 0000 |MSB(12) |LSB ||MMMM | 1086 |CoAP Token | |bi| 0x80 |MSB(5) |LSB ||TTT | 1087 |CoAP Uri-Path | |up|temperature|equal |not-sent || | 1088 |COAP Option-End| |dw| 0xFF |equal |not-sent || | 1089 +---------------+--+--+-----------+---------+-----------++--------+ 1091 Figure 20: SCHC-CoAP Rules (No OSCORE) 1093 This yields the results in Figure 21 for the Request, and Figure 22 1094 for the Response. 1096 Compressed message: 1097 ================== 1098 0x0114 1099 0x01 = Rule ID 1101 Compression residue: 1102 0b00010100 (1 byte) 1104 Compressed msg length: 2 1106 Figure 21: CoAP GET Compressed without OSCORE 1108 Compressed message: 1109 ================== 1110 0x010a32332043 1111 0x01 = Rule ID 1113 Compression residue: 1114 0b00001010 (1 byte) 1116 Payload 1117 0x32332043 1119 Compressed msg length: 6 1121 Figure 22: CoAP CONTENT Compressed without OSCORE 1123 As can be seen, the difference between applying SCHC + OSCORE as 1124 compared to regular SCHC + COAP is about 10 bytes of cost. 1126 8. IANA Considerations 1128 This document has no request to IANA. 1130 9. Security considerations 1132 This document does not have any more Security consideration than the 1133 ones already raised on [I-D.ietf-lpwan-ipv6-static-context-hc] 1135 10. Acknowledgements 1137 Thanks to all the persons that have give us feedback 1139 11. Normative References 1141 [I-D.ietf-core-object-security] 1142 Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 1143 "Object Security for Constrained RESTful Environments 1144 (OSCORE)", draft-ietf-core-object-security-15 (work in 1145 progress), August 2018. 1147 [I-D.ietf-lpwan-ipv6-static-context-hc] 1148 Minaburo, A., Toutain, L., Gomez, C., Barthel, D., and J. 1149 Zuniga, "LPWAN Static Context Header Compression (SCHC) 1150 and fragmentation for IPv6 and UDP", draft-ietf-lpwan- 1151 ipv6-static-context-hc-18 (work in progress), December 1152 2018. 1154 [I-D.toutain-core-time-scale] 1155 Minaburo, A. and L. Toutain, "CoAP Time Scale Option", 1156 draft-toutain-core-time-scale-00 (work in progress), 1157 October 2017. 1159 [rfc7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 1160 Application Protocol (CoAP)", RFC 7252, 1161 DOI 10.17487/RFC7252, June 2014, 1162 . 1164 [rfc7641] Hartke, K., "Observing Resources in the Constrained 1165 Application Protocol (CoAP)", RFC 7641, 1166 DOI 10.17487/RFC7641, September 2015, 1167 . 1169 [rfc7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 1170 the Constrained Application Protocol (CoAP)", RFC 7959, 1171 DOI 10.17487/RFC7959, August 2016, 1172 . 1174 [rfc7967] Bhattacharyya, A., Bandyopadhyay, S., Pal, A., and T. 1175 Bose, "Constrained Application Protocol (CoAP) Option for 1176 No Server Response", RFC 7967, DOI 10.17487/RFC7967, 1177 August 2016, . 1179 Authors' Addresses 1181 Ana Minaburo 1182 Acklio 1183 1137A avenue des Champs Blancs 1184 35510 Cesson-Sevigne Cedex 1185 France 1187 Email: ana@ackl.io 1189 Laurent Toutain 1190 Institut MINES TELECOM; IMT Atlantique 1191 2 rue de la Chataigneraie 1192 CS 17607 1193 35576 Cesson-Sevigne Cedex 1194 France 1196 Email: Laurent.Toutain@imt-atlantique.fr 1197 Ricardo Andreasen 1198 Universidad de Buenos Aires 1199 Av. Paseo Colon 850 1200 C1063ACV Ciudad Autonoma de Buenos Aires 1201 Argentina 1203 Email: randreasen@fi.uba.ar