1ASN1_STRING_LENGTH(3ossl)           OpenSSL          ASN1_STRING_LENGTH(3ossl)
2
3
4

NAME

6       ASN1_STRING_dup, ASN1_STRING_cmp, ASN1_STRING_set, ASN1_STRING_length,
7       ASN1_STRING_type, ASN1_STRING_get0_data, ASN1_STRING_data,
8       ASN1_STRING_to_UTF8 - ASN1_STRING utility functions
9

SYNOPSIS

11        #include <openssl/asn1.h>
12
13        int ASN1_STRING_length(ASN1_STRING *x);
14        const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);
15        unsigned char *ASN1_STRING_data(ASN1_STRING *x);
16
17        ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);
18
19        int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
20
21        int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
22
23        int ASN1_STRING_type(const ASN1_STRING *x);
24
25        int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);
26

DESCRIPTION

28       These functions allow an ASN1_STRING structure to be manipulated.
29
30       ASN1_STRING_length() returns the length of the content of x.
31
32       ASN1_STRING_get0_data() returns an internal pointer to the data of x.
33       Since this is an internal pointer it should not be freed or modified in
34       any way.
35
36       ASN1_STRING_data() is similar to ASN1_STRING_get0_data() except the
37       returned value is not constant. This function is deprecated:
38       applications should use ASN1_STRING_get0_data() instead.
39
40       ASN1_STRING_dup() returns a copy of the structure a.
41
42       ASN1_STRING_cmp() compares a and b returning 0 if the two are
43       identical. The string types and content are compared.
44
45       ASN1_STRING_set() sets the data of string str to the buffer data or
46       length len. The supplied data is copied. If len is -1 then the length
47       is determined by strlen(data).
48
49       ASN1_STRING_type() returns the type of x, using standard constants such
50       as V_ASN1_OCTET_STRING.
51
52       ASN1_STRING_to_UTF8() converts the string in to UTF8 format, the
53       converted data is allocated in a buffer in *out. The length of out is
54       returned or a negative error code. The buffer *out should be freed
55       using OPENSSL_free().
56

NOTES

58       Almost all ASN1 types in OpenSSL are represented as an ASN1_STRING
59       structure. Other types such as ASN1_OCTET_STRING are simply typedef'ed
60       to ASN1_STRING and the functions call the ASN1_STRING equivalents.
61       ASN1_STRING is also used for some CHOICE types which consist entirely
62       of primitive string types such as DirectoryString and Time.
63
64       These functions should not be used to examine or modify ASN1_INTEGER or
65       ASN1_ENUMERATED types: the relevant INTEGER or ENUMERATED utility
66       functions should be used instead.
67
68       In general it cannot be assumed that the data returned by
69       ASN1_STRING_data() is null terminated or does not contain embedded
70       nulls. The actual format of the data will depend on the actual string
71       type itself: for example for an IA5String the data will be ASCII, for a
72       BMPString two bytes per character in big endian format, and for a
73       UTF8String it will be in UTF8 format.
74
75       Similar care should be take to ensure the data is in the correct format
76       when calling ASN1_STRING_set().
77

RETURN VALUES

79       ASN1_STRING_length() returns the length of the content of x.
80
81       ASN1_STRING_get0_data() and ASN1_STRING_data() return an internal
82       pointer to the data of x.
83
84       ASN1_STRING_dup() returns a valid ASN1_STRING structure or NULL if an
85       error occurred.
86
87       ASN1_STRING_cmp() returns an integer greater than, equal to, or less
88       than 0, according to whether a is greater than, equal to, or less than
89       b.
90
91       ASN1_STRING_set() returns 1 on success or 0 on error.
92
93       ASN1_STRING_type() returns the type of x.
94
95       ASN1_STRING_to_UTF8() returns the number of bytes in output string out
96       or a negative value if an error occurred.
97

SEE ALSO

99       ERR_get_error(3)
100
102       Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
103
104       Licensed under the Apache License 2.0 (the "License").  You may not use
105       this file except in compliance with the License.  You can obtain a copy
106       in the file LICENSE in the source distribution or at
107       <https://www.openssl.org/source/license.html>.
108
109
110
1113.0.9                             2023-07-27         ASN1_STRING_LENGTH(3ossl)
Impressum