Blame doc/man3/ASN1_TYPE_get.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp, ASN1_TYPE_unpack_sequence, ASN1_TYPE_pack_sequence - ASN1_TYPE utility
Packit c4476c
functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/asn1.h>
Packit c4476c
Packit c4476c
 int ASN1_TYPE_get(const ASN1_TYPE *a);
Packit c4476c
 void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
Packit c4476c
 int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
Packit c4476c
 int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
Packit c4476c
Packit c4476c
 void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
Packit c4476c
 ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s,
Packit c4476c
                                    ASN1_TYPE **t);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
These functions allow an ASN1_TYPE structure to be manipulated. The
Packit c4476c
ASN1_TYPE structure can contain any ASN.1 type or constructed type
Packit c4476c
such as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type.
Packit c4476c
Packit c4476c
ASN1_TYPE_get() returns the type of B.
Packit c4476c
Packit c4476c
ASN1_TYPE_set() sets the value of B to B<type> and B<value>. This
Packit c4476c
function uses the pointer B<value> internally so it must B<not> be freed
Packit c4476c
up after the call.
Packit c4476c
Packit c4476c
ASN1_TYPE_set1() sets the value of B to B<type> a copy of B<value>.
Packit c4476c
Packit c4476c
ASN1_TYPE_cmp() compares ASN.1 types B and B and returns 0 if
Packit c4476c
they are identical and non-zero otherwise.
Packit c4476c
Packit c4476c
ASN1_TYPE_unpack_sequence() attempts to parse the SEQUENCE present in
Packit c4476c
B<t> using the ASN.1 structure B<it>. If successful it returns a pointer
Packit c4476c
to the ASN.1 structure corresponding to B<it> which must be freed by the
Packit c4476c
caller. If it fails it return NULL.
Packit c4476c
Packit c4476c
ASN1_TYPE_pack_sequence() attempts to encode the ASN.1 structure B<s>
Packit c4476c
corresponding to B<it> into an ASN1_TYPE. If successful the encoded
Packit c4476c
ASN1_TYPE is returned. If B<t> and B<*t> are not NULL the encoded type
Packit c4476c
is written to B<t> overwriting any existing data. If B<t> is not NULL
Packit c4476c
but B<*t> is NULL the returned ASN1_TYPE is written to B<*t>.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The type and meaning of the B<value> parameter for ASN1_TYPE_set() and
Packit c4476c
ASN1_TYPE_set1() is determined by the B<type> parameter.
Packit c4476c
If B<type> is V_ASN1_NULL B<value> is ignored. If B<type> is V_ASN1_BOOLEAN
Packit c4476c
then the boolean is set to TRUE if B<value> is not NULL. If B<type> is
Packit c4476c
V_ASN1_OBJECT then value is an ASN1_OBJECT structure. Otherwise B<type>
Packit c4476c
is and ASN1_STRING structure. If B<type> corresponds to a primitive type
Packit c4476c
(or a string type) then the contents of the ASN1_STRING contain the content
Packit c4476c
octets of the type. If B<type> corresponds to a constructed type or
Packit c4476c
a tagged type (V_ASN1_SEQUENCE, V_ASN1_SET or V_ASN1_OTHER) then the
Packit c4476c
ASN1_STRING contains the entire ASN.1 encoding verbatim (including tag and
Packit c4476c
length octets).
Packit c4476c
Packit c4476c
ASN1_TYPE_cmp() may not return zero if two types are equivalent but have
Packit c4476c
different encodings. For example the single content octet of the boolean TRUE
Packit c4476c
value under BER can have any non-zero encoding but ASN1_TYPE_cmp() will
Packit c4476c
only return zero if the values are the same.
Packit c4476c
Packit c4476c
If either or both of the parameters passed to ASN1_TYPE_cmp() is NULL the
Packit c4476c
return value is non-zero. Technically if both parameters are NULL the two
Packit c4476c
types could be absent OPTIONAL fields and so should match, however passing
Packit c4476c
NULL values could also indicate a programming error (for example an
Packit c4476c
unparsable type which returns NULL) for types which do B<not> match. So
Packit c4476c
applications should handle the case of two absent values separately.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
ASN1_TYPE_get() returns the type of the ASN1_TYPE argument.
Packit c4476c
Packit c4476c
ASN1_TYPE_set() does not return a value.
Packit c4476c
Packit c4476c
ASN1_TYPE_set1() returns 1 for success and 0 for failure.
Packit c4476c
Packit c4476c
ASN1_TYPE_cmp() returns 0 if the types are identical and non-zero otherwise.
Packit c4476c
Packit c4476c
ASN1_TYPE_unpack_sequence() returns a pointer to an ASN.1 structure or
Packit c4476c
NULL on failure.
Packit c4476c
Packit c4476c
ASN1_TYPE_pack_sequence() return an ASN1_TYPE structure if it succeeds or
Packit c4476c
NULL on failure.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut