summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2021-11-28 15:48:12 +0000
committerschwarze <>2021-11-28 15:48:12 +0000
commit1c03917613c5125002c20148a9e7e605fae25a88 (patch)
treebe93760671c476aae57db4bc8fe64cf8f19a132d /src
parent605140abba3f3cf7d75a973d12c26060733fa516 (diff)
downloadopenbsd-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.370
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
40begins writing the BER encoding of an arbitrary ASN.1 data element 47begins 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
82After completing the identifier byte(s), 89After completing the identifier byte(s),
83when using the definite form, the given 90when using the definite form, the given
84.Fa length 91.Fa content_length
85is encoded in one or more bytes as needed. 92is encoded in one or more bytes as needed,
86Otherwise, the special byte 0x80 is written instead and the 93using the long form if and only if the
87.Ar length 94.Fa content_length
95is greater than 127.
96When using the indefinite form,
97the special byte 0x80 is written instead and the
98.Fa content_length
88argument is ignored. 99argument is ignored.
89.Pp 100.Pp
90At the end, 101At the end,
@@ -100,9 +111,30 @@ which writes an end-of-content marker to
100consisting of two NUL bytes, and advances 111consisting of two NUL bytes, and advances
101.Pf * Fa ber_out 112.Pf * Fa ber_out
102by two bytes. 113by two bytes.
114.Pp
115.Fn ASN1_object_size
116calculates the total length in bytes of the BER encoding
117of an ASN.1 data element with the given
118.Fa tag
119and the number of content bytes given by
120.Fa content_length .
121The
122.Fa constructed
123argument has the same meaning as for
124.Fn ASN1_put_object .
125The return value includes the identifier, length, and content bytes.
126If
127.Fa constructed
128is 2, it also includes the end-of-content bytes.
129For the definite form, only the short form is supported if the
130.Fa content_length
131is less than 128.
103.Sh RETURN VALUES 132.Sh RETURN VALUES
104.Fn ASN1_put_eoc 133.Fn ASN1_put_eoc
105returns the number of bytes written, which is always 2. 134returns the number of bytes written, which is always 2.
135.Pp
136.Fn ASN1_object_size
137returns 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
147ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
148Information technology - ASN.1 encoding rules:
149Specification of Basic Encoding Rules (BER), Canonical Encoding
150Rules (CER) and Distinguished Encoding Rules (DER),
151section 8.1: General rules for encoding
114.Sh HISTORY 152.Sh HISTORY
115.Fn ASN1_put_object 153.Fn ASN1_put_object
116first appeared in SSLeay 0.5.1 and has been available since 154and
155.Fn ASN1_object_size
156first 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
120first appeared in OpenSSL 0.9.8 and has been available since 160first 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
123Neither 163None of these functions do any sanity checking.
124.Fn ASN1_put_object
125nor
126.Fn ASN1_put_eoc
127do any sanity checking.
128When called in inconsistent ways, invalid content may result in 164When called in inconsistent ways, invalid content may result in
129.Pf * Fa ber_out , 165.Pf * Fa ber_out ,
130for example 166for example
@@ -156,12 +192,12 @@ etc. without the
156bit set 192bit set
157.It 193.It
158a 194a
159.Fa length 195.Fa content_length
160that makes no sense for the given 196that makes no sense for the given
161.Fa tag 197.Fa tag
162.It 198.It
163a 199a
164.Fa length 200.Fa content_length
165that disagrees with the following data 201that disagrees with the following data
166.It 202.It
167a 203a