summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-09-26 08:56:18 +0000
committertb <>2023-09-26 08:56:18 +0000
commit2dd2c41aa425d01ef11152f868e04e3f2823788a (patch)
tree7aa6038101d617a39b4c317f2593a621be8f2b7f /src
parent87f4e679b28a61c8b0d86b06035af80f721af97b (diff)
downloadopenbsd-2dd2c41aa425d01ef11152f868e04e3f2823788a.tar.gz
openbsd-2dd2c41aa425d01ef11152f868e04e3f2823788a.tar.bz2
openbsd-2dd2c41aa425d01ef11152f868e04e3f2823788a.zip
Document some barely usable parts of the ASIdentifiers API.
Someone clearly didn't actually use much of the code they wrote and exposed and therefore didn't think it through properly.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/ASIdentifiers_new.37
-rw-r--r--src/lib/libcrypto/man/ASRange_new.3186
-rw-r--r--src/lib/libcrypto/man/X509v3_asid_add_id_or_range.39
3 files changed, 184 insertions, 18 deletions
diff --git a/src/lib/libcrypto/man/ASIdentifiers_new.3 b/src/lib/libcrypto/man/ASIdentifiers_new.3
index f6ab5e5aaf..f95b258cae 100644
--- a/src/lib/libcrypto/man/ASIdentifiers_new.3
+++ b/src/lib/libcrypto/man/ASIdentifiers_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASIdentifiers_new.3,v 1.3 2023/09/25 11:59:10 tb Exp $ 1.\" $OpenBSD: ASIdentifiers_new.3,v 1.4 2023/09/26 08:56:18 tb Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2021 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 25 2023 $ 17.Dd $Mdocdate: September 26 2023 $
18.Dt ASIDENTIFIERS_NEW 3 18.Dt ASIDENTIFIERS_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -59,6 +59,9 @@ allocates and initializes a new, empty
59.Vt ASIdentifiers 59.Vt ASIdentifiers
60object that can be populated with 60object that can be populated with
61.Xr X509v3_asid_add_id_or_range 3 . 61.Xr X509v3_asid_add_id_or_range 3 .
62See
63.Xr ASRange_new 3
64for implementation details.
62.Pp 65.Pp
63.Fn ASIdentifiers_free 66.Fn ASIdentifiers_free
64frees 67frees
diff --git a/src/lib/libcrypto/man/ASRange_new.3 b/src/lib/libcrypto/man/ASRange_new.3
index 6aa33f2c79..48c3a403c5 100644
--- a/src/lib/libcrypto/man/ASRange_new.3
+++ b/src/lib/libcrypto/man/ASRange_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASRange_new.3,v 1.1 2023/09/25 11:59:10 tb Exp $ 1.\" $OpenBSD: ASRange_new.3,v 1.2 2023/09/26 08:56:18 tb Exp $
2.\" 2.\"
3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 25 2023 $ 17.Dd $Mdocdate: September 26 2023 $
18.Dt ASRANGE_NEW 3 18.Dt ASRANGE_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,7 +25,11 @@
25.Nm ASIdOrRange_new , 25.Nm ASIdOrRange_new ,
26.Nm ASIdOrRange_free , 26.Nm ASIdOrRange_free ,
27.Nm d2i_ASIdOrRange , 27.Nm d2i_ASIdOrRange ,
28.Nm i2d_ASIdOrRange 28.Nm i2d_ASIdOrRange ,
29.Nm ASIdentifierChoice_new ,
30.Nm ASIdentifierChoice_free ,
31.Nm d2i_ASIdentifierChoice ,
32.Nm i2d_ASIdentifierChoice
29.Nd Autonomous system identifiers and ranges 33.Nd Autonomous system identifiers and ranges
30.Sh SYNOPSIS 34.Sh SYNOPSIS
31.In openssl/x509v3.h 35.In openssl/x509v3.h
@@ -59,10 +63,26 @@
59.Fa "ASIdOrRange *aor" 63.Fa "ASIdOrRange *aor"
60.Fa "unsigned char **der_out" 64.Fa "unsigned char **der_out"
61.Fc 65.Fc
66.Ft "ASIdentifierChoice *"
67.Fn ASIdentifierChoice_new void
68.Ft void
69.Fn ASIdentifierChoice_free "ASIdentifierChoice *aic"
70.Ft ASIdentifierChoice *
71.Fo d2i_ASIdentifierChoice
72.Fa "ASIdentifierChoice **aic"
73.Fa "const unsigned char **der_in"
74.Fa "long length"
75.Fc
76.Ft int
77.Fo i2d_ASIdentifierChoice
78.Fa "ASIdentifierChoice *aic"
79.Fa "unsigned char **der_out"
80.Fc
62.Sh DESCRIPTION 81.Sh DESCRIPTION
63.Vt ASRange 82.Vt ASRange ,
83.Vt ASIdOrRange ,
64and 84and
65.Vt ASIdOrRange 85.Vt ASIdentifierChoice
66are building blocks of the RFC 3779 86are building blocks of the RFC 3779
67.Vt ASIdentifiers 87.Vt ASIdentifiers
68type representing the autonomous system identifier delegation extension. 88type representing the autonomous system identifier delegation extension.
@@ -167,15 +187,108 @@ is
167.Dv NULL , 187.Dv NULL ,
168no action occurs. 188no action occurs.
169.Pp 189.Pp
190In order to express a list of AS identifiers and ranges,
191RFC 3779 section 3.2.3.4
192uses an ASN.1 SEQUENCE,
193which is implemented via a
194.Xr STACK_OF 3
195construction over
196.Vt ASIdOrRange :
197.Bd -literal -offset indent
198typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
199.Ed
200.Pp
201Since an
202.Vt ASIdOrRanges
203object should be sorted in a specific way (see
204.Xr X509v3_asid_canonize 3 Ns ),
205a comparison function is needed for a correct instantiation
206with
207.Xr sk_new 3 .
208The
209.Fn ASIdOrRange_cmp
210function is not directly exposed and not easily accessible
211from outside the library,
212and it is non-trivial to implement.
213It is therefore discouraged to use
214.Vt ASIdOrRanges
215objects that are not part of an
216.Vt ASIdentifiers
217object.
218.Pp
219The
220.Dq inherit
221marker from RFC 3779 section 3.2.3.3 is implemented as
222.Vt ASN1_NULL .
223It has no dedicated type or API and can be instantiated with
224.Xr ASN1_NULL_new 3 .
225.Pp
226The
227.Vt ASIdentifierChoice
228type defined in RFC 3779 section 3.2.3.2 is implemented as
229.Bd -literal -offset indent
230typedef struct ASIdentifierChoice_st {
231 int type;
232 union {
233 ASN1_NULL *inherit;
234 ASIdOrRanges *asIdsOrRanges;
235 } u;
236} ASIdentifierChoice;
237.Ed
238.Pp
239where the
240.Fa type
241member should be set to
242.Dv ASIdentifierChoice_inherit
243or
244.Dv ASIdentifierChoice_asIdsOrRanges
245to indicate whether a given
246.Vt ASIdentifierChoice
247object represents an inherited list or an explicit list.
248.Pp
249.Fn ASIdentifierChoice_new
250returns a new
251.Vt ASIdentifierChoice
252object with invalid type and
253.Dv NULL
254members of the union
255.Fa u .
256.Pp
257.Fn ASIdentifierChoice_free
258frees
259.Fa aic
260including any data contained in it,
261provided
262.Fa type
263is set correctly.
264.Pp
265The
266.Vt ASIdentifiers
267type defined in RFC 3779 section 3.2.3.1 is implemented as
268.Bd -literal -offset indent
269typedef struct ASIdentifiers_st {
270 ASIdentifierChoice *asnum;
271 ASIdentifierChoice *rdi;
272} ASIdentifiers;
273.Ed
274.Pp
275It should be instantiated with
276.Xr ASIdentifiers_new 3
277and populated with
278.Xr X509v3_asid_add_id_or_range 3 .
279.Pp
170.Fn d2i_ASRange , 280.Fn d2i_ASRange ,
171.Fn i2d_ASRange , 281.Fn i2d_ASRange ,
172.Fn d2i_ASIdOrRange , 282.Fn d2i_ASIdOrRange ,
283.Fn i2d_ASIdOrRange ,
284.Fn d2i_ASIdentifierChoice ,
173and 285and
174.Fn i2d_ASIdOrRange 286.Fn i2d_ASIdentifierChoice
175decode and encode ASN.1 287decode and encode ASN.1
176.Vt ASRange 288.Vt ASRange ,
289.Vt ASIdOrRange ,
177and 290and
178.Vt ASIdOrRange 291.Vt ASIdentifierChoice
179objects. 292objects.
180For details about the semantics, examples, caveats, and bugs, see 293For details about the semantics, examples, caveats, and bugs, see
181.Xr ASN1_item_d2i 3 . 294.Xr ASN1_item_d2i 3 .
@@ -207,23 +320,34 @@ object or
207.Dv NULL 320.Dv NULL
208if an error occurs. 321if an error occurs.
209.Pp 322.Pp
323.Fn ASIdentifierChoice_new
324returns a new, empty
325.Vt ASIdentifierChoice
326object or
327.Dv NULL
328if an error occurs.
329.Pp
210The encoding functions 330The encoding functions
211.Fn d2i_ASRange 331.Fn d2i_ASRange ,
332.Fn d2i_ASIdOrRange ,
212and 333and
213.Fn d2i_ASIdOrRange 334.Fn d2i_ASIdentifierChoice
214return an 335return an
215.Vt ASRange 336.Vt ASRange ,
337an
338.Vt ASIdOrRange ,
216or an 339or an
217.Vt ASIdOrRange 340.Vt ASIdentifierChoice ,
218object, respectively, 341object, respectively,
219or 342or
220.Dv NULL 343.Dv NULL
221if an error occurs. 344if an error occurs.
222.Pp 345.Pp
223The encoding functions 346The encoding functions
224.Fn i2d_ASRange 347.Fn i2d_ASRange ,
348.Fn i2d_ASIdOrRange ,
225and 349and
226.Fn i2d_ASIdOrRange 350.Fn i2d_ASIdentifierChoice
227return the number of bytes successfully encoded 351return the number of bytes successfully encoded
228or a value <= 0 if an error occurs. 352or a value <= 0 if an error occurs.
229.Sh SEE ALSO 353.Sh SEE ALSO
@@ -241,6 +365,14 @@ RFC 3779: X.509 Extensions for IP Addresses and AS Identifiers:
241.It 365.It
242section 3.2.3: Syntax 366section 3.2.3: Syntax
243.It 367.It
368section 3.2.3.1: Type ASIdentifiers
369.It
370section 3.2.3.2: Elements asnum, rdi, and Type ASIdentifierChoice
371.It
372section 3.2.3.3: Element inherit
373.It
374section 3.2.3.4: Element asIdsOrRanges
375.It
244section 3.2.3.5: Type ASIdOrRange 376section 3.2.3.5: Type ASIdOrRange
245.It 377.It
246section 3.2.3.6: Element id 378section 3.2.3.6: Element id
@@ -255,3 +387,29 @@ section 3.2.3.9: Elements min and max
255These functions first appeared in OpenSSL 0.9.8e 387These functions first appeared in OpenSSL 0.9.8e
256and have been available since 388and have been available since
257.Ox 7.1 . 389.Ox 7.1 .
390.Sh BUGS
391An
392.Fn ASIdOrRanges_new
393function that installs the correct comparison function
394on the stack of
395.Vt ASIdOrRange
396should have been part of the API to make it usable.
397.Pp
398.Fn ASIdentifierChoice_new
399is of very limited use because
400.Fn ASIdOrRanges_new
401is missing.
402.Pp
403There is no way of ensuring that an
404.Vt ASIdOrRanges
405object is in canonical form unless it is part of an
406.Vt ASIdentifiers
407object.
408It is therefore difficult to guarantee that the output of
409.Fn i2d_ASIdentifierChoice
410is conformant.
411.Pp
412RFC 3779 3.2.3.4 has
413.Dq Fa asIdsOrRanges
414while its type in this implementation is
415.Vt ASIdOrRanges .
diff --git a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3 b/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
index cd25945865..272acc31e2 100644
--- a/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
+++ b/src/lib/libcrypto/man/X509v3_asid_add_id_or_range.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509v3_asid_add_id_or_range.3,v 1.2 2023/09/25 10:34:44 tb Exp $ 1.\" $OpenBSD: X509v3_asid_add_id_or_range.3,v 1.3 2023/09/26 08:56:18 tb Exp $
2.\" 2.\"
3.\" Copyright (c) 2021-2023 Theo Buehler <tb@openbsd.org> 3.\" Copyright (c) 2021-2023 Theo Buehler <tb@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: September 25 2023 $ 17.Dd $Mdocdate: September 26 2023 $
18.Dt X509V3_ASID_ADD_ID_OR_RANGE 3 18.Dt X509V3_ASID_ADD_ID_OR_RANGE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -51,6 +51,11 @@ An
51.Vt ASIdentifiers 51.Vt ASIdentifiers
52object represents the content of the X509v3 certificate extension 52object represents the content of the X509v3 certificate extension
53defined in RFC 3779, section 3.2.3.1. 53defined in RFC 3779, section 3.2.3.1.
54It can be instantiated with
55.Xr ASIdentifiers_new 3
56and its internals are documented in
57.Xr ASRange_new 3 .
58.Pp
54An autonomous system is identified by an unsigned 32-bit integer, 59An autonomous system is identified by an unsigned 32-bit integer,
55called an AS number. 60called an AS number.
56An 61An