summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2016-11-03 10:24:26 +0000
committerschwarze <>2016-11-03 10:24:26 +0000
commit99421a4d33ceb28652f51f4a28160d96485e712e (patch)
tree155e30b5ca7dd36c2675796fc6962aeadace902e
parentc8f23a73c54fa03e5487282a15314fd81bdcef57 (diff)
downloadopenbsd-99421a4d33ceb28652f51f4a28160d96485e712e.tar.gz
openbsd-99421a4d33ceb28652f51f4a28160d96485e712e.tar.bz2
openbsd-99421a4d33ceb28652f51f4a28160d96485e712e.zip
convert remaining ASN1 object manuals from pod to mdoc
-rw-r--r--src/lib/libcrypto/doc/OBJ_nid2obj.pod147
-rw-r--r--src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod25
-rw-r--r--src/lib/libcrypto/man/Makefile6
-rw-r--r--src/lib/libcrypto/man/OBJ_nid2obj.3267
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OBJECT.329
5 files changed, 299 insertions, 175 deletions
diff --git a/src/lib/libcrypto/doc/OBJ_nid2obj.pod b/src/lib/libcrypto/doc/OBJ_nid2obj.pod
deleted file mode 100644
index 95949ac091..0000000000
--- a/src/lib/libcrypto/doc/OBJ_nid2obj.pod
+++ /dev/null
@@ -1,147 +0,0 @@
1=pod
2
3=head1 NAME
4
5OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid,
6OBJ_sn2nid, OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup
7- ASN1 object utility functions
8
9=head1 SYNOPSIS
10
11 #include <openssl/objects.h>
12
13 ASN1_OBJECT * OBJ_nid2obj(int n);
14 const char * OBJ_nid2ln(int n);
15 const char * OBJ_nid2sn(int n);
16
17 int OBJ_obj2nid(const ASN1_OBJECT *o);
18 int OBJ_ln2nid(const char *ln);
19 int OBJ_sn2nid(const char *sn);
20
21 int OBJ_txt2nid(const char *s);
22
23 ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
24 int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
25
26 int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
27 ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
28
29 int OBJ_create(const char *oid,const char *sn,const char *ln);
30 void OBJ_cleanup(void);
31
32=head1 DESCRIPTION
33
34The ASN1 object utility functions process ASN1_OBJECT structures which are
35a representation of the ASN1 OBJECT IDENTIFIER (OID) type.
36
37OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID B<n> to
38an ASN1_OBJECT structure, its long name and its short name respectively,
39or B<NULL> is an error occurred.
40
41OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID
42for the object B<o>, the long name <ln> or the short name <sn> respectively
43or NID_undef if an error occurred.
44
45OBJ_txt2nid() returns NID corresponding to text string <s>. B<s> can be
46a long name, a short name or the numerical representation of an object.
47
48OBJ_txt2obj() converts the text string B<s> into an ASN1_OBJECT structure.
49If B<no_name> is 0 then long names and short names will be interpreted
50as well as numerical forms. If B<no_name> is 1 only the numerical form
51is acceptable.
52
53OBJ_obj2txt() converts the B<ASN1_OBJECT> B<a> into a textual representation.
54The representation is written as a null terminated string to B<buf>
55at most B<buf_len> bytes are written, truncating the result if necessary.
56The total amount of space required is returned. If B<no_name> is 0 then
57if the object has a long or short name then that will be used, otherwise
58the numerical form will be used. If B<no_name> is 1 then the numerical
59form will always be used.
60
61OBJ_cmp() compares B<a> to B<b>. If the two are identical 0 is returned.
62
63OBJ_dup() returns a copy of B<o>.
64
65OBJ_create() adds a new object to the internal table. B<oid> is the
66numerical form of the object, B<sn> the short name and B<ln> the
67long name. A new NID is returned for the created object.
68
69OBJ_cleanup() cleans up OpenSSLs internal object table: this should
70be called before an application exits if any new objects were added
71using OBJ_create().
72
73=head1 NOTES
74
75Objects in OpenSSL can have a short name, a long name and a numerical
76identifier (NID) associated with them. A standard set of objects is
77represented in an internal table. The appropriate values are defined
78in the header file B<objects.h>.
79
80For example the OID for commonName has the following definitions:
81
82 #define SN_commonName "CN"
83 #define LN_commonName "commonName"
84 #define NID_commonName 13
85
86New objects can be added by calling OBJ_create().
87
88Table objects have certain advantages over other objects: for example
89their NIDs can be used in a C language switch statement. They are
90also static constant structures which are shared: that is there
91is only a single constant structure for each table object.
92
93Objects which are not in the table have the NID value NID_undef.
94
95Objects do not need to be in the internal tables to be processed,
96the functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical
97form of an OID.
98
99=head1 EXAMPLES
100
101Create an object for B<commonName>:
102
103 ASN1_OBJECT *o;
104 o = OBJ_nid2obj(NID_commonName);
105
106Check if an object is B<commonName>
107
108 if (OBJ_obj2nid(obj) == NID_commonName)
109 /* Do something */
110
111Create a new NID and initialize an object from it:
112
113 int new_nid;
114 ASN1_OBJECT *obj;
115 new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
116
117 obj = OBJ_nid2obj(new_nid);
118
119Create a new object directly:
120
121 obj = OBJ_txt2obj("1.2.3.4", 1);
122
123=head1 BUGS
124
125OBJ_obj2txt() is awkward and messy to use: it doesn't follow the
126convention of other OpenSSL functions where the buffer can be set
127to B<NULL> to determine the amount of data that should be written.
128Instead B<buf> must point to a valid buffer and B<buf_len> should
129be set to a positive value. A buffer length of 80 should be more
130than enough to handle any OID encountered in practice.
131
132=head1 RETURN VALUES
133
134OBJ_nid2obj() returns an B<ASN1_OBJECT> structure or B<NULL> is an
135error occurred.
136
137OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or B<NULL>
138on error.
139
140OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return
141a NID or B<NID_undef> on error.
142
143=head1 SEE ALSO
144
145L<ERR_get_error(3)|ERR_get_error(3)>
146
147=cut
diff --git a/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod b/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod
deleted file mode 100644
index b2712dc55c..0000000000
--- a/src/lib/libcrypto/doc/d2i_ASN1_OBJECT.pod
+++ /dev/null
@@ -1,25 +0,0 @@
1=pod
2
3=head1 NAME
4
5d2i_ASN1_OBJECT, i2d_ASN1_OBJECT - ASN1 OBJECT IDENTIFIER functions
6
7=head1 SYNOPSIS
8
9 #include <openssl/objects.h>
10
11 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp, long length);
12 int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);
13
14=head1 DESCRIPTION
15
16These functions decode and encode an ASN1 OBJECT IDENTIFIER.
17
18Othewise these behave in a similar way to d2i_X509() and i2d_X509()
19described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
20
21=head1 SEE ALSO
22
23L<d2i_X509(3)|d2i_X509(3)>
24
25=cut
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 1989a25092..802b34399f 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.39 2016/11/03 10:02:57 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.40 2016/11/03 10:24:26 schwarze Exp $
2 2
3.include <bsd.own.mk> # for NOMAN 3.include <bsd.own.mk> # for NOMAN
4 4
@@ -117,16 +117,17 @@ MAN= \
117 EVP_VerifyInit.3 \ 117 EVP_VerifyInit.3 \
118 HMAC.3 \ 118 HMAC.3 \
119 MD5.3 \ 119 MD5.3 \
120 OBJ_nid2obj.3 \
120 UI_new.3 \ 121 UI_new.3 \
121 bn_dump.3 \ 122 bn_dump.3 \
122 crypto.3 \ 123 crypto.3 \
124 d2i_ASN1_OBJECT.3 \
123 d2i_PKCS8PrivateKey_bio.3 \ 125 d2i_PKCS8PrivateKey_bio.3 \
124 des_read_pw.3 \ 126 des_read_pw.3 \
125 evp.3 \ 127 evp.3 \
126 lh_new.3 \ 128 lh_new.3 \
127 129
128GENMAN= \ 130GENMAN= \
129 OBJ_nid2obj.3 \
130 OPENSSL_VERSION_NUMBER.3 \ 131 OPENSSL_VERSION_NUMBER.3 \
131 OPENSSL_config.3 \ 132 OPENSSL_config.3 \
132 OPENSSL_load_builtin_modules.3 \ 133 OPENSSL_load_builtin_modules.3 \
@@ -178,7 +179,6 @@ GENMAN= \
178 X509_new.3 \ 179 X509_new.3 \
179 X509_verify_cert.3 \ 180 X509_verify_cert.3 \
180 bn.3 \ 181 bn.3 \
181 d2i_ASN1_OBJECT.3 \
182 d2i_DHparams.3 \ 182 d2i_DHparams.3 \
183 d2i_DSAPublicKey.3 \ 183 d2i_DSAPublicKey.3 \
184 d2i_ECPKParameters.3 \ 184 d2i_ECPKParameters.3 \
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.
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
new file mode 100644
index 0000000000..686101cff5
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3
@@ -0,0 +1,29 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt D2I_ASN1_OBJECT 3
3.Os
4.Sh NAME
5.Nm d2i_ASN1_OBJECT ,
6.Nm i2d_ASN1_OBJECT
7.Nd ASN1 OBJECT IDENTIFIER functions
8.Sh SYNOPSIS
9.In openssl/objects.h
10.Ft ASN1_OBJECT *
11.Fo d2i_ASN1_OBJECT
12.Fa "ASN1_OBJECT **a"
13.Fa "unsigned char **pp"
14.Fa "long length"
15.Fc
16.Ft int
17.Fo i2d_ASN1_OBJECT
18.Fa "ASN1_OBJECT *a"
19.Fa "unsigned char **pp"
20.Fc
21.Sh DESCRIPTION
22These functions decode and encode an ASN1 OBJECT IDENTIFIER.
23.Pp
24Otherwise these behave in a similar way to
25.Xr d2i_X509 3
26and
27.Xr i2d_X509 3 .
28.Sh SEE ALSO
29.Xr d2i_X509 3