1ASN1_STRING_length(3)               OpenSSL              ASN1_STRING_length(3)
2
3
4

NAME

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

SYNOPSIS

11        int ASN1_STRING_length(ASN1_STRING *x);
12        unsigned char * ASN1_STRING_data(ASN1_STRING *x);
13
14        ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a);
15
16        int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
17
18        int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
19
20        int ASN1_STRING_type(ASN1_STRING *x);
21
22        int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
23

DESCRIPTION

25       These functions allow an ASN1_STRING structure to be manipulated.
26
27       ASN1_STRING_length() returns the length of the content of x.
28
29       ASN1_STRING_data() returns an internal pointer to the data of x.  Since
30       this is an internal pointer it should not be freed or modified in any
31       way.
32
33       ASN1_STRING_dup() returns a copy of the structure a.
34
35       ASN1_STRING_cmp() compares a and b returning 0 if the two are identi‐
36       cal. The string types and content are compared.
37
38       ASN1_STRING_set() sets the data of string str to the buffer data or
39       length len. The supplied data is copied. If len is -1 then the length
40       is determined by strlen(data).
41
42       ASN1_STRING_type() returns the type of x, using standard constants such
43       as V_ASN1_OCTET_STRING.
44
45       ASN1_STRING_to_UTF8() converts the string in to UTF8 format, the con‐
46       verted data is allocated in a buffer in *out. The length of out is
47       returned or a negative error code. The buffer *out should be free using
48       OPENSSL_free().
49

NOTES

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

RETURN VALUES

SEE ALSO

73       ERR_get_error(3)
74

HISTORY

760.9.8b                            2002-10-20             ASN1_STRING_length(3)
Impressum