diff options
Diffstat (limited to 'src/lib/libcrypto/man')
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/man/OBJ_nid2obj.3 | 267 | ||||
-rw-r--r-- | src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 | 29 |
3 files changed, 299 insertions, 3 deletions
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 | ||
128 | GENMAN= \ | 130 | GENMAN= \ |
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 | ||
79 | The ASN1 object utility functions process | ||
80 | .Vt ASN1_OBJECT | ||
81 | structures which are a representation of the ASN1 OBJECT IDENTIFIER | ||
82 | (OID) type. | ||
83 | .Pp | ||
84 | .Fn OBJ_nid2obj , | ||
85 | .Fn OBJ_nid2ln , | ||
86 | and | ||
87 | .Fn OBJ_nid2sn | ||
88 | convert the NID | ||
89 | .Fa n | ||
90 | to an | ||
91 | .Vt ASN1_OBJECT | ||
92 | structure, its long name, and its short name, respectively, or return | ||
93 | .Dv NULL | ||
94 | if an error occurred. | ||
95 | .Pp | ||
96 | .Fn OBJ_obj2nid , | ||
97 | .Fn OBJ_ln2nid , | ||
98 | and | ||
99 | .Fn OBJ_sn2nid | ||
100 | return the corresponding NID for the object | ||
101 | .Fa o , | ||
102 | the long name | ||
103 | .Fa ln , | ||
104 | or the short name | ||
105 | .Fa sn , | ||
106 | respectively, or | ||
107 | .Dv NID_undef | ||
108 | if an error occurred. | ||
109 | .Pp | ||
110 | .Fn OBJ_txt2nid | ||
111 | returns the NID corresponding to text string | ||
112 | .Fa s . | ||
113 | .Fa s | ||
114 | can be a long name, a short name, or the numerical representation | ||
115 | of an object. | ||
116 | .Pp | ||
117 | .Fn OBJ_txt2obj | ||
118 | converts the text string | ||
119 | .Fa s | ||
120 | into an | ||
121 | .Vt ASN1_OBJECT | ||
122 | structure. | ||
123 | If | ||
124 | .Fa no_name | ||
125 | is 0 then long names and short names will be interpreted as well as | ||
126 | numerical forms. | ||
127 | If | ||
128 | .Fa no_name | ||
129 | is 1 only the numerical form is acceptable. | ||
130 | .Pp | ||
131 | .Fn OBJ_obj2txt | ||
132 | converts the | ||
133 | .Vt ASN1_OBJECT | ||
134 | .Fa a | ||
135 | into a textual representation. | ||
136 | The representation is written as a NUL terminated string to | ||
137 | .Fa buf . | ||
138 | At most | ||
139 | .Fa buf_len | ||
140 | bytes are written, truncating the result if necessary. | ||
141 | The total amount of space required is returned. | ||
142 | If | ||
143 | .Fa no_name | ||
144 | is 0 and the object has a long or short name, then that will be used, | ||
145 | otherwise the numerical form will be used. | ||
146 | .Pp | ||
147 | .Fn OBJ_cmp | ||
148 | compares | ||
149 | .Fa a | ||
150 | to | ||
151 | .Fa b . | ||
152 | If the two are identical, 0 is returned. | ||
153 | .Pp | ||
154 | .Fn OBJ_dup | ||
155 | returns a copy of | ||
156 | .Fa o . | ||
157 | .Pp | ||
158 | .Fn OBJ_create | ||
159 | adds a new object to the internal table. | ||
160 | .Fa oid | ||
161 | is the numerical form of the object, | ||
162 | .Fa sn | ||
163 | the short name and | ||
164 | .Fa ln | ||
165 | the long name. | ||
166 | A new NID is returned for the created object. | ||
167 | .Pp | ||
168 | .Fn OBJ_cleanup | ||
169 | cleans up the internal object table: this should be called before | ||
170 | an application exits if any new objects were added using | ||
171 | .Fn OBJ_create . | ||
172 | .Pp | ||
173 | Objects can have a short name, a long name, and a numerical | ||
174 | identifier (NID) associated with them. | ||
175 | A standard set of objects is represented in an internal table. | ||
176 | The appropriate values are defined in the header file | ||
177 | .In openssl/objects.h . | ||
178 | .Pp | ||
179 | For 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 | ||
186 | New objects can be added by calling | ||
187 | .Fn OBJ_create . | ||
188 | .Pp | ||
189 | Table objects have certain advantages over other objects: for example | ||
190 | their NIDs can be used in a C language switch statement. | ||
191 | They are also static constant structures which are shared: that is there | ||
192 | is only a single constant structure for each table object. | ||
193 | .Pp | ||
194 | Objects which are not in the table have the NID value | ||
195 | .Dv NID_undef . | ||
196 | .Pp | ||
197 | Objects do not need to be in the internal tables to be processed, the | ||
198 | functions | ||
199 | .Fn OBJ_txt2obj | ||
200 | and | ||
201 | .Fn OBJ_obj2txt | ||
202 | can process the numerical form of an OID. | ||
203 | .Sh RETURN VALUES | ||
204 | .Fn OBJ_nid2obj | ||
205 | returns an | ||
206 | .Vt ASN1_OBJECT | ||
207 | structure or | ||
208 | .Dv NULL | ||
209 | if an error occurred. | ||
210 | .Pp | ||
211 | .Fn OBJ_nid2ln | ||
212 | and | ||
213 | .Fn OBJ_nid2sn | ||
214 | returns a valid string or | ||
215 | .Dv NULL | ||
216 | on error. | ||
217 | .Pp | ||
218 | .Fn OBJ_obj2nid , | ||
219 | .Fn OBJ_ln2nid , | ||
220 | .Fn OBJ_sn2nid , | ||
221 | and | ||
222 | .Fn OBJ_txt2nid | ||
223 | return a NID or | ||
224 | .Dv NID_undef | ||
225 | on error. | ||
226 | .Sh EXAMPLES | ||
227 | Create an object for | ||
228 | .Sy commonName : | ||
229 | .Bd -literal | ||
230 | ASN1_OBJECT *o; | ||
231 | o = OBJ_nid2obj(NID_commonName); | ||
232 | .Ed | ||
233 | .Pp | ||
234 | Check if an object is | ||
235 | .Sy commonName | ||
236 | .Bd -literal | ||
237 | if (OBJ_obj2nid(obj) == NID_commonName) | ||
238 | /* Do something */ | ||
239 | .Ed | ||
240 | .Pp | ||
241 | Create a new NID and initialize an object from it: | ||
242 | .Bd -literal | ||
243 | int new_nid; | ||
244 | ASN1_OBJECT *obj; | ||
245 | new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier"); | ||
246 | obj = OBJ_nid2obj(new_nid); | ||
247 | .Ed | ||
248 | .Pp | ||
249 | Create a new object directly: | ||
250 | .Bd -literal | ||
251 | obj = 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 | ||
257 | is awkward and messy to use: it doesn't follow the convention of other | ||
258 | OpenSSL functions where the buffer can be set to | ||
259 | .Dv NULL | ||
260 | to determine the amount of data that should be written. | ||
261 | Instead | ||
262 | .Fa buf | ||
263 | must point to a valid buffer and | ||
264 | .Fa buf_len | ||
265 | should be set to a positive value. | ||
266 | A buffer length of 80 should be more than enough to handle any OID | ||
267 | encountered 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 | ||
22 | These functions decode and encode an ASN1 OBJECT IDENTIFIER. | ||
23 | .Pp | ||
24 | Otherwise these behave in a similar way to | ||
25 | .Xr d2i_X509 3 | ||
26 | and | ||
27 | .Xr i2d_X509 3 . | ||
28 | .Sh SEE ALSO | ||
29 | .Xr d2i_X509 3 | ||