diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/man/OBJ_create.3 | 100 |
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 | ||
| 101 | returns the smallest currently unassigned ASN.1 numeric | ||
| 102 | object identifier (NID) and reserves | ||
| 103 | .Fa increment | ||
| 104 | consecutive NIDs starting with it. | ||
| 105 | Passing an argument of 1 is usually recommended. | ||
| 106 | The return value can be assigned to a new object by passing it as the | ||
| 107 | .Fa nid | ||
| 108 | argument to | ||
| 109 | .Xr ASN1_OBJECT_create 3 | ||
| 110 | and by passing the resulting object to | ||
| 111 | .Fn OBJ_add_object . | ||
| 112 | .Pp | ||
| 113 | .Fn OBJ_add_object | ||
| 114 | adds a copy of the | ||
| 115 | .Fa object | ||
| 116 | to the internal table of ASN.1 object identifiers for use by | ||
| 117 | .Xr OBJ_nid2obj 3 | ||
| 118 | and related functions. | ||
| 119 | .Pp | ||
| 90 | .Fn OBJ_create | 120 | .Fn OBJ_create |
| 91 | adds a new object to the internal table. | 121 | provides a simpler way to add a new object to the internal table. |
| 92 | .Fa oid | 122 | .Fa oid |
| 93 | is the numerical form of the object, | 123 | is the numerical form of the object, |
| 94 | .Fa sn | 124 | .Fa sn |
| 95 | the short name and | 125 | the short name and |
| 96 | .Fa ln | 126 | .Fa ln |
| 97 | the long name. | 127 | the long name. |
| 98 | A new NID is returned for the created object. | 128 | A new NID is automatically assigned using |
| 129 | .Fn OBJ_new_nid . | ||
| 130 | .Pp | ||
| 131 | .Fn OBJ_create_objects | ||
| 132 | reads text lines of the form | ||
| 133 | .Pp | ||
| 134 | .D1 Fa oid sn ln | ||
| 135 | .Pp | ||
| 136 | from | ||
| 137 | .Fa in_bio | ||
| 138 | and calls | ||
| 139 | .Fn OBJ_create oid sn ln | ||
| 140 | for every line read. | ||
| 141 | The three fields of the input lines | ||
| 142 | are separated by one or more whitespace characters. | ||
| 99 | .Pp | 143 | .Pp |
| 100 | The new object added to the internal table and all the data | 144 | For all three functions, the objects added to the internal table and |
| 101 | contained in it is marked as not dynamically allocated. | 145 | all the data contained in them is marked as not dynamically allocated. |
| 102 | Consequently, retrieving it with | 146 | Consequently, retrieving them with |
| 103 | .Xr OBJ_nid2obj 3 | 147 | .Xr OBJ_nid2obj 3 |
| 104 | or a similar function and then calling | 148 | or 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 |
| 109 | cleans up the internal object table: this should be called before | 153 | cleans up the internal object table: this should be called before |
| 110 | an application exits if any new objects were added using | 154 | an application exits if any new objects were added using |
| 111 | .Fn OBJ_create . | 155 | .Fn OBJ_add_object , |
| 156 | .Fn OBJ_create , | ||
| 157 | or | ||
| 158 | .Fn OBJ_create_objects . | ||
| 112 | .Sh RETURN VALUES | 159 | .Sh RETURN VALUES |
| 160 | .Fn OBJ_new_nid | ||
| 161 | returns the new NID. | ||
| 162 | .Pp | ||
| 163 | .Fn OBJ_add_object | ||
| 164 | returns the NID associated with the | ||
| 165 | .Fa object | ||
| 166 | or | ||
| 167 | .Dv NID_undef | ||
| 168 | if memory allocation fails. | ||
| 169 | .Pp | ||
| 113 | .Fn OBJ_create | 170 | .Fn OBJ_create |
| 114 | returns the new NID or | 171 | returns the new NID or |
| 115 | .Dv NID_undef | 172 | .Dv NID_undef |
| 116 | if an error occurs. | 173 | if |
| 174 | .Fa oid | ||
| 175 | is not a valid representation of an object identfier | ||
| 176 | or if memory allocation fails. | ||
| 177 | .Pp | ||
| 178 | .Fn OBJ_create_objects | ||
| 179 | returns the number of objects added. | ||
| 117 | .Pp | 180 | .Pp |
| 118 | In some cases of failure of | 181 | In some cases of failure of |
| 182 | .Fn OBJ_add_object , | ||
| 119 | .Fn OBJ_create , | 183 | .Fn OBJ_create , |
| 184 | and | ||
| 185 | .Fn OBJ_create_objects , | ||
| 120 | the reason can be determined with | 186 | the reason can be determined with |
| 121 | .Xr ERR_get_error 3 . | 187 | .Xr ERR_get_error 3 . |
| 122 | .Sh EXAMPLES | 188 | .Sh EXAMPLES |
| 123 | Create a new NID and initialize an object from it: | 189 | Create a new NID and initialize an object from it: |
| 124 | .Bd -literal -offset indent | 190 | .Bd -literal -offset indent |
| 125 | int new_nid; | 191 | int new_nid; |
| 126 | |||
| 127 | ASN1_OBJECT *obj; | 192 | ASN1_OBJECT *obj; |
| 193 | |||
| 128 | new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier"); | 194 | new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier"); |
| 129 | obj = OBJ_nid2obj(new_nid); | 195 | obj = 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 , | ||
| 203 | and | ||
| 135 | .Fn OBJ_cleanup | 204 | .Fn OBJ_cleanup |
| 136 | first appeared in SSLeay 0.8.0 and | 205 | first appeared in SSLeay 0.8.0 and |
| 137 | .Fn OBJ_create | 206 | .Fn OBJ_create |
| 138 | in SSLeay 0.9.0. | 207 | in SSLeay 0.9.0. |
| 139 | These functions have been available since | 208 | These functions have been available since |
| 140 | .Ox 2.4 . | 209 | .Ox 2.4 . |
| 210 | .Sh BUGS | ||
| 211 | .Fn OBJ_new_nid | ||
| 212 | does not reserve any return value to indicate an error. | ||
| 213 | Consequently, to avoid conflicting NID assignments and integer overflows, | ||
| 214 | care must be taken to not pass negative, zero, or large arguments to | ||
| 215 | .Fn OBJ_new_nid . | ||
| 216 | .Pp | ||
| 217 | .Fn OBJ_create_objects | ||
| 218 | does not distinguish between end of file, I/O errors, temporary | ||
| 219 | unavailability of data on a non-blocking BIO, invalid input syntax, | ||
| 220 | and memory allocation failure. | ||
| 221 | In all these cases, reading is aborted and the number of objects | ||
| 222 | that were already added is returned. | ||
