idnits 2.17.1 draft-ietf-cbor-network-addresses-10.txt: -(5): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding 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: ---------------------------------------------------------------------------- == There are 2 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (6 October 2021) is 925 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Obsolete informational reference (is this intentional?): RFC 7042 (Obsoleted by RFC 9542) Summary: 0 errors (**), 0 flaws (~~), 2 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CBOR Working Group M. Richardson 3 Internet-Draft Sandelman Software Works 4 Intended status: Standards Track C. Bormann 5 Expires: 9 April 2022 Universität Bremen TZI 6 6 October 2021 8 CBOR tags for IPv4 and IPv6 addresses and prefixes 9 draft-ietf-cbor-network-addresses-10 11 Abstract 13 This specification defines two CBOR Tags for use with IPv6 and IPv4 14 addresses and prefixes. 16 // RFC-EDITOR-please-remove: This work is tracked at 17 // https://github.com/cbor-wg/cbor-network-address 19 Status of This Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at https://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on 9 April 2022. 36 Copyright Notice 38 Copyright (c) 2021 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 43 license-info) in effect on the date of publication of this document. 44 Please review these documents carefully, as they describe your rights 45 and restrictions with respect to this document. Code Components 46 extracted from this document must include Simplified BSD License text 47 as described in Section 4.e of the Trust Legal Provisions and are 48 provided without warranty as described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 53 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 54 3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 3 55 3.1. Three Forms . . . . . . . . . . . . . . . . . . . . . . . 3 56 3.1.1. Addresses . . . . . . . . . . . . . . . . . . . . . . 3 57 3.1.2. Prefixes . . . . . . . . . . . . . . . . . . . . . . 3 58 3.1.3. Interface Definition . . . . . . . . . . . . . . . . 4 59 3.2. IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 4 60 3.3. IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . 5 61 4. Encoder Considerations for Prefixes . . . . . . . . . . . . . 6 62 5. Decoder Considerations for Prefixes . . . . . . . . . . . . . 6 63 6. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 64 7. Security Considerations . . . . . . . . . . . . . . . . . . . 8 65 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 66 8.1. Tag 54 - IPv6 . . . . . . . . . . . . . . . . . . . . . . 9 67 8.2. Tag 52 - IPv4 . . . . . . . . . . . . . . . . . . . . . . 9 68 8.3. Tags 260 and 261 . . . . . . . . . . . . . . . . . . . . 9 69 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 9 70 9.1. Normative References . . . . . . . . . . . . . . . . . . 9 71 9.2. Informative References . . . . . . . . . . . . . . . . . 10 72 Appendix A. Changelog . . . . . . . . . . . . . . . . . . . . . 10 73 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 10 74 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 10 76 1. Introduction 78 [RFC8949] defines a number of CBOR Tags for common items. Tags 260 79 and 261 were later defined in drafts listed with IANA 80 [IANA.cbor-tags]. These tags were intended to cover addresses (260) 81 and prefixes (261). Tag 260 distinguishes between IPv6, IPv4, and 82 MAC [RFC7042] addresses only through the length of the byte string 83 making it impossible, for example, to drop trailing zeros in the 84 encoding of IP addresses. Tag 261 was not documented well enough for 85 use. 87 This specification defines tags 54 and 52 achieving an explicit 88 indication of IPv6 or IPv4 by the tag number. These new tags are 89 intended to be used in preference to tags 260 and 261. They provide 90 formats for IPv6 and IPv4 addresses, prefixes, and addresses with 91 prefixes, achieving an explicit indication of IPv6 or IPv4. The 92 prefix format omits trailing zeroes in the address part. (Due to the 93 complexity of testing, the value of omitting trailing zeros for the 94 pure address format was considered non-essential and support for that 95 is not provided in this specification.) This specification does not 96 deal with 6- or 8-byte Ethernet addresses. 98 2. Terminology 100 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 101 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 102 "OPTIONAL" in this document are to be interpreted as described in 103 BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all 104 capitals, as shown here. 106 3. Protocol 108 3.1. Three Forms 110 3.1.1. Addresses 112 These tags can be applied to byte strings to represent a single 113 address. 115 This form is called the Address Format. 117 3.1.2. Prefixes 119 When applied to an array that starts with an unsigned integer, they 120 represent a CIDR-style prefix of that length. 122 When the Address Format (i.e., without prefix) appears in a context 123 where a prefix is expected, then it is to be assumed that all bits 124 are relevant. That is, for IPv4, a /32 is implied, and for IPv6, a 125 /128 is implied. 127 This form is called the Prefix Format. 129 3.1.3. Interface Definition 131 When applied to an array that starts with a byte string, which stands 132 for an IP address, followed by an unsigned integer giving the bit 133 length of a prefix built out of the first length bits of the address, 134 they represent information that is commonly used to specify both the 135 network prefix and the IP address of an interface. 137 The length of the byte string is always 16 bytes (for IPv6) and 4 138 bytes (for IPv4). 140 This form is called the Interface Format. 142 Interface Format definitions support an optional third element to the 143 array, which is to be used as the IPv6 Link-Local interface 144 identifier Section 4 of [RFC3542]. This may be an integer, in which 145 case it is to be interpreted as the interface index. This may be a 146 string, in which case it is to be interpreted as an interface name. 148 In the cases where the Interface Format is being used to represent 149 only an address with an interface identifier, and no interface prefix 150 information, then the prefix length may be replaced with the CBOR 151 "false" (0xF4). 153 3.2. IPv6 155 IANA has allocated tag 54 for IPv6 uses. (This is the ASCII code for 156 '6'.) 158 An IPv6 address is to be encoded as a sixteen-byte byte string 159 (Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 54. 161 For example: 163 54(h'20010db81234deedbeefcafefacefeed') 165 An IPv6 prefix, such as 2001:db8:1234::/48 is to be encoded as a two 166 element array, with the length of the prefix first. Trailing zero 167 bytes MUST be omitted. 169 For example: 171 54([48, h'20010db81234']) 173 An IPv6 address combined with a prefix length, such as being used for 174 configuring an interface, is to be encoded as a two element array, 175 with the (full-length) IPv6 address first and the length of the 176 associated network the prefix next. 178 For example: 180 54([h'20010db81234deedbeefcafefacefeed', 56]) 182 The address-with-prefix form can be reliably distinguished from the 183 prefix form only in the sequence of the array elements. 185 Some example of a link-local IPv6 address with a 64-bit prefix: 187 54([h'fe8000000000020202fffffffe030303', 64, 'eth0']) 189 with a numeric interface identifier: 191 54([h'fe8000000000020202fffffffe030303', 64, 42]) 193 An IPv6 link-local address without a prefix length: 195 54([h'fe8000000000020202fffffffe030303', false, 42]) 197 Interface identifiers may be used with any kind of IPv6 address, not 198 just Link-Local addresses. In particular, they are valid for 199 multicast addresses, and there may still be some significance for 200 Globally Unique Addresses (GUA). 202 3.3. IPv4 204 IANA has allocated tag 52 for IPv4 uses. (This is the ASCII code for 205 '4'.) 207 An IPv4 address is to be encoded as a four-byte byte string 208 (Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 52. 210 For example: 212 52(h'c0000201') 214 An IPv4 prefix, such as 192.0.2.0/24 is to be encoded as a two 215 element array, with the length of the prefix first. Trailing zero 216 bytes MUST be omitted. 218 For example: 220 52([24, h'c00002']) 222 An IPv4 address combined with a prefix length, such as being used for 223 configuring an interface, is to be encoded as a two element array, 224 with the (full-length) IPv4 address first and the length of the 225 associated network the prefix next. 227 For example, 192.0.2.1/24 is to be encoded as a two element array, 228 with the length of the prefix (implied 192.0.2.0/24) last. 230 52([h'c0000201', 24]) 232 The address-with-prefix form can be reliably distinguished from the 233 prefix form only in the sequence of the array elements. 235 4. Encoder Considerations for Prefixes 237 For the byte strings used in representing prefixes, an encoder MUST 238 omit any right-aligned (trailing) sequence of bytes that are all 239 zero. 241 There is no relationship between the number of bytes omitted and the 242 prefix length. For instance, the prefix 2001:db8::/64 is encoded as: 244 54([64, h'20010db8']) 246 An encoder MUST take care to set all trailing bits in the final byte 247 to zero, if any. While decoders are expected to ignore them, such 248 garbage entities could be used as a covert channel, or may reveal the 249 state of what would otherwise be private memory contents. So for 250 example, 2001:db8:1230::/44 MUST be encoded as: 252 52([44, h'20010db81230']) 254 even though variations like: 256 54([44, h'20010db81233']) 257 54([45, h'20010db8123f']) 259 would be parsed in the exact same way; they MUST be considered 260 invalid. 262 The same considerations apply to IPv4 prefixes. 264 5. Decoder Considerations for Prefixes 266 A decoder MUST consider all bits to the right of the prefix length to 267 be zero. 269 A decoder MUST handle the case where a prefix length specifies that 270 more bits are relevant than are actually present in the byte-string. 271 As a pathological case, ::/128 can be encoded as 273 54([128, h'']) 274 A recommendation for implementations is to first create an array of 275 16 (or 4) zero bytes. 277 Then taking whichever is smaller between (a) the length of the 278 included byte-string, and (b) the number of bytes covered by the 279 prefix-length rounded up to the next multiple of 8: fail if that 280 number is greater than 16 (or 4), and then copy that many bytes from 281 the byte-string into the array. 283 Finally, looking at the last three bits of the prefix-length in bits 284 (that is, the prefix-length modulo 8), use a static array of 8 values 285 to force the lower, non-relevant bits to zero, or simply: 287 unused_bits = (8 - (prefix_length_in_bits & 7)) % 8; 288 if (length_in_bytes > 0) 289 address_bytes[length_in_bytes - 1] &= (0xFF << unused_bits); 291 A particularly paranoid decoder could examine the lower non-relevant 292 bits to determine if they are non-zero, and reject the prefix. This 293 would detect non-compliant encoders, or a possible covert channel. 295 if (length_in_bytes > 0 && 296 (address_bytes[length_in_bytes - 1] & ~(0xFF << unused_bits)) 297 != 0) 298 fail(); 300 6. CDDL 302 For use with CDDL [RFC8610], the typenames defined in Figure 1 are 303 recommended: 305 ip-address-or-prefix = ipv6-address-or-prefix / 306 ipv4-address-or-prefix 308 ipv6-address-or-prefix = #6.54(ipv6-address / 309 ipv6-address-with-prefix / 310 ipv6-prefix) 311 ipv4-address-or-prefix = #6.52(ipv4-address / 312 ipv4-address-with-prefix / 313 ipv4-prefix) 315 ipv6-address = bytes .size 16 316 ipv4-address = bytes .size 4 318 ipv6-address-with-prefix = [ipv6-address, ipv6-prefix-value, 319 ?ipv6-interface-identifier] 320 ipv4-address-with-prefix = [ipv4-address, ipv4-prefix-length] 322 ipv6-prefix-value = ipv6-prefix-length 323 / false 324 ipv6-prefix-length = 0..128 325 ipv4-prefix-length = 0..32 327 ipv6-prefix = [ipv6-prefix-length, ipv6-prefix-bytes] 328 ipv4-prefix = [ipv4-prefix-length, ipv4-prefix-bytes] 330 ipv6-prefix-bytes = bytes .size (uint .le 16) 331 ipv4-prefix-bytes = bytes .size (uint .le 4) 333 ipv6-interface-identifier = uint / tstr 335 Figure 1 337 7. Security Considerations 339 This document provides an CBOR encoding for IPv4 and IPv6 address 340 information. Any applications using these encodings will need to 341 consider the security implications of this data in their specific 342 context. For example, identifying which byte sequences in a protocol 343 are addresses may allow an attacker or eavesdropper to better 344 understand what parts of a packet to attack. 346 The right-hand bits of the prefix, after the prefix-length, are 347 ignored by this protocol. A malicious party could use them to 348 transmit covert data in a way that would not affect the primary use 349 of this encoding. Such abuse would be detected by examination of the 350 raw protocol bytes. Users of this encoding should be aware of this 351 possibility. 353 There are many ways in which the encodings may be invalid: wrong byte 354 lengths (too long, too short), or invalid prefix lengths (greater 355 than 32 for IPv4, greater than 128 for IPv6, negative values, etc.) 356 These are all invalid and this error needs to be signaled to the 357 application, and the entire content thrown away. 359 8. IANA Considerations 361 IANA has allocated two tags from the Specification Required area of 362 the Concise Binary Object Representation (CBOR) Tags 363 [IANA.cbor-tags]: 365 8.1. Tag 54 - IPv6 367 Data Item: byte string or array 368 Semantics: IPv6, [prefixlen,IPv6], [IPv6,prefixpart] 370 8.2. Tag 52 - IPv4 372 Data Item: byte string or array 373 Semantics: IPv4, [prefixlen,IPv4], [IPv4,prefixpart] 375 8.3. Tags 260 and 261 377 IANA is requested to add the note "DEPRECATED in favor of 52 and 54 378 for IP addresses" to registrations 260 and 261 380 9. References 382 9.1. Normative References 384 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 385 Requirement Levels", BCP 14, RFC 2119, 386 DOI 10.17487/RFC2119, March 1997, 387 . 389 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 390 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 391 May 2017, . 393 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 394 Definition Language (CDDL): A Notational Convention to 395 Express Concise Binary Object Representation (CBOR) and 396 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 397 June 2019, . 399 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 400 Representation (CBOR)", STD 94, RFC 8949, 401 DOI 10.17487/RFC8949, December 2020, 402 . 404 9.2. Informative References 406 [IANA.cbor-tags] 407 IANA, "Concise Binary Object Representation (CBOR) Tags", 408 . 410 [RFC3542] Stevens, W., Thomas, M., Nordmark, E., and T. Jinmei, 411 "Advanced Sockets Application Program Interface (API) for 412 IPv6", RFC 3542, DOI 10.17487/RFC3542, May 2003, 413 . 415 [RFC7042] Eastlake 3rd, D. and J. Abley, "IANA Considerations and 416 IETF Protocol and Documentation Usage for IEEE 802 417 Parameters", BCP 141, RFC 7042, DOI 10.17487/RFC7042, 418 October 2013, . 420 Appendix A. Changelog 422 This section is to be removed before publishing as an RFC. 424 * 03 426 * 02 428 * 01 added security considerations about covert channel 430 Acknowledgements 432 Roman Danyliw, Donald Eastlake, Ben Kaduk, Barry Leiba, and Eric 433 Vyncke reviewed the document and provided suggested text. 435 Authors' Addresses 437 Michael Richardson 438 Sandelman Software Works 440 Email: mcr+ietf@sandelman.ca 442 Carsten Bormann 443 Universität Bremen TZI 444 Germany 445 Email: cabo@tzi.org