summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-12-15 15:29:23 +0000
committerschwarze <>2021-12-15 15:29:23 +0000
commit9aa720b0f4385bdd0bb932d2fff4cb3ae60b9379 (patch)
tree3a1eb6d1b9d87f41cb15085e8946c4c07b74ad4b
parente038fe56a36f216a765dae4937dac485a99e831e (diff)
downloadopenbsd-9aa720b0f4385bdd0bb932d2fff4cb3ae60b9379.tar.gz
openbsd-9aa720b0f4385bdd0bb932d2fff4cb3ae60b9379.tar.bz2
openbsd-9aa720b0f4385bdd0bb932d2fff4cb3ae60b9379.zip
Document i2c_ASN1_INTEGER(3).
While it was probably a mistake that steve@ made some i2c_*() and c2i_*() functions public back in 2000 and while we would like to delete them from the API, it may not be possible to delete this particular function because in contrast to the others (which are already marked as intentionally undocumented), this one is used by various real-world software, so for now, explain what it does, just in case people find it in existing code. While here, use the familiar term "byte" that we generally use throughout all our manual pages, even though the ASN.1 standard uses the term "octet" instead, which is more precise only in theory.
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.353
1 files changed, 46 insertions, 7 deletions
diff --git a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3 b/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
index b6c62106b7..faccbe6ad9 100644
--- a/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
+++ b/src/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.15 2021/12/14 20:14:22 schwarze Exp $ 1.\" $OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.16 2021/12/15 15:29:23 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
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: December 14 2021 $ 17.Dd $Mdocdate: December 15 2021 $
18.Dt D2I_ASN1_OCTET_STRING 3 18.Dt D2I_ASN1_OCTET_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -24,6 +24,7 @@
24.Nm i2d_ASN1_BIT_STRING , 24.Nm i2d_ASN1_BIT_STRING ,
25.Nm d2i_ASN1_INTEGER , 25.Nm d2i_ASN1_INTEGER ,
26.Nm i2d_ASN1_INTEGER , 26.Nm i2d_ASN1_INTEGER ,
27.Nm i2c_ASN1_INTEGER ,
27.Nm d2i_ASN1_UINTEGER , 28.Nm d2i_ASN1_UINTEGER ,
28.Nm d2i_ASN1_ENUMERATED , 29.Nm d2i_ASN1_ENUMERATED ,
29.Nm i2d_ASN1_ENUMERATED , 30.Nm i2d_ASN1_ENUMERATED ,
@@ -94,6 +95,11 @@
94.Fa "ASN1_INTEGER *val_in" 95.Fa "ASN1_INTEGER *val_in"
95.Fa "unsigned char **der_out" 96.Fa "unsigned char **der_out"
96.Fc 97.Fc
98.Ft int
99.Fo i2c_ASN1_INTEGER
100.Fa "ASN1_INTEGER *val_in"
101.Fa "unsigned char **der_out"
102.Fc
97.Ft ASN1_INTEGER * 103.Ft ASN1_INTEGER *
98.Fo d2i_ASN1_UINTEGER 104.Fo d2i_ASN1_UINTEGER
99.Fa "ASN1_INTEGER **val_out" 105.Fa "ASN1_INTEGER **val_out"
@@ -273,10 +279,9 @@ objects.
273For details about the semantics, examples, caveats, and bugs, see 279For details about the semantics, examples, caveats, and bugs, see
274.Xr ASN1_item_d2i 3 . 280.Xr ASN1_item_d2i 3 .
275.Pp 281.Pp
276The format consists of one identifier octet, 282The format consists of one identifier byte, one or more length bytes,
277one or more length octets, 283and one or more content bytes.
278and one or more content octets. 284The identifier bytes and corresponding ASN.1 types are as follows:
279The identifier octets and corresponding ASN.1 types are as follows:
280.Bl -column ASN1_GENERALIZEDTIME identifier 285.Bl -column ASN1_GENERALIZEDTIME identifier
281.It Em OpenSSL type Ta Em identifier Ta Em ASN.1 type 286.It Em OpenSSL type Ta Em identifier Ta Em ASN.1 type
282.It Ta 287.It Ta
@@ -296,6 +301,27 @@ The identifier octets and corresponding ASN.1 types are as follows:
296.It Vt ASN1_UTCTIME Ta 0x17 Ta UTCTime 301.It Vt ASN1_UTCTIME Ta 0x17 Ta UTCTime
297.El 302.El
298.Pp 303.Pp
304.Fn i2c_ASN1_INTEGER
305writes only the content bytes of
306.Fa val_in
307to
308.Pf * Fa der_out
309and advances
310.Pf * Fa der_out
311to the byte after the last one written.
312The identifier and content length bytes are not written.
313It is the responsibility of the caller to make sure that the buffer
314pointed to by
315.Pf * Fa der_out
316is long enough, such that no buffer overflow can occur.
317This function does not support automatic memory allocation.
318If
319.Fa der_out
320is a
321.Dv NULL
322pointer, the function only calculates the number of content bytes
323that would be written, without writing them anywhere.
324.Pp
299.Fn d2i_DIRECTORYSTRING 325.Fn d2i_DIRECTORYSTRING
300and 326and
301.Fn i2d_DIRECTORYSTRING 327.Fn i2d_DIRECTORYSTRING
@@ -320,7 +346,7 @@ and
320.Fn i2d_DIRECTORYSTRING 346.Fn i2d_DIRECTORYSTRING
321that also accept IA5String, NumericString, BIT STRING, and SEQUENCE 347that also accept IA5String, NumericString, BIT STRING, and SEQUENCE
322ASN.1 values as well as ASN.1 values with unknown identifier 348ASN.1 values as well as ASN.1 values with unknown identifier
323octets (0x07, 0x08, 0x09, 0x0b, 0x0d, 0x0e, 0x0f, 0x1d, and 0x1f). 349bytes (0x07, 0x08, 0x09, 0x0b, 0x0d, 0x0e, 0x0f, 0x1d, and 0x1f).
324Even though the standard requires the use of 350Even though the standard requires the use of
325.Vt DirectoryString 351.Vt DirectoryString
326in the relative distinguished names described in 352in the relative distinguished names described in
@@ -392,6 +418,15 @@ The
392.Fn i2d_* 418.Fn i2d_*
393encoding functions return the number of bytes successfully encoded 419encoding functions return the number of bytes successfully encoded
394or a negative value if an error occurs. 420or a negative value if an error occurs.
421.Pp
422.Fn i2c_ASN1_INTEGER
423returns the number of content bytes that were or would be written or 0 if
424.Fa val_in
425is a
426.Dv NULL
427pointer or if its
428.Xr ASN1_STRING_length 3
429is negative.
395.Sh SEE ALSO 430.Sh SEE ALSO
396.Xr ASN1_item_d2i 3 , 431.Xr ASN1_item_d2i 3 ,
397.Xr ASN1_STRING_new 3 432.Xr ASN1_STRING_new 3
@@ -449,6 +484,10 @@ first appeared in OpenSSL 0.9.3.
449These functions have been available since 484These functions have been available since
450.Ox 2.6 . 485.Ox 2.6 .
451.Pp 486.Pp
487.Fn i2c_ASN1_INTEGER
488first appeared in OpenSSL 0.9.6 and has been available since
489.Ox 2.9 .
490.Pp
452.Fn d2i_ASN1_UNIVERSALSTRING , 491.Fn d2i_ASN1_UNIVERSALSTRING ,
453.Fn i2d_ASN1_UNIVERSALSTRING , 492.Fn i2d_ASN1_UNIVERSALSTRING ,
454.Fn d2i_ASN1_GENERALSTRING , 493.Fn d2i_ASN1_GENERALSTRING ,