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