-.\" $OpenBSD: ASN1_STRING_length.3,v 1.21 2021/10/20 13:14:00 schwarze Exp $
-.\" full merge up to: OpenSSL 4a56d2a3 Feb 25 16:49:27 2018 +0300
+.\" $OpenBSD: ASN1_STRING_length.3,v 1.22 2021/10/25 10:26:21 schwarze Exp $
+.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
.\"
.\" This file is a derived work.
.\" The changes are covered by the following Copyright and license:
.\"
-.\" Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2018, 2019, 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: October 20 2021 $
+.Dd $Mdocdate: October 25 2021 $
.Dt ASN1_STRING_LENGTH 3
.Os
.Sh NAME
.Nm ASN1_STRING_get0_data ,
.Nm ASN1_STRING_length ,
.Nm ASN1_STRING_length_set ,
+.Nm ASN1_STRING_set0 ,
.Nm ASN1_STRING_set ,
.Nm ASN1_OCTET_STRING_set ,
.Nm ASN1_STRING_to_UTF8 ,
.Fa "ASN1_STRING *x"
.Fa "int len"
.Fc
+.Ft void
+.Fo ASN1_STRING_set0
+.Fa "ASN1_STRING *str"
+.Fa "void *data"
+.Fa "int len"
+.Fc
.Ft int
.Fo ASN1_STRING_set
.Fa "ASN1_STRING *str"
.Fa x
into an inconsistent internal state.
.Pp
+.Fn ASN1_STRING_set0
+frees any data stored in
+.Fa str ,
+sets the length attribute to
+.Fa len
+bytes, and sets the data attribute to
+.Fa data ,
+transferring ownership, without doing any validation.
+.Pp
.Fn ASN1_STRING_set
and
.Fn ASN1_OCTET_STRING_set
and copy that number of bytes from
.Fa data
into
-.Fa str .
+.Fa str ,
+overwriting any previous data.
If
.Fa len
is -1, then
.Pp
Similar care should be taken to ensure the data is in the correct format
when calling
-.Fn ASN1_STRING_set .
+.Fn ASN1_STRING_set
+or
+.Fn ASN1_STRING_set0 .
.Sh RETURN VALUES
.Fn ASN1_STRING_cmp
and
first appeared in OpenSSL 0.9.6 and has been available since
.Ox 2.9 .
.Pp
+.Fn ASN1_STRING_set0
+first appeared in OpenSSL 0.9.8h and has been available since
+.Ox 4.5 .
+.Pp
.Fn ASN1_STRING_get0_data
first appeared in OpenSSL 1.1.0 and has been available since
.Ox 6.3 .