gnutls-opencdk.html
Prev
ch01.html
Up
index.html
Home
GNU TLS API Reference Manual
libtasn1
libtasn1 —
Synopsis
#define
gnutls-libtasn1.html#LIBTASN1-VERSION:CAPS
LIBTASN1_VERSION
#define
gnutls-libtasn1.html#MAX-NAME-SIZE:CAPS
MAX_NAME_SIZE
#define
gnutls-libtasn1.html#MAX-ERROR-DESCRIPTION-SIZE:CAPS
MAX_ERROR_DESCRIPTION_SIZE
typedef
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
;
#define
gnutls-libtasn1.html#ASN1-SUCCESS:CAPS
ASN1_SUCCESS
#define
gnutls-libtasn1.html#ASN1-FILE-NOT-FOUND:CAPS
ASN1_FILE_NOT_FOUND
#define
gnutls-libtasn1.html#ASN1-ELEMENT-NOT-FOUND:CAPS
ASN1_ELEMENT_NOT_FOUND
#define
gnutls-libtasn1.html#ASN1-IDENTIFIER-NOT-FOUND:CAPS
ASN1_IDENTIFIER_NOT_FOUND
#define
gnutls-libtasn1.html#ASN1-DER-ERROR:CAPS
ASN1_DER_ERROR
#define
gnutls-libtasn1.html#ASN1-VALUE-NOT-FOUND:CAPS
ASN1_VALUE_NOT_FOUND
#define
gnutls-libtasn1.html#ASN1-GENERIC-ERROR:CAPS
ASN1_GENERIC_ERROR
#define
gnutls-libtasn1.html#ASN1-VALUE-NOT-VALID:CAPS
ASN1_VALUE_NOT_VALID
#define
gnutls-libtasn1.html#ASN1-TAG-ERROR:CAPS
ASN1_TAG_ERROR
#define
gnutls-libtasn1.html#ASN1-TAG-IMPLICIT:CAPS
ASN1_TAG_IMPLICIT
#define
gnutls-libtasn1.html#ASN1-ERROR-TYPE-ANY:CAPS
ASN1_ERROR_TYPE_ANY
#define
gnutls-libtasn1.html#ASN1-SYNTAX-ERROR:CAPS
ASN1_SYNTAX_ERROR
#define
gnutls-libtasn1.html#ASN1-MEM-ERROR:CAPS
ASN1_MEM_ERROR
#define
gnutls-libtasn1.html#ASN1-MEM-ALLOC-ERROR:CAPS
ASN1_MEM_ALLOC_ERROR
#define
gnutls-libtasn1.html#ASN1-DER-OVERFLOW:CAPS
ASN1_DER_OVERFLOW
#define
gnutls-libtasn1.html#ASN1-NAME-TOO-LONG:CAPS
ASN1_NAME_TOO_LONG
#define
gnutls-libtasn1.html#ASN1-ARRAY-ERROR:CAPS
ASN1_ARRAY_ERROR
#define
gnutls-libtasn1.html#ASN1-ELEMENT-NOT-EMPTY:CAPS
ASN1_ELEMENT_NOT_EMPTY
#define
gnutls-libtasn1.html#ASN1-PRINT-NAME:CAPS
ASN1_PRINT_NAME
#define
gnutls-libtasn1.html#ASN1-PRINT-NAME-TYPE:CAPS
ASN1_PRINT_NAME_TYPE
#define
gnutls-libtasn1.html#ASN1-PRINT-NAME-TYPE-VALUE:CAPS
ASN1_PRINT_NAME_TYPE_VALUE
#define
gnutls-libtasn1.html#ASN1-PRINT-ALL:CAPS
ASN1_PRINT_ALL
#define
gnutls-libtasn1.html#ASN1-CLASS-UNIVERSAL:CAPS
ASN1_CLASS_UNIVERSAL
#define
gnutls-libtasn1.html#ASN1-CLASS-APPLICATION:CAPS
ASN1_CLASS_APPLICATION
#define
gnutls-libtasn1.html#ASN1-CLASS-CONTEXT-SPECIFIC:CAPS
ASN1_CLASS_CONTEXT_SPECIFIC
#define
gnutls-libtasn1.html#ASN1-CLASS-PRIVATE:CAPS
ASN1_CLASS_PRIVATE
#define
gnutls-libtasn1.html#ASN1-TAG-BOOLEAN:CAPS
ASN1_TAG_BOOLEAN
#define
gnutls-libtasn1.html#ASN1-TAG-INTEGER:CAPS
ASN1_TAG_INTEGER
#define
gnutls-libtasn1.html#ASN1-TAG-SEQUENCE:CAPS
ASN1_TAG_SEQUENCE
#define
gnutls-libtasn1.html#ASN1-TAG-SET:CAPS
ASN1_TAG_SET
#define
gnutls-libtasn1.html#ASN1-TAG-OCTET-STRING:CAPS
ASN1_TAG_OCTET_STRING
#define
gnutls-libtasn1.html#ASN1-TAG-BIT-STRING:CAPS
ASN1_TAG_BIT_STRING
#define
gnutls-libtasn1.html#ASN1-TAG-UTCTime
ASN1_TAG_UTCTime
#define
gnutls-libtasn1.html#ASN1-TAG-GENERALIZEDTime
ASN1_TAG_GENERALIZEDTime
#define
gnutls-libtasn1.html#ASN1-TAG-OBJECT-ID:CAPS
ASN1_TAG_OBJECT_ID
#define
gnutls-libtasn1.html#ASN1-TAG-ENUMERATED:CAPS
ASN1_TAG_ENUMERATED
#define
gnutls-libtasn1.html#ASN1-TAG-NULL:CAPS
ASN1_TAG_NULL
#define
gnutls-libtasn1.html#ASN1-TAG-GENERALSTRING:CAPS
ASN1_TAG_GENERALSTRING
gnutls-libtasn1.html#node-asn
node_asn
;
typedef
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
;
#define
gnutls-libtasn1.html#ASN1-TYPE-EMPTY:CAPS
ASN1_TYPE_EMPTY
struct
gnutls-libtasn1.html#static-struct-asn
static_struct_asn
;
typedef
gnutls-libtasn1.html#ASN1-ARRAY-TYPE:CAPS
ASN1_ARRAY_TYPE
;
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-parser2tree
asn1_parser2tree
(const char *file_name,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*definitions,
char *errorDescription);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-parser2array
asn1_parser2array
(const char *inputFileName,
const char *outputFileName,
const char *vectorName,
char *errorDescription);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-array2tree
asn1_array2tree
(const
gnutls-libtasn1.html#ASN1-ARRAY-TYPE:CAPS
ASN1_ARRAY_TYPE
*array,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*definitions,
char *errorDescription);
../shishi/shishi-shishi.html#void
void
gnutls-libtasn1.html#asn1-print-structure
asn1_print_structure
(FILE *out,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
structure,
const char *name,
int mode);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-create-element
asn1_create_element
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
const char *source_name,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-delete-structure
asn1_delete_structure
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*structure);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-delete-element
asn1_delete_element
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
structure,
const char *element_name);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-write-value
asn1_write_value
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
node_root,
const char *name,
const
../shishi/shishi-shishi.html#void
void
*ivalue,
int len);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-read-value
asn1_read_value
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
root,
const char *name,
../shishi/shishi-shishi.html#void
void
*ivalue,
int *len);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-number-of-elements
asn1_number_of_elements
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const char *name,
int *num);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-der-coding
asn1_der_coding
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const char *name,
../shishi/shishi-shishi.html#void
void
*ider,
int *len,
char *ErrorDescription);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-der-decoding
asn1_der_decoding
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
char *errorDescription);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-der-decoding-element
asn1_der_decoding_element
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*structure,
const char *elementName,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
char *errorDescription);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-der-decoding-startEnd
asn1_der_decoding_startEnd
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
const char *name_element,
int *start,
int *end);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-expand-any-defined-by
asn1_expand_any_defined_by
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-expand-octet-string
asn1_expand_octet_string
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element,
const char *octetName,
const char *objectName);
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
gnutls-libtasn1.html#asn1-read-tag
asn1_read_tag
(
gnutls-libtasn1.html#node-asn
node_asn
*root,
const char *name,
int *tagValue,
int *classValue);
const char*
gnutls-libtasn1.html#asn1-find-structure-from-oid
asn1_find_structure_from_oid
(
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
const char *oidValue);
const char*
gnutls-libtasn1.html#asn1-check-version
asn1_check_version
(const char *req_version);
const char*
gnutls-libtasn1.html#libtasn1-strerror
libtasn1_strerror
(
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
error);
../shishi/shishi-shishi.html#void
void
gnutls-libtasn1.html#libtasn1-perror
libtasn1_perror
(
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
error);
Description
Details
LIBTASN1_VERSION
#define LIBTASN1_VERSION "0.2.13"
MAX_NAME_SIZE
#define MAX_NAME_SIZE 128 /* maximum number of characters of a name */
MAX_ERROR_DESCRIPTION_SIZE
#define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters */
asn1_retCode
typedef int asn1_retCode;  /* type returned by libasn1 functions */
ASN1_SUCCESS
#define ASN1_SUCCESS               0
ASN1_FILE_NOT_FOUND
#define ASN1_FILE_NOT_FOUND        1
ASN1_ELEMENT_NOT_FOUND
#define ASN1_ELEMENT_NOT_FOUND     2
ASN1_IDENTIFIER_NOT_FOUND
#define ASN1_IDENTIFIER_NOT_FOUND  3
ASN1_DER_ERROR
#define ASN1_DER_ERROR             4
ASN1_VALUE_NOT_FOUND
#define ASN1_VALUE_NOT_FOUND       5
ASN1_GENERIC_ERROR
#define ASN1_GENERIC_ERROR         6
ASN1_VALUE_NOT_VALID
#define ASN1_VALUE_NOT_VALID       7
ASN1_TAG_ERROR
#define ASN1_TAG_ERROR             8
ASN1_TAG_IMPLICIT
#define ASN1_TAG_IMPLICIT          9
ASN1_ERROR_TYPE_ANY
#define ASN1_ERROR_TYPE_ANY        10
ASN1_SYNTAX_ERROR
#define ASN1_SYNTAX_ERROR          11
ASN1_MEM_ERROR
#define ASN1_MEM_ERROR		   12
ASN1_MEM_ALLOC_ERROR
#define ASN1_MEM_ALLOC_ERROR	   13
ASN1_DER_OVERFLOW
#define ASN1_DER_OVERFLOW          14
ASN1_NAME_TOO_LONG
#define ASN1_NAME_TOO_LONG         15
ASN1_ARRAY_ERROR
#define ASN1_ARRAY_ERROR           16
ASN1_ELEMENT_NOT_EMPTY
#define ASN1_ELEMENT_NOT_EMPTY     17
ASN1_PRINT_NAME
#define ASN1_PRINT_NAME             1
ASN1_PRINT_NAME_TYPE
#define ASN1_PRINT_NAME_TYPE        2
ASN1_PRINT_NAME_TYPE_VALUE
#define ASN1_PRINT_NAME_TYPE_VALUE  3
ASN1_PRINT_ALL
#define ASN1_PRINT_ALL              4
ASN1_CLASS_UNIVERSAL
#define ASN1_CLASS_UNIVERSAL        1
ASN1_CLASS_APPLICATION
#define ASN1_CLASS_APPLICATION      2
ASN1_CLASS_CONTEXT_SPECIFIC
#define ASN1_CLASS_CONTEXT_SPECIFIC 3
ASN1_CLASS_PRIVATE
#define ASN1_CLASS_PRIVATE          4
ASN1_TAG_BOOLEAN
#define ASN1_TAG_BOOLEAN          0x01
ASN1_TAG_INTEGER
#define ASN1_TAG_INTEGER          0x02
ASN1_TAG_SEQUENCE
#define ASN1_TAG_SEQUENCE         0x10
ASN1_TAG_SET
#define ASN1_TAG_SET              0x11
ASN1_TAG_OCTET_STRING
#define ASN1_TAG_OCTET_STRING     0x04
ASN1_TAG_BIT_STRING
#define ASN1_TAG_BIT_STRING       0x03
ASN1_TAG_UTCTime
#define ASN1_TAG_UTCTime          0x17
ASN1_TAG_GENERALIZEDTime
#define ASN1_TAG_GENERALIZEDTime  0x18
ASN1_TAG_OBJECT_ID
#define ASN1_TAG_OBJECT_ID        0x06
ASN1_TAG_ENUMERATED
#define ASN1_TAG_ENUMERATED       0x0A
ASN1_TAG_NULL
#define ASN1_TAG_NULL             0x05
ASN1_TAG_GENERALSTRING
#define ASN1_TAG_GENERALSTRING    0x1B
node_asn
typedef struct {
char *name;                    /* Node name */
unsigned int type;             /* Node type */
unsigned char *value;          /* Node value */
struct node_asn_struct *down;  /* Pointer to the son node */
struct node_asn_struct *right; /* Pointer to the brother node */
struct node_asn_struct *left;  /* Pointer to the next list element */
} node_asn;
ASN1_TYPE
typedef node_asn* ASN1_TYPE;
ASN1_TYPE_EMPTY
#define ASN1_TYPE_EMPTY  NULL
struct static_struct_asn
struct static_struct_asn {
char *name;                    /* Node name */
unsigned int type;             /* Node type */
unsigned char *value;          /* Node value */
};
ASN1_ARRAY_TYPE
typedef struct static_struct_asn ASN1_ARRAY_TYPE;
asn1_parser2tree ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_parser2tree               (const char *file_name,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*definitions,
char *errorDescription);
file_name
:
definitions
:
errorDescription
:
Returns
:
asn1_parser2array ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_parser2array              (const char *inputFileName,
const char *outputFileName,
const char *vectorName,
char *errorDescription);
inputFileName
:
outputFileName
:
vectorName
:
errorDescription
:
Returns
:
asn1_array2tree ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_array2tree                (const
gnutls-libtasn1.html#ASN1-ARRAY-TYPE:CAPS
ASN1_ARRAY_TYPE
*array,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*definitions,
char *errorDescription);
Creates the structures needed to manage the ASN.1 definitions.
array
is a vector created by
gnutls-libtasn1.html#asn1-parser2array
asn1_parser2array()
.
array
:
specify the array that contains ASN.1 declarations
definitions
:
return the pointer to the structure created by
*ARRAY ASN.1 declarations
errorDescription
:
return the error description.
Returns
:
ASN1_SUCCESS: Structure created correctly.
ASN1_ELEMENT_NOT_EMPTY: *
definitions
not ASN1_TYPE_EMPTY.
ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
is not defined (see
errorDescription
for more information).
ASN1_ARRAY_ERROR: The array pointed by
array
is wrong.
asn1_print_structure ()
../shishi/shishi-shishi.html#void
void
asn1_print_structure            (FILE *out,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
structure,
const char *name,
int mode);
Prints on the
out
file descriptor the structure's tree starting
from the
name
element inside the structure
structure
.
out
:
pointer to the output file (e.g. stdout).
structure
:
pointer to the structure that you want to visit.
name
:
an element of the structure
mode
:
specify how much of the structure to print, can be
ASN1_PRINT_NAME
,
ASN1_PRINT_NAME_TYPE
,
ASN1_PRINT_NAME_TYPE_VALUE
, or
ASN1_PRINT_ALL
.
asn1_create_element ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_create_element            (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
const char *source_name,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element);
Creates a structure of type
source_name
.  Example using
"pkix.asn":
rc = asn1_create_structure(cert_def, "PKIX1.Certificate",
certptr);
definitions
:
pointer to the structure returned by "parser_asn1" function
source_name
:
the name of the type of the new structure (must be
inside p_structure).
element
:
pointer to the structure created.
Returns
:
ASN1_SUCCESS: Creation OK.
ASN1_ELEMENT_NOT_FOUND: SOURCE_NAME isn't known
asn1_delete_structure ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_delete_structure          (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*structure);
Deletes the structure *
structure
.  At the end, *
structure
is set
to ASN1_TYPE_EMPTY.
structure
:
pointer to the structure that you want to delete.
Returns
:
ASN1_SUCCESS: Everything OK.
ASN1_ELEMENT_NOT_FOUND: *
structure
was ASN1_TYPE_EMPTY.
asn1_delete_element ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_delete_element            (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
structure,
const char *element_name);
Deletes the element named *
element_name
inside *
structure
.
structure
:
pointer to the structure that contains the element you
want to delete.
element_name
:
element's name you want to delete.
Returns
:
ASN1_SUCCESS: Everything OK.
ASN1_ELEMENT_NOT_FOUND: The name element was not found.
asn1_write_value ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_write_value               (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
node_root,
const char *name,
const
../shishi/shishi-shishi.html#void
void
*ivalue,
int len);
Set the value of one element inside a structure.
If an element is OPTIONAL and you want to delete it, you must use
the value=NULL and len=0.  Using "pkix.asn":
result=asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
NULL, 0);
Description for each type:
INTEGER: VALUE must contain a two's complement form integer.
value[0]=0xFF ,               len=1 -> integer=-1.
value[0]=0xFF value[1]=0xFF , len=2 -> integer=-1.
value[0]=0x01 ,               len=1 -> integer= 1.
value[0]=0x00 value[1]=0x01 , len=2 -> integer= 1.
value="123"                 , len=0 -> integer= 123.
ENUMERATED: As INTEGER (but only with not negative numbers).
BOOLEAN: VALUE must be the null terminated string "TRUE" or
"FALSE" and LEN != 0.
value="TRUE" , len=1 -> boolean=TRUE.
value="FALSE" , len=1 -> boolean=FALSE.
OBJECT IDENTIFIER: VALUE must be a null terminated string with
each number separated by a dot (e.g. "1.2.3.543.1").  LEN != 0.
value="1 2 840 10040 4 3" , len=1 -> OID=dsa-with-sha.
UTCTime: VALUE must be a null terminated string in one of these
formats: "YYMMDDhhmmssZ", "YYMMDDhhmmssZ",
"YYMMDDhhmmss+hh'mm'", "YYMMDDhhmmss-hh'mm'",
"YYMMDDhhmm+hh'mm'", or "YYMMDDhhmm-hh'mm'".  LEN != 0.
value="9801011200Z" , len=1 -> time=Jannuary 1st, 1998
at 12h 00m Greenwich Mean Time
GeneralizedTime: VALUE must be in one of this format:
"YYYYMMDDhhmmss.sZ", "YYYYMMDDhhmmss.sZ",
"YYYYMMDDhhmmss.s+hh'mm'", "YYYYMMDDhhmmss.s-hh'mm'",
"YYYYMMDDhhmm+hh'mm'", or "YYYYMMDDhhmm-hh'mm'" where ss.s
indicates the seconds with any precision like "10.1" or "01.02".
LEN != 0
value="2001010112001.12-0700" , len=1 -> time=Jannuary
1st, 2001 at 12h 00m 01.12s Pacific Daylight Time
OCTET STRING: VALUE contains the octet string and LEN is the
number of octets.
value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
len=3 -> three bytes octet string
GeneralString: VALUE contains the generalstring and LEN is the
number of octets.
value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
len=3 -> three bytes generalstring
BIT STRING: VALUE contains the bit string organized by bytes and
LEN is the number of bits.
value="$\backslash$xCF" , len=6 -> bit string="110011" (six
bits)
CHOICE: if NAME indicates a choice type, VALUE must specify one of
the alternatives with a null terminated string. LEN != 0. Using
"pkix.asn"\:
result=asn1_write_value(cert,
"certificate1.tbsCertificate.subject", "rdnSequence",
1);
ANY: VALUE indicates the der encoding of a structure.  LEN != 0.
SEQUENCE OF: VALUE must be the null terminated string "NEW" and
LEN != 0. With this instruction another element is appended in
the sequence. The name of this element will be "?1" if it's the
first one, "?2" for the second and so on.
Using "pkix.asn"\:
result=asn1_write_value(cert,
"certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
SET OF: the same as SEQUENCE OF.  Using "pkix.asn":
result=asn1_write_value(cert,
"tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
node_root
:
pointer to a structure
name
:
the name of the element inside the structure that you want to set.
ivalue
:
vector used to specify the value to set. If len is >0,
VALUE must be a two's complement form integer.  if len=0 *VALUE
must be a null terminated string with an integer value.
len
:
number of bytes of *value to use to set the value:
value[0]..value[len-1] or 0 if value is a null terminated string
Returns
:
ASN1_SUCCESS: Set value OK.
ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
ASN1_VALUE_NOT_VALID: VALUE has a wrong format.
asn1_read_value ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_read_value                (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
root,
const char *name,
../shishi/shishi-shishi.html#void
void
*ivalue,
int *len);
Returns the value of one element inside a structure.
If an element is OPTIONAL and the function "read_value" returns
ASN1_ELEMENT_NOT_FOUND
, it means that this element wasn't present
in the der encoding that created the structure.  The first element
of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
so on.
INTEGER: VALUE will contain a two's complement form integer.
integer=-1  -> value[0]=0xFF , len=1.
integer=1   -> value[0]=0x01 , len=1.
ENUMERATED: As INTEGER (but only with not negative numbers).
BOOLEAN: VALUE will be the null terminated string "TRUE" or
"FALSE" and LEN=5 or LEN=6.
OBJECT IDENTIFIER: VALUE will be a null terminated string with
each number separated by a dot (i.e. "1.2.3.543.1").
LEN = strlen(VALUE)+1
UTCTime: VALUE will be a null terminated string in one of these
formats: "YYMMDDhhmmss+hh'mm'" or "YYMMDDhhmmss-hh'mm'".
LEN=strlen(VALUE)+1.
GeneralizedTime: VALUE will be a null terminated string in the
same format used to set the value.
OCTET STRING: VALUE will contain the octet string and LEN will be
the number of octets.
GeneralString: VALUE will contain the generalstring and LEN will
be the number of octets.
BIT STRING: VALUE will contain the bit string organized by bytes
and LEN will be the number of bits.
CHOICE: If NAME indicates a choice type, VALUE will specify the
alternative selected.
ANY: If NAME indicates an any type, VALUE will indicate the DER
encoding of the structure actually used.
root
:
pointer to a structure.
name
:
the name of the element inside a structure that you want to read.
ivalue
:
vector that will contain the element's content, must be a
pointer to memory cells already allocated.
len
:
number of bytes of *value: value[0]..value[len-1]. Initialy
holds the sizeof value.
Returns
:
ASN1_SUCCESS: Set value OK.
ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
ASN1_VALUE_NOT_FOUND: There isn't any value for the element selected.
ASN1_MEM_ERROR: The value vector isn't big enough to store the result.
In this case LEN will contain the number of bytes needed.
asn1_number_of_elements ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_number_of_elements        (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const char *name,
int *num);
Counts the number of elements of a sub-structure called NAME with
names equal to "?1","?2", ...
element
:
pointer to the root of an ASN1 structure.
name
:
the name of a sub-structure of ROOT.
num
:
pointer to an integer where the result will be stored
Returns
:
ASN1_SUCCESS: Creation OK.
ASN1_ELEMENT_NOT_FOUND: NAME isn't known.
ASN1_GENERIC_ERROR: Pointer num equal to NULL.
asn1_der_coding ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_der_coding                (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const char *name,
../shishi/shishi-shishi.html#void
void
*ider,
int *len,
char *ErrorDescription);
Creates the DER encoding for the NAME structure (inside *POINTER
structure).
element
:
pointer to an ASN1 element
name
:
the name of the structure you want to encode (it must be
inside *POINTER).
ider
:
vector that will contain the DER encoding. DER must be a
pointer to memory cells already allocated.
len
:
number of bytes of *
ider
:
ider
[0]..
ider
[len-1], Initialy
holds the sizeof of der vector.
ErrorDescription
:
return the error description or an empty
string if success.
Returns
:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
ASN1_VALUE_NOT_FOUND: There is an element without a value.
ASN1_MEM_ERROR:
ider
vector isn't big enough. Also in this case
LEN will contain the length needed.
asn1_der_decoding ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_der_decoding              (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
char *errorDescription);
Fill the structure *ELEMENT with values of a DER encoding
string. The sructure must just be created with function
'create_stucture'.  If an error occurs during the decoding
procedure, the *ELEMENT is deleted and set equal to
ASN1_TYPE_EMPTY
.
element
:
pointer to an ASN1 structure.
ider
:
vector that contains the DER encoding.
len
:
number of bytes of *
ider
:
ider
[0]..
ider
[len-1].
errorDescription
:
null-terminated string contains details when an
error occurred.
Returns
:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY.
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match
the structure NAME. *ELEMENT deleted.
asn1_der_decoding_element ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_der_decoding_element      (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*structure,
const char *elementName,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
char *errorDescription);
Fill the element named ELEMENTNAME with values of a DER encoding
string.  The sructure must just be created with function
'create_stucture'.  The DER vector must contain the encoding
string of the whole STRUCTURE.  If an error occurs during the
decoding procedure, the *STRUCTURE is deleted and set equal to
ASN1_TYPE_EMPTY
.
structure
:
pointer to an ASN1 structure
elementName
:
name of the element to fill
ider
:
vector that contains the DER encoding of the whole structure.
len
:
number of bytes of *der: der[0]..der[len-1]
errorDescription
:
null-terminated string contains details when an
error occurred.
Returns
:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY or
elementName == NULL.
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match
the structure STRUCTURE. *ELEMENT deleted.
asn1_der_decoding_startEnd ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_der_decoding_startEnd     (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
element,
const
../shishi/shishi-shishi.html#void
void
*ider,
int len,
const char *name_element,
int *start,
int *end);
Find the start and end point of an element in a DER encoding
string. I mean that if you have a der encoding and you have
already used the function "asn1_der_decoding" to fill a structure,
it may happen that you want to find the piece of string concerning
an element of the structure.
Example: the sequence "tbsCertificate" inside an X509 certificate.
element
:
pointer to an ASN1 element
ider
:
vector that contains the DER encoding.
len
:
number of bytes of *
ider
:
ider
[0]..
ider
[len-1]
name_element
:
an element of NAME structure.
start
:
the position of the first byte of NAME_ELEMENT decoding
(
ider
[*start])
end
:
the position of the last byte of NAME_ELEMENT decoding
(
ider
[*end])
Returns
:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE EMPTY or
NAME_ELEMENT is not a valid element.
ASN1_TAG_ERROR,ASN1_DER_ERROR: the der encoding doesn't match
the structure ELEMENT.
asn1_expand_any_defined_by ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_expand_any_defined_by     (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element);
Expands every "ANY DEFINED BY" element of a structure created from
a DER decoding process (asn1_der_decoding function). The element ANY
must be defined by an OBJECT IDENTIFIER. The type used to expand
the element ANY is the first one following the definition of
the actual value of the OBJECT IDENTIFIER.
definitions
:
ASN1 definitions
element
:
pointer to an ASN1 structure
Returns
:
ASN1_SUCCESS: Substitution OK.
ASN1_ERROR_TYPE_ANY: Some "ANY DEFINED BY" element couldn't be
expanded due to a problem in OBJECT_ID -> TYPE association.
other errors: Result of der decoding process.
asn1_expand_octet_string ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_expand_octet_string       (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
*element,
const char *octetName,
const char *objectName);
Expands an "OCTET STRING" element of a structure created from a
DER decoding process (asn1_der_decoding function). The type used
for expansion is the first one following the definition of the
actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
definitions
:
ASN1 definitions
element
:
pointer to an ASN1 structure
octetName
:
name of the OCTECT STRING field to expand.
objectName
:
name of the OBJECT IDENTIFIER field to use to define
the type for expansion.
Returns
:
ASN1_SUCCESS: Substitution OK.
ASN1_ELEMENT_NOT_FOUND: OBJECTNAME or OCTETNAME are not correct.
ASN1_VALUE_NOT_VALID: Wasn't possible to find the type to use
for expansion.
other errors: result of der decoding process.
asn1_read_tag ()
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
asn1_read_tag                  (
gnutls-libtasn1.html#node-asn
node_asn
*root,
const char *name,
int *tagValue,
int *classValue);
Returns the TAG and the CLASS of one element inside a structure.
CLASS can have one of these constants:
ASN1_CLASS_APPLICATION
,
ASN1_CLASS_UNIVERSAL
,
ASN1_CLASS_PRIVATE
or
ASN1_CLASS_CONTEXT_SPECIFIC
.
root
:
pointer to a structure
name
:
the name of the element inside a structure.
tagValue
:
variable that will contain the TAG value.
classValue
:
variable that will specify the TAG type.
Returns
:
ASN1_SUCCESS: Set value OK.
ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
asn1_find_structure_from_oid ()
const char* asn1_find_structure_from_oid    (
gnutls-libtasn1.html#ASN1-TYPE:CAPS
ASN1_TYPE
definitions,
const char *oidValue);
Search the structure that is defined just after an OID definition.
definitions
:
ASN1 definitions
oidValue
:
value of the OID to search (e.g. "1.2.3.4").
Returns
:
NULL when OIDVALUE not found, otherwise the pointer to a
constant string that contains the element name defined just
after the OID.
asn1_check_version ()
const char* asn1_check_version              (const char *req_version);
Check that the the version of the library is at minimum the
requested one and return the version string; return
NULL
if the
condition is not satisfied.  If a
NULL
is passed to this function,
no check is done, but the version string is simply returned.
See
LIBTASN1_VERSION
for a suitable
req_version
string.
req_version
:
Required version number, or NULL.
Returns
:
Version string of run-time library, or
NULL
if the
run-time library does not meet the required version number.
libtasn1_strerror ()
const char* libtasn1_strerror               (
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
error);
This function is similar to
strerror()
. The only difference is
that it accepts an error (number) returned by a libasn1 function.
error
:
is an error returned by a libtasn1 function.
Returns
:
Pointer to static zero-terminated string describing error
code.
libtasn1_perror ()
../shishi/shishi-shishi.html#void
void
libtasn1_perror                 (
gnutls-libtasn1.html#asn1-retCode
asn1_retCode
error);
This function is like
perror()
. The only difference is that it
accepts an error returned by a libasn1 function.
error
:
is an error returned by a libasn1 function.
gnutls-opencdk.html
<< opencdk
