draft-ietf-cbor-network-addresses-05.txt   draft-ietf-cbor-network-addresses-06.txt 
CBOR Working Group M. Richardson CBOR Working Group M. Richardson
Internet-Draft Sandelman Software Works Internet-Draft Sandelman Software Works
Intended status: Standards Track C. Bormann Intended status: Standards Track C. Bormann
Expires: 13 January 2022 Universit├Ąt Bremen TZI Expires: 26 January 2022 Universit├Ąt Bremen TZI
12 July 2021 25 July 2021
CBOR tags for IPv4 and IPv6 addresses and prefixes CBOR tags for IPv4 and IPv6 addresses and prefixes
draft-ietf-cbor-network-addresses-05 draft-ietf-cbor-network-addresses-06
Abstract Abstract
This document describes two CBOR Tags to be used with IPv4 and IPv6 This specification describes two CBOR Tags to be used with IPv4 and
addresses and prefixes. IPv6 addresses and prefixes.
RFC-EDITOR-please remove: This work is tracked at https://github.com/ // RFC-EDITOR-please-remove: This work is tracked at
cbor-wg/cbor-network-address // https://github.com/cbor-wg/cbor-network-address
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on 13 January 2022. This Internet-Draft will expire on 26 January 2022.
Copyright Notice Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/ Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text extracted from this document must include Simplified BSD License text
as described in Section 4.e of the Trust Legal Provisions and are as described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Simplified BSD License. provided without warranty as described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3
3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.1. IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1. Three Forms . . . . . . . . . . . . . . . . . . . . . . . 3
3.2. IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1.1. Addresses . . . . . . . . . . . . . . . . . . . . . . 3
4. Encoder Consideration for prefixes . . . . . . . . . . . . . 4 3.1.2. Prefixes . . . . . . . . . . . . . . . . . . . . . . 3
5. Decoder Considerations for prefixes . . . . . . . . . . . . . 5 3.1.3. Interface Definition . . . . . . . . . . . . . . . . 3
6. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2. IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 3
7. Security Considerations . . . . . . . . . . . . . . . . . . . 6 3.3. IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4. Encoder Considerations for Prefixes . . . . . . . . . . . . . 5
5. Decoder Considerations for Prefixes . . . . . . . . . . . . . 5
6. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
7. Security Considerations . . . . . . . . . . . . . . . . . . . 7
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 7
8.1. Tag 54 - IPv6 . . . . . . . . . . . . . . . . . . . . . . 7 8.1. Tag 54 - IPv6 . . . . . . . . . . . . . . . . . . . . . . 7
8.2. Tag 52 - IPv4 . . . . . . . . . . . . . . . . . . . . . . 7 8.2. Tag 52 - IPv4 . . . . . . . . . . . . . . . . . . . . . . 8
9. Normative References . . . . . . . . . . . . . . . . . . . . 7 9. Normative References . . . . . . . . . . . . . . . . . . . . 8
Appendix A. Changelog . . . . . . . . . . . . . . . . . . . . . 7 Appendix A. Changelog . . . . . . . . . . . . . . . . . . . . . 8
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 8 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 8
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 8 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 8
1. Introduction 1. Introduction
[RFC8949] defines a number of CBOR Tags for common items. [RFC8949] defines a number of CBOR Tags for common items. Tags 260
and 261 were later defined through IANA. These tags cover addresses
Tag 260 and tag 261 was later defined through IANA. These tags cover (260), and prefixes (261). Tag 260 distinguishes between IPv4, IPv6
addresses (260), and prefixes (261). Tag 260 distinguishes between and Ethernet through the length of the byte string only. Tag 261 was
IPv4, IPv6 and Ethernet through the length of the byte string only. not documented well enough to be used.
Tag 261 was not documented well enough to be used.
The present specification achieves an explicit indication of IPv4 or
IPv6, and the possibility to omit trailing zeroes.
This document provides a format for IPv6 and IPv4 addresses, This specification provides a format for IPv6 and IPv4 addresses,
prefixes, and addresses with prefixes. Prefixes MUST omit trailing prefixes, and addresses with prefixes, achieving an explicit
zeroes in the address. Due to the complexity of testing the value of indication of IPv4 or IPv6. Prefixes omit trailing zeroes in the
omitting trailing zeros for addresses was considered non-essential address. (Due to the complexity of testing, the value of omitting
and support for that was removed in this specification. trailing zeros for addresses was considered non-essential and support
for that was removed in this specification.)
This document does not deal with 6 or 8-byte Ethernet addressees. This specification does not deal with 6 or 8-byte Ethernet addresses.
2. Terminology 2. Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in "OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
3. Protocol 3. Protocol
These tags can applied to byte strings to represent a single address. 3.1. Three Forms
3.1.1. Addresses
These tags can be applied to byte strings to represent a single
address.
This form is called the Address Format.
3.1.2. Prefixes
When applied to an array that starts with a number, they represent a When applied to an array that starts with a number, they represent a
CIDR-style prefix of that length. When a byte string (without CIDR-style prefix of that length.
prefix) appears in a context where a prefix is expected, then it is
to be assumed that all bits are relevant. That is, for IPv4, a /32 When the Address Format (i.e., without prefix) appears in a context
is implied, and for IPv6, a /128 is implied. where a prefix is expected, then it is to be assumed that all bits
are relevant. That is, for IPv4, a /32 is implied, and for IPv6, a
/128 is implied.
This form is called the Prefix Format.
3.1.3. Interface Definition
When applied to an array that starts with a byte string, that stands When applied to an array that starts with a byte string, that stands
for an IP address, followed by the bit length of a prefix built out for an IP address, followed by the bit length of a prefix built out
of the first "length" bits of the address. of the first "length" bits of the address.
3.1. IPv6 This form is called the Interface Format.
3.2. IPv6
IANA has allocated tag 54 for IPv6 uses. (Note that this is the IANA has allocated tag 54 for IPv6 uses. (Note that this is the
ASCII code for '6'.) ASCII code for '6'.)
An IPv6 address is to be encoded as a sixteen-byte byte string An IPv6 address is to be encoded as a sixteen-byte byte string
(Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 54. (Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 54.
For example:
54(h'20010db81234DEEDBEEFCAFEFACEFEED')
An IPv6 prefix, such as 2001:db8:1234::/48 is to be encoded as a two An IPv6 prefix, such as 2001:db8:1234::/48 is to be encoded as a two
element array, with the length of the prefix first. Trailing zero element array, with the length of the prefix first. Trailing zero
bytes MUST be omitted. bytes MUST be omitted.
For example: For example:
54([ 48, h'20010db81234']) 54([48, h'20010db81234'])
An IPv6 address combined with a prefix length, such as being used for An IPv6 address combined with a prefix length, such as being used for
configuring an interface, is to be encoded as a two element array, configuring an interface, is to be encoded as a two element array,
with the (full-length) IPv6 address first and the length of the with the (full-length) IPv6 address first and the length of the
associated network the prefix next. associated network the prefix next.
For example: For example:
54([h'20010db81234DEEDBEEFCAFEFACEFEED', 56]) 54([h'20010db81234DEEDBEEFCAFEFACEFEED', 56])
Note that the address-with-prefix form can be reliably distinguished Note that the address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements. from the prefix form only in the sequence of the array elements.
3.2. IPv4 3.3. IPv4
IANA has allocated tag 52 for IPv4 uses. (Note that this is the IANA has allocated tag 52 for IPv4 uses. (Note that this is the
ASCII code for '4'.) ASCII code for '4'.)
An IPv4 address is to be encoded as a four-byte byte string An IPv4 address is to be encoded as a four-byte byte string
(Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 52. (Section 3.1 of [RFC8949], major type 2), enclosed in Tag number 52.
For example:
52(h'C0000201')
An IPv4 prefix, such as 192.0.2.0/24 is to be encoded as a two An IPv4 prefix, such as 192.0.2.0/24 is to be encoded as a two
element array, with the length of the prefix first. Trailing zero element array, with the length of the prefix first. Trailing zero
bytes MUST be omitted. bytes MUST be omitted.
For example: For example:
52([ 24, h'C00002']) 52([24, h'C00002'])
An IPv4 address combined with a prefix length, such as being used for An IPv4 address combined with a prefix length, such as being used for
configuring an interface, is to be encoded as a two element array, configuring an interface, is to be encoded as a two element array,
with the (full-length) IPv4 address first and the length of the with the (full-length) IPv4 address first and the length of the
associated network the prefix next. associated network the prefix next.
For example, 192.0.2.1/24 is to be encoded as a two element array, For example, 192.0.2.1/24 is to be encoded as a two element array,
with the length of the prefix (implied 192.0.2.0/24) last. with the length of the prefix (implied 192.0.2.0/24) last.
52([ h'C0000201', 24]) 52([h'C0000201', 24])
Note that the address-with-prefix form can be reliably distinguished Note that the address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements. from the prefix form only in the sequence of the array elements.
4. Encoder Consideration for prefixes 4. Encoder Considerations for Prefixes
An encoder may omit as many right-hand (trailing) bytes which are all For the byte strings used in representing prefixes, an encoder MUST
zero as it wishes. omit any right-aligned (trailing) sequence of bytes that are all
zero.
There is no relationship between the number of bytes omitted and the There is no relationship between the number of bytes omitted and the
prefix length. For instance, the prefix 2001:db8::/64 is optimally prefix length. For instance, the prefix 2001:db8::/64 is encoded as:
encoded as:
54([64, h'20010db8']) 54([64, h'20010db8'])
An encoder MUST take care to set all trailing bits to zero. While An encoder MUST take care to set all trailing bits in the final byte
decoders are expected to ignore them, such garbage entities could be to zero, if any. While decoders are expected to ignore them, such
used as a covert channel, or may reveal the state of what would garbage entities could be used as a covert channel, or may reveal the
otherewise be private memory contents. So for example, state of what would otherwise be private memory contents. So for
2001:db8:1230::/44 MUST be encoded as: example, "2001:db8:1230::/44" MUST be encoded as:
52([44, h'20010db81230']) 52([44, h'20010db81230'])
even though variations like: even though variations like:
54([44, h'20010db81233']) WRONG 54([44, h'20010db81233']) WRONG
54([45, h'20010db8123f']) WRONG 54([45, h'20010db8123f']) WRONG
would be parsed in the exact same way. would be parsed in the exact same way.
The same considerations apply to IPv4 prefixes. The same considerations apply to IPv4 prefixes.
5. Decoder Considerations for prefixes 5. Decoder Considerations for Prefixes
A decoder MUST consider all bits to the right of the prefix length to A decoder MUST consider all bits to the right of the prefix length to
be zero. be zero.
A decoder MUST handle the case where a prefix length specifies that A decoder MUST handle the case where a prefix length specifies that
more bits are relevant than are actually present in the byte-string. more bits are relevant than are actually present in the byte-string.
As a pathological case, ::/128 can be encoded as As a pathological case, ::/128 can be encoded as
54([128, h'']) 54([128, h''])
A recommendation for implementations is to first create an array of
16 (or 4) zero bytes.
A recommendation for implementation is to first create an array of 16 Then taking whichever is smaller between (a) the length of the
(or 4) bytes in size, set it all to zero. included byte-string, and (b) the number of bytes covered by the
prefix-length rounded up to the next multiple of 8: fail if that
number is greater than 16 (or 4), and then copy that many bytes from
the byte-string into the array.
Then looking at the length of the included byte-string, and of the Finally, looking at the last three bits of the prefix-length in bits
prefix-length, rounded up to the next multiple of 8, and taking (that is, the prefix-length modulo 8), use a static array of 8 values
whichever is smaller, copy that many bytes from the byte-string into to force the lower, non-relevant bits to zero, or simply:
the array.
Finally, looking at the last three bits of the prefix-length (that unused_bits = (-prefix_length_in_bits) & 7;
is, the prefix-length modulo 8), use a static array of 8 values to if (length_in_bytes > 0)
force the lower bits, non-relevant bits to zero. address_bytes[length_in_bytes - 1] &= (0xFF << unused_bits);
A particularly paranoid decoder could examine the lower non-relevant A particularly paranoid decoder could examine the lower non-relevant
bits to determine if they are non-zero, and reject the prefix. This bits to determine if they are non-zero, and reject the prefix. This
would detect non-compliant encoders, or a possible covert channel. would detect non-compliant encoders, or a possible covert channel.
if (length_in_bytes > 0 &&
(address_bytes[length_in_bytes - 1] & ~(0xFF << unused_bits))
!= 0)
fail();
6. CDDL 6. CDDL
For use with CDDL [RFC8610], the typenames defined in Figure 1 are For use with CDDL [RFC8610], the typenames defined in Figure 1 are
recommended: recommended:
ip-address-or-prefix = ipv6-address-or-prefix / ip-address-or-prefix = ipv6-address-or-prefix /
ipv4-address-or-prefix ipv4-address-or-prefix
ipv6-address-or-prefix = #6.54(ipv6-address / ipv6-address-or-prefix = #6.54(ipv6-address /
ipv6-address-with-prefix / ipv6-address-with-prefix /
skipping to change at page 6, line 36 skipping to change at page 7, line 36
ipv6-prefix-bytes = bytes .size (uint .le 16) ipv6-prefix-bytes = bytes .size (uint .le 16)
ipv4-prefix-bytes = bytes .size (uint .le 4) ipv4-prefix-bytes = bytes .size (uint .le 4)
Figure 1 Figure 1
7. Security Considerations 7. Security Considerations
Identifying which byte sequences in a protocol are addresses may Identifying which byte sequences in a protocol are addresses may
allow an attacker or eavesdropper to better understand what parts of allow an attacker or eavesdropper to better understand what parts of
a packet to attack. a packet to attack. That information, however, is likely to be found
in the relevant RFCs anyway, so this is not a significant exposure.
Reading the relevant RFC may provide more information, so it would
seem that any additional security that was provided by not being able
to identify what are IP addresses falls into the security by
obscurity category.
The right-hand bits of the prefix, after the prefix-length, are The right-hand bits of the prefix, after the prefix-length, are
ignored by this protocol. A malicious party could use them to ignored by this protocol. A malicious party could use them to
transmit covert data in a way that would not affect the primary use transmit covert data in a way that would not affect the primary use
of this encoding. Such abuse would be detected by examination of the of this encoding. Such abuse would be detected by examination of the
raw protocol bytes. Users of this encoding should be aware of this raw protocol bytes. Users of this encoding should be aware of this
possibility. possibility.
8. IANA Considerations 8. IANA Considerations
 End of changes. 33 change blocks. 
69 lines changed or deleted 102 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/