From dd14f911714da77876a3c17e0168b6afef923be8 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 3 Feb 2015 16:09:32 +0000 Subject: [PATCH] ASN1_TYPE documentation. Reviewed-by: Richard Levitte --- doc/crypto/ASN1_STRING_length.pod | 2 +- doc/crypto/ASN1_TYPE_get.pod | 70 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 doc/crypto/ASN1_TYPE_get.pod diff --git a/doc/crypto/ASN1_STRING_length.pod b/doc/crypto/ASN1_STRING_length.pod index f651e4f2ae..6fb9c949b6 100644 --- a/doc/crypto/ASN1_STRING_length.pod +++ b/doc/crypto/ASN1_STRING_length.pod @@ -48,7 +48,7 @@ such as B. ASN1_STRING_to_UTF8() converts the string B to UTF8 format, the converted data is allocated in a buffer in B<*out>. The length of B is returned or a negative error code. The buffer B<*out> -should be free using OPENSSL_free(). +should be freed using OPENSSL_free(). =head1 NOTES diff --git a/doc/crypto/ASN1_TYPE_get.pod b/doc/crypto/ASN1_TYPE_get.pod new file mode 100644 index 0000000000..a6c65aaa34 --- /dev/null +++ b/doc/crypto/ASN1_TYPE_get.pod @@ -0,0 +1,70 @@ +=pod + +=head1 NAME + +ASN1_TYPE_get, ASN1_TYPE_set, ASN1_TYPE_set1, ASN1_TYPE_cmp - ASN1_TYPE utility +functions + +=head1 SYNOPSIS + + #include + + int ASN1_TYPE_get(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); + +=head1 DESCRIPTION + +These functions allow an ASN1_TYPE structure to be manipulated. The +ASN1_TYPE structure can contain any ASN.1 type or constructed type +such as a SEQUENCE: it is effectively equivalent to the ASN.1 ANY type. + +ASN1_TYPE_get() returns the type of B. + +ASN1_TYPE_set() sets the value of B to B and B. This +function uses the pointer B internally so it must B be freed +up after the call. + +ASN1_TYPE_set1() sets the value of B to B a copy of B. + +ASN1_TYPE_cmp() compares ASN.1 types B and B and returns 0 if +they are identical and non-zero otherwise. + +=head1 NOTES + +The type and meaning of the B parameter for ASN1_TYPE_set() and +ASN1_TYPE_set1() is determined by the B parameter. +If B is V_ASN1_NULL B is ignored. If B is V_ASN1_BOOLEAN +then the boolean is set to TRUE if B is not NULL. If B is +V_ASN1_OBJECT then value is an ASN1_OBJECT structure. Otherwise B +is and ASN1_STRING structure. If B corresponds to a primitive type +(or a string type) then the contents of the ASN1_STRING contain the content +octets of the type. If B corresponds to a constructed type or +a tagged type (V_ASN1_SEQUENCE, V_ASN1_SET or V_ASN1_OTHER) then the +ASN1_STRING contains the entire ASN.1 encoding verbatim (including tag and +length octets). + +ASN1_TYPE_cmp() may not return zero if two types are equivalent but have +different encodings. For example the single content octet of the boolean TRUE +value under BER can have any non-zero encoding but ASN1_TYPE_cmp() will +only return zero if the values are the same. + +If either or both of the parameters passed to ASN1_TYPE_cmp() is NULL the +return value is non-zero. Technically if both parameters are NULL the two +types could be absent OPTIONAL fields and so should match, however passing +NULL values could also indicate a programming error (for example an +unparseable type which returns NULL) for types which do B match. So +applications should handle the case of two absent values separately. + +=head1 RETURN VALUES + +ASN1_TYPE_get() returns the type of the ASN1_TYPE argument. + +ASN1_TYPE_set() does not return a value. + +ASN1_TYPE_set1() returns 1 for sucess and 0 for failure. + +ASN1_TYPE_cmp() returns 0 if the types are identical and non-zero otherwise. + +=cut -- 2.34.1