draft-ietf-cbor-network-addresses-02.txt   draft-ietf-cbor-network-addresses-03.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 9 March 2021 Intended status: Standards Track 25 March 2021
Expires: 10 September 2021 Expires: 26 September 2021
CBOR tags for IPv4 and IPv6 addresses and prefixes CBOR tags for IPv4 and IPv6 addresses and prefixes
draft-ietf-cbor-network-addresses-02 draft-ietf-cbor-network-addresses-03
Abstract Abstract
This document describes two CBOR Tags to be used with IPv4 and IPv6 This document describes two CBOR Tags to be used with IPv4 and IPv6
addresses and prefixes. addresses and prefixes.
RFC-EDITOR-please remove: This work is tracked at RFC-EDITOR-please remove: This work is tracked at
https://github.com/mcr/cbor-network-address.git https://github.com/mcr/cbor-network-address.git
Status of This Memo Status of This Memo
skipping to change at page 1, line 34 skipping to change at page 1, line 34
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 10 September 2021. This Internet-Draft will expire on 26 September 2021.
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
skipping to change at page 2, line 14 skipping to change at page 2, line 14
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3. Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.1. IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3.1. IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2. IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.2. IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4. Encoder Consideration for prefixes . . . . . . . . . . . . . 3 4. Encoder Consideration for prefixes . . . . . . . . . . . . . 3
5. Decoder Considerations for prefixes . . . . . . . . . . . . . 4 5. Decoder Considerations for prefixes . . . . . . . . . . . . . 4
6. Security Considerations . . . . . . . . . . . . . . . . . . . 5 6. Security Considerations . . . . . . . . . . . . . . . . . . . 4
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 5 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 5
7.1. TBD1 - IPv6 . . . . . . . . . . . . . . . . . . . . . . . 5 7.1. Tag 54 - IPv6 . . . . . . . . . . . . . . . . . . . . . . 5
7.2. TBD2 - IPv4 . . . . . . . . . . . . . . . . . . . . . . . 5 7.2. Tag 52 - IPv4 . . . . . . . . . . . . . . . . . . . . . . 5
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 5 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 5
9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 5
10. Normative References . . . . . . . . . . . . . . . . . . . . 5 10. Normative References . . . . . . . . . . . . . . . . . . . . 5
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6
1. Introduction 1. Introduction
[RFC8949] defines a number of CBOR Tags for common items. [RFC8949] defines a number of CBOR Tags for common items.
Not included are ones to indicate if the item is an IPv4 or IPv6 Not included are ones to indicate if the item is an IPv4 or IPv6
skipping to change at page 2, line 50 skipping to change at page 2, line 50
These tags can applied to byte strings to represent a single address. These tags can applied to byte strings to represent a single address.
When applied to an array, the represent a CIDR-style prefix. When a When applied to an array, the represent a CIDR-style prefix. When a
byte string (without prefix) appears in a context where a prefix is byte string (without prefix) appears in a context where a prefix is
expected, then it is to be assumed that all bits are relevant. That 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. is, for IPv4, a /32 is implied, and for IPv6, a /128 is implied.
3.1. IPv6 3.1. IPv6
IANA has allocated tag TBD1 for IPv6 uses. IANA has allocated tag 54 for IPv6 uses. (Note that this is the
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
([RFC8949] section, 3.1, major type 2), prefixed with tag TBD1. ([RFC8949] section, 3.1, major type 2), prefixed with Tag(54).
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
octets MUST be omitted. octets MUST be omitted.
For example: For example:
TBD1([ 48, h'20010db81234']) 54([ 48, h'20010db81234'])
3.2. IPv4 3.2. IPv4
IANA has allocated tag TBD2 for IPv4 uses. IANA has allocated tag 54 for IPv4 uses. (Note that this is the
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
([RFC8949] section, 3.1, major type 2), prefixed with tag TBD2. ([RFC8949] section, 3.1, major type 2), prefixed with Tag(52).
An IPv4 prefix, such as 192.0.2.1/24 is to be encoded as a two An IPv4 prefix, such as 192.0.2.1/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
octets MUST be omitted. octets MUST be omitted.
For example: For example:
TBD2([ 24, h'C00002']) 52([ 24, h'C00002'])
4. Encoder Consideration for prefixes 4. Encoder Consideration for prefixes
An encoder may omit as many right-hand (trailing) bytes which are all An encoder may omit as many right-hand (trailing) bytes which are all
zero as it wishes. zero as it wishes.
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 optimally
encoded as: encoded as:
TBD1([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 to zero. While
decoders are expected to ignore them, such garbage entities could be decoders are expected to ignore them, such garbage entities could be
used as a covert channel, or may reveal the state of what would used as a covert channel, or may reveal the state of what would
otherewise be private memory contents. So for example, otherewise be private memory contents. So for example,
2001:db8:1230::/44 MUST be encoded as: 2001:db8:1230::/44 MUST be encoded as:
TBD1([44, h'20010db81230']) 52([44, h'20010db81230'])
even though variations like: even though variations like:
TBD1([44, h'20010db81233']) WRONG 54([44, h'20010db81233']) WRONG
TBD1([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
TBD1([0, h'']) 54([128, h''])
(EDNOTE: do we want to support:
[0]
or
[0, null]
(EDNOTE: what if the array has more than 2 members? Is this a
convert channel, or is this a possible extension point?)
A recommendation for implementation is to first create an array of 16 A recommendation for implementation is to first create an array of 16
(or 4) bytes in size, set it all to zero. (or 4) bytes in size, set it all to zero.
Then looking at the length of the included byte-string, and of the Then looking at the length of the included byte-string, and of the
prefix-length, rounded up to the next multiple of 8, and taking prefix-length, rounded up to the next multiple of 8, and taking
whichever is smaller, copy that many bytes from the byte-string into whichever is smaller, copy that many bytes from the byte-string into
the array. the array.
Finally, looking at the last three bits of the prefix-length (that Finally, looking at the last three bits of the prefix-length (that
skipping to change at page 5, line 29 skipping to change at page 5, line 14
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.
7. IANA Considerations 7. IANA Considerations
IANA is asked to allocate two tags from the Specification Required IANA is asked to allocate two tags from the Specification Required
area of the Concise Binary Object Representation (CBOR) Tags, in the area of the Concise Binary Object Representation (CBOR) Tags, in the
("1+1") area. ("1+1") area.
7.1. TBD1 - IPv6 7.1. Tag 54 - IPv6
Data Item: byte string and array Data Item: byte string and array
Semantics: IPv6 or [prefixlen,IPv6] Semantics: IPv6 or [prefixlen,IPv6]
7.2. TBD2 - IPv4 7.2. Tag 52 - IPv4
Data Item: byte string and array Data Item: byte string and array
Semantics: IPv4 or [prefixlen,IPv4] Semantics: IPv4 or [prefixlen,IPv4]
8. Acknowledgements 8. Acknowledgements
none yet none yet
9. Changelog 9. Changelog
 End of changes. 17 change blocks. 
32 lines changed or deleted 22 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/