ASN1_TYPE documentation.
[openssl.git] / doc / crypto / ASN1_TYPE_get.pod
1 =pod
2
3 =head1 NAME
4
5 ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp - ASN1_TYPE utility
6 functions
7
8 =head1 SYNOPSIS
9
10  #include <openssl/asn1.h>
11
12  int ASN1_TYPE_get(ASN1_TYPE *a);
13  void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
14  int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
15  int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
16
17 =head1 DESCRIPTION
18
19 These functions allow an ASN1_TYPE structure to be manipulated. The
20 ASN1_TYPE structure can contain any ASN.1 type or constructed type
21 such as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type.
22
23 ASN1_TYPE_get() returns the type of B<a>.
24
25 ASN1_TYPE_set() sets the value of B<a> to B<type> and B<value>. This
26 function uses the pointer B<value> internally so it must B<not> be freed
27 up after the call.
28
29 ASN1_TYPE_set1() sets the value of B<a> to B<type> a copy of B<value>.
30
31 ASN1_TYPE_cmp() compares ASN.1 types B<a> and B<b> and returns 0 if
32 they are identical and non-zero otherwise.
33
34 =head1 NOTES
35
36 The type and meaning of the B<value> parameter for ASN1_TYPE_set() and
37 ASN1_TYPE_set1() is determined by the B<type> parameter.
38 If B<type> is V_ASN1_NULL B<value> is ignored. If B<type> is V_ASN1_BOOLEAN
39 then the boolean is set to TRUE if B<value> is not NULL. If B<type> is
40 V_ASN1_OBJECT then value is an ASN1_OBJECT structure. Otherwise B<type>
41 is and ASN1_STRING structure. If B<type> corresponds to a primitive type
42 (or a string type) then the contents of the ASN1_STRING contain the content
43 octets of the type. If B<type> corresponds to a constructed type or
44 a tagged type (V_ASN1_SEQUENCE, V_ASN1_SET or V_ASN1_OTHER) then the
45 ASN1_STRING contains the entire ASN.1 encoding verbatim (including tag and
46 length octets).
47
48 ASN1_TYPE_cmp() may not return zero if two types are equivalent but have
49 different encodings. For example the single content octet of the boolean TRUE
50 value under BER can have any non-zero encoding but ASN1_TYPE_cmp() will
51 only return zero if the values are the same.
52
53 If either or both of the parameters passed to ASN1_TYPE_cmp() is NULL the
54 return value is non-zero. Technically if both parameters are NULL the two
55 types could be absent OPTIONAL fields and so should match, however passing
56 NULL values could also indicate a programming error (for example an
57 unparseable type which returns NULL) for types which do B<not> match. So
58 applications should handle the case of two absent values separately.
59
60 =head1 RETURN VALUES
61
62 ASN1_TYPE_get() returns the type of the ASN1_TYPE argument.
63
64 ASN1_TYPE_set() does not return a value.
65
66 ASN1_TYPE_set1() returns 1 for sucess and 0 for failure.
67
68 ASN1_TYPE_cmp() returns 0 if the types are identical and non-zero otherwise.
69
70 =cut