1.\" $OpenBSD: X509v3_addr_subset.3,v 1.2 2023/09/30 14:24:00 schwarze Exp $
2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 30 2023 $
18.Dt X509V3_ADDR_SUBSET 3
19.Os
20.Sh NAME
21.Nm X509v3_addr_subset ,
22.Nm X509v3_asid_subset
23.Nd RFC 3779 subset relationship
24.Sh SYNOPSIS
25.In openssl/x509v3.h
26.Ft int
27.Fn X509v3_addr_subset "IPAddrBlocks *child" "IPAddrBlocks *parent"
28.Ft int
29.Fn X509v3_asid_subset "ASIdentifiers *child" "ASIdentifiers *parent"
30.Sh DESCRIPTION
31.Fn X509v3_addr_subset
32determines if all IP address resources present in
33.Fa child
34are contained in the corresponding resources in
35.Fa parent .
36.Pp
37The implementation assumes but does not ensure that both
38.Fa child
39and
40.Fa parent
41are in canonical form as described in
42.Xr X509v3_addr_is_canonical 3 .
43In particular, both
44.Fa child
45and
46.Fa parent
47are sorted appropriately and they contain at most one
48.Vt IPAddressFamily
49object per address family identifier (AFI) and optional
50subsequent address family identifier (SAFI).
51.Pp
52The checks are, in order:
53.Bl -enum
54.It
55If
56.Fa child
57is
58.Dv NULL
59or identical to
60.Fa parent
61then
62.Fa child
63is a subset of
64.Fa parent .
65In particular, a
66.Dv NULL
67.Fa parent
68is allowed for a
69.Dv NULL
70.Fa child .
71.It
72If
73.Fa parent
74is
75.Dv NULL
76then
77.Fa child
78is not a subset of
79.Fa parent .
80.It
81If
82.Xr X509v3_addr_inherits 3
83determines that
84.Fa child
85inherits or that
86.Fa parent
87inherits
88then
89.Fa child
90is not a subset of
91.Fa parent .
92.It
93Each address prefix or range in
94.Fa child
95must be a subset of an address prefix or range in the
96.Fa parent ,
97taking AFI and optional SAFI into account:
98.Bl -bullet -compact
99.It
100For each
101.Vt IPAddressFamily
102of
103.Fa child
104there must be an
105.Vt IPAddressFamily
106of
107.Fa parent
108with the same AFI and optional SAFI.
109.It
110Since the address prefixes and ranges in corresponding
111.Vt IPAddressFamily
112objects in
113.Fa child
114and
115.Fa parent
116are sorted in ascending order,
117and do not overlap,
118they can be traversed simultaneously in linear time.
119For each prefix or range in
120.Fa child
121there must be a prefix or range in
122.Fa parent
123whose minimal address is smaller
124and whose maximal address is larger.
125.El
126If any of these steps fails,
127.Fa child
128is not a subset of
129.Fa parent .
130.El
131.Pp
132.Fn X509v3_asid_subset
133determines if all AS identifier resources in
134.Fa child
135are contained in the corresponding resources in
136.Fa parent .
137.Pp
138The description for
139.Fn X509v3_addr_subset
140applies mutatis mutandis.
141In particular,
142.Fa child
143and
144.Fa parent
145must be in canonical form per
146.Xr X509v3_asid_is_canonical 3 ,
147but this is not enforced.
148.Sh RETURN VALUES
149.Fn X509v3_addr_subset
150and
151.Fn X509v3_asid_subset
152return 1 if and only if
153.Fa child
154is a subset of
155.Fa parent ,
156otherwise they return 0.
157If both
158.Fa child
159and
160.Fa parent
161are in canonical form,
162these functions cannot fail.
163.Sh SEE ALSO
164.Xr ASIdentifiers_new 3 ,
165.Xr ASRange_new 3 ,
166.Xr crypto 3 ,
167.Xr IPAddressRange_new 3 ,
168.Xr X509_new 3 ,
169.Xr X509v3_addr_add_inherit 3 ,
170.Xr X509v3_asid_add_inherit 3
171.Sh STANDARDS
172RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers.
173.Sh HISTORY
174These functions first appeared in OpenSSL 0.9.8e
175and have been available since
176.Ox 7.1 .
177