1
@deftypefun {signed long} {asn1_get_length_der} (const unsigned char * @var{der}, int @var{der_len}, int * @var{len})
2
@var{der}: DER data to decode.
4
@var{der_len}: Length of DER data to decode.
6
@var{len}: Output variable containing the length of the DER length field.
8
Extract a length field from DER data.
10
@strong{Return value:} Return the decoded length value, or -1 on indefinite
11
length, or -2 when the value was too big.
14
@deftypefun {int} {asn1_get_tag_der} (const unsigned char * @var{der}, int @var{der_len}, unsigned char * @var{class}, int * @var{len}, unsigned long * @var{tag})
15
@var{der}: DER data to decode.
17
@var{der_len}: Length of DER data to decode.
19
@var{class}: Output variable containing decoded class.
21
@var{len}: Output variable containing the length of the DER TAG data.
23
@var{tag}: Output variable containing the decoded tag.
25
Decode the class and TAG from DER code.
27
@strong{Return value:} Returns ASN1_SUCCESS on success, or an error.
30
@deftypefun {int} {asn1_get_octet_der} (const unsigned char * @var{der}, int @var{der_len}, int * @var{ret_len}, unsigned char * @var{str}, int @var{str_size}, int * @var{str_len})
31
@var{der}: DER data to decode containing the OCTET SEQUENCE.
33
@var{der_len}: Length of DER data to decode.
35
@var{ret_len}: Output variable containing the length of the DER data.
37
@var{str}: Pre-allocated output buffer to put decoded OCTET SEQUENCE in.
39
@var{str_size}: Length of pre-allocated output buffer.
41
@var{str_len}: Output variable containing the length of the OCTET SEQUENCE.
43
Extract an OCTET SEQUENCE from DER data.
45
@strong{Return value:} Returns ASN1_SUCCESS on success, or an error.
48
@deftypefun {int} {asn1_get_bit_der} (const unsigned char * @var{der}, int @var{der_len}, int * @var{ret_len}, unsigned char * @var{str}, int @var{str_size}, int * @var{bit_len})
49
@var{der}: DER data to decode containing the BIT SEQUENCE.
51
@var{der_len}: Length of DER data to decode.
53
@var{ret_len}: Output variable containing the length of the DER data.
55
@var{str}: Pre-allocated output buffer to put decoded BIT SEQUENCE in.
57
@var{str_size}: Length of pre-allocated output buffer.
59
@var{bit_len}: Output variable containing the size of the BIT SEQUENCE.
61
Extract a BIT SEQUENCE from DER data.
63
@strong{Return value:} Return ASN1_SUCCESS on success, or an error.
66
@deftypefun {asn1_retCode} {asn1_der_decoding} (ASN1_TYPE * @var{element}, const void * @var{ider}, int @var{len}, char * @var{errorDescription})
67
@var{element}: pointer to an ASN1 structure.
69
@var{ider}: vector that contains the DER encoding.
71
@var{len}: number of bytes of *@code{ider}: @code{ider}[0]..@code{ider}[len-1].
73
@var{errorDescription}: null-terminated string contains details when an
76
Fill the structure *ELEMENT with values of a DER encoding
77
string. The sructure must just be created with function
78
'create_stucture'. If an error occurs during the decoding
79
procedure, the *ELEMENT is deleted and set equal to
80
@code{ASN1_TYPE_EMPTY}.
83
@strong{ASN1_SUCCESS:} DER encoding OK.
85
@strong{ASN1_ELEMENT_NOT_FOUND:} ELEMENT is ASN1_TYPE_EMPTY.
87
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match
88
the structure NAME. *ELEMENT deleted.
91
@deftypefun {asn1_retCode} {asn1_der_decoding_element} (ASN1_TYPE * @var{structure}, const char * @var{elementName}, const void * @var{ider}, int @var{len}, char * @var{errorDescription})
92
@var{structure}: pointer to an ASN1 structure
94
@var{elementName}: name of the element to fill
96
@var{ider}: vector that contains the DER encoding of the whole structure.
98
@var{len}: number of bytes of *der: der[0]..der[len-1]
100
@var{errorDescription}: null-terminated string contains details when an
103
Fill the element named ELEMENTNAME with values of a DER encoding
104
string. The sructure must just be created with function
105
'create_stucture'. The DER vector must contain the encoding
106
string of the whole STRUCTURE. If an error occurs during the
107
decoding procedure, the *STRUCTURE is deleted and set equal to
108
@code{ASN1_TYPE_EMPTY}.
111
@strong{ASN1_SUCCESS:} DER encoding OK.
113
@strong{ASN1_ELEMENT_NOT_FOUND:} ELEMENT is ASN1_TYPE_EMPTY or
116
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match
117
the structure STRUCTURE. *ELEMENT deleted.
120
@deftypefun {asn1_retCode} {asn1_der_decoding_startEnd} (ASN1_TYPE @var{element}, const void * @var{ider}, int @var{len}, const char * @var{name_element}, int * @var{start}, int * @var{end})
121
@var{element}: pointer to an ASN1 element
123
@var{ider}: vector that contains the DER encoding.
125
@var{len}: number of bytes of *@code{ider}: @code{ider}[0]..@code{ider}[len-1]
127
@var{name_element}: an element of NAME structure.
129
@var{start}: the position of the first byte of NAME_ELEMENT decoding
130
(@code{ider}[*start])
132
@var{end}: the position of the last byte of NAME_ELEMENT decoding
135
Find the start and end point of an element in a DER encoding
136
string. I mean that if you have a der encoding and you have
137
already used the function "asn1_der_decoding" to fill a structure,
138
it may happen that you want to find the piece of string concerning
139
an element of the structure.
141
@strong{Example:} the sequence "tbsCertificate" inside an X509 certificate.
144
@strong{ASN1_SUCCESS:} DER encoding OK.
146
@strong{ASN1_ELEMENT_NOT_FOUND:} ELEMENT is ASN1_TYPE EMPTY or
147
NAME_ELEMENT is not a valid element.
149
ASN1_TAG_ERROR,ASN1_DER_ERROR: the der encoding doesn't match
150
the structure ELEMENT.
153
@deftypefun {asn1_retCode} {asn1_expand_any_defined_by} (ASN1_TYPE @var{definitions}, ASN1_TYPE * @var{element})
154
@var{definitions}: ASN1 definitions
156
@var{element}: pointer to an ASN1 structure
158
Expands every "ANY DEFINED BY" element of a structure created from
159
a DER decoding process (asn1_der_decoding function). The element ANY
160
must be defined by an OBJECT IDENTIFIER. The type used to expand
161
the element ANY is the first one following the definition of
162
the actual value of the OBJECT IDENTIFIER.
165
@strong{ASN1_SUCCESS:} Substitution OK.
167
@strong{ASN1_ERROR_TYPE_ANY:} Some "ANY DEFINED BY" element couldn't be
168
expanded due to a problem in OBJECT_ID -> TYPE association.
170
other errors: Result of der decoding process.
173
@deftypefun {asn1_retCode} {asn1_expand_octet_string} (ASN1_TYPE @var{definitions}, ASN1_TYPE * @var{element}, const char * @var{octetName}, const char * @var{objectName})
174
@var{definitions}: ASN1 definitions
176
@var{element}: pointer to an ASN1 structure
178
@var{octetName}: name of the OCTECT STRING field to expand.
180
@var{objectName}: name of the OBJECT IDENTIFIER field to use to define
181
the type for expansion.
183
Expands an "OCTET STRING" element of a structure created from a
184
DER decoding process (asn1_der_decoding function). The type used
185
for expansion is the first one following the definition of the
186
actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
189
@strong{ASN1_SUCCESS:} Substitution OK.
191
@strong{ASN1_ELEMENT_NOT_FOUND:} OBJECTNAME or OCTETNAME are not correct.
193
@strong{ASN1_VALUE_NOT_VALID:} Wasn't possible to find the type to use
196
other errors: result of der decoding process.