diff options
author | schwarze <> | 2023-08-09 17:27:26 +0000 |
---|---|---|
committer | schwarze <> | 2023-08-09 17:27:26 +0000 |
commit | 687acad7a255dcb08882c2e0d4187d60655df78a (patch) | |
tree | 992ee562a7bf56941e798613fa43bdbf01a045cd | |
parent | d7d2735b3bfc925a72116d82cd0515de75328df8 (diff) | |
download | openbsd-687acad7a255dcb08882c2e0d4187d60655df78a.tar.gz openbsd-687acad7a255dcb08882c2e0d4187d60655df78a.tar.bz2 openbsd-687acad7a255dcb08882c2e0d4187d60655df78a.zip |
In objects.h rev. 1.14 and 1.15 (Jan 2022), tb@ provided
OBJ_get0_data(3) and OBJ_length(3). Document them.
Feedback and OK tb@.
-rw-r--r-- | src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 index a555490f65..cf750162e5 100644 --- a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 +++ b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 | |||
@@ -1,6 +1,6 @@ | |||
1 | .\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.13 2022/09/12 14:33:47 tb Exp $ | 1 | .\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.14 2023/08/09 17:27:26 schwarze Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2017, 2022 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2017, 2022, 2023 Ingo Schwarze <schwarze@openbsd.org> |
4 | .\" | 4 | .\" |
5 | .\" Permission to use, copy, modify, and distribute this software for any | 5 | .\" Permission to use, copy, modify, and distribute this software for any |
6 | .\" purpose with or without fee is hereby granted, provided that the above | 6 | .\" purpose with or without fee is hereby granted, provided that the above |
@@ -14,12 +14,14 @@ | |||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | .\" | 16 | .\" |
17 | .Dd $Mdocdate: September 12 2022 $ | 17 | .Dd $Mdocdate: August 9 2023 $ |
18 | .Dt D2I_ASN1_OBJECT 3 | 18 | .Dt D2I_ASN1_OBJECT 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
21 | .Nm d2i_ASN1_OBJECT , | 21 | .Nm d2i_ASN1_OBJECT , |
22 | .Nm i2d_ASN1_OBJECT | 22 | .Nm i2d_ASN1_OBJECT , |
23 | .Nm OBJ_get0_data , | ||
24 | .Nm OBJ_length | ||
23 | .Nd decode and encode ASN.1 object identifiers | 25 | .Nd decode and encode ASN.1 object identifiers |
24 | .Sh SYNOPSIS | 26 | .Sh SYNOPSIS |
25 | .In openssl/asn1.h | 27 | .In openssl/asn1.h |
@@ -34,6 +36,11 @@ | |||
34 | .Fa "const ASN1_OBJECT *val_in" | 36 | .Fa "const ASN1_OBJECT *val_in" |
35 | .Fa "unsigned char **der_out" | 37 | .Fa "unsigned char **der_out" |
36 | .Fc | 38 | .Fc |
39 | .In openssl/objects.h | ||
40 | .Ft const unsigned char * | ||
41 | .Fn OBJ_get0_data "const ASN1_OBJECT *val_in" | ||
42 | .Ft size_t | ||
43 | .Fn OBJ_length "const ASN1_OBJECT *val_in" | ||
37 | .Sh DESCRIPTION | 44 | .Sh DESCRIPTION |
38 | These functions decode and encode ASN.1 object identifiers. | 45 | These functions decode and encode ASN.1 object identifiers. |
39 | For details about the semantics, examples, caveats, and bugs, see | 46 | For details about the semantics, examples, caveats, and bugs, see |
@@ -60,6 +67,16 @@ and the data contained in them are always marked as dynamically | |||
60 | allocated, so when they are no longer needed, | 67 | allocated, so when they are no longer needed, |
61 | .Xr ASN1_OBJECT_free 3 | 68 | .Xr ASN1_OBJECT_free 3 |
62 | can be called on them. | 69 | can be called on them. |
70 | .Pp | ||
71 | .Fn i2d_ASN1_OBJECT | ||
72 | encodes the object identifier pointed to by | ||
73 | .Fa val_in | ||
74 | into DER format. | ||
75 | .Fn OBJ_get0_data | ||
76 | and | ||
77 | .Fn OBJ_length | ||
78 | only deal with the content octets of that DER encoding, | ||
79 | without taking the identifier and length octets into account. | ||
63 | .Sh RETURN VALUES | 80 | .Sh RETURN VALUES |
64 | .Fn d2i_ASN1_OBJECT | 81 | .Fn d2i_ASN1_OBJECT |
65 | returns a pointer to the new | 82 | returns a pointer to the new |
@@ -71,12 +88,38 @@ With other implementations, it might return a pointer to the reused | |||
71 | .Vt ASN1_OBJECT . | 88 | .Vt ASN1_OBJECT . |
72 | .Pp | 89 | .Pp |
73 | .Fn i2d_ASN1_OBJECT | 90 | .Fn i2d_ASN1_OBJECT |
74 | returns the number of bytes successfully encoded | 91 | returns the number of octets successfully encoded |
75 | or a value <= 0 if an error occurs. | 92 | or a value <= 0 if an error occurs. |
93 | .Pp | ||
94 | .Fn OBJ_get0_data | ||
95 | returns an internal pointer to the first content octet of the DER | ||
96 | encoding of | ||
97 | .Fa val_in . | ||
98 | The other content octets follow the returned pointer contiguously. | ||
99 | .Fn OBJ_length | ||
100 | returns the number of content octets contained in the DER encoding of | ||
101 | .Fa val_in . | ||
102 | This number is always smaller than the total length of the encoding | ||
103 | returned by | ||
104 | .Xr ASN1_object_size 3 . | ||
105 | .Pp | ||
106 | If | ||
107 | .Fa val_in | ||
108 | is a | ||
109 | .Dv NULL | ||
110 | pointer or points to an empty object, for example one freshly created with | ||
111 | .Xr ASN1_OBJECT_new 3 , | ||
112 | .Fn OBJ_get0_data | ||
113 | returns | ||
114 | .Dv NULL | ||
115 | and | ||
116 | .Fn OBJ_length | ||
117 | returns zero. | ||
76 | .Sh SEE ALSO | 118 | .Sh SEE ALSO |
77 | .Xr a2d_ASN1_OBJECT 3 , | 119 | .Xr a2d_ASN1_OBJECT 3 , |
78 | .Xr ASN1_item_d2i 3 , | 120 | .Xr ASN1_item_d2i 3 , |
79 | .Xr ASN1_OBJECT_new 3 , | 121 | .Xr ASN1_OBJECT_new 3 , |
122 | .Xr ASN1_put_object 3 , | ||
80 | .Xr OBJ_nid2obj 3 | 123 | .Xr OBJ_nid2obj 3 |
81 | .Sh STANDARDS | 124 | .Sh STANDARDS |
82 | ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: | 125 | ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: |
@@ -90,6 +133,12 @@ and | |||
90 | .Fn i2d_ASN1_OBJECT | 133 | .Fn i2d_ASN1_OBJECT |
91 | first appeared in SSLeay 0.5.1 and have been available since | 134 | first appeared in SSLeay 0.5.1 and have been available since |
92 | .Ox 2.4 . | 135 | .Ox 2.4 . |
136 | .Pp | ||
137 | .Fn OBJ_get0_data | ||
138 | and | ||
139 | .Fn OBJ_length | ||
140 | first appeared in OpenSSL 1.1.0 and have been available since | ||
141 | .Ox 7.1 . | ||
93 | .Sh CAVEATS | 142 | .Sh CAVEATS |
94 | .Fn d2i_ASN1_OBJECT | 143 | .Fn d2i_ASN1_OBJECT |
95 | never sets the long and short names of the object, not even if the | 144 | never sets the long and short names of the object, not even if the |
@@ -102,3 +151,14 @@ on the returned object, and then | |||
102 | and | 151 | and |
103 | .Xr OBJ_nid2ln 3 | 152 | .Xr OBJ_nid2ln 3 |
104 | on the result. | 153 | on the result. |
154 | .Pp | ||
155 | Calling | ||
156 | .Fn OBJ_get0_data | ||
157 | and then accessing memory in front of the returned pointer | ||
158 | results in undefined behaviour. | ||
159 | In particular, it is not possible to find the identifier or | ||
160 | length octets in that way; use | ||
161 | .Xr ASN1_put_object 3 | ||
162 | or | ||
163 | .Fn i2d_ASN1_OBJECT | ||
164 | instead. | ||