summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/OBJ_nid2obj.3
diff options
context:
space:
mode:
authorschwarze <>2016-11-03 10:24:26 +0000
committerschwarze <>2016-11-03 10:24:26 +0000
commit99421a4d33ceb28652f51f4a28160d96485e712e (patch)
tree155e30b5ca7dd36c2675796fc6962aeadace902e /src/lib/libcrypto/man/OBJ_nid2obj.3
parentc8f23a73c54fa03e5487282a15314fd81bdcef57 (diff)
downloadopenbsd-99421a4d33ceb28652f51f4a28160d96485e712e.tar.gz
openbsd-99421a4d33ceb28652f51f4a28160d96485e712e.tar.bz2
openbsd-99421a4d33ceb28652f51f4a28160d96485e712e.zip
convert remaining ASN1 object manuals from pod to mdoc
Diffstat (limited to 'src/lib/libcrypto/man/OBJ_nid2obj.3')
-rw-r--r--src/lib/libcrypto/man/OBJ_nid2obj.3267
1 files changed, 267 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/OBJ_nid2obj.3 b/src/lib/libcrypto/man/OBJ_nid2obj.3
new file mode 100644
index 0000000000..5634d8ea4a
--- /dev/null
+++ b/src/lib/libcrypto/man/OBJ_nid2obj.3
@@ -0,0 +1,267 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt OBJ_NID2OBJ 3
3.Os
4.Sh NAME
5.Nm OBJ_nid2obj ,
6.Nm OBJ_nid2ln ,
7.Nm OBJ_nid2sn ,
8.Nm OBJ_obj2nid ,
9.Nm OBJ_txt2nid ,
10.Nm OBJ_ln2nid ,
11.Nm OBJ_sn2nid ,
12.Nm OBJ_cmp ,
13.Nm OBJ_dup ,
14.Nm OBJ_txt2obj ,
15.Nm OBJ_obj2txt ,
16.Nm OBJ_create ,
17.Nm OBJ_cleanup
18.Nd ASN1 object utility functions
19.Sh SYNOPSIS
20.In openssl/objects.h
21.Ft ASN1_OBJECT *
22.Fo OBJ_nid2obj
23.Fa "int n"
24.Fc
25.Ft const char *
26.Fo OBJ_nid2ln
27.Fa "int n"
28.Fc
29.Ft const char *
30.Fo OBJ_nid2sn
31.Fa "int n"
32.Fc
33.Ft int
34.Fo OBJ_obj2nid
35.Fa "const ASN1_OBJECT *o"
36.Fc
37.Ft int
38.Fo OBJ_ln2nid
39.Fa "const char *ln"
40.Fc
41.Ft int
42.Fo OBJ_sn2nid
43.Fa "const char *sn"
44.Fc
45.Ft int
46.Fo OBJ_txt2nid
47.Fa "const char *s"
48.Fc
49.Ft ASN1_OBJECT *
50.Fo OBJ_txt2obj
51.Fa "const char *s"
52.Fa "int no_name"
53.Fc
54.Ft int
55.Fo OBJ_obj2txt
56.Fa "char *buf"
57.Fa "int buf_len"
58.Fa "const ASN1_OBJECT *a"
59.Fa "int no_name"
60.Fc
61.Ft int
62.Fo OBJ_cmp
63.Fa "const ASN1_OBJECT *a"
64.Fa "const ASN1_OBJECT *b"
65.Fc
66.Ft ASN1_OBJECT *
67.Fo OBJ_dup
68.Fa "const ASN1_OBJECT *o"
69.Fc
70.Ft int
71.Fo OBJ_create
72.Fa "const char *oid"
73.Fa "const char *sn"
74.Fa "const char *ln"
75.Fc
76.Ft void
77.Fn OBJ_cleanup void
78.Sh DESCRIPTION
79The ASN1 object utility functions process
80.Vt ASN1_OBJECT
81structures which are a representation of the ASN1 OBJECT IDENTIFIER
82(OID) type.
83.Pp
84.Fn OBJ_nid2obj ,
85.Fn OBJ_nid2ln ,
86and
87.Fn OBJ_nid2sn
88convert the NID
89.Fa n
90to an
91.Vt ASN1_OBJECT
92structure, its long name, and its short name, respectively, or return
93.Dv NULL
94if an error occurred.
95.Pp
96.Fn OBJ_obj2nid ,
97.Fn OBJ_ln2nid ,
98and
99.Fn OBJ_sn2nid
100return the corresponding NID for the object
101.Fa o ,
102the long name
103.Fa ln ,
104or the short name
105.Fa sn ,
106respectively, or
107.Dv NID_undef
108if an error occurred.
109.Pp
110.Fn OBJ_txt2nid
111returns the NID corresponding to text string
112.Fa s .
113.Fa s
114can be a long name, a short name, or the numerical representation
115of an object.
116.Pp
117.Fn OBJ_txt2obj
118converts the text string
119.Fa s
120into an
121.Vt ASN1_OBJECT
122structure.
123If
124.Fa no_name
125is 0 then long names and short names will be interpreted as well as
126numerical forms.
127If
128.Fa no_name
129is 1 only the numerical form is acceptable.
130.Pp
131.Fn OBJ_obj2txt
132converts the
133.Vt ASN1_OBJECT
134.Fa a
135into a textual representation.
136The representation is written as a NUL terminated string to
137.Fa buf .
138At most
139.Fa buf_len
140bytes are written, truncating the result if necessary.
141The total amount of space required is returned.
142If
143.Fa no_name
144is 0 and the object has a long or short name, then that will be used,
145otherwise the numerical form will be used.
146.Pp
147.Fn OBJ_cmp
148compares
149.Fa a
150to
151.Fa b .
152If the two are identical, 0 is returned.
153.Pp
154.Fn OBJ_dup
155returns a copy of
156.Fa o .
157.Pp
158.Fn OBJ_create
159adds a new object to the internal table.
160.Fa oid
161is the numerical form of the object,
162.Fa sn
163the short name and
164.Fa ln
165the long name.
166A new NID is returned for the created object.
167.Pp
168.Fn OBJ_cleanup
169cleans up the internal object table: this should be called before
170an application exits if any new objects were added using
171.Fn OBJ_create .
172.Pp
173Objects can have a short name, a long name, and a numerical
174identifier (NID) associated with them.
175A standard set of objects is represented in an internal table.
176The appropriate values are defined in the header file
177.In openssl/objects.h .
178.Pp
179For example, the OID for commonName has the following definitions:
180.Bd -literal
181#define SN_commonName "CN"
182#define LN_commonName "commonName"
183#define NID_commonName 13
184.Ed
185.Pp
186New objects can be added by calling
187.Fn OBJ_create .
188.Pp
189Table objects have certain advantages over other objects: for example
190their NIDs can be used in a C language switch statement.
191They are also static constant structures which are shared: that is there
192is only a single constant structure for each table object.
193.Pp
194Objects which are not in the table have the NID value
195.Dv NID_undef .
196.Pp
197Objects do not need to be in the internal tables to be processed, the
198functions
199.Fn OBJ_txt2obj
200and
201.Fn OBJ_obj2txt
202can process the numerical form of an OID.
203.Sh RETURN VALUES
204.Fn OBJ_nid2obj
205returns an
206.Vt ASN1_OBJECT
207structure or
208.Dv NULL
209if an error occurred.
210.Pp
211.Fn OBJ_nid2ln
212and
213.Fn OBJ_nid2sn
214returns a valid string or
215.Dv NULL
216on error.
217.Pp
218.Fn OBJ_obj2nid ,
219.Fn OBJ_ln2nid ,
220.Fn OBJ_sn2nid ,
221and
222.Fn OBJ_txt2nid
223return a NID or
224.Dv NID_undef
225on error.
226.Sh EXAMPLES
227Create an object for
228.Sy commonName :
229.Bd -literal
230ASN1_OBJECT *o;
231o = OBJ_nid2obj(NID_commonName);
232.Ed
233.Pp
234Check if an object is
235.Sy commonName
236.Bd -literal
237if (OBJ_obj2nid(obj) == NID_commonName)
238 /* Do something */
239.Ed
240.Pp
241Create a new NID and initialize an object from it:
242.Bd -literal
243int new_nid;
244ASN1_OBJECT *obj;
245new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
246obj = OBJ_nid2obj(new_nid);
247.Ed
248.Pp
249Create a new object directly:
250.Bd -literal
251obj = OBJ_txt2obj("1.2.3.4", 1);
252.Ed
253.Sh SEE ALSO
254.Xr ERR_get_error 3
255.Sh BUGS
256.Fn OBJ_obj2txt
257is awkward and messy to use: it doesn't follow the convention of other
258OpenSSL functions where the buffer can be set to
259.Dv NULL
260to determine the amount of data that should be written.
261Instead
262.Fa buf
263must point to a valid buffer and
264.Fa buf_len
265should be set to a positive value.
266A buffer length of 80 should be more than enough to handle any OID
267encountered in practice.