diff options
author | schwarze <> | 2021-11-28 15:48:12 +0000 |
---|---|---|
committer | schwarze <> | 2021-11-28 15:48:12 +0000 |
commit | 1c03917613c5125002c20148a9e7e605fae25a88 (patch) | |
tree | be93760671c476aae57db4bc8fe64cf8f19a132d /src | |
parent | 605140abba3f3cf7d75a973d12c26060733fa516 (diff) | |
download | openbsd-1c03917613c5125002c20148a9e7e605fae25a88.tar.gz openbsd-1c03917613c5125002c20148a9e7e605fae25a88.tar.bz2 openbsd-1c03917613c5125002c20148a9e7e605fae25a88.zip |
Document ASN1_object_size(3).
While here,
* call the function arguments "content_length" rather than just
"length" to make it less likely that the reader confuses them with
the total length returned by ASN1_object_size(3);
* state that only the short form is supported for content_length <= 127;
* add the missing STANDARDS section.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/man/ASN1_put_object.3 | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/src/lib/libcrypto/man/ASN1_put_object.3 b/src/lib/libcrypto/man/ASN1_put_object.3 index e69550f0d2..843838143b 100644 --- a/src/lib/libcrypto/man/ASN1_put_object.3 +++ b/src/lib/libcrypto/man/ASN1_put_object.3 | |||
@@ -1,6 +1,6 @@ | |||
1 | .\" $OpenBSD: ASN1_put_object.3,v 1.2 2021/11/21 15:11:01 schwarze Exp $ | 1 | .\" $OpenBSD: ASN1_put_object.3,v 1.3 2021/11/28 15:48:12 schwarze Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2019, 2021 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,13 @@ | |||
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: November 21 2021 $ | 17 | .Dd $Mdocdate: November 28 2021 $ |
18 | .Dt ASN1_PUT_OBJECT 3 | 18 | .Dt ASN1_PUT_OBJECT 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
21 | .Nm ASN1_put_object , | 21 | .Nm ASN1_put_object , |
22 | .Nm ASN1_put_eoc | 22 | .Nm ASN1_put_eoc , |
23 | .Nm ASN1_object_size | ||
23 | .Nd start and end the BER encoding of an arbitrary ASN.1 data element | 24 | .Nd start and end the BER encoding of an arbitrary ASN.1 data element |
24 | .Sh SYNOPSIS | 25 | .Sh SYNOPSIS |
25 | .In openssl/asn1.h | 26 | .In openssl/asn1.h |
@@ -27,7 +28,7 @@ | |||
27 | .Fo ASN1_put_object | 28 | .Fo ASN1_put_object |
28 | .Fa "unsigned char **ber_out" | 29 | .Fa "unsigned char **ber_out" |
29 | .Fa "int constructed" | 30 | .Fa "int constructed" |
30 | .Fa "int length" | 31 | .Fa "int content_length" |
31 | .Fa "int tag" | 32 | .Fa "int tag" |
32 | .Fa "int class" | 33 | .Fa "int class" |
33 | .Fc | 34 | .Fc |
@@ -35,6 +36,12 @@ | |||
35 | .Fo ASN1_put_eoc | 36 | .Fo ASN1_put_eoc |
36 | .Fa "unsigned char **ber_out" | 37 | .Fa "unsigned char **ber_out" |
37 | .Fc | 38 | .Fc |
39 | .Ft int | ||
40 | .Fo ASN1_object_size | ||
41 | .Fa "int constructed" | ||
42 | .Fa "int content_length" | ||
43 | .Fa "int tag" | ||
44 | .Fc | ||
38 | .Sh DESCRIPTION | 45 | .Sh DESCRIPTION |
39 | .Fn ASN1_put_object | 46 | .Fn ASN1_put_object |
40 | begins writing the BER encoding of an arbitrary ASN.1 data element | 47 | begins writing the BER encoding of an arbitrary ASN.1 data element |
@@ -81,10 +88,14 @@ is encoded in one or more following identifier bytes as needed. | |||
81 | .Pp | 88 | .Pp |
82 | After completing the identifier byte(s), | 89 | After completing the identifier byte(s), |
83 | when using the definite form, the given | 90 | when using the definite form, the given |
84 | .Fa length | 91 | .Fa content_length |
85 | is encoded in one or more bytes as needed. | 92 | is encoded in one or more bytes as needed, |
86 | Otherwise, the special byte 0x80 is written instead and the | 93 | using the long form if and only if the |
87 | .Ar length | 94 | .Fa content_length |
95 | is greater than 127. | ||
96 | When using the indefinite form, | ||
97 | the special byte 0x80 is written instead and the | ||
98 | .Fa content_length | ||
88 | argument is ignored. | 99 | argument is ignored. |
89 | .Pp | 100 | .Pp |
90 | At the end, | 101 | At the end, |
@@ -100,9 +111,30 @@ which writes an end-of-content marker to | |||
100 | consisting of two NUL bytes, and advances | 111 | consisting of two NUL bytes, and advances |
101 | .Pf * Fa ber_out | 112 | .Pf * Fa ber_out |
102 | by two bytes. | 113 | by two bytes. |
114 | .Pp | ||
115 | .Fn ASN1_object_size | ||
116 | calculates the total length in bytes of the BER encoding | ||
117 | of an ASN.1 data element with the given | ||
118 | .Fa tag | ||
119 | and the number of content bytes given by | ||
120 | .Fa content_length . | ||
121 | The | ||
122 | .Fa constructed | ||
123 | argument has the same meaning as for | ||
124 | .Fn ASN1_put_object . | ||
125 | The return value includes the identifier, length, and content bytes. | ||
126 | If | ||
127 | .Fa constructed | ||
128 | is 2, it also includes the end-of-content bytes. | ||
129 | For the definite form, only the short form is supported if the | ||
130 | .Fa content_length | ||
131 | is less than 128. | ||
103 | .Sh RETURN VALUES | 132 | .Sh RETURN VALUES |
104 | .Fn ASN1_put_eoc | 133 | .Fn ASN1_put_eoc |
105 | returns the number of bytes written, which is always 2. | 134 | returns the number of bytes written, which is always 2. |
135 | .Pp | ||
136 | .Fn ASN1_object_size | ||
137 | returns the total number of bytes in the encoding of the data element. | ||
106 | .Sh SEE ALSO | 138 | .Sh SEE ALSO |
107 | .Xr ASN1_item_i2d 3 , | 139 | .Xr ASN1_item_i2d 3 , |
108 | .Xr ASN1_TYPE_get 3 , | 140 | .Xr ASN1_TYPE_get 3 , |
@@ -111,20 +143,24 @@ returns the number of bytes written, which is always 2. | |||
111 | .Xr i2d_ASN1_OBJECT 3 , | 143 | .Xr i2d_ASN1_OBJECT 3 , |
112 | .Xr i2d_ASN1_OCTET_STRING 3 , | 144 | .Xr i2d_ASN1_OCTET_STRING 3 , |
113 | .Xr i2d_ASN1_SEQUENCE_ANY 3 | 145 | .Xr i2d_ASN1_SEQUENCE_ANY 3 |
146 | .Sh STANDARDS | ||
147 | ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: | ||
148 | Information technology - ASN.1 encoding rules: | ||
149 | Specification of Basic Encoding Rules (BER), Canonical Encoding | ||
150 | Rules (CER) and Distinguished Encoding Rules (DER), | ||
151 | section 8.1: General rules for encoding | ||
114 | .Sh HISTORY | 152 | .Sh HISTORY |
115 | .Fn ASN1_put_object | 153 | .Fn ASN1_put_object |
116 | first appeared in SSLeay 0.5.1 and has been available since | 154 | and |
155 | .Fn ASN1_object_size | ||
156 | first appeared in SSLeay 0.5.1 and have been available since | ||
117 | .Ox 2.4 . | 157 | .Ox 2.4 . |
118 | .Pp | 158 | .Pp |
119 | .Fn ASN1_put_eoc | 159 | .Fn ASN1_put_eoc |
120 | first appeared in OpenSSL 0.9.8 and has been available since | 160 | first appeared in OpenSSL 0.9.8 and has been available since |
121 | .Ox 4.5 . | 161 | .Ox 4.5 . |
122 | .Sh CAVEATS | 162 | .Sh CAVEATS |
123 | Neither | 163 | None of these functions do any sanity checking. |
124 | .Fn ASN1_put_object | ||
125 | nor | ||
126 | .Fn ASN1_put_eoc | ||
127 | do any sanity checking. | ||
128 | When called in inconsistent ways, invalid content may result in | 164 | When called in inconsistent ways, invalid content may result in |
129 | .Pf * Fa ber_out , | 165 | .Pf * Fa ber_out , |
130 | for example | 166 | for example |
@@ -156,12 +192,12 @@ etc. without the | |||
156 | bit set | 192 | bit set |
157 | .It | 193 | .It |
158 | a | 194 | a |
159 | .Fa length | 195 | .Fa content_length |
160 | that makes no sense for the given | 196 | that makes no sense for the given |
161 | .Fa tag | 197 | .Fa tag |
162 | .It | 198 | .It |
163 | a | 199 | a |
164 | .Fa length | 200 | .Fa content_length |
165 | that disagrees with the following data | 201 | that disagrees with the following data |
166 | .It | 202 | .It |
167 | a | 203 | a |