![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
IPAddressRange *
void
IPAddressRange *
int
IPAddressOrRange *
void
IPAddressOrRange *
int
IPAddressChoice *
void
IPAddressChoice *
int
IPAddressFamily *
void
IPAddressFamily *
int
DESCRIPTIONIPAddressRange, IPAddressOrRange, IPAddressChoice, and IPAddressFamily are building blocks of the IPAddrBlocks type representing the RFC 3779 IP address delegation extension. Per RFC 3779, section 2.1.1, an IPv4 or an IPv6 address is encoded in network byte order in an ASN.1 BIT STRING of bit size 32 or 128 bits, respectively. The bit size of a prefix is its prefix length; all insignificant zero bits are omitted from the encoding. Per section 2.1.2, an address range is expressed as a pair of BIT STRINGs where all the least significant zero bits of the lower bound and all the least significant one bits of the upper bound are omitted. The library provides no API for directly converting an IP address
or prefix (in any form) to and from an
ASN1_BIT_STRING. It also provides no API for directly
handling ranges. The ASN1_BIT_STRING internals are
subtle and directly manipulating them in the context of the RFC 3779 API is
discouraged. The bit size of an ASN1_BIT_STRING
representing an IP address prefix or range is eight times its
length member minus the lowest three bits of its
flags, provided the
The IPAddressRange type defined in RFC 3779 section 2.2.3.9 is implemented as typedef struct IPAddressRange_st { ASN1_BIT_STRING *min; ASN1_BIT_STRING *max; } IPAddressRange; It represents the closed range [min,max] of IP addresses between min and max, where min should be strictly smaller than max and the range should not be expressible as a prefix.
There is no dedicated type representing the IPAddress type defined in RFC 3779 section 2.2.3.8. The API uses ASN1_BIT_STRING for this. The IPAddressOrRange type defined in RFC 3779 section 2.2.3.7 is implemented as typedef struct IPAddressOrRange_st { int type; union { ASN1_BIT_STRING *addressPrefix; IPAddressRange *addressRange; } u; } IPAddressOrRange; representing an individual address prefix or an address range. The
type member should be set to
In order to express a list of address prefixes and address ranges, RFC 3779 section 2.2.3.6 uses an ASN.1 SEQUENCE, which is implemented via a STACK_OF(3) construction over IPAddressOrRange: typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; Since an
IPAddressOrRanges object should be sorted in a
specific way (see
X509v3_addr_canonize(3)),
a comparison function is needed for a correct instantiation with
sk_new(3).
The
The “inherit” marker from RFC 3779 section 2.2.3.5 is implemented as ASN1_NULL. It has no dedicated type or API and can be instantiated with ASN1_NULL_new(3). The IPAddressChoice type defined in RFC 3779 section 2.2.3.4 is implemented as typedef struct IPAddressChoice_st { int type; union { ASN1_NULL *inherit; IPAddressOrRanges *addressesOrRanges; } u; } IPAddressChoice; where the type member should be set to
The addressFamily element defined in RFC
3779 section 2.2.3.3 is implemented as an
ASN1_OCTET_STRING and it contains two or three octets.
The first two octets are always present and represent the address family
identifier (AFI) in network byte order. The optional subsequent address
family identifier (SAFI) occupies the third octet. For IPv4 and IPv6,
The IPAddressFamily type defined in RFC 3779 section 2.2.3.2 is implemented as typedef struct IPAddressFamily_st { ASN1_OCTET_STRING *addressFamily; IPAddressChoice *ipAddressChoice; } IPAddressFamily; The addressFamily member indicates the address family the ipAddressChoice represents.
The IPAddrBlocks type defined in RFC 3779 section 2.2.3.1 uses an ASN.1 SEQUENCE, which is implemented via a STACK_OF(3) construction over IPAddressFamily: typedef STACK_OF(IPAddressFamily) IPAddrBlocks; It can be instantiated with
RETURN VALUES
The decoding functions
The encoding functions
SEE ALSOASIdentifiers_new(3), ASN1_BIT_STRING_new(3), ASN1_OCTET_STRING_new(3), ASN1_OCTET_STRING_set(3), crypto(3), X509_new(3), X509v3_addr_add_inherit(3), X509v3_addr_inherits(3), X509v3_addr_subset(3) STANDARDSRFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER), section 8.6: Encoding of a bitstring value HISTORYThese functions first appeared in OpenSSL 0.9.8e and have been available since OpenBSD 7.1. BUGSAs it stands, the API is barely usable due to missing convenience accessors, constructors and destructors and due to the complete absence of API that checks that the individual building blocks are correct. Extracting information from a given object can be done relatively safely. However, constructing objects is very error prone, be it by hand or using the bug-ridden X509v3_addr_add_inherit(3) API. RFC 3779 has element “addressesOrRanges”. Its type in this API is IPAddressOrRanges.
|