DragonFly On-Line Manual Pages

Search: Section:  


ASN1_TYPE_GET(3)      DragonFly Library Functions Manual      ASN1_TYPE_GET(3)

NAME

ASN1_TYPE_new, ASN1_TYPE_free, ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp -- ASN.1 objects of arbitrary type

SYNOPSIS

#include <openssl/asn1.h> ASN1_TYPE * ASN1_TYPE_new(void); void ASN1_TYPE_free(ASN1_TYPE *a); int ASN1_TYPE_get(const ASN1_TYPE *a); void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);

DESCRIPTION

ASN1_TYPE represents the ASN.1 ANY type. An ASN1_TYPE object can store an ASN.1 value of arbitrary type, including constructed types such as a SEQUENCE. It also remembers internally which type it currently holds. ASN1_TYPE_new() allocates and initializes an empty ASN1_TYPE object of undefined type. ASN1_TYPE_free() frees a including the value stored in it, if any. If a is a NULL pointer, no action occurs. ASN1_TYPE_get() returns the type of a, represented by one of the V_ASN1_* constants defined in <openssl/asn1.h>. ASN1_TYPE_set() frees the value contained in a, if any, and sets a to type and value. This function uses the pointer value internally so it must not be freed up after the call. ASN1_TYPE_set1() sets the type of a to type and its value to a copy of value. If copying succeeds, the previous value that was contained in a is freed. If copying fails, a remains unchanged. The type and meaning of the value argument of ASN1_TYPE_set() and ASN1_TYPE_set1() is determined by the type argument. If type is V_ASN1_NULL, value is ignored. If type is V_ASN1_BOOLEAN, then the bool- ean is set to TRUE if value is not NULL. If type is V_ASN1_OBJECT, then value is an ASN1_OBJECT structure. Otherwise type is an ASN1_STRING structure. If type corresponds to a primitive type or a string type, then the contents of the ASN1_STRING contains the content octets of the type. If type corresponds to a constructed type or a tagged type (V_ASN1_SEQUENCE, V_ASN1_SET, or V_ASN1_OTHER), then the ASN1_STRING con- tains the entire ASN.1 encoding verbatim, including tag and length octets. ASN1_TYPE_cmp() checks that a and b have the same type, the same value, and are encoded in the same way. If the types agree and the values have the same meaning but are encoded differently, they are considered different. For example, a boolean value is represented using a single content octet. Under BER, any non-zero octet represents the TRUE value, but ASN1_TYPE_cmp() will only report a match if the content octet is the same. If either or both of the arguments passed to ASN1_TYPE_cmp() is NULL, the result is a mismatch. Technically, if both arguments are NULL, the two types could be absent OPTIONAL fields and so should match, however pass- ing NULL values could also indicate a programming error (for example an unparseable type which returns NULL) for types which do not match. So applications should handle the case of two absent values separately.

RETURN VALUES

ASN1_TYPE_new() returns the new ASN1_TYPE object or NULL if an error occurs. ASN1_TYPE_get() returns the type of a or 0 if an error occurs. The lat- ter can happen if a does not contain a value even though its type is not V_ASN1_NULL. For example, it will always happen for empty objects newly constructed with ASN1_TYPE_new(). ASN1_TYPE_set1() returns 1 if the copying succeeds or 0 if it fails. ASN1_TYPE_cmp() returns 0 for a match or non-zero for a mismatch.

SEE ALSO

ASN1_item_free(3), ASN1_STRING_dup(3), d2i_ASN1_TYPE(3), OBJ_dup(3)

HISTORY

ASN1_TYPE_new() and ASN1_TYPE_free() first appeared in SSLeay 0.5.1. ASN1_TYPE_get() and ASN1_TYPE_set() first appeared in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4. ASN1_TYPE_set1() first appeared in OpenSSL 0.9.8h and has been available since OpenBSD 4.5. ASN1_TYPE_cmp() first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k and has been available since OpenBSD 4.9. DragonFly 5.5 April 25, 2018 DragonFly 5.5

Search: Section: