diff options
Diffstat (limited to 'src/lib/libcrypto/man/OBJ_nid2obj.3')
| -rw-r--r-- | src/lib/libcrypto/man/OBJ_nid2obj.3 | 521 |
1 files changed, 0 insertions, 521 deletions
diff --git a/src/lib/libcrypto/man/OBJ_nid2obj.3 b/src/lib/libcrypto/man/OBJ_nid2obj.3 deleted file mode 100644 index ccab1ed30c..0000000000 --- a/src/lib/libcrypto/man/OBJ_nid2obj.3 +++ /dev/null | |||
| @@ -1,521 +0,0 @@ | |||
| 1 | .\" $OpenBSD: OBJ_nid2obj.3,v 1.22 2024/01/31 08:02:53 tb Exp $ | ||
| 2 | .\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000 | ||
| 3 | .\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 | ||
| 4 | .\" | ||
| 5 | .\" This file is a derived work. | ||
| 6 | .\" The changes are covered by the following Copyright and license: | ||
| 7 | .\" | ||
| 8 | .\" Copyright (c) 2017, 2021, 2023 Ingo Schwarze <schwarze@openbsd.org> | ||
| 9 | .\" | ||
| 10 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 11 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 12 | .\" copyright notice and this permission notice appear in all copies. | ||
| 13 | .\" | ||
| 14 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 15 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 16 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 17 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 18 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 19 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 20 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 21 | .\" | ||
| 22 | .\" The original file was written by Dr. Stephen Henson <steve@openssl.org>. | ||
| 23 | .\" Copyright (c) 2002, 2006, 2016 The OpenSSL Project. | ||
| 24 | .\" All rights reserved. | ||
| 25 | .\" | ||
| 26 | .\" Redistribution and use in source and binary forms, with or without | ||
| 27 | .\" modification, are permitted provided that the following conditions | ||
| 28 | .\" are met: | ||
| 29 | .\" | ||
| 30 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 31 | .\" notice, this list of conditions and the following disclaimer. | ||
| 32 | .\" | ||
| 33 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 34 | .\" notice, this list of conditions and the following disclaimer in | ||
| 35 | .\" the documentation and/or other materials provided with the | ||
| 36 | .\" distribution. | ||
| 37 | .\" | ||
| 38 | .\" 3. All advertising materials mentioning features or use of this | ||
| 39 | .\" software must display the following acknowledgment: | ||
| 40 | .\" "This product includes software developed by the OpenSSL Project | ||
| 41 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 42 | .\" | ||
| 43 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 44 | .\" endorse or promote products derived from this software without | ||
| 45 | .\" prior written permission. For written permission, please contact | ||
| 46 | .\" openssl-core@openssl.org. | ||
| 47 | .\" | ||
| 48 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 49 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 50 | .\" permission of the OpenSSL Project. | ||
| 51 | .\" | ||
| 52 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 53 | .\" acknowledgment: | ||
| 54 | .\" "This product includes software developed by the OpenSSL Project | ||
| 55 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 56 | .\" | ||
| 57 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 58 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 59 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 60 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 61 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 62 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 63 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 64 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 65 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 66 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 67 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 68 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 69 | .\" | ||
| 70 | .Dd $Mdocdate: January 31 2024 $ | ||
| 71 | .Dt OBJ_NID2OBJ 3 | ||
| 72 | .Os | ||
| 73 | .Sh NAME | ||
| 74 | .Nm OBJ_nid2obj , | ||
| 75 | .Nm OBJ_nid2ln , | ||
| 76 | .Nm OBJ_nid2sn , | ||
| 77 | .Nm OBJ_obj2nid , | ||
| 78 | .Nm OBJ_ln2nid , | ||
| 79 | .Nm OBJ_sn2nid , | ||
| 80 | .Nm OBJ_txt2nid , | ||
| 81 | .Nm OBJ_txt2obj , | ||
| 82 | .Nm OBJ_obj2txt , | ||
| 83 | .Nm OBJ_cmp , | ||
| 84 | .Nm OBJ_dup , | ||
| 85 | .Nm i2t_ASN1_OBJECT , | ||
| 86 | .Nm i2a_ASN1_OBJECT | ||
| 87 | .Nd inspect and create ASN.1 object identifiers | ||
| 88 | .Sh SYNOPSIS | ||
| 89 | .In openssl/objects.h | ||
| 90 | .Ft ASN1_OBJECT * | ||
| 91 | .Fo OBJ_nid2obj | ||
| 92 | .Fa "int nid" | ||
| 93 | .Fc | ||
| 94 | .Ft const char * | ||
| 95 | .Fo OBJ_nid2ln | ||
| 96 | .Fa "int nid" | ||
| 97 | .Fc | ||
| 98 | .Ft const char * | ||
| 99 | .Fo OBJ_nid2sn | ||
| 100 | .Fa "int nid" | ||
| 101 | .Fc | ||
| 102 | .Ft int | ||
| 103 | .Fo OBJ_obj2nid | ||
| 104 | .Fa "const ASN1_OBJECT *object" | ||
| 105 | .Fc | ||
| 106 | .Ft int | ||
| 107 | .Fo OBJ_ln2nid | ||
| 108 | .Fa "const char *ln" | ||
| 109 | .Fc | ||
| 110 | .Ft int | ||
| 111 | .Fo OBJ_sn2nid | ||
| 112 | .Fa "const char *sn" | ||
| 113 | .Fc | ||
| 114 | .Ft int | ||
| 115 | .Fo OBJ_txt2nid | ||
| 116 | .Fa "const char *s" | ||
| 117 | .Fc | ||
| 118 | .Ft ASN1_OBJECT * | ||
| 119 | .Fo OBJ_txt2obj | ||
| 120 | .Fa "const char *s" | ||
| 121 | .Fa "int no_name" | ||
| 122 | .Fc | ||
| 123 | .Ft int | ||
| 124 | .Fo OBJ_obj2txt | ||
| 125 | .Fa "char *buf" | ||
| 126 | .Fa "int buf_len" | ||
| 127 | .Fa "const ASN1_OBJECT *object" | ||
| 128 | .Fa "int no_name" | ||
| 129 | .Fc | ||
| 130 | .Ft int | ||
| 131 | .Fo OBJ_cmp | ||
| 132 | .Fa "const ASN1_OBJECT *a" | ||
| 133 | .Fa "const ASN1_OBJECT *b" | ||
| 134 | .Fc | ||
| 135 | .Ft ASN1_OBJECT * | ||
| 136 | .Fo OBJ_dup | ||
| 137 | .Fa "const ASN1_OBJECT *object" | ||
| 138 | .Fc | ||
| 139 | .In openssl/asn1.h | ||
| 140 | .Ft int | ||
| 141 | .Fo i2t_ASN1_OBJECT | ||
| 142 | .Fa "char *buf" | ||
| 143 | .Fa "int buf_len" | ||
| 144 | .Fa "const ASN1_OBJECT *object" | ||
| 145 | .Fc | ||
| 146 | .Ft int | ||
| 147 | .Fo i2a_ASN1_OBJECT | ||
| 148 | .Fa "BIO *out_bio" | ||
| 149 | .Fa "const ASN1_OBJECT *object" | ||
| 150 | .Fc | ||
| 151 | .Sh DESCRIPTION | ||
| 152 | The ASN.1 object utility functions process | ||
| 153 | .Vt ASN1_OBJECT | ||
| 154 | structures, in the following called | ||
| 155 | .Dq objects . | ||
| 156 | An object represents an ASN.1 | ||
| 157 | .Vt OBJECT IDENTIFIER | ||
| 158 | .Pq OID . | ||
| 159 | The library maintains an internal global table of objects. | ||
| 160 | Many of these objects are built into the library | ||
| 161 | and contained in the global table by default. | ||
| 162 | The application program can add additional objects to the global table | ||
| 163 | by using functions documented in the | ||
| 164 | .Xr OBJ_create 3 | ||
| 165 | manual page. | ||
| 166 | Consequently, there are three classes of objects: | ||
| 167 | built-in table objects, user-defined table objects, and non-table objects. | ||
| 168 | .Pp | ||
| 169 | In addition to the OID, each object can hold | ||
| 170 | a long name, a short name, and a numerical identifier (NID). | ||
| 171 | Even though the concept of NIDs is specific to the library | ||
| 172 | and not standardized, using the NID is often the most convenient way | ||
| 173 | for source code to refer to a specific OID. | ||
| 174 | The NIDs of the built-in objects are available as defined constants. | ||
| 175 | .Pp | ||
| 176 | Built-in table objects have certain advantages | ||
| 177 | over objects that are not in the global table: | ||
| 178 | for example, their NIDs can be used in C language switch statements. | ||
| 179 | They are also shared: | ||
| 180 | there is only a single static constant structure for each built-on OID. | ||
| 181 | .Pp | ||
| 182 | Some functions operate on table objects only: | ||
| 183 | .Pp | ||
| 184 | .Fn OBJ_nid2obj | ||
| 185 | retrieves the table object associated with the | ||
| 186 | .Fa nid . | ||
| 187 | .Fn OBJ_nid2ln | ||
| 188 | and | ||
| 189 | .Fn OBJ_nid2sn | ||
| 190 | retrieve its long and short name, respectively. | ||
| 191 | .Pp | ||
| 192 | .Fn OBJ_obj2nid | ||
| 193 | retrieves the NID associated with the given | ||
| 194 | .Fa object , | ||
| 195 | which is either the NID stored in the | ||
| 196 | .Fa object | ||
| 197 | itself, if any, or otherwise the NID stored in a table object | ||
| 198 | containing the same OID. | ||
| 199 | .Pp | ||
| 200 | .Fn OBJ_ln2nid | ||
| 201 | and | ||
| 202 | .Fn OBJ_sn2nid | ||
| 203 | retrieve the NID from the table object with the long name | ||
| 204 | .Fa ln | ||
| 205 | or the short name | ||
| 206 | .Fa sn , | ||
| 207 | respectively. | ||
| 208 | .Pp | ||
| 209 | .Fn OBJ_txt2nid | ||
| 210 | retrieves the NID from the table object described by the text string | ||
| 211 | .Fa s , | ||
| 212 | which can be a long name, a short name, | ||
| 213 | or the numerical representation of an OID. | ||
| 214 | .Pp | ||
| 215 | The remaining functions can be used both on table objects | ||
| 216 | and on objects that are not in the global table: | ||
| 217 | .Pp | ||
| 218 | .Fn OBJ_txt2obj | ||
| 219 | retrieves or creates an object matching the text string | ||
| 220 | .Fa s . | ||
| 221 | If | ||
| 222 | .Fa no_name | ||
| 223 | is 1, only the numerical representation of an OID is accepted. | ||
| 224 | If | ||
| 225 | .Fa no_name | ||
| 226 | is 0, long names and short names are accepted as well. | ||
| 227 | .Pp | ||
| 228 | .Fn OBJ_obj2txt | ||
| 229 | writes a NUL terminated textual representation | ||
| 230 | of the OID contained in the given | ||
| 231 | .Fa object | ||
| 232 | into | ||
| 233 | .Fa buf . | ||
| 234 | At most | ||
| 235 | .Fa buf_len | ||
| 236 | bytes are written, truncating the result if necessary. | ||
| 237 | The total amount of space required is returned. | ||
| 238 | If | ||
| 239 | .Fa no_name | ||
| 240 | is 0 and the table object containing the same OID | ||
| 241 | contains a long name, the long name is written. | ||
| 242 | Otherwise, if | ||
| 243 | .Fa no_name | ||
| 244 | is 0 and the table object containing the same OID | ||
| 245 | contains a short name, the short name is written. | ||
| 246 | Otherwise, the numerical representation of the OID is written. | ||
| 247 | .Pp | ||
| 248 | .Fn i2t_ASN1_OBJECT | ||
| 249 | is the same as | ||
| 250 | .Fn OBJ_obj2txt | ||
| 251 | with | ||
| 252 | .Fa no_name | ||
| 253 | set to 0. | ||
| 254 | .Pp | ||
| 255 | .Fn i2a_ASN1_OBJECT | ||
| 256 | writes a textual representation of the OID contained in the given | ||
| 257 | .Fa object | ||
| 258 | to | ||
| 259 | .Fa out_bio | ||
| 260 | using | ||
| 261 | .Xr BIO_write 3 . | ||
| 262 | It does not write a terminating NUL byte. | ||
| 263 | If the | ||
| 264 | .Fa object | ||
| 265 | argument is | ||
| 266 | .Dv NULL | ||
| 267 | or contains no OID, it writes the 4-byte string | ||
| 268 | .Qq NULL . | ||
| 269 | If | ||
| 270 | .Fn i2t_ASN1_OBJECT | ||
| 271 | fails, | ||
| 272 | .Fn i2a_ASN1_OBJECT | ||
| 273 | writes the 9-byte string | ||
| 274 | .Qq <INVALID> . | ||
| 275 | Otherwise, it writes the string constructed with | ||
| 276 | .Fn i2t_ASN1_OBJECT . | ||
| 277 | .Pp | ||
| 278 | .Fn OBJ_cmp | ||
| 279 | tests whether | ||
| 280 | .Fa a | ||
| 281 | and | ||
| 282 | .Fa b | ||
| 283 | represent the same ASN.1 | ||
| 284 | .Vt OBJECT IDENTIFIER . | ||
| 285 | Any names and NIDs contained in the two objects are ignored, | ||
| 286 | even if they differ between both objects. | ||
| 287 | .Pp | ||
| 288 | .Fn OBJ_dup | ||
| 289 | returns a deep copy of the given | ||
| 290 | .Fa object | ||
| 291 | if it is marked as dynamically allocated. | ||
| 292 | The new object and all data contained in it are marked as dynamically | ||
| 293 | allocated. | ||
| 294 | If the given | ||
| 295 | .Fa object | ||
| 296 | is not marked as dynamically allocated, | ||
| 297 | .Fn OBJ_dup | ||
| 298 | just returns a pointer to the | ||
| 299 | .Fa object | ||
| 300 | itself. | ||
| 301 | .Sh RETURN VALUES | ||
| 302 | Application code should treat all returned values \(em | ||
| 303 | objects, names, and NIDs \(em as constants. | ||
| 304 | .Pp | ||
| 305 | .Fn OBJ_nid2obj | ||
| 306 | returns a pointer to a table object owned by the library or | ||
| 307 | .Dv NULL | ||
| 308 | if no matching table object is found. | ||
| 309 | .Pp | ||
| 310 | .Fn OBJ_nid2ln | ||
| 311 | and | ||
| 312 | .Fn OBJ_nid2sn | ||
| 313 | return a pointer to a string owned by a table object or | ||
| 314 | .Dv NULL | ||
| 315 | if no matching table object is found. | ||
| 316 | For | ||
| 317 | .Dv NID_undef , | ||
| 318 | they return the constant static strings | ||
| 319 | .Qq undefined | ||
| 320 | and | ||
| 321 | .Qq UNDEF , | ||
| 322 | respectively. | ||
| 323 | .Pp | ||
| 324 | .Fn OBJ_obj2nid | ||
| 325 | returns an NID on success, or | ||
| 326 | .Dv NID_undef | ||
| 327 | if | ||
| 328 | .Fa object | ||
| 329 | is | ||
| 330 | .Dv NULL , | ||
| 331 | does not contain an OID, | ||
| 332 | if no table object matching the OID is found, | ||
| 333 | or if the matching object does not contain an NID. | ||
| 334 | .Pp | ||
| 335 | .Fn OBJ_ln2nid | ||
| 336 | and | ||
| 337 | .Fn OBJ_sn2nid | ||
| 338 | return an NID on success or | ||
| 339 | .Dv NID_undef | ||
| 340 | if no matching table object is found | ||
| 341 | or if the matching object does not contain an NID. | ||
| 342 | .Pp | ||
| 343 | .Fn OBJ_txt2nid | ||
| 344 | returns an NID on success or | ||
| 345 | .Dv NID_undef | ||
| 346 | if parsing of | ||
| 347 | .Fa s | ||
| 348 | or memory allocation fails, if no matching table object is found, | ||
| 349 | or if the matching object does not contain an NID. | ||
| 350 | .Pp | ||
| 351 | .Fn OBJ_txt2obj | ||
| 352 | returns a pointer to a table object owned by the library if lookup of | ||
| 353 | .Fa s | ||
| 354 | as a long or short name succeeds. | ||
| 355 | Otherwise, it returns a newly created object, | ||
| 356 | transferring ownership to the caller, or | ||
| 357 | .Dv NULL | ||
| 358 | if parsing of | ||
| 359 | .Fa s | ||
| 360 | or memory allocation fails. | ||
| 361 | .Pp | ||
| 362 | .Fn OBJ_obj2txt | ||
| 363 | and | ||
| 364 | .Fn i2t_ASN1_OBJECT | ||
| 365 | return the amount of space required in bytes, | ||
| 366 | including the terminating NUL byte, | ||
| 367 | or zero if an error occurs before the required space can be calculated, | ||
| 368 | in particular if | ||
| 369 | .Fa buf_len | ||
| 370 | is negative, | ||
| 371 | .Fa object | ||
| 372 | is | ||
| 373 | .Dv NULL | ||
| 374 | or does not contain an OID, | ||
| 375 | or if memory allocation fails. | ||
| 376 | .Pp | ||
| 377 | .Fn OBJ_cmp | ||
| 378 | returns 0 if both objects refer to the same OID | ||
| 379 | or neither of them are associated with any OID, | ||
| 380 | or a non-zero value if at least one of them refers to an OID | ||
| 381 | but the other one does not refer to the same OID. | ||
| 382 | .Pp | ||
| 383 | .Fn OBJ_dup | ||
| 384 | returns the pointer to the original | ||
| 385 | .Fa object | ||
| 386 | if it is not marked as dynamically allocated. | ||
| 387 | Otherwise, it returns a newly created object, | ||
| 388 | transferring ownership to the caller, or | ||
| 389 | .Dv NULL | ||
| 390 | if | ||
| 391 | .Fa object | ||
| 392 | is | ||
| 393 | .Dv NULL | ||
| 394 | or memory allocation fails. | ||
| 395 | .Pp | ||
| 396 | .Fn i2a_ASN1_OBJECT | ||
| 397 | returns the number of bytes written, even if the given | ||
| 398 | .Fa object | ||
| 399 | is invalid or contains invalid data, | ||
| 400 | but a negative value if memory allocation or a write operation fails. | ||
| 401 | .Pp | ||
| 402 | In some cases of failure of | ||
| 403 | .Fn OBJ_nid2obj , | ||
| 404 | .Fn OBJ_nid2ln , | ||
| 405 | .Fn OBJ_nid2sn , | ||
| 406 | .Fn OBJ_txt2nid , | ||
| 407 | .Fn OBJ_txt2obj , | ||
| 408 | .Fn OBJ_obj2txt , | ||
| 409 | .Fn OBJ_dup , | ||
| 410 | .Fn i2t_ASN1_OBJECT , | ||
| 411 | and | ||
| 412 | .Fn i2a_ASN1_OBJECT , | ||
| 413 | the reason can be determined with | ||
| 414 | .Xr ERR_get_error 3 . | ||
| 415 | .Sh EXAMPLES | ||
| 416 | Retrieve the object for | ||
| 417 | .Sy commonName : | ||
| 418 | .Bd -literal -offset indent | ||
| 419 | ASN1_OBJECT *object; | ||
| 420 | object = OBJ_nid2obj(NID_commonName); | ||
| 421 | .Ed | ||
| 422 | .Pp | ||
| 423 | Check whether an object contains the OID for | ||
| 424 | .Sy commonName : | ||
| 425 | .Bd -literal -offset indent | ||
| 426 | if (OBJ_obj2nid(object) == NID_commonName) | ||
| 427 | /* Do something */ | ||
| 428 | .Ed | ||
| 429 | .Pp | ||
| 430 | Create a new object directly: | ||
| 431 | .Bd -literal -offset indent | ||
| 432 | object = OBJ_txt2obj("1.2.3.4", 1); | ||
| 433 | .Ed | ||
| 434 | .Sh SEE ALSO | ||
| 435 | .Xr ASN1_OBJECT_new 3 , | ||
| 436 | .Xr BIO_new 3 , | ||
| 437 | .Xr d2i_ASN1_OBJECT 3 , | ||
| 438 | .Xr OBJ_create 3 | ||
| 439 | .Sh HISTORY | ||
| 440 | .Fn OBJ_nid2obj , | ||
| 441 | .Fn OBJ_nid2ln , | ||
| 442 | .Fn OBJ_nid2sn , | ||
| 443 | .Fn OBJ_obj2nid , | ||
| 444 | .Fn OBJ_ln2nid , | ||
| 445 | .Fn OBJ_sn2nid , | ||
| 446 | .Fn OBJ_txt2nid , | ||
| 447 | .Fn OBJ_cmp , | ||
| 448 | and | ||
| 449 | .Fn OBJ_dup | ||
| 450 | first appeared in SSLeay 0.5.1. | ||
| 451 | .Fn i2a_ASN1_OBJECT | ||
| 452 | first appeared in SSLeay 0.6.0, and | ||
| 453 | .Fn i2t_ASN1_OBJECT | ||
| 454 | in SSLeay 0.9.0. | ||
| 455 | All these functions have been available since | ||
| 456 | .Ox 2.4 . | ||
| 457 | .Pp | ||
| 458 | .Fn OBJ_txt2obj | ||
| 459 | first appeared in OpenSSL 0.9.2b. | ||
| 460 | .Fn OBJ_obj2txt | ||
| 461 | first appeared in OpenSSL 0.9.4. | ||
| 462 | Both functions have been available since | ||
| 463 | .Ox 2.6 . | ||
| 464 | .Sh CAVEATS | ||
| 465 | The API contract of | ||
| 466 | .Fn OBJ_txt2obj | ||
| 467 | when called with a | ||
| 468 | .Fa no_name | ||
| 469 | argument of 0 and of | ||
| 470 | .Fn OBJ_dup | ||
| 471 | is scary in so far as the caller cannot find out from the returned | ||
| 472 | object whether it is owned by the library or whether ownership was | ||
| 473 | transferred to the caller. | ||
| 474 | Consequently, it is best practice to assume that ownership of the object | ||
| 475 | may have been transferred and call | ||
| 476 | .Xr ASN1_OBJECT_free 3 | ||
| 477 | on the returned object when the caller no longer needs it. | ||
| 478 | In case the library retained ownership of the returned object, | ||
| 479 | .Xr ASN1_OBJECT_free 3 | ||
| 480 | has no effect and is harmless. | ||
| 481 | .Pp | ||
| 482 | Objects returned from | ||
| 483 | .Fn OBJ_txt2obj | ||
| 484 | with a | ||
| 485 | .Fa no_name | ||
| 486 | argument of 1 always require | ||
| 487 | .Xr ASN1_OBJECT_free 3 | ||
| 488 | to prevent memory leaks. | ||
| 489 | .Pp | ||
| 490 | Objects returned from | ||
| 491 | .Fn OBJ_nid2obj | ||
| 492 | never require | ||
| 493 | .Xr ASN1_OBJECT_free 3 , | ||
| 494 | but calling it anyway has no effect and is harmless. | ||
| 495 | .Sh BUGS | ||
| 496 | Usually, an object is expected to contain an NID other than | ||
| 497 | .Dv NID_undef | ||
| 498 | if and only if it is a table object. | ||
| 499 | However, this is not an invariant guaranteed by the API. | ||
| 500 | In particular, | ||
| 501 | .Xr ASN1_OBJECT_create 3 | ||
| 502 | allows the creation of non-table objects containing bogus NIDs. | ||
| 503 | .Fn OBJ_obj2nid | ||
| 504 | returns such bogus NIDs even though | ||
| 505 | .Fn OBJ_nid2obj | ||
| 506 | cannot use them for retrieval. | ||
| 507 | On top of that, the global table contains one built-in object with an NID of | ||
| 508 | .Dv NID_undef . | ||
| 509 | .Pp | ||
| 510 | .Fn OBJ_obj2txt | ||
| 511 | is awkward and messy to use: it doesn't follow the convention of other | ||
| 512 | OpenSSL functions where the buffer can be set to | ||
| 513 | .Dv NULL | ||
| 514 | to determine the amount of data that should be written. | ||
| 515 | Instead | ||
| 516 | .Fa buf | ||
| 517 | must point to a valid buffer and | ||
| 518 | .Fa buf_len | ||
| 519 | should be set to a positive value. | ||
| 520 | A buffer length of 80 should be more than enough to handle any OID | ||
| 521 | encountered in practice. | ||
