summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-12-15 22:20:12 +0000
committerschwarze <>2021-12-15 22:20:12 +0000
commit93f72c22f0cebe4b6a760100c045c6f1eeb9f893 (patch)
treea1e45b4d20b20fdd68dcd45a1a0e79c5c23b6127
parent1959f03a0a5b06e7800a2876638580fa1f2a8713 (diff)
downloadopenbsd-93f72c22f0cebe4b6a760100c045c6f1eeb9f893.tar.gz
openbsd-93f72c22f0cebe4b6a760100c045c6f1eeb9f893.tar.bz2
openbsd-93f72c22f0cebe4b6a760100c045c6f1eeb9f893.zip
document OBJ_new_nid(3), OBJ_add_object(3), and OBJ_create_objects(3);
mark OBJ_create_and_add_object() as intentionally undocumented
-rw-r--r--src/lib/libcrypto/man/OBJ_create.3100
1 files changed, 91 insertions, 9 deletions
diff --git a/src/lib/libcrypto/man/OBJ_create.3 b/src/lib/libcrypto/man/OBJ_create.3
index 37a3907193..e79ef90853 100644
--- a/src/lib/libcrypto/man/OBJ_create.3
+++ b/src/lib/libcrypto/man/OBJ_create.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_create.3,v 1.1 2021/12/15 20:07:51 schwarze Exp $ 1.\" $OpenBSD: OBJ_create.3,v 1.2 2021/12/15 22:20:12 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400 3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400
4.\" selective merge up to: 4.\" selective merge up to:
@@ -73,33 +73,77 @@
73.Dt OBJ_CREATE 3 73.Dt OBJ_CREATE 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
76.Nm OBJ_new_nid ,
77.Nm OBJ_add_object ,
76.Nm OBJ_create , 78.Nm OBJ_create ,
79.\" OBJ_create_and_add_object is a deprecated, unused alias for OBJ_create(3).
80.Nm OBJ_create_objects ,
77.Nm OBJ_cleanup 81.Nm OBJ_cleanup
78.Nd modify the table of ASN.1 object identifiers 82.Nd modify the table of ASN.1 object identifiers
79.Sh SYNOPSIS 83.Sh SYNOPSIS
80.In openssl/objects.h 84.In openssl/objects.h
81.Ft int 85.Ft int
86.Fn OBJ_new_nid "int increment"
87.Ft int
88.Fn OBJ_add_object "const ASN1_OBJECT *object"
89.Ft int
82.Fo OBJ_create 90.Fo OBJ_create
83.Fa "const char *oid" 91.Fa "const char *oid"
84.Fa "const char *sn" 92.Fa "const char *sn"
85.Fa "const char *ln" 93.Fa "const char *ln"
86.Fc 94.Fc
95.Ft int
96.Fn OBJ_create_objects "BIO *in_bio"
87.Ft void 97.Ft void
88.Fn OBJ_cleanup void 98.Fn OBJ_cleanup void
89.Sh DESCRIPTION 99.Sh DESCRIPTION
100.Fn OBJ_new_nid
101returns the smallest currently unassigned ASN.1 numeric
102object identifier (NID) and reserves
103.Fa increment
104consecutive NIDs starting with it.
105Passing an argument of 1 is usually recommended.
106The return value can be assigned to a new object by passing it as the
107.Fa nid
108argument to
109.Xr ASN1_OBJECT_create 3
110and by passing the resulting object to
111.Fn OBJ_add_object .
112.Pp
113.Fn OBJ_add_object
114adds a copy of the
115.Fa object
116to the internal table of ASN.1 object identifiers for use by
117.Xr OBJ_nid2obj 3
118and related functions.
119.Pp
90.Fn OBJ_create 120.Fn OBJ_create
91adds a new object to the internal table. 121provides a simpler way to add a new object to the internal table.
92.Fa oid 122.Fa oid
93is the numerical form of the object, 123is the numerical form of the object,
94.Fa sn 124.Fa sn
95the short name and 125the short name and
96.Fa ln 126.Fa ln
97the long name. 127the long name.
98A new NID is returned for the created object. 128A new NID is automatically assigned using
129.Fn OBJ_new_nid .
130.Pp
131.Fn OBJ_create_objects
132reads text lines of the form
133.Pp
134.D1 Fa oid sn ln
135.Pp
136from
137.Fa in_bio
138and calls
139.Fn OBJ_create oid sn ln
140for every line read.
141The three fields of the input lines
142are separated by one or more whitespace characters.
99.Pp 143.Pp
100The new object added to the internal table and all the data 144For all three functions, the objects added to the internal table and
101contained in it is marked as not dynamically allocated. 145all the data contained in them is marked as not dynamically allocated.
102Consequently, retrieving it with 146Consequently, retrieving them with
103.Xr OBJ_nid2obj 3 147.Xr OBJ_nid2obj 3
104or a similar function and then calling 148or a similar function and then calling
105.Xr ASN1_OBJECT_free 3 149.Xr ASN1_OBJECT_free 3
@@ -108,23 +152,45 @@ on the returned pointer will have no effect.
108.Fn OBJ_cleanup 152.Fn OBJ_cleanup
109cleans up the internal object table: this should be called before 153cleans up the internal object table: this should be called before
110an application exits if any new objects were added using 154an application exits if any new objects were added using
111.Fn OBJ_create . 155.Fn OBJ_add_object ,
156.Fn OBJ_create ,
157or
158.Fn OBJ_create_objects .
112.Sh RETURN VALUES 159.Sh RETURN VALUES
160.Fn OBJ_new_nid
161returns the new NID.
162.Pp
163.Fn OBJ_add_object
164returns the NID associated with the
165.Fa object
166or
167.Dv NID_undef
168if memory allocation fails.
169.Pp
113.Fn OBJ_create 170.Fn OBJ_create
114returns the new NID or 171returns the new NID or
115.Dv NID_undef 172.Dv NID_undef
116if an error occurs. 173if
174.Fa oid
175is not a valid representation of an object identfier
176or if memory allocation fails.
177.Pp
178.Fn OBJ_create_objects
179returns the number of objects added.
117.Pp 180.Pp
118In some cases of failure of 181In some cases of failure of
182.Fn OBJ_add_object ,
119.Fn OBJ_create , 183.Fn OBJ_create ,
184and
185.Fn OBJ_create_objects ,
120the reason can be determined with 186the reason can be determined with
121.Xr ERR_get_error 3 . 187.Xr ERR_get_error 3 .
122.Sh EXAMPLES 188.Sh EXAMPLES
123Create a new NID and initialize an object from it: 189Create a new NID and initialize an object from it:
124.Bd -literal -offset indent 190.Bd -literal -offset indent
125int new_nid; 191int new_nid;
126
127ASN1_OBJECT *obj; 192ASN1_OBJECT *obj;
193
128new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier"); 194new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
129obj = OBJ_nid2obj(new_nid); 195obj = OBJ_nid2obj(new_nid);
130.Ed 196.Ed
@@ -132,9 +198,25 @@ obj = OBJ_nid2obj(new_nid);
132.Xr ASN1_OBJECT_new 3 , 198.Xr ASN1_OBJECT_new 3 ,
133.Xr OBJ_nid2obj 3 199.Xr OBJ_nid2obj 3
134.Sh HISTORY 200.Sh HISTORY
201.Fn OBJ_new_nid ,
202.Fn OBJ_add_object ,
203and
135.Fn OBJ_cleanup 204.Fn OBJ_cleanup
136first appeared in SSLeay 0.8.0 and 205first appeared in SSLeay 0.8.0 and
137.Fn OBJ_create 206.Fn OBJ_create
138in SSLeay 0.9.0. 207in SSLeay 0.9.0.
139These functions have been available since 208These functions have been available since
140.Ox 2.4 . 209.Ox 2.4 .
210.Sh BUGS
211.Fn OBJ_new_nid
212does not reserve any return value to indicate an error.
213Consequently, to avoid conflicting NID assignments and integer overflows,
214care must be taken to not pass negative, zero, or large arguments to
215.Fn OBJ_new_nid .
216.Pp
217.Fn OBJ_create_objects
218does not distinguish between end of file, I/O errors, temporary
219unavailability of data on a non-blocking BIO, invalid input syntax,
220and memory allocation failure.
221In all these cases, reading is aborted and the number of objects
222that were already added is returned.