1ASN1_TYPE_GET(3)                    OpenSSL                   ASN1_TYPE_GET(3)
2
3
4

NAME

6       ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp,
7       ASN1_TYPE_unpack_sequence, ASN1_TYPE_pack_sequence - ASN1_TYPE utility
8       functions
9

SYNOPSIS

11        #include <openssl/asn1.h>
12
13        int ASN1_TYPE_get(const ASN1_TYPE *a);
14        void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
15        int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
16        int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
17
18        void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
19        ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s,
20                                           ASN1_TYPE **t);
21

DESCRIPTION

23       These functions allow an ASN1_TYPE structure to be manipulated. The
24       ASN1_TYPE structure can contain any ASN.1 type or constructed type such
25       as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type.
26
27       ASN1_TYPE_get() returns the type of a.
28
29       ASN1_TYPE_set() sets the value of a to type and value. This function
30       uses the pointer value internally so it must not be freed up after the
31       call.
32
33       ASN1_TYPE_set1() sets the value of a to type a copy of value.
34
35       ASN1_TYPE_cmp() compares ASN.1 types a and b and returns 0 if they are
36       identical and nonzero otherwise.
37
38       ASN1_TYPE_unpack_sequence() attempts to parse the SEQUENCE present in t
39       using the ASN.1 structure it. If successful it returns a pointer to the
40       ASN.1 structure corresponding to it which must be freed by the caller.
41       If it fails it return NULL.
42
43       ASN1_TYPE_pack_sequence() attempts to encode the ASN.1 structure s
44       corresponding to it into an ASN1_TYPE. If successful the encoded
45       ASN1_TYPE is returned. If t and *t are not NULL the encoded type is
46       written to t overwriting any existing data. If t is not NULL but *t is
47       NULL the returned ASN1_TYPE is written to *t.
48

NOTES

50       The type and meaning of the value parameter for ASN1_TYPE_set() and
51       ASN1_TYPE_set1() is determined by the type parameter.  If type is
52       V_ASN1_NULL value is ignored. If type is V_ASN1_BOOLEAN then the
53       boolean is set to TRUE if value is not NULL. If type is V_ASN1_OBJECT
54       then value is an ASN1_OBJECT structure. Otherwise type is and
55       ASN1_STRING structure. If type corresponds to a primitive type (or a
56       string type) then the contents of the ASN1_STRING contain the content
57       octets of the type. If type corresponds to a constructed type or a
58       tagged type (V_ASN1_SEQUENCE, V_ASN1_SET or V_ASN1_OTHER) then the
59       ASN1_STRING contains the entire ASN.1 encoding verbatim (including tag
60       and length octets).
61
62       ASN1_TYPE_cmp() may not return zero if two types are equivalent but
63       have different encodings. For example the single content octet of the
64       boolean TRUE value under BER can have any nonzero encoding but
65       ASN1_TYPE_cmp() will only return zero if the values are the same.
66
67       If either or both of the parameters passed to ASN1_TYPE_cmp() is NULL
68       the return value is nonzero. Technically if both parameters are NULL
69       the two types could be absent OPTIONAL fields and so should match,
70       however, passing NULL values could also indicate a programming error
71       (for example an unparsable type which returns NULL) for types which do
72       not match. So applications should handle the case of two absent values
73       separately.
74

RETURN VALUES

76       ASN1_TYPE_get() returns the type of the ASN1_TYPE argument.
77
78       ASN1_TYPE_set() does not return a value.
79
80       ASN1_TYPE_set1() returns 1 for success and 0 for failure.
81
82       ASN1_TYPE_cmp() returns 0 if the types are identical and nonzero
83       otherwise.
84
85       ASN1_TYPE_unpack_sequence() returns a pointer to an ASN.1 structure or
86       NULL on failure.
87
88       ASN1_TYPE_pack_sequence() return an ASN1_TYPE structure if it succeeds
89       or NULL on failure.
90
92       Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
93
94       Licensed under the OpenSSL license (the "License").  You may not use
95       this file except in compliance with the License.  You can obtain a copy
96       in the file LICENSE in the source distribution or at
97       <https://www.openssl.org/source/license.html>.
98
99
100
1011.1.1q                            2023-02-06                  ASN1_TYPE_GET(3)
Impressum