-.\" $OpenBSD: ASN1_TYPE_get.3,v 1.13 2021/11/21 15:11:01 schwarze Exp $
+.\" $OpenBSD: ASN1_TYPE_get.3,v 1.14 2021/11/23 14:58:08 schwarze Exp $
.\" OpenSSL 99d63d46 Mon Jun 6 00:43:05 2016 -0400
.\"
.\" This file is a derived work.
.\" The changes are covered by the following Copyright and license:
.\"
-.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: November 21 2021 $
+.Dd $Mdocdate: November 23 2021 $
.Dt ASN1_TYPE_GET 3
.Os
.Sh NAME
.Nm ASN1_TYPE_get ,
.Nm ASN1_TYPE_set ,
.Nm ASN1_TYPE_set1 ,
+.Nm ASN1_TYPE_set_octetstring ,
+.Nm ASN1_TYPE_get_octetstring ,
.Nm ASN1_TYPE_cmp
.Nd ASN.1 objects of arbitrary type
.Sh SYNOPSIS
.Fa "const void *value"
.Fc
.Ft int
+.Fo ASN1_TYPE_set_octetstring
+.Fa "ASN1_TYPE *a"
+.Fa "const unsigned char *data"
+.Fa "int len"
+.Fc
+.Ft int
+.Fo ASN1_TYPE_get_octetstring
+.Fa "const ASN1_TYPE *a"
+.Fa "unsigned char *buffer"
+.Fa "int buflen"
+.Fc
+.Ft int
.Fo ASN1_TYPE_cmp
.Fa "const ASN1_TYPE *a"
.Fa "const ASN1_TYPE *b"
contains the entire ASN.1 encoding verbatim, including tag and
length octets.
.Pp
+.Fn ASN1_TYPE_set_octetstring
+allocates a new
+.Vt ASN1_OCTET_STRING
+object, copies
+.Fa len
+bytes of
+.Fa data
+into it using
+.Xr ASN1_STRING_set 3 ,
+and replaces the value of
+.Fa a
+with it by calling
+.Fn ASN1_TYPE_set
+with a type of
+.Dv V_ASN1_OCTET_STRING .
+.Pp
+.Fn ASN1_TYPE_get_octetstring
+copies the contents of the
+.Vt ASN1_OCTET_STRING
+object contained in
+.Fa a ,
+but not more than
+.Fa buflen
+bytes, into the
+.Fa buffer
+provided by the caller.
+.Pp
.Fn ASN1_TYPE_cmp
checks that
.Fa a
.Fn ASN1_TYPE_new .
.Pp
.Fn ASN1_TYPE_set1
-returns 1 if the copying succeeds or 0 if it fails.
+and
+.Fn ASN1_TYPE_set_octetstring
+return 1 if the copying succeeds or 0 if it fails.
+.Pp
+.Fn ASN1_TYPE_get_octetstring
+returns the number of data bytes contained in the
+.Vt ASN1_OCTET_STRING
+object contained in
+.Fa a
+or \-1 if
+.Fa a
+is not of the type
+.Dv V_ASN1_OCTET_STRING
+or does not contain any object.
+If the return value is greater than the
+.Fa buflen
+argument, the content was truncated when copied to the
+.Fa buffer .
.Pp
.Fn ASN1_TYPE_cmp
returns 0 for a match or non-zero for a mismatch.
.Fn ASN1_TYPE_get
and
.Fn ASN1_TYPE_set
-first appeared in SSLeay 0.8.0.
+in SSLeay 0.8.0, and
+.Fn ASN1_TYPE_set_octetstring
+and
+.Fn ASN1_TYPE_get_octetstring
+in SSLeay 0.9.0.
These functions have been available since
.Ox 2.4 .
.Pp