Concise Binary Object Representation (CBOR) Tags for IPv4 and IPv6 Addresses and PrefixesSandelman Software Worksmcr+ietf@sandelman.caUniversität Bremen TZIGermanycabo@tzi.org
Internet
CBOR Working Groupbinary formatdata interchange formatinterface addresszone identifierThis specification defines two Concise Binary Object Representation (CBOR) tags for use with IPv6 and IPv4 addresses and prefixes.Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by
the Internet Engineering Steering Group (IESG). Further
information on Internet Standards is available in Section 2 of
RFC 7841.
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
.
Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
() in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with
respect to this document. Code Components extracted from this
document must include Revised BSD License text as described in
Section 4.e of the Trust Legal Provisions and are provided without
warranty as described in the Revised BSD License.
Table of Contents
. Introduction
. Terminology
. Protocol
. Three Forms
. Addresses
. Prefixes
. Interface Definition
. IPv6
. IPv4
. Tag Validity
. Deterministic Encoding
. Encoder Considerations for Prefixes
. Decoder Considerations for Prefixes
. Example Implementation
. CDDL
. Security Considerations
. IANA Considerations
. Tag 54 - IPv6
. Tag 52 - IPv4
. Tags 260 and 261
. References
. Normative References
. Informative References
Acknowledgements
Authors' Addresses
Introduction defines a number of CBOR tags for common items.
Tags 260 and 261 were later defined in documents listed with IANA .
These tags were intended to cover addresses (260) and prefixes (261).
Tag 260 distinguishes between IPv6, IPv4, and MAC addresses only through the length of the byte string, making it impossible, for example, to drop trailing zeros in the encoding of IP addresses. Tag 261 was not documented well enough for use.This specification defines tags 54 and 52 to explicitly
indicate use of IPv6 or IPv4 by the tag number.
These new tags are intended to be used in preference to tags 260 and
261.
They provide formats for IPv6 and IPv4 addresses, prefixes,
and addresses with prefixes, while explicitly indicating use of IPv6 or IPv4.
The prefix format omits trailing zeroes in the address part.
(Due to the complexity of testing, the value of omitting trailing
zeros for the pure address format was considered nonessential, and
support for that is not provided in this specification.)
This specification does not deal with MAC addresses ().TerminologyThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
"MAY", and "OPTIONAL" in this document are to be interpreted as
described in BCP 14 when, and only when, they
appear in all capitals, as shown here.ProtocolThree FormsAddressesThese tags can be applied to byte strings to represent a single address.This form is called the "Address Format".PrefixesWhen applied to an array that starts with an unsigned integer, the tags represent a
CIDR-style prefix of that length.When the Address Format (i.e., without 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 is implied, and for IPv6, a /128 is implied.This form is called the "Prefix Format".Interface DefinitionWhen applied to an array that starts with a byte string, which stands
for an IP address, followed by an unsigned integer giving the bit
length of a prefix built out of the first length bits of the
address, the tags represent information that is commonly used to specify
both the network prefix and the IP address of an interface.The length of the byte string is always 16 bytes (for IPv6) and 4 bytes (for IPv4).This form is called the "Interface Format".Interface Format definitions support an optional third element to the array, which is to be used as the IPv6 link-local zone identifier from ;
for symmetry, this is also provided for IPv4 as in and .
The zone identifier may be an integer, in which case it is to be interpreted as the interface index.
It may be a text string, in which case it is to be interpreted as an interface name.As explained in , the zone identifiers are strictly local to the node.
They are useful for communications within a node about connected addresses (for instance, where a link-local peer is discovered by one daemon and another daemon needs to be informed).
They may also have utility in some management protocols.In the cases where the Interface Format is being used to represent
only an address with a zone identifier and no interface prefix information, the prefix length may be replaced with the CBOR "null" (0xF6).IPv6IANA has allocated tag 54 for IPv6 uses.
(This is the ASCII code for '6'.)An IPv6 address is to be encoded as a sixteen-byte byte string
(, 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-element array, with the length of the prefix first.
See for the detailed construction of the second element.For example:
54([48, h'20010db81234'])
An IPv6 address combined with a prefix length, such as one used for
configuring an interface, is to be encoded as a two-element array,
with the (full-length) IPv6 address first and the length of the
associated network the prefix next; a third element can be added for
the zone identifier.For example:
54([h'20010db81234deedbeefcafefacefeed', 56])
The address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements.An example of a link-local IPv6 address with a 64-bit prefix:
54([h'fe8000000000020202fffffffe030303', 64, 'eth0'])
with a numeric zone identifier:
54([h'fe8000000000020202fffffffe030303', 64, 42])
An IPv6 link-local address without a prefix length:
54([h'fe8000000000020202fffffffe030303', null, 42])
Zone identifiers may be used with any kind of IP address, not just link-local addresses.
In particular, they are valid for multicast addresses, and there may still be some significance
for Globally Unique Addresses (GUAs).IPv4IANA has allocated tag 52 for IPv4 uses.
(This is the ASCII code for '4'.)An IPv4 address is to be encoded as a four-byte byte string
(, 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-element array, with the length of the prefix first.
See for the detailed construction of the second element.For example:
52([24, h'c00002'])
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,
with the (full-length) IPv4 address first and the length of the
associated network the prefix next; a third element can be added for
the zone identifier.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.
52([h'c0000201', 24])
The address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements.Tag ValidityThis section discusses when tag 54 or tag 52 is valid ().
As with all CBOR tags, validity checking can be handled in a generic
CBOR library or in the application.
A generic CBOR library needs to document whether and how it handles
validity checking.The rule ip-address-or-prefix in shows how to check the
overall structure of these tags and their content, the ranges of
integer values, and the lengths of byte strings.
An instance of tag 52 or 54 is valid if it matches that rule and, for
ipv6-prefix and ipv4-prefix, the considerations of Sections
and .Deterministic EncodingThe tag validity rules, combined with the rules in , lead to deterministic encoding for tags 54 and 52 and require
no further additional deterministic encoding considerations as per
.Encoder Considerations for PrefixesFor the byte strings used as the second element in the array
representing a prefix:(1) An encoder MUST set any unused bytes and any unused bits in the
final byte, if any, to zero.
Unused bytes (or bits) are bytes (or bits) that are not covered by the prefix length given.
So, for example, 2001:db8:1230::/44MUST be encoded as:
54([44, h'20010db81230'])
even though variations like:
54([44, h'20010db81233'])
54([44, h'20010db8123f'])
54([44, h'20010db8123012'])
start with the same 44 bits but are not valid.(Analogous examples can be constructed for IPv4 prefixes.)(2) An encoder MUST then omit any right-aligned (trailing) sequence of
bytes in which the bytes are all zeros.There is no relationship between the number of bytes omitted and the prefix length.
For instance, the prefix 2001:db8::/64 is encoded as:
54([64, h'20010db8'])
Decoder Considerations for PrefixesA decoder MUST check that all unused bits encoded in the byte string
ipv6-prefix-bytes/ipv4-prefix-bytes, i.e., the bits to the right of
the prefix length, are zero.A decoder MUST also check that the byte string does not end in a zero
byte.Since encoders are required to remove zero-valued trailing bytes, a
decoder MUST handle cases where a prefix length specifies that more
bits are relevant than are actually present in the byte string.As an example, ::/128 is encoded as
54([128, h''])
Example ImplementationA recommendation for prefix decoder implementations is to first create
an array of 16 (or 4) zero bytes.Then, taking whichever is smaller between (a) the length of the
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 byte array.Finally, when looking at the number of unused bits in the last byte (if
any) of the range covered by the prefix length, check that any unused
bits in the byte string are zero:
unused_bits = (8 - (prefix_length_in_bits % 8)) % 8;
if (length_in_bytes > 0 &&
(address_bytes[length_in_bytes - 1] & ~(0xFF << unused_bits))
!= 0)
fail();
CDDLFor use with Concise Data Definition Language (CDDL) , the type names defined in
are recommended:Security ConsiderationsThis document provides a CBOR encoding for IPv4 and IPv6 address information.
Any applications using these encodings will need to consider the security
implications of this data in their specific context. For example, identifying
which byte sequences in a protocol are addresses may allow an attacker or
eavesdropper to better understand what parts of a packet to attack.Applications need to check the validity () of a tag before
acting on any of its contents.
If the validity checking is not done in the generic CBOR decoder, it
needs to be done in the application; in any case, it needs to be done
before the tag is transformed into a platform-specific representation
that could conceal validity errors.The right-hand bits of the prefix, after the prefix length, are set to
zero by this protocol.
(Otherwise, a malicious party could use them to transmit covert data
in a way that would not affect the primary use of this encoding.
Such abuse is detected by tag validity checking and can also be
detected by examination of the raw protocol bytes.)IANA ConsiderationsIANA has allocated two tags from the Specification Required area of
the "Concise Binary Object Representation (CBOR) Tags" registry :Tag 54 - IPv6
Data Item:
byte string or array
Semantics:
IPv6, [prefixlen,IPv6], [IPv6,prefixpart]
Tag 52 - IPv4
Data Item:
byte string or array
Semantics:
IPv4, [prefixlen,IPv4], [IPv4,prefixpart]
Tags 260 and 261IANA has added the note "DEPRECATED in favor of 52 and 54 for IP addresses" to registrations 260 and 261.ReferencesNormative ReferencesKey words for use in RFCs to Indicate Requirement LevelsIn many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.Guidelines for Writing an IANA Considerations Section in RFCsMany protocols make use of points of extensibility that use constants to identify various protocol parameters. To ensure that the values in these fields do not have conflicting uses and to promote interoperability, their allocations are often coordinated by a central record keeper. For IETF protocols, that role is filled by the Internet Assigned Numbers Authority (IANA).To make assignments in a given registry prudently, guidance describing the conditions under which new values should be assigned, as well as when and how modifications to existing values can be made, is needed. This document defines a framework for the documentation of these guidelines by specification authors, in order to assure that the provided guidance for the IANA Considerations is clear and addresses the various issues that are likely in the operation of a registry.This is the third edition of this document; it obsoletes RFC 5226.Ambiguity of Uppercase vs Lowercase in RFC 2119 Key WordsRFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data StructuresThis document proposes a notational convention to express Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.Concise Binary Object Representation (CBOR)The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.This document obsoletes RFC 7049, providing editorial improvements, new details, and errata fixes while keeping full compatibility with the interchange format of RFC 7049. It does not create a new version of the format.Informative ReferencesConcise Binary Object Representation (CBOR) TagsIANATextual Conventions for Internet Network AddressesThis MIB module defines textual conventions to represent commonly used Internet network layer addressing information. The intent is that these textual conventions will be imported and used in MIB modules that would otherwise define their own representations. [STANDARDS-TRACK]IPv6 Scoped Address ArchitectureThis document specifies the architectural characteristics, expected behavior, textual representation, and usage of IPv6 addresses of different scopes. According to a decision in the IPv6 working group, this document intentionally avoids the syntax and usage of unicast site-local addresses. [STANDARDS-TRACK]Common YANG Data TypesThis document introduces a collection of common data types to be used with the YANG data modeling language. This document obsoletes RFC 6021.IANA Considerations and IETF Protocol and Documentation Usage for IEEE 802 ParametersSome IETF protocols make use of Ethernet frame formats and IEEE 802 parameters. This document discusses several uses of such parameters in IETF protocols, specifies IANA considerations for assignment of points under the IANA OUI (Organizationally Unique Identifier), and provides some values for use in documentation. This document obsoletes RFC 5342.Acknowledgements, , , , and reviewed the document and provided suggested text.
helped find the history of IPv4 zone identifiers.Authors' AddressesSandelman Software Worksmcr+ietf@sandelman.caUniversität Bremen TZIGermanycabo@tzi.org