summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/minitasn1/coding.c58
-rw-r--r--lib/minitasn1/decoding.c141
-rw-r--r--lib/minitasn1/element.c90
-rw-r--r--lib/minitasn1/element.h6
-rw-r--r--lib/minitasn1/errors.c47
-rw-r--r--lib/minitasn1/gstr.c11
-rw-r--r--lib/minitasn1/gstr.h2
-rw-r--r--lib/minitasn1/int.h70
-rw-r--r--lib/minitasn1/libtasn1.h198
-rw-r--r--lib/minitasn1/parser_aux.c285
-rw-r--r--lib/minitasn1/parser_aux.h143
-rw-r--r--lib/minitasn1/structure.c197
-rw-r--r--lib/minitasn1/structure.h8
-rw-r--r--lib/minitasn1/version.c2
14 files changed, 633 insertions, 625 deletions
diff --git a/lib/minitasn1/coding.c b/lib/minitasn1/coding.c
index 8b72eba3f4..581ef9675f 100644
--- a/lib/minitasn1/coding.c
+++ b/lib/minitasn1/coding.c
@@ -44,7 +44,7 @@
/* Return: */
/******************************************************/
static void
-_asn1_error_description_value_not_found (ASN1_TYPE node,
+_asn1_error_description_value_not_found (asn1_node node,
char *ErrorDescription)
{
@@ -177,7 +177,7 @@ asn1_octet_der (const unsigned char *str, int str_len,
/* ASN1_MEM_ERROR when DER isn't big enough */
/* ASN1_SUCCESS otherwise */
/******************************************************/
-static asn1_retCode
+static int
_asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
{
int len_len;
@@ -249,24 +249,24 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
/* ASN1_MEM_ERROR when DER isn't big enough */
/* ASN1_SUCCESS otherwise */
/******************************************************/
-static asn1_retCode
+static int
_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
{
int len_len, counter, k, first, max_len;
char *temp, *n_end, *n_start;
unsigned char bit7;
unsigned long val, val1 = 0;
- int str_len = _asn1_strlen(str);
+ int str_len = _asn1_strlen (str);
max_len = *der_len;
- temp = _asn1_malloc (str_len + 2);
+ temp = malloc (str_len + 2);
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
memcpy (temp, str, str_len);
temp[str_len] = '.';
- temp[str_len+1] = 0;
+ temp[str_len + 1] = 0;
counter = 0;
n_start = temp;
@@ -313,7 +313,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
}
*der_len += len_len;
- _asn1_free (temp);
+ free (temp);
if (max_len < (*der_len))
return ASN1_MEM_ERROR;
@@ -372,11 +372,11 @@ asn1_bit_der (const unsigned char *str, int bit_len,
/* ASN1_MEM_ERROR if der vector isn't big enough, */
/* otherwise ASN1_SUCCESS. */
/******************************************************/
-static asn1_retCode
-_asn1_complete_explicit_tag (ASN1_TYPE node, unsigned char *der,
+static int
+_asn1_complete_explicit_tag (asn1_node node, unsigned char *der,
int *counter, int *max_len)
{
- ASN1_TYPE p;
+ asn1_node p;
int is_tag_implicit, len2, len3;
unsigned char temp[SIZEOF_UNSIGNED_INT];
@@ -445,11 +445,11 @@ _asn1_complete_explicit_tag (ASN1_TYPE node, unsigned char *der,
/* ASN1_MEM_ERROR if der vector isn't big enough, */
/* otherwise ASN1_SUCCESS. */
/******************************************************/
-static asn1_retCode
-_asn1_insert_tag_der (ASN1_TYPE node, unsigned char *der, int *counter,
+static int
+_asn1_insert_tag_der (asn1_node node, unsigned char *der, int *counter,
int *max_len)
{
- ASN1_TYPE p;
+ asn1_node p;
int tag_len, is_tag_implicit;
unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
unsigned long tag_implicit = 0;
@@ -607,7 +607,7 @@ _asn1_insert_tag_der (ASN1_TYPE node, unsigned char *der, int *counter,
/* Return: */
/******************************************************/
static void
-_asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
+_asn1_ordering_set (unsigned char *der, int der_len, asn1_node node)
{
struct vet
{
@@ -618,7 +618,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
int counter, len, len2;
struct vet *first, *last, *p_vet, *p2_vet;
- ASN1_TYPE p;
+ asn1_node p;
unsigned char class, *temp;
unsigned long tag;
@@ -638,7 +638,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
first = last = NULL;
while (p)
{
- p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet));
+ p_vet = malloc (sizeof (struct vet));
if (p_vet == NULL)
return;
@@ -679,7 +679,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
if (p_vet->value > p2_vet->value)
{
/* change position */
- temp = (unsigned char *) _asn1_malloc (p_vet->end - counter);
+ temp = malloc (p_vet->end - counter);
if (temp == NULL)
return;
@@ -688,7 +688,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
p2_vet->end - p_vet->end);
memcpy (der + counter + p2_vet->end - p_vet->end, temp,
p_vet->end - counter);
- _asn1_free (temp);
+ free (temp);
tag = p_vet->value;
p_vet->value = p2_vet->value;
@@ -706,7 +706,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
p_vet->prev->next = NULL;
else
first = NULL;
- _asn1_free (p_vet);
+ free (p_vet);
p_vet = first;
}
}
@@ -721,7 +721,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
/* Return: */
/******************************************************/
static void
-_asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
+_asn1_ordering_set_of (unsigned char *der, int der_len, asn1_node node)
{
struct vet
{
@@ -731,7 +731,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
int counter, len, len2, change;
struct vet *first, *last, *p_vet, *p2_vet;
- ASN1_TYPE p;
+ asn1_node p;
unsigned char *temp, class;
unsigned long k, max;
@@ -752,7 +752,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
first = last = NULL;
while (p)
{
- p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet));
+ p_vet = malloc (sizeof (struct vet));
if (p_vet == NULL)
return;
@@ -817,7 +817,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
if (change == 1)
{
/* change position */
- temp = (unsigned char *) _asn1_malloc (p_vet->end - counter);
+ temp = malloc (p_vet->end - counter);
if (temp == NULL)
return;
@@ -826,7 +826,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
(p2_vet->end) - (p_vet->end));
memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
(p_vet->end) - counter);
- _asn1_free (temp);
+ free (temp);
p_vet->end = counter + (p2_vet->end - p_vet->end);
}
@@ -840,7 +840,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
p_vet->prev->next = NULL;
else
first = NULL;
- _asn1_free (p_vet);
+ free (p_vet);
p_vet = first;
}
}
@@ -866,14 +866,14 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
* vector isn't big enough and in this case @len will contain the
* length needed.
**/
-asn1_retCode
-asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
+int
+asn1_der_coding (asn1_node element, const char *name, void *ider, int *len,
char *ErrorDescription)
{
- ASN1_TYPE node, p, p2;
+ asn1_node node, p, p2;
unsigned char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
- asn1_retCode err;
+ int err;
unsigned char *der = ider;
node = asn1_find_node (element, name);
diff --git a/lib/minitasn1/decoding.c b/lib/minitasn1/decoding.c
index 1cfad3556b..79766a1802 100644
--- a/lib/minitasn1/decoding.c
+++ b/lib/minitasn1/decoding.c
@@ -32,11 +32,11 @@
#include "element.h"
#include <limits.h>
-static asn1_retCode
+static int
_asn1_get_indefinite_length_string (const unsigned char *der, int *len);
static void
-_asn1_error_description_tag_error (ASN1_TYPE node, char *ErrorDescription)
+_asn1_error_description_tag_error (asn1_node node, char *ErrorDescription)
{
Estrcpy (ErrorDescription, ":: tag error near element '");
@@ -58,11 +58,11 @@ _asn1_error_description_tag_error (ASN1_TYPE node, char *ErrorDescription)
* length, or -2 when the value was too big to fit in a int, or -4
* when the decoded length value plus @len would exceed @der_len.
**/
-signed long
+long
asn1_get_length_der (const unsigned char *der, int der_len, int *len)
{
unsigned int ans, sum, last;
- unsigned int k, punt;
+ int k, punt;
*len = 0;
if (der_len <= 0)
@@ -87,7 +87,7 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len)
last = ans;
ans = (ans*256) + der[punt++];
- if (ans < last)
+ if (ans < last)
/* we wrapped around, no bignum support... */
return -2;
}
@@ -102,13 +102,13 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len)
}
sum = ans + *len;
-
+
/* check for overflow as well INT_MAX as a maximum upper
* limit for length */
if (sum >= INT_MAX || sum < ans)
return -2;
-
- if (sum > der_len)
+
+ if (((int) sum) > der_len)
return -4;
return ans;
@@ -130,7 +130,8 @@ int
asn1_get_tag_der (const unsigned char *der, int der_len,
unsigned char *cls, int *len, unsigned long *tag)
{
- unsigned int punt, ris;
+ unsigned int ris;
+ int punt;
unsigned int last;
if (der == NULL || der_len < 2 || len == NULL)
@@ -162,10 +163,10 @@ asn1_get_tag_der (const unsigned char *der, int der_len,
return ASN1_DER_ERROR;
last = ris;
-
+
ris = (ris * 128) + (der[punt++] & 0x7F);
if (ris < last)
- return ASN1_DER_ERROR;
+ return ASN1_DER_ERROR;
*len = punt;
}
@@ -189,7 +190,7 @@ asn1_get_tag_der (const unsigned char *der, int der_len,
*
* Since: 2.0
**/
-signed long
+long
asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len)
{
int ret;
@@ -368,10 +369,10 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
}
static int
-_asn1_extract_tag_der (ASN1_TYPE node, const unsigned char *der, int der_len,
+_asn1_extract_tag_der (asn1_node node, const unsigned char *der, int der_len,
int *ret_len)
{
- ASN1_TYPE p;
+ asn1_node p;
int counter, len2, len3, is_tag_implicit;
unsigned long tag, tag_implicit = 0;
unsigned char class, class2, class_implicit = 0;
@@ -566,9 +567,9 @@ _asn1_extract_tag_der (ASN1_TYPE node, const unsigned char *der, int der_len,
}
static int
-_asn1_delete_not_used (ASN1_TYPE node)
+_asn1_delete_not_used (asn1_node node)
{
- ASN1_TYPE p, p2;
+ asn1_node p, p2;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
@@ -624,8 +625,8 @@ _asn1_delete_not_used (ASN1_TYPE node)
return ASN1_SUCCESS;
}
-static asn1_retCode
-_asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der,
+static int
+_asn1_extract_der_octet (asn1_node node, const unsigned char *der,
int der_len)
{
int len2, len3;
@@ -669,8 +670,8 @@ _asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der,
return ASN1_SUCCESS;
}
-static asn1_retCode
-_asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
+static int
+_asn1_get_octet_string (const unsigned char *der, asn1_node node, int *len)
{
int len2, len3, counter, tot_len, indefinite;
@@ -727,8 +728,6 @@ _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
asn1_length_der (tot_len, temp, &len2);
_asn1_set_value (node, temp, len2);
- tot_len += len2;
-
ret = _asn1_extract_der_octet (node, der, *len);
if (ret != ASN1_SUCCESS)
return ret;
@@ -740,9 +739,10 @@ _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
len2 = asn1_get_length_der (der, *len, &len3);
if (len2 < 0)
return ASN1_DER_ERROR;
- if (node)
- _asn1_set_value (node, der, len3 + len2);
+
counter = len3 + len2;
+ if (node)
+ _asn1_set_value (node, der, counter);
}
*len = counter;
@@ -750,7 +750,7 @@ _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
}
-static asn1_retCode
+static int
_asn1_get_indefinite_length_string (const unsigned char *der, int *len)
{
int len2, len3, counter, indefinite;
@@ -812,18 +812,18 @@ _asn1_get_indefinite_length_string (const unsigned char *der, int *len)
* string. The structure must just be created with function
* asn1_create_element(). If an error occurs during the decoding
* procedure, the *@ELEMENT is deleted and set equal to
- * %ASN1_TYPE_EMPTY.
+ * %NULL.
*
* Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if @ELEMENT is %ASN1_TYPE_EMPTY, and %ASN1_TAG_ERROR or
+ * if @ELEMENT is %NULL, and %ASN1_TAG_ERROR or
* %ASN1_DER_ERROR if the der encoding doesn't match the structure
* name (*@ELEMENT deleted).
**/
-asn1_retCode
-asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
+int
+asn1_der_decoding (asn1_node * element, const void *ider, int len,
char *errorDescription)
{
- ASN1_TYPE node, p, p2, p3;
+ asn1_node node, p, p2, p3;
char temp[128];
int counter, len2, len3, len4, move, ris, tlen;
unsigned char class;
@@ -833,7 +833,10 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
node = *element;
- if (node == ASN1_TYPE_EMPTY)
+ if (errorDescription != NULL)
+ errorDescription[0] = 0;
+
+ if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
if (node->type & CONST_OPTION)
@@ -1390,18 +1393,18 @@ cleanup:
* asn1_create_element(). 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.
+ * %NULL.
*
* Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if ELEMENT is %ASN1_TYPE_EMPTY or @elementName == NULL, and
+ * if ELEMENT is %NULL or @elementName == NULL, and
* %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding doesn't
* match the structure @structure (*ELEMENT deleted).
**/
-asn1_retCode
-asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
+int
+asn1_der_decoding_element (asn1_node * structure, const char *elementName,
const void *ider, int len, char *errorDescription)
{
- ASN1_TYPE node, p, p2, p3, nodeFound = ASN1_TYPE_EMPTY;
+ asn1_node node, p, p2, p3, nodeFound = NULL;
char temp[128], currentName[ASN1_MAX_NAME_SIZE * 10], *dot_p, *char_p;
int nameLen = ASN1_MAX_NAME_SIZE * 10 - 1, state;
int counter, len2, len3, len4, move, ris, tlen;
@@ -1412,7 +1415,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
node = *structure;
- if (node == ASN1_TYPE_EMPTY)
+ if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
if (elementName == NULL)
@@ -1427,7 +1430,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
goto cleanup;
}
- if ((*structure)->name)
+ if ((*structure)->name[0] != 0)
{ /* Has *structure got a name? */
nameLen -= strlen ((*structure)->name);
if (nameLen > 0)
@@ -2207,15 +2210,15 @@ cleanup:
* certificate.
*
* Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if ELEMENT is %ASN1_TYPE EMPTY or @name_element is not a valid
+ * if ELEMENT is %asn1_node EMPTY or @name_element is not a valid
* element, %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding
* doesn't match the structure ELEMENT.
**/
-asn1_retCode
-asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
+int
+asn1_der_decoding_startEnd (asn1_node element, const void *ider, int len,
const char *name_element, int *start, int *end)
{
- ASN1_TYPE node, node_to_find, p, p2, p3;
+ asn1_node node, node_to_find, p, p2, p3;
int counter, len2, len3, len4, move, ris;
unsigned char class;
unsigned long tag;
@@ -2224,7 +2227,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
node = element;
- if (node == ASN1_TYPE_EMPTY)
+ if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
node_to_find = asn1_find_node (node, name_element);
@@ -2247,6 +2250,9 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
p = node;
while (1)
{
+ if (p == NULL)
+ return ASN1_DER_ERROR;
+
ris = ASN1_SUCCESS;
if (move != UP)
@@ -2254,6 +2260,9 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
if (p->type & CONST_SET)
{
p2 = _asn1_find_up (p);
+ if (p2 == NULL)
+ return ASN1_DER_ERROR;
+
len2 = _asn1_strtol (p2->value, NULL, 10);
if (len2 == -1)
{
@@ -2273,7 +2282,9 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
}
else if (counter > len2)
return ASN1_DER_ERROR;
+
p2 = p2->down;
+
while (p2)
{
if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
@@ -2285,6 +2296,9 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
else
{
p3 = p2->down;
+ if (p3 == NULL)
+ return ASN1_DER_ERROR;
+
ris =
_asn1_extract_tag_der (p3, der + counter,
len - counter, &len2);
@@ -2308,6 +2322,9 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
if (type_field (p->type) == TYPE_CHOICE)
{
p = p->down;
+ if (p == NULL)
+ return ASN1_DER_ERROR;
+
ris =
_asn1_extract_tag_der (p, der + counter, len - counter,
&len2);
@@ -2548,17 +2565,17 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
* problem in OBJECT_ID -> TYPE association, or other error codes
* depending on DER decoding.
**/
-asn1_retCode
-asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
+int
+asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
{
char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1],
value[ASN1_MAX_NAME_SIZE];
- asn1_retCode retCode = ASN1_SUCCESS, result;
+ int retCode = ASN1_SUCCESS, result;
int len, len2, len3;
- ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY;
+ asn1_node p, p2, p3, aux = NULL;
char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
- if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
+ if ((definitions == NULL) || (*element == NULL))
return ASN1_ELEMENT_NOT_FOUND;
strcpy (definitionsName, definitions->name);
@@ -2595,7 +2612,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
p3 = p3->down;
while (p3)
{
- if ((p3->name) && !(strcmp (p3->name, p2->name)))
+ if (!(strcmp (p3->name, p2->name)))
break;
p3 = p3->right;
}
@@ -2617,7 +2634,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
while (p3)
{
- if ((p3->name) && !(strcmp (p3->name, p2->name)))
+ if (!(strcmp (p3->name, p2->name)))
break;
p3 = p3->right;
}
@@ -2661,7 +2678,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
asn1_create_element (definitions, name, &aux);
if (result == ASN1_SUCCESS)
{
- _asn1_set_name (aux, p->name);
+ _asn1_cpy_name (aux, p);
len2 =
asn1_get_length_der (p->value,
p->value_len, &len3);
@@ -2682,7 +2699,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
if (result == ASN1_SUCCESS)
{
p = aux;
- aux = ASN1_TYPE_EMPTY;
+ aux = NULL;
break;
}
else
@@ -2778,22 +2795,22 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
* %ASN1_VALUE_NOT_VALID if it wasn't possible to find the type to
* use for expansion, or other errors depending on DER decoding.
**/
-asn1_retCode
-asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
+int
+asn1_expand_octet_string (asn1_node definitions, asn1_node * element,
const char *octetName, const char *objectName)
{
char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE];
- asn1_retCode retCode = ASN1_SUCCESS, result;
+ int retCode = ASN1_SUCCESS, result;
int len, len2, len3;
- ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY;
- ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY;
+ asn1_node p2, aux = NULL;
+ asn1_node octetNode = NULL, objectNode = NULL;
char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
- if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
+ if ((definitions == NULL) || (*element == NULL))
return ASN1_ELEMENT_NOT_FOUND;
octetNode = asn1_find_node (*element, octetName);
- if (octetNode == ASN1_TYPE_EMPTY)
+ if (octetNode == NULL)
return ASN1_ELEMENT_NOT_FOUND;
if (type_field (octetNode->type) != TYPE_OCTET_STRING)
return ASN1_ELEMENT_NOT_FOUND;
@@ -2801,7 +2818,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
return ASN1_VALUE_NOT_FOUND;
objectNode = asn1_find_node (*element, objectName);
- if (objectNode == ASN1_TYPE_EMPTY)
+ if (objectNode == NULL)
return ASN1_ELEMENT_NOT_FOUND;
if (type_field (objectNode->type) != TYPE_OBJECT_ID)
@@ -2843,7 +2860,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
result = asn1_create_element (definitions, name, &aux);
if (result == ASN1_SUCCESS)
{
- _asn1_set_name (aux, octetNode->name);
+ _asn1_cpy_name (aux, octetNode);
len2 =
asn1_get_length_der (octetNode->value,
octetNode->value_len, &len3);
@@ -2862,7 +2879,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
result = asn1_delete_structure (&octetNode);
if (result == ASN1_SUCCESS)
{
- aux = ASN1_TYPE_EMPTY;
+ aux = NULL;
break;
}
else
diff --git a/lib/minitasn1/element.c b/lib/minitasn1/element.c
index ead899c953..4c871a1b31 100644
--- a/lib/minitasn1/element.c
+++ b/lib/minitasn1/element.c
@@ -34,9 +34,9 @@
#include "element.h"
void
-_asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size)
+_asn1_hierarchical_name (asn1_node node, char *name, int name_size)
{
- ASN1_TYPE p;
+ asn1_node p;
char tmp_name[64];
p = node;
@@ -45,7 +45,7 @@ _asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size)
while (p != NULL)
{
- if (p->name != NULL)
+ if (p->name[0] != 0)
{
_asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
_asn1_str_cpy (name, name_size, p->name);
@@ -74,7 +74,7 @@ _asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size)
/* len: number of significant byte of value_out. */
/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
+int
_asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
int value_out_size, int *len)
{
@@ -127,9 +127,9 @@ _asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
int
-_asn1_append_sequence_set (ASN1_TYPE node)
+_asn1_append_sequence_set (asn1_node node)
{
- ASN1_TYPE p, p2;
+ asn1_node p, p2;
char temp[10];
long n;
@@ -145,7 +145,7 @@ _asn1_append_sequence_set (ASN1_TYPE node)
p = p->right;
_asn1_set_right (p, p2);
- if (p->name == NULL)
+ if (p->name[0] == 0)
_asn1_str_cpy (temp, sizeof (temp), "?1");
else
{
@@ -267,11 +267,11 @@ _asn1_append_sequence_set (ASN1_TYPE node)
* %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element, and
* %ASN1_VALUE_NOT_VALID if @ivalue has a wrong format.
**/
-asn1_retCode
-asn1_write_value (ASN1_TYPE node_root, const char *name,
+int
+asn1_write_value (asn1_node node_root, const char *name,
const void *ivalue, int len)
{
- ASN1_TYPE node, p, p2;
+ asn1_node node, p, p2;
unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
int len2, k, k2, negative;
size_t i;
@@ -343,8 +343,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
{
if ((isdigit (value[0])) || (value[0] == '-'))
{
- value_temp =
- (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
+ value_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
if (value_temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
@@ -360,11 +359,9 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
{
if (type_field (p->type) == TYPE_CONSTANT)
{
- if ((p->name) && (!_asn1_strcmp (p->name, value)))
+ if (!_asn1_strcmp (p->name, value))
{
- value_temp =
- (unsigned char *)
- _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
+ value_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
if (value_temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
@@ -383,7 +380,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
}
else
{ /* len != 0 */
- value_temp = (unsigned char *) _asn1_malloc (len);
+ value_temp = malloc (len);
if (value_temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
memcpy (value_temp, value, len);
@@ -397,7 +394,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
if (negative && (type_field (node->type) == TYPE_ENUMERATED))
{
- _asn1_free (value_temp);
+ free (value_temp);
return ASN1_VALUE_NOT_VALID;
}
@@ -420,11 +417,10 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
p = p->right;
if ((isdigit (p->value[0])) || (p->value[0] == '-'))
{
- default_temp =
- (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
+ default_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
if (default_temp == NULL)
{
- _asn1_free (value_temp);
+ free (value_temp);
return ASN1_MEM_ALLOC_ERROR;
}
@@ -435,7 +431,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
{ /* is an identifier like v1 */
if (!(node->type & CONST_LIST))
{
- _asn1_free (value_temp);
+ free (value_temp);
return ASN1_VALUE_NOT_VALID;
}
p2 = node->down;
@@ -443,14 +439,12 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
+ if (!_asn1_strcmp (p2->name, p->value))
{
- default_temp =
- (unsigned char *)
- _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
+ default_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
if (default_temp == NULL)
{
- _asn1_free (value_temp);
+ free (value_temp);
return ASN1_MEM_ALLOC_ERROR;
}
@@ -465,7 +459,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
}
if (p2 == NULL)
{
- _asn1_free (value_temp);
+ free (value_temp);
return ASN1_VALUE_NOT_VALID;
}
}
@@ -481,9 +475,9 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
if (k2 == len2)
_asn1_set_value (node, NULL, 0);
}
- _asn1_free (default_temp);
+ free (default_temp);
}
- _asn1_free (value_temp);
+ free (value_temp);
break;
case TYPE_OBJECT_ID:
for (i = 0; i < _asn1_strlen (value); i++)
@@ -562,7 +556,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
if (len == 0)
len = _asn1_strlen (value);
asn1_length_der ((len >> 3) + 2, NULL, &len2);
- temp = (unsigned char *) _asn1_malloc ((len >> 3) + 2 + len2);
+ temp = malloc ((len >> 3) + 2 + len2);
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
@@ -699,10 +693,10 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
* to store the result, and in this case @len will contain the number of
* bytes needed.
**/
-asn1_retCode
-asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
+int
+asn1_read_value (asn1_node root, const char *name, void *ivalue, int *len)
{
- ASN1_TYPE node, p, p2;
+ asn1_node node, p, p2;
int len2, len3;
int value_size = *len;
unsigned char *value = ivalue;
@@ -767,7 +761,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
+ if (!_asn1_strcmp (p2->name, p->value))
{
if (_asn1_convert_integer
(p2->value, value, value_size,
@@ -877,11 +871,11 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
* Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
* @name is not a valid element.
**/
-asn1_retCode
-asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue,
+int
+asn1_read_tag (asn1_node root, const char *name, int *tagValue,
int *classValue)
{
- ASN1_TYPE node, p, pTag;
+ asn1_node node, p, pTag;
node = asn1_find_node (root, name);
if (node == NULL)
@@ -976,3 +970,23 @@ asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue,
return ASN1_SUCCESS;
}
+
+/**
+ * asn1_read_node_value:
+ * @node: pointer to a node.
+ * @data: a point to a asn1_data_node_st
+ *
+ * Returns the value a data node inside a asn1_node structure.
+ * The data returned should be handled as constant values.
+ *
+ * Returns: %ASN1_SUCCESS if the node exists.
+ **/
+int asn1_read_node_value (asn1_node node, asn1_data_node_st* data)
+{
+ data->name = node->name;
+ data->value = node->value;
+ data->value_len = node->value_len;
+ data->type = type_field(node->type);
+
+ return ASN1_SUCCESS;
+}
diff --git a/lib/minitasn1/element.h b/lib/minitasn1/element.h
index 9cad46edc5..3bd38bb923 100644
--- a/lib/minitasn1/element.h
+++ b/lib/minitasn1/element.h
@@ -23,12 +23,12 @@
#define _ELEMENT_H
-asn1_retCode _asn1_append_sequence_set (ASN1_TYPE node);
+int _asn1_append_sequence_set (asn1_node node);
-asn1_retCode _asn1_convert_integer (const unsigned char *value,
+int _asn1_convert_integer (const unsigned char *value,
unsigned char *value_out,
int value_out_size, int *len);
-void _asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size);
+void _asn1_hierarchical_name (asn1_node node, char *name, int name_size);
#endif
diff --git a/lib/minitasn1/errors.c b/lib/minitasn1/errors.c
index 7878c50af5..e01c3ee9ea 100644
--- a/lib/minitasn1/errors.c
+++ b/lib/minitasn1/errors.c
@@ -21,7 +21,7 @@
#include <int.h>
#ifdef STDC_HEADERS
-# include <stdarg.h>
+#include <stdarg.h>
#endif
#define LIBTASN1_ERROR_ENTRY(name) { #name, name }
@@ -68,7 +68,7 @@ static const libtasn1_error_entry error_algorithms[] = {
* Since: 1.6
**/
void
-asn1_perror (asn1_retCode error)
+asn1_perror (int error)
{
const char *str = asn1_strerror (error);
fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)");
@@ -90,7 +90,7 @@ asn1_perror (asn1_retCode error)
* Since: 1.6
**/
const char *
-asn1_strerror (asn1_retCode error)
+asn1_strerror (int error)
{
const libtasn1_error_entry *p;
@@ -100,44 +100,3 @@ asn1_strerror (asn1_retCode error)
return NULL;
}
-
-#ifndef ASN1_DISABLE_DEPRECATED
-
-/* Compatibility mappings to preserve ABI. */
-
-/**
- * libtasn1_perror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Prints a string to stderr with a description of an error. This
- * function is like perror(). The only difference is that it accepts
- * an error returned by a libtasn1 function.
- *
- * Deprecated: Use asn1_perror() instead.
- **/
-void
-libtasn1_perror (asn1_retCode error)
-{
- asn1_perror (error);
-}
-
-/**
- * libtasn1_strerror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Returns a string with a description of an error. This function is
- * similar to strerror. The only difference is that it accepts an
- * error (number) returned by a libtasn1 function.
- *
- * Returns: Pointer to static zero-terminated string describing error
- * code.
- *
- * Deprecated: Use asn1_strerror() instead.
- **/
-const char *
-libtasn1_strerror (asn1_retCode error)
-{
- return asn1_strerror (error);
-}
-
-#endif
diff --git a/lib/minitasn1/gstr.c b/lib/minitasn1/gstr.c
index 9590b45a00..0558c77771 100644
--- a/lib/minitasn1/gstr.c
+++ b/lib/minitasn1/gstr.c
@@ -48,7 +48,8 @@ _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
}
}
-void
+/* Returns the bytes copied (not including the null terminator) */
+unsigned int
_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
{
size_t str_size = strlen (src);
@@ -56,13 +57,17 @@ _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
if (dest_tot_size > str_size)
{
strcpy (dest, src);
+ return str_size;
}
else
{
if (dest_tot_size > 0)
{
- strncpy (dest, src, (dest_tot_size) - 1);
- dest[dest_tot_size - 1] = 0;
+ str_size = dest_tot_size - 1;
+ memcpy (dest, src, str_size);
+ dest[str_size] = 0;
+ return str_size;
}
+ else return 0;
}
}
diff --git a/lib/minitasn1/gstr.h b/lib/minitasn1/gstr.h
index baaa6a0b1a..672d59eb59 100644
--- a/lib/minitasn1/gstr.h
+++ b/lib/minitasn1/gstr.h
@@ -19,7 +19,7 @@
* 02110-1301, USA
*/
-void _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
+unsigned int _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
diff --git a/lib/minitasn1/int.h b/lib/minitasn1/int.h
index fcaf0d8d09..09082845ac 100644
--- a/lib/minitasn1/int.h
+++ b/lib/minitasn1/int.h
@@ -23,7 +23,7 @@
#define INT_H
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <string.h>
@@ -33,7 +33,7 @@
#include <stdint.h>
#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
+#include <sys/types.h>
#endif
#include <libtasn1.h>
@@ -43,25 +43,21 @@
/* This structure is also in libtasn1.h, but then contains less
fields. You cannot make any modifications to these first fields
without breaking ABI. */
-struct node_asn_struct
+struct asn1_node_st
{
/* public fields: */
- char *name; /* Node name */
+ char name[ASN1_MAX_NAME_SIZE+1]; /* Node name */
+ unsigned int name_hash;
unsigned int type; /* Node type */
unsigned char *value; /* Node value */
int value_len;
- ASN1_TYPE down; /* Pointer to the son node */
- ASN1_TYPE right; /* Pointer to the brother node */
- ASN1_TYPE left; /* Pointer to the next list element */
+ asn1_node down; /* Pointer to the son node */
+ asn1_node right; /* Pointer to the brother node */
+ asn1_node left; /* Pointer to the next list element */
/* private fields: */
unsigned char small_value[ASN1_SMALL_VALUE_SIZE]; /* For small values */
};
-#define _asn1_malloc malloc
-#define _asn1_free free
-#define _asn1_calloc calloc
-#define _asn1_realloc realloc
-#define _asn1_strdup strdup
#define _asn1_strlen(s) strlen((const char *) s)
#define _asn1_strtol(n,e,b) strtol((const char *) n, e, b)
#define _asn1_strtoul(n,e,b) strtoul((const char *) n, e, b)
@@ -78,37 +74,37 @@ struct node_asn_struct
/****************************************/
/* Returns the first 8 bits. */
-/* Used with the field type of node_asn */
+/* Used with the field type of asn1_node_st */
/****************************************/
#define type_field(x) (x&0xFF)
-/* List of constants for field type of typedef node_asn */
-#define TYPE_CONSTANT 1
-#define TYPE_IDENTIFIER 2
-#define TYPE_INTEGER 3
-#define TYPE_BOOLEAN 4
-#define TYPE_SEQUENCE 5
-#define TYPE_BIT_STRING 6
-#define TYPE_OCTET_STRING 7
-#define TYPE_TAG 8
-#define TYPE_DEFAULT 9
-#define TYPE_SIZE 10
-#define TYPE_SEQUENCE_OF 11
-#define TYPE_OBJECT_ID 12
-#define TYPE_ANY 13
-#define TYPE_SET 14
-#define TYPE_SET_OF 15
-#define TYPE_DEFINITIONS 16
-#define TYPE_TIME 17
-#define TYPE_CHOICE 18
-#define TYPE_IMPORTS 19
-#define TYPE_NULL 20
-#define TYPE_ENUMERATED 21
-#define TYPE_GENERALSTRING 27
+/* List of constants for field type of typedef asn1_node_st */
+#define TYPE_CONSTANT ASN1_ETYPE_CONSTANT
+#define TYPE_IDENTIFIER ASN1_ETYPE_IDENTIFIER
+#define TYPE_INTEGER ASN1_ETYPE_INTEGER
+#define TYPE_BOOLEAN ASN1_ETYPE_BOOLEAN
+#define TYPE_SEQUENCE ASN1_ETYPE_SEQUENCE
+#define TYPE_BIT_STRING ASN1_ETYPE_BIT_STRING
+#define TYPE_OCTET_STRING ASN1_ETYPE_OCTET_STRING
+#define TYPE_TAG ASN1_ETYPE_TAG
+#define TYPE_DEFAULT ASN1_ETYPE_DEFAULT
+#define TYPE_SIZE ASN1_ETYPE_SIZE
+#define TYPE_SEQUENCE_OF ASN1_ETYPE_SEQUENCE_OF
+#define TYPE_OBJECT_ID ASN1_ETYPE_OBJECT_ID
+#define TYPE_ANY ASN1_ETYPE_ANY
+#define TYPE_SET ASN1_ETYPE_SET
+#define TYPE_SET_OF ASN1_ETYPE_SET_OF
+#define TYPE_DEFINITIONS ASN1_ETYPE_DEFINITIONS
+#define TYPE_TIME ASN1_ETYPE_TIME
+#define TYPE_CHOICE ASN1_ETYPE_CHOICE
+#define TYPE_IMPORTS ASN1_ETYPE_IMPORTS
+#define TYPE_NULL ASN1_ETYPE_NULL
+#define TYPE_ENUMERATED ASN1_ETYPE_ENUMERATED
+#define TYPE_GENERALSTRING ASN1_ETYPE_GENERALSTRING
/***********************************************************************/
-/* List of constants to better specify the type of typedef node_asn. */
+/* List of constants to better specify the type of typedef asn1_node_st. */
/***********************************************************************/
/* Used with TYPE_TAG */
#define CONST_UNIVERSAL (1<<8)
diff --git a/lib/minitasn1/libtasn1.h b/lib/minitasn1/libtasn1.h
index 289fb5792a..5be46d073c 100644
--- a/lib/minitasn1/libtasn1.h
+++ b/lib/minitasn1/libtasn1.h
@@ -44,9 +44,7 @@ extern "C"
{
#endif
-#define ASN1_VERSION "2.12"
-
- typedef int asn1_retCode; /* type returned by libtasn1 functions */
+#define ASN1_VERSION "3.0"
/*****************************************/
/* Errors returned by libtasn1 functions */
@@ -108,46 +106,63 @@ extern "C"
/* that represent an ASN.1 DEFINITION. */
/******************************************************/
-#if !defined ASN1_BUILDING
- /* This structure is also in internal.h, but then contains more
- fields. You cannot make any modifications to these fields
- without breaking ABI. */
- struct node_asn_struct
- {
- char *name; /* Node name */
- unsigned int type; /* Node type */
- unsigned char *value; /* Node value */
- int value_len;
- 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 */
- };
-#endif
+ typedef struct asn1_node_st asn1_node_st;
- typedef struct node_asn_struct node_asn;
+ typedef asn1_node_st *asn1_node;
- typedef node_asn *ASN1_TYPE;
+ /* maximum number of characters of a name */
+ /* inside a file with ASN1 definitons */
+#define ASN1_MAX_NAME_SIZE 64
-#define ASN1_TYPE_EMPTY NULL
/*****************************************/
/* For the on-disk format of ASN.1 trees */
/*****************************************/
- struct static_struct_asn
+ struct asn1_static_node_st
{
const char *name; /* Node name */
unsigned int type; /* Node type */
const void *value; /* Node value */
};
- typedef struct static_struct_asn ASN1_ARRAY_TYPE;
+ typedef struct asn1_static_node_st asn1_static_node_t;
+
+/* List of constants for field type of typedef node_asn */
+#define ASN1_ETYPE_CONSTANT 1
+#define ASN1_ETYPE_IDENTIFIER 2
+#define ASN1_ETYPE_INTEGER 3
+#define ASN1_ETYPE_BOOLEAN 4
+#define ASN1_ETYPE_SEQUENCE 5
+#define ASN1_ETYPE_BIT_STRING 6
+#define ASN1_ETYPE_OCTET_STRING 7
+#define ASN1_ETYPE_TAG 8
+#define ASN1_ETYPE_DEFAULT 9
+#define ASN1_ETYPE_SIZE 10
+#define ASN1_ETYPE_SEQUENCE_OF 11
+#define ASN1_ETYPE_OBJECT_ID 12
+#define ASN1_ETYPE_ANY 13
+#define ASN1_ETYPE_SET 14
+#define ASN1_ETYPE_SET_OF 15
+#define ASN1_ETYPE_DEFINITIONS 16
+#define ASN1_ETYPE_TIME 17
+#define ASN1_ETYPE_CHOICE 18
+#define ASN1_ETYPE_IMPORTS 19
+#define ASN1_ETYPE_NULL 20
+#define ASN1_ETYPE_ENUMERATED 21
+#define ASN1_ETYPE_GENERALSTRING 27
+
+ struct asn1_data_node_st
+ {
+ const char *name; /* Node name */
+ const void *value; /* Node value */
+ unsigned int value_len; /* Node value size */
+ unsigned int type; /* Node value type (ASN1_ETYPE_*) */
+ };
+ typedef struct asn1_data_node_st asn1_data_node_st;
/***********************************/
/* Fixed constants */
/***********************************/
- /* maximum number of characters of a name */
- /* inside a file with ASN1 definitons */
-#define ASN1_MAX_NAME_SIZE 128
/* maximum number of characters */
/* of a description message */
@@ -158,85 +173,88 @@ extern "C"
/* Functions definitions */
/***********************************/
- extern ASN1_API asn1_retCode
+ extern ASN1_API int
asn1_parser2tree (const char *file_name,
- ASN1_TYPE * definitions, char *errorDescription);
+ asn1_node * definitions, char *errorDescription);
- extern ASN1_API asn1_retCode
+ extern ASN1_API int
asn1_parser2array (const char *inputFileName,
const char *outputFileName,
const char *vectorName, char *errorDescription);
- extern ASN1_API asn1_retCode
- asn1_array2tree (const ASN1_ARRAY_TYPE * array,
- ASN1_TYPE * definitions, char *errorDescription);
+ extern ASN1_API int
+ asn1_array2tree (const asn1_static_node_t * array,
+ asn1_node * definitions, char *errorDescription);
extern ASN1_API void
- asn1_print_structure (FILE * out, ASN1_TYPE structure,
+ asn1_print_structure (FILE * out, asn1_node structure,
const char *name, int mode);
- extern ASN1_API asn1_retCode
- asn1_create_element (ASN1_TYPE definitions,
- const char *source_name, ASN1_TYPE * element);
+ extern ASN1_API int
+ asn1_create_element (asn1_node definitions,
+ const char *source_name, asn1_node * element);
- extern ASN1_API asn1_retCode asn1_delete_structure (ASN1_TYPE * structure);
+ extern ASN1_API int asn1_delete_structure (asn1_node * structure);
- extern ASN1_API asn1_retCode
- asn1_delete_element (ASN1_TYPE structure, const char *element_name);
+ extern ASN1_API int
+ asn1_delete_element (asn1_node structure, const char *element_name);
- extern ASN1_API asn1_retCode
- asn1_write_value (ASN1_TYPE node_root, const char *name,
+ extern ASN1_API int
+ asn1_write_value (asn1_node node_root, const char *name,
const void *ivalue, int len);
- extern ASN1_API asn1_retCode
- asn1_read_value (ASN1_TYPE root, const char *name,
+ extern ASN1_API int
+ asn1_read_value (asn1_node root, const char *name,
void *ivalue, int *len);
- extern ASN1_API asn1_retCode
- asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num);
+ extern ASN1_API int
+ asn1_read_node_value (asn1_node node, asn1_data_node_st* data);
- extern ASN1_API asn1_retCode
- asn1_der_coding (ASN1_TYPE element, const char *name,
+ extern ASN1_API int
+ asn1_number_of_elements (asn1_node element, const char *name, int *num);
+
+ extern ASN1_API int
+ asn1_der_coding (asn1_node element, const char *name,
void *ider, int *len, char *ErrorDescription);
- extern ASN1_API asn1_retCode
- asn1_der_decoding (ASN1_TYPE * element, const void *ider,
+ extern ASN1_API int
+ asn1_der_decoding (asn1_node * element, const void *ider,
int len, char *errorDescription);
- extern ASN1_API asn1_retCode
- asn1_der_decoding_element (ASN1_TYPE * structure,
+ extern ASN1_API int
+ asn1_der_decoding_element (asn1_node * structure,
const char *elementName,
const void *ider, int len,
char *errorDescription);
- extern ASN1_API asn1_retCode
- asn1_der_decoding_startEnd (ASN1_TYPE element,
+ extern ASN1_API int
+ asn1_der_decoding_startEnd (asn1_node element,
const void *ider, int len,
const char *name_element,
int *start, int *end);
- extern ASN1_API asn1_retCode
- asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element);
+ extern ASN1_API int
+ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element);
- extern ASN1_API asn1_retCode
- asn1_expand_octet_string (ASN1_TYPE definitions,
- ASN1_TYPE * element,
+ extern ASN1_API int
+ asn1_expand_octet_string (asn1_node definitions,
+ asn1_node * element,
const char *octetName, const char *objectName);
- extern ASN1_API asn1_retCode
- asn1_read_tag (ASN1_TYPE root, const char *name,
+ extern ASN1_API int
+ asn1_read_tag (asn1_node root, const char *name,
int *tagValue, int *classValue);
- extern ASN1_API const char *asn1_find_structure_from_oid (ASN1_TYPE
+ extern ASN1_API const char *asn1_find_structure_from_oid (asn1_node
definitions,
const char
*oidValue);
extern ASN1_API const char *asn1_check_version (const char *req_version);
- extern ASN1_API const char *asn1_strerror (asn1_retCode error);
+ extern ASN1_API const char *asn1_strerror (int error);
- extern ASN1_API void asn1_perror (asn1_retCode error);
+ extern ASN1_API void asn1_perror (int error);
/* DER utility functions. */
@@ -248,7 +266,7 @@ extern "C"
asn1_octet_der (const unsigned char *str, int str_len,
unsigned char *der, int *der_len);
- extern ASN1_API asn1_retCode
+ extern ASN1_API int
asn1_get_octet_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str,
int str_size, int *str_len);
@@ -256,15 +274,15 @@ extern "C"
extern ASN1_API void asn1_bit_der (const unsigned char *str, int bit_len,
unsigned char *der, int *der_len);
- extern ASN1_API asn1_retCode
+ extern ASN1_API int
asn1_get_bit_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str,
int str_size, int *bit_len);
- extern ASN1_API signed long
+ extern ASN1_API long
asn1_get_length_der (const unsigned char *der, int der_len, int *len);
- extern ASN1_API signed long
+ extern ASN1_API long
asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len);
extern ASN1_API void
@@ -272,43 +290,27 @@ extern "C"
/* Other utility functions. */
- extern ASN1_API ASN1_TYPE
- asn1_find_node (ASN1_TYPE pointer, const char *name);
-
- extern ASN1_API asn1_retCode
- asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
- ASN1_TYPE src, const char *src_name);
+ extern ASN1_API asn1_node
+ asn1_find_node (asn1_node pointer, const char *name);
- /* Deprecated stuff. */
-
-#ifndef ASN1_DISABLE_DEPRECATED
-
-#define LIBTASN1_VERSION ASN1_VERSION
-
-#ifndef MAX_NAME_SIZE
-# define MAX_NAME_SIZE ASN1_MAX_NAME_SIZE
-#endif
+ extern ASN1_API int
+ asn1_copy_node (asn1_node dst, const char *dst_name,
+ asn1_node src, const char *src_name);
-#ifndef MAX_ERROR_DESCRIPTION_SIZE
-# define MAX_ERROR_DESCRIPTION_SIZE ASN1_MAX_ERROR_DESCRIPTION_SIZE
-#endif
+/* Compatibility types */
-#ifndef __attribute__
- /* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-# define __attribute__(Spec) /* empty */
-# endif
-#endif
+typedef int asn1_retCode; /* type returned by libtasn1 functions */
- /* Use asn1_strerror instead. */
- extern ASN1_API const char *libtasn1_strerror (asn1_retCode error)
- __attribute__ ((deprecated));
+#define node_asn_struct asn1_node_st
+#define node_asn asn1_node_st
+#define ASN1_TYPE asn1_node
+#define ASN1_TYPE_EMPTY NULL
- /* Use asn1_perror instead. */
- extern ASN1_API void
- libtasn1_perror (asn1_retCode error) __attribute__ ((deprecated));
+#define static_struct_asn asn1_static_node_st
+#define ASN1_ARRAY_TYPE asn1_static_node_t
-#endif
+#define node_data_struct asn1_data_node_st
+#define ASN1_DATA_NODE asn1_data_node_st
#ifdef __cplusplus
}
diff --git a/lib/minitasn1/parser_aux.c b/lib/minitasn1/parser_aux.c
index ce55253f05..96ecac6bb2 100644
--- a/lib/minitasn1/parser_aux.c
+++ b/lib/minitasn1/parser_aux.c
@@ -20,6 +20,7 @@
*/
#include <int.h>
+#include <hash-pjw-bare.h>
#include "parser_aux.h"
#include "gstr.h"
#include "structure.h"
@@ -34,7 +35,7 @@ char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1]; /* identifier name not fou
/***********************************************/
typedef struct list_struct
{
- ASN1_TYPE node;
+ asn1_node node;
struct list_struct *next;
} list_type;
@@ -43,7 +44,7 @@ typedef struct list_struct
list_type *firstElement = NULL;
/******************************************************/
-/* Function : _asn1_add_node */
+/* Function : _asn1_add_static_node */
/* Description: creates a new NODE_ASN element and */
/* puts it in the list pointed by firstElement. */
/* Parameters: */
@@ -51,20 +52,20 @@ list_type *firstElement = NULL;
/* and CONST_ constants). */
/* Return: pointer to the new element. */
/******************************************************/
-ASN1_TYPE
-_asn1_add_node (unsigned int type)
+asn1_node
+_asn1_add_static_node (unsigned int type)
{
list_type *listElement;
- ASN1_TYPE punt;
+ asn1_node punt;
- punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
+ punt = calloc (1, sizeof (struct asn1_node_st));
if (punt == NULL)
return NULL;
- listElement = (list_type *) _asn1_malloc (sizeof (list_type));
+ listElement = malloc (sizeof (list_type));
if (listElement == NULL)
{
- _asn1_free (punt);
+ free (punt);
return NULL;
}
@@ -89,12 +90,14 @@ _asn1_add_node (unsigned int type)
*
* Returns: the search result, or %NULL if not found.
**/
-ASN1_TYPE
-asn1_find_node (ASN1_TYPE pointer, const char *name)
+asn1_node
+asn1_find_node (asn1_node pointer, const char *name)
{
- ASN1_TYPE p;
+ asn1_node p;
char *n_end, n[ASN1_MAX_NAME_SIZE + 1];
const char *n_start;
+ unsigned int nsize;
+ unsigned int nhash;
if (pointer == NULL)
return NULL;
@@ -105,25 +108,30 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
p = pointer;
n_start = name;
- if (p->name != NULL)
+ if (p->name[0] != 0)
{ /* has *pointer got a name ? */
n_end = strchr (n_start, '.'); /* search the first dot */
if (n_end)
{
- memcpy (n, n_start, n_end - n_start);
- n[n_end - n_start] = 0;
+ nsize = n_end - n_start;
+ memcpy (n, n_start, nsize);
+ n[nsize] = 0;
n_start = n_end;
n_start++;
+
+ nhash = hash_pjw_bare(n, nsize);
}
else
{
- _asn1_str_cpy (n, sizeof (n), n_start);
+ nsize = _asn1_str_cpy (n, sizeof (n), n_start);
+ nhash = hash_pjw_bare(n, nsize);
+
n_start = NULL;
}
while (p)
{
- if ((p->name) && (!strcmp (p->name, n)))
+ if ((p->name) && nhash == p->name_hash && (!strcmp (p->name, n)))
break;
else
p = p->right;
@@ -143,14 +151,18 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
n_end = strchr (n_start, '.'); /* search the next dot */
if (n_end)
{
- memcpy (n, n_start, n_end - n_start);
- n[n_end - n_start] = 0;
+ nsize = n_end - n_start;
+ memcpy (n, n_start, nsize);
+ n[nsize] = 0;
n_start = n_end;
n_start++;
+
+ nhash = hash_pjw_bare(n, nsize);
}
else
{
- _asn1_str_cpy (n, sizeof (n), n_start);
+ nsize = _asn1_str_cpy (n, sizeof (n), n_start);
+ nhash = hash_pjw_bare(n, nsize);
n_start = NULL;
}
@@ -172,7 +184,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
{ /* no "?LAST" */
while (p)
{
- if ((p->name) && (!strcmp (p->name, n)))
+ if (p->name_hash == nhash && !strcmp (p->name, n))
break;
else
p = p->right;
@@ -196,15 +208,15 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
/* len: character number of value. */
/* Return: pointer to the NODE_ASN element. */
/******************************************************************/
-ASN1_TYPE
-_asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len)
+asn1_node
+_asn1_set_value (asn1_node node, const void *value, unsigned int len)
{
if (node == NULL)
return node;
if (node->value)
{
if (node->value != node->small_value)
- _asn1_free (node->value);
+ free (node->value);
node->value = NULL;
node->value_len = 0;
}
@@ -218,7 +230,7 @@ _asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len)
}
else
{
- node->value = _asn1_malloc (len);
+ node->value = malloc (len);
if (node->value == NULL)
return NULL;
}
@@ -239,8 +251,8 @@ _asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len)
/* len: character number of value. */
/* Return: pointer to the NODE_ASN element. */
/******************************************************************/
-ASN1_TYPE
-_asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len)
+asn1_node
+_asn1_set_value_octet (asn1_node node, const void *value, unsigned int len)
{
int len2;
void *temp;
@@ -249,7 +261,7 @@ _asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len)
return node;
asn1_length_der (len, NULL, &len2);
- temp = (unsigned char *) _asn1_malloc (len + len2);
+ temp = malloc (len + len2);
if (temp == NULL)
return NULL;
@@ -260,8 +272,8 @@ _asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len)
/* the same as _asn1_set_value except that it sets an already malloc'ed
* value.
*/
-ASN1_TYPE
-_asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len)
+asn1_node
+_asn1_set_value_m (asn1_node node, void *value, unsigned int len)
{
if (node == NULL)
return node;
@@ -269,7 +281,7 @@ _asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len)
if (node->value)
{
if (node->value != node->small_value)
- _asn1_free (node->value);
+ free (node->value);
node->value = NULL;
node->value_len = 0;
}
@@ -293,8 +305,8 @@ _asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len)
/* len: character number of value. */
/* Return: pointer to the NODE_ASN element. */
/******************************************************************/
-ASN1_TYPE
-_asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len)
+asn1_node
+_asn1_append_value (asn1_node node, const void *value, unsigned int len)
{
if (node == NULL)
return node;
@@ -303,7 +315,7 @@ _asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len)
/* value is allocated */
int prev_len = node->value_len;
node->value_len += len;
- node->value = _asn1_realloc (node->value, node->value_len);
+ node->value = realloc (node->value, node->value_len);
if (node->value == NULL)
{
node->value_len = 0;
@@ -318,7 +330,7 @@ _asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len)
/* value is in node */
int prev_len = node->value_len;
node->value_len += len;
- node->value = _asn1_malloc (node->value_len);
+ node->value = malloc (node->value_len);
if (node->value == NULL)
{
node->value_len = 0;
@@ -343,30 +355,52 @@ _asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len)
/* to set. */
/* Return: pointer to the NODE_ASN element. */
/******************************************************************/
-ASN1_TYPE
-_asn1_set_name (ASN1_TYPE node, const char *name)
+asn1_node
+_asn1_set_name (asn1_node node, const char *name)
{
+unsigned int nsize;
+
if (node == NULL)
return node;
- if (node->name)
+ if (name == NULL)
{
- _asn1_free (node->name);
- node->name = NULL;
+ node->name[0] = 0;
+ node->name_hash = hash_pjw_bare(node->name, 0);
+ return node;
}
- if (name == NULL)
- return node;
+ nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);
+ node->name_hash = hash_pjw_bare(node->name, nsize);
+
+ return node;
+}
- if (strlen (name))
+/******************************************************************/
+/* Function : _asn1_cpy_name */
+/* Description: copies the field NAME in a NODE_ASN element. */
+/* Parameters: */
+/* dst: a dest element pointer. */
+/* src: a source element pointer. */
+/* Return: pointer to the NODE_ASN element. */
+/******************************************************************/
+asn1_node
+_asn1_cpy_name (asn1_node dst, asn1_node src)
+{
+ if (dst == NULL)
+ return dst;
+
+ if (src == NULL)
{
- node->name = (char *) _asn1_strdup (name);
- if (node->name == NULL)
- return NULL;
+ dst->name[0] = 0;
+ dst->name_hash = hash_pjw_bare(dst->name, 0);
+ return dst;
}
- else
- node->name = NULL;
- return node;
+
+ _asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
+ dst->name_hash = src->name_hash;
+
+ return dst;
}
/******************************************************************/
@@ -378,8 +412,8 @@ _asn1_set_name (ASN1_TYPE node, const char *name)
/* by NODE. */
/* Return: pointer to *NODE. */
/******************************************************************/
-ASN1_TYPE
-_asn1_set_right (ASN1_TYPE node, ASN1_TYPE right)
+asn1_node
+_asn1_set_right (asn1_node node, asn1_node right)
{
if (node == NULL)
return node;
@@ -389,21 +423,6 @@ _asn1_set_right (ASN1_TYPE node, ASN1_TYPE right)
return node;
}
-/******************************************************************/
-/* Function : _asn1_get_right */
-/* Description: returns the element pointed by the RIGHT field of */
-/* a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: field RIGHT of NODE. */
-/******************************************************************/
-ASN1_TYPE
-_asn1_get_right (ASN1_TYPE node)
-{
- if (node == NULL)
- return NULL;
- return node->right;
-}
/******************************************************************/
/* Function : _asn1_get_last_right */
@@ -412,10 +431,10 @@ _asn1_get_right (ASN1_TYPE node)
/* node: starting element pointer. */
/* Return: pointer to the last element along the right chain. */
/******************************************************************/
-ASN1_TYPE
-_asn1_get_last_right (ASN1_TYPE node)
+asn1_node
+_asn1_get_last_right (asn1_node node)
{
- ASN1_TYPE p;
+ asn1_node p;
if (node == NULL)
return NULL;
@@ -426,78 +445,6 @@ _asn1_get_last_right (ASN1_TYPE node)
}
/******************************************************************/
-/* Function : _asn1_set_down */
-/* Description: sets the field DOWN in a NODE_ASN element. */
-/* Parameters: */
-/* node: element pointer. */
-/* down: pointer to a NODE_ASN element that you want be pointed */
-/* by NODE. */
-/* Return: pointer to *NODE. */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_down (ASN1_TYPE node, ASN1_TYPE down)
-{
- if (node == NULL)
- return node;
- node->down = down;
- if (down)
- down->left = node;
- return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_down */
-/* Description: returns the element pointed by the DOWN field of */
-/* a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: field DOWN of NODE. */
-/******************************************************************/
-ASN1_TYPE
-_asn1_get_down (ASN1_TYPE node)
-{
- if (node == NULL)
- return NULL;
- return node->down;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_name */
-/* Description: returns the name of a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: a null terminated string. */
-/******************************************************************/
-char *
-_asn1_get_name (ASN1_TYPE node)
-{
- if (node == NULL)
- return NULL;
- return node->name;
-}
-
-/******************************************************************/
-/* Function : _asn1_mod_type */
-/* Description: change the field TYPE of an NODE_ASN element. */
-/* The new value is the old one | (bitwise or) the */
-/* paramener VALUE. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* value: the integer value that must be or-ed with the current */
-/* value of field TYPE. */
-/* Return: NODE pointer. */
-/******************************************************************/
-ASN1_TYPE
-_asn1_mod_type (ASN1_TYPE node, unsigned int value)
-{
- if (node == NULL)
- return node;
- node->type |= value;
- return node;
-}
-
-
-/******************************************************************/
/* Function : _asn1_remove_node */
/* Description: gets free the memory allocated for an NODE_ASN */
/* element (not the elements pointed by it). */
@@ -505,16 +452,14 @@ _asn1_mod_type (ASN1_TYPE node, unsigned int value)
/* node: NODE_ASN element pointer. */
/******************************************************************/
void
-_asn1_remove_node (ASN1_TYPE node)
+_asn1_remove_node (asn1_node node)
{
if (node == NULL)
return;
- if (node->name != NULL)
- _asn1_free (node->name);
if (node->value != NULL && node->value != node->small_value)
- _asn1_free (node->value);
- _asn1_free (node);
+ free (node->value);
+ free (node);
}
/******************************************************************/
@@ -524,10 +469,10 @@ _asn1_remove_node (ASN1_TYPE node)
/* node: NODE_ASN element pointer. */
/* Return: Null if not found. */
/******************************************************************/
-ASN1_TYPE
-_asn1_find_up (ASN1_TYPE node)
+asn1_node
+_asn1_find_up (asn1_node node)
{
- ASN1_TYPE p;
+ asn1_node p;
if (node == NULL)
return NULL;
@@ -554,7 +499,7 @@ _asn1_delete_list (void)
{
listElement = firstElement;
firstElement = firstElement->next;
- _asn1_free (listElement);
+ free (listElement);
}
}
@@ -573,7 +518,7 @@ _asn1_delete_list_and_nodes (void)
listElement = firstElement;
firstElement = firstElement->next;
_asn1_remove_node (listElement->node);
- _asn1_free (listElement);
+ free (listElement);
}
}
@@ -622,10 +567,10 @@ _asn1_ltostr (long v, char *str)
/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
/* otherwise ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
-_asn1_change_integer_value (ASN1_TYPE node)
+int
+_asn1_change_integer_value (asn1_node node)
{
- ASN1_TYPE p;
+ asn1_node p;
unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
int len;
@@ -689,10 +634,10 @@ _asn1_change_integer_value (ASN1_TYPE node)
/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
/* otherwise ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
-_asn1_expand_object_id (ASN1_TYPE node)
+int
+_asn1_expand_object_id (asn1_node node)
{
- ASN1_TYPE p, p2, p3, p4, p5;
+ asn1_node p, p2, p3, p4, p5;
char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
int move, tlen;
@@ -718,7 +663,8 @@ _asn1_expand_object_id (ASN1_TYPE node)
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
+ _asn1_str_cat (name2, sizeof (name2),
+ (char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
!(p3->type & CONST_ASSIGN))
@@ -731,7 +677,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
{
if (type_field (p4->type) == TYPE_CONSTANT)
{
- p5 = _asn1_add_node_only (TYPE_CONSTANT);
+ p5 = _asn1_add_single_node (TYPE_CONSTANT);
_asn1_set_name (p5, p4->name);
tlen = _asn1_strlen (p4->value);
if (tlen > 0)
@@ -871,10 +817,10 @@ _asn1_expand_object_id (ASN1_TYPE node)
/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
/* otherwise ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
-_asn1_type_set_config (ASN1_TYPE node)
+int
+_asn1_type_set_config (asn1_node node)
{
- ASN1_TYPE p, p2;
+ asn1_node p, p2;
int move;
if (node == NULL)
@@ -944,10 +890,10 @@ _asn1_type_set_config (ASN1_TYPE node)
/* ASN1_IDENTIFIER_NOT_FOUND if an identifier is not defined, */
/* otherwise ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
-_asn1_check_identifier (ASN1_TYPE node)
+int
+_asn1_check_identifier (asn1_node node)
{
- ASN1_TYPE p, p2;
+ asn1_node p, p2;
char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
if (node == NULL)
@@ -964,7 +910,10 @@ _asn1_check_identifier (ASN1_TYPE node)
p2 = asn1_find_node (node, name2);
if (p2 == NULL)
{
- _asn1_strcpy (_asn1_identifierMissing, p->value);
+ if (p->value)
+ _asn1_strcpy (_asn1_identifierMissing, p->value);
+ else
+ _asn1_strcpy (_asn1_identifierMissing, "(null)");
return ASN1_IDENTIFIER_NOT_FOUND;
}
}
@@ -1048,10 +997,10 @@ _asn1_check_identifier (ASN1_TYPE node)
/* a DEFINITIONS element, */
/* otherwise ASN1_SUCCESS */
/******************************************************************/
-asn1_retCode
-_asn1_set_default_tag (ASN1_TYPE node)
+int
+_asn1_set_default_tag (asn1_node node)
{
- ASN1_TYPE p;
+ asn1_node p;
if ((node == NULL) || (type_field (node->type) != TYPE_DEFINITIONS))
return ASN1_ELEMENT_NOT_FOUND;
diff --git a/lib/minitasn1/parser_aux.h b/lib/minitasn1/parser_aux.h
index 374f59953f..df369c79c6 100644
--- a/lib/minitasn1/parser_aux.h
+++ b/lib/minitasn1/parser_aux.h
@@ -27,36 +27,28 @@
/***************************************/
/* Functions used by ASN.1 parser */
/***************************************/
-ASN1_TYPE _asn1_add_node (unsigned int type);
+asn1_node _asn1_add_static_node (unsigned int type);
-ASN1_TYPE
-_asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len);
+asn1_node
+_asn1_set_value (asn1_node node, const void *value, unsigned int len);
-ASN1_TYPE _asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len);
+asn1_node _asn1_set_value_m (asn1_node node, void *value, unsigned int len);
-ASN1_TYPE
-_asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len);
+asn1_node
+_asn1_set_value_octet (asn1_node node, const void *value, unsigned int len);
-ASN1_TYPE
-_asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len);
+asn1_node
+_asn1_append_value (asn1_node node, const void *value, unsigned int len);
-ASN1_TYPE _asn1_set_name (ASN1_TYPE node, const char *name);
+asn1_node _asn1_set_name (asn1_node node, const char *name);
-ASN1_TYPE _asn1_set_right (ASN1_TYPE node, ASN1_TYPE right);
+asn1_node _asn1_cpy_name (asn1_node dst, asn1_node src);
-ASN1_TYPE _asn1_get_right (ASN1_TYPE node);
+asn1_node _asn1_set_right (asn1_node node, asn1_node right);
-ASN1_TYPE _asn1_get_last_right (ASN1_TYPE node);
+asn1_node _asn1_get_last_right (asn1_node node);
-ASN1_TYPE _asn1_set_down (ASN1_TYPE node, ASN1_TYPE down);
-
-char *_asn1_get_name (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_get_down (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_mod_type (ASN1_TYPE node, unsigned int value);
-
-void _asn1_remove_node (ASN1_TYPE node);
+void _asn1_remove_node (asn1_node node);
void _asn1_delete_list (void);
@@ -64,16 +56,103 @@ void _asn1_delete_list_and_nodes (void);
char *_asn1_ltostr (long v, char *str);
-ASN1_TYPE _asn1_find_up (ASN1_TYPE node);
-
-asn1_retCode _asn1_change_integer_value (ASN1_TYPE node);
-
-asn1_retCode _asn1_expand_object_id (ASN1_TYPE node);
-
-asn1_retCode _asn1_type_set_config (ASN1_TYPE node);
-
-asn1_retCode _asn1_check_identifier (ASN1_TYPE node);
-
-asn1_retCode _asn1_set_default_tag (ASN1_TYPE node);
+asn1_node _asn1_find_up (asn1_node node);
+
+int _asn1_change_integer_value (asn1_node node);
+
+int _asn1_expand_object_id (asn1_node node);
+
+int _asn1_type_set_config (asn1_node node);
+
+int _asn1_check_identifier (asn1_node node);
+
+int _asn1_set_default_tag (asn1_node node);
+
+/******************************************************************/
+/* Function : _asn1_get_right */
+/* Description: returns the element pointed by the RIGHT field of */
+/* a NODE_ASN element. */
+/* Parameters: */
+/* node: NODE_ASN element pointer. */
+/* Return: field RIGHT of NODE. */
+/******************************************************************/
+inline static asn1_node
+_asn1_get_right (asn1_node node)
+{
+ if (node == NULL)
+ return NULL;
+ return node->right;
+}
+
+/******************************************************************/
+/* Function : _asn1_set_down */
+/* Description: sets the field DOWN in a NODE_ASN element. */
+/* Parameters: */
+/* node: element pointer. */
+/* down: pointer to a NODE_ASN element that you want be pointed */
+/* by NODE. */
+/* Return: pointer to *NODE. */
+/******************************************************************/
+inline static asn1_node
+_asn1_set_down (asn1_node node, asn1_node down)
+{
+ if (node == NULL)
+ return node;
+ node->down = down;
+ if (down)
+ down->left = node;
+ return node;
+}
+
+/******************************************************************/
+/* Function : _asn1_get_down */
+/* Description: returns the element pointed by the DOWN field of */
+/* a NODE_ASN element. */
+/* Parameters: */
+/* node: NODE_ASN element pointer. */
+/* Return: field DOWN of NODE. */
+/******************************************************************/
+inline static asn1_node
+_asn1_get_down (asn1_node node)
+{
+ if (node == NULL)
+ return NULL;
+ return node->down;
+}
+
+/******************************************************************/
+/* Function : _asn1_get_name */
+/* Description: returns the name of a NODE_ASN element. */
+/* Parameters: */
+/* node: NODE_ASN element pointer. */
+/* Return: a null terminated string. */
+/******************************************************************/
+inline static char *
+_asn1_get_name (asn1_node node)
+{
+ if (node == NULL)
+ return NULL;
+ return node->name;
+}
+
+/******************************************************************/
+/* Function : _asn1_mod_type */
+/* Description: change the field TYPE of an NODE_ASN element. */
+/* The new value is the old one | (bitwise or) the */
+/* paramener VALUE. */
+/* Parameters: */
+/* node: NODE_ASN element pointer. */
+/* value: the integer value that must be or-ed with the current */
+/* value of field TYPE. */
+/* Return: NODE pointer. */
+/******************************************************************/
+inline static asn1_node
+_asn1_mod_type (asn1_node node, unsigned int value)
+{
+ if (node == NULL)
+ return node;
+ node->type |= value;
+ return node;
+}
#endif
diff --git a/lib/minitasn1/structure.c b/lib/minitasn1/structure.c
index 41cebe4b13..4613d06066 100644
--- a/lib/minitasn1/structure.c
+++ b/lib/minitasn1/structure.c
@@ -37,19 +37,19 @@ extern char _asn1_identifierMissing[];
/******************************************************/
-/* Function : _asn1_add_node_only */
+/* Function : _asn1_add_single_node */
/* Description: creates a new NODE_ASN element. */
/* Parameters: */
/* type: type of the new element (see TYPE_ */
/* and CONST_ constants). */
/* Return: pointer to the new element. */
/******************************************************/
-ASN1_TYPE
-_asn1_add_node_only (unsigned int type)
+asn1_node
+_asn1_add_single_node (unsigned int type)
{
- ASN1_TYPE punt;
+ asn1_node punt;
- punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
+ punt = calloc (1, sizeof (struct asn1_node_st));
if (punt == NULL)
return NULL;
@@ -67,8 +67,8 @@ _asn1_add_node_only (unsigned int type)
/* node: NODE_ASN element pointer. */
/* Return: NULL if not found. */
/******************************************************************/
-ASN1_TYPE
-_asn1_find_left (ASN1_TYPE node)
+asn1_node
+_asn1_find_left (asn1_node node)
{
if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
return NULL;
@@ -77,12 +77,12 @@ _asn1_find_left (ASN1_TYPE node)
}
-asn1_retCode
-_asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
+int
+_asn1_create_static_structure (asn1_node pointer, char *output_file_name,
char *vector_name)
{
FILE *file;
- ASN1_TYPE p;
+ asn1_node p;
unsigned long t;
file = fopen (output_file_name, "w");
@@ -96,7 +96,7 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
fprintf (file, "#include <libtasn1.h>\n\n");
- fprintf (file, "const ASN1_ARRAY_TYPE %s[] = {\n", vector_name);
+ fprintf (file, "const asn1_static_node_t %s[] = {\n", vector_name);
p = pointer;
@@ -104,7 +104,7 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
{
fprintf (file, " { ");
- if (p->name)
+ if (p->name[0] != 0)
fprintf (file, "\"%s\", ", p->name);
else
fprintf (file, "NULL, ");
@@ -168,22 +168,22 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
* @array is a vector created by asn1_parser2array().
*
* Returns: %ASN1_SUCCESS if structure was created correctly,
- * %ASN1_ELEMENT_NOT_EMPTY if *@definitions not ASN1_TYPE_EMPTY,
+ * %ASN1_ELEMENT_NOT_EMPTY if *@definitions not NULL,
* %ASN1_IDENTIFIER_NOT_FOUND if in the file there is an identifier
* that is not defined (see @errorDescription for more information),
* %ASN1_ARRAY_ERROR if the array pointed by @array is wrong.
**/
-asn1_retCode
-asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
+int
+asn1_array2tree (const asn1_static_node_t * array, asn1_node * definitions,
char *errorDescription)
{
- ASN1_TYPE p, p_last = NULL;
+ asn1_node p, p_last = NULL;
unsigned long k;
int move;
- asn1_retCode result;
+ int result;
- if (*definitions != ASN1_TYPE_EMPTY)
+ if (*definitions != NULL)
return ASN1_ELEMENT_NOT_EMPTY;
move = UP;
@@ -191,7 +191,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
k = 0;
while (array[k].value || array[k].type || array[k].name)
{
- p = _asn1_add_node (array[k].type & (~CONST_DOWN));
+ p = _asn1_add_static_node (array[k].type & (~CONST_DOWN));
if (array[k].name)
_asn1_set_name (p, array[k].name);
if (array[k].value)
@@ -263,7 +263,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
if (result != ASN1_SUCCESS)
{
_asn1_delete_list_and_nodes ();
- *definitions = ASN1_TYPE_EMPTY;
+ *definitions = NULL;
}
else
_asn1_delete_list ();
@@ -276,17 +276,17 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
* @structure: pointer to the structure that you want to delete.
*
* Deletes the structure *@structure. At the end, *@structure is set
- * to ASN1_TYPE_EMPTY.
+ * to NULL.
*
* Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * *@structure was ASN1_TYPE_EMPTY.
+ * *@structure was NULL.
**/
-asn1_retCode
-asn1_delete_structure (ASN1_TYPE * structure)
+int
+asn1_delete_structure (asn1_node * structure)
{
- ASN1_TYPE p, p2, p3;
+ asn1_node p, p2, p3;
- if (*structure == ASN1_TYPE_EMPTY)
+ if (*structure == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = *structure;
@@ -328,7 +328,7 @@ asn1_delete_structure (ASN1_TYPE * structure)
}
}
- *structure = ASN1_TYPE_EMPTY;
+ *structure = NULL;
return ASN1_SUCCESS;
}
@@ -345,14 +345,14 @@ asn1_delete_structure (ASN1_TYPE * structure)
* Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
* the @element_name was not found.
**/
-asn1_retCode
-asn1_delete_element (ASN1_TYPE structure, const char *element_name)
+int
+asn1_delete_element (asn1_node structure, const char *element_name)
{
- ASN1_TYPE p2, p3, source_node;
+ asn1_node p2, p3, source_node;
source_node = asn1_find_node (structure, element_name);
- if (source_node == ASN1_TYPE_EMPTY)
+ if (source_node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p2 = source_node->right;
@@ -371,16 +371,16 @@ asn1_delete_element (ASN1_TYPE structure, const char *element_name)
return asn1_delete_structure (&source_node);
}
-ASN1_TYPE
-_asn1_copy_structure3 (ASN1_TYPE source_node)
+asn1_node
+_asn1_copy_structure3 (asn1_node source_node)
{
- ASN1_TYPE dest_node, p_s, p_d, p_d_prev;
+ asn1_node dest_node, p_s, p_d, p_d_prev;
int move;
if (source_node == NULL)
return NULL;
- dest_node = _asn1_add_node_only (source_node->type);
+ dest_node = _asn1_add_single_node (source_node->type);
p_s = source_node;
p_d = dest_node;
@@ -391,48 +391,37 @@ _asn1_copy_structure3 (ASN1_TYPE source_node)
{
if (move != UP)
{
- if (p_s->name)
- _asn1_set_name (p_d, p_s->name);
+ if (p_s->name[0] != 0)
+ _asn1_cpy_name (p_d, p_s);
if (p_s->value)
_asn1_set_value (p_d, p_s->value, p_s->value_len);
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
if (p_s->down)
{
p_s = p_s->down;
p_d_prev = p_d;
- p_d = _asn1_add_node_only (p_s->type);
+ p_d = _asn1_add_single_node (p_s->type);
_asn1_set_down (p_d_prev, p_d);
+ continue;
}
- else
- move = RIGHT;
}
if (p_s == source_node)
- break;
+ break;
- if (move == RIGHT)
- {
- if (p_s->right)
- {
- p_s = p_s->right;
- p_d_prev = p_d;
- p_d = _asn1_add_node_only (p_s->type);
- _asn1_set_right (p_d_prev, p_d);
- }
- else
+ if (p_s->right)
+ {
+ move = RIGHT;
+ p_s = p_s->right;
+ p_d_prev = p_d;
+ p_d = _asn1_add_single_node (p_s->type);
+ _asn1_set_right (p_d_prev, p_d);
+ }
+ else
+ {
move = UP;
- }
- if (move == UP)
- {
- p_s = _asn1_find_up (p_s);
- p_d = _asn1_find_up (p_d);
- }
+ p_s = _asn1_find_up (p_s);
+ p_d = _asn1_find_up (p_d);
+ }
}
while (p_s != source_node);
@@ -440,10 +429,10 @@ _asn1_copy_structure3 (ASN1_TYPE source_node)
}
-static ASN1_TYPE
-_asn1_copy_structure2 (ASN1_TYPE root, const char *source_name)
+static asn1_node
+_asn1_copy_structure2 (asn1_node root, const char *source_name)
{
- ASN1_TYPE source_node;
+ asn1_node source_node;
source_node = asn1_find_node (root, source_name);
@@ -452,10 +441,10 @@ _asn1_copy_structure2 (ASN1_TYPE root, const char *source_name)
}
-static asn1_retCode
-_asn1_type_choice_config (ASN1_TYPE node)
+static int
+_asn1_type_choice_config (asn1_node node)
{
- ASN1_TYPE p, p2, p3, p4;
+ asn1_node p, p2, p3, p4;
int move, tlen;
if (node == NULL)
@@ -481,7 +470,7 @@ _asn1_type_choice_config (ASN1_TYPE node)
{
if (type_field (p3->type) == TYPE_TAG)
{
- p4 = _asn1_add_node_only (p3->type);
+ p4 = _asn1_add_single_node (p3->type);
tlen = _asn1_strlen (p3->value);
if (tlen > 0)
_asn1_set_value (p4, p3->value, tlen + 1);
@@ -537,10 +526,10 @@ _asn1_type_choice_config (ASN1_TYPE node)
}
-static asn1_retCode
-_asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root)
+static int
+_asn1_expand_identifier (asn1_node * node, asn1_node root)
{
- ASN1_TYPE p, p2, p3;
+ asn1_node p, p2, p3;
char name2[ASN1_MAX_NAME_SIZE + 2];
int move;
@@ -556,15 +545,13 @@ _asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root)
{
if (type_field (p->type) == TYPE_IDENTIFIER)
{
- _asn1_str_cpy (name2, sizeof (name2), root->name);
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
+ snprintf(name2, sizeof (name2), "%s.%s", root->name, p->value);
p2 = _asn1_copy_structure2 (root, name2);
if (p2 == NULL)
{
return ASN1_IDENTIFIER_NOT_FOUND;
}
- _asn1_set_name (p2, p->name);
+ _asn1_cpy_name (p2, p);
p2->right = p->right;
p2->left = p->left;
if (p->right)
@@ -661,11 +648,11 @@ _asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root)
* Returns: %ASN1_SUCCESS if creation OK, %ASN1_ELEMENT_NOT_FOUND if
* @source_name is not known.
**/
-asn1_retCode
-asn1_create_element (ASN1_TYPE definitions, const char *source_name,
- ASN1_TYPE * element)
+int
+asn1_create_element (asn1_node definitions, const char *source_name,
+ asn1_node * element)
{
- ASN1_TYPE dest_node;
+ asn1_node dest_node;
int res;
dest_node = _asn1_copy_structure2 (definitions, source_name);
@@ -697,10 +684,10 @@ asn1_create_element (ASN1_TYPE definitions, const char *source_name,
* from the @name element inside the structure @structure.
**/
void
-asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
+asn1_print_structure (FILE * out, asn1_node structure, const char *name,
int mode)
{
- ASN1_TYPE p, root;
+ asn1_node p, root;
int k, indent = 0, len, len2, len3;
if (out == NULL)
@@ -719,7 +706,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
for (k = 0; k < indent; k++)
fprintf (out, " ");
fprintf (out, "name:");
- if (p->name)
+ if (p->name[0] != 0)
fprintf (out, "%s ", p->name);
else
fprintf (out, "NULL ");
@@ -736,7 +723,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
for (k = 0; k < indent; k++)
fprintf (out, " ");
fprintf (out, "name:");
- if (p->name)
+ if (p->name[0] != 0)
fprintf (out, "%s ", p->name);
else
fprintf (out, "NULL ");
@@ -1060,10 +1047,10 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
* Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
* @name is not known, %ASN1_GENERIC_ERROR if pointer @num is %NULL.
**/
-asn1_retCode
-asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
+int
+asn1_number_of_elements (asn1_node element, const char *name, int *num)
{
- ASN1_TYPE node, p;
+ asn1_node node, p;
if (num == NULL)
return ASN1_GENERIC_ERROR;
@@ -1078,7 +1065,7 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
while (p)
{
- if ((p->name) && (p->name[0] == '?'))
+ if (p->name[0] == '?')
(*num)++;
p = p->right;
}
@@ -1099,15 +1086,15 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
* the OID.
**/
const char *
-asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
+asn1_find_structure_from_oid (asn1_node definitions, const char *oidValue)
{
char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1];
char value[ASN1_MAX_NAME_SIZE];
- ASN1_TYPE p;
+ asn1_node p;
int len;
- asn1_retCode result;
+ int result;
- if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL))
+ if ((definitions == NULL) || (oidValue == NULL))
return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
@@ -1144,24 +1131,24 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
/**
* asn1_copy_node:
- * @dst: Destination ASN1_TYPE node.
+ * @dst: Destination asn1_node node.
* @dst_name: Field name in destination node.
- * @src: Source ASN1_TYPE node.
+ * @src: Source asn1_node node.
* @src_name: Field name in source node.
*
- * Create a deep copy of a ASN1_TYPE variable.
+ * Create a deep copy of a asn1_node variable.
*
* Returns: Return %ASN1_SUCCESS on success.
**/
-asn1_retCode
-asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
- ASN1_TYPE src, const char *src_name)
+int
+asn1_copy_node (asn1_node dst, const char *dst_name,
+ asn1_node src, const char *src_name)
{
/* FIXME: rewrite using copy_structure().
* It seems quite hard to do.
*/
int result;
- ASN1_TYPE dst_node;
+ asn1_node dst_node;
void *data = NULL;
int size = 0;
@@ -1169,27 +1156,27 @@ asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
if (result != ASN1_MEM_ERROR)
return result;
- data = _asn1_malloc (size);
+ data = malloc (size);
if (data == NULL)
return ASN1_MEM_ERROR;
result = asn1_der_coding (src, src_name, data, &size, NULL);
if (result != ASN1_SUCCESS)
{
- _asn1_free (data);
+ free (data);
return result;
}
dst_node = asn1_find_node (dst, dst_name);
if (dst_node == NULL)
{
- _asn1_free (data);
+ free (data);
return ASN1_ELEMENT_NOT_FOUND;
}
result = asn1_der_decoding (&dst_node, data, size, NULL);
- _asn1_free (data);
+ free (data);
return result;
}
diff --git a/lib/minitasn1/structure.h b/lib/minitasn1/structure.h
index 0a84e26bec..986e13a309 100644
--- a/lib/minitasn1/structure.h
+++ b/lib/minitasn1/structure.h
@@ -28,14 +28,14 @@
#ifndef _STRUCTURE_H
#define _STRUCTURE_H
-asn1_retCode _asn1_create_static_structure (ASN1_TYPE pointer,
+int _asn1_create_static_structure (asn1_node pointer,
char *output_file_name,
char *vector_name);
-ASN1_TYPE _asn1_copy_structure3 (ASN1_TYPE source_node);
+asn1_node _asn1_copy_structure3 (asn1_node source_node);
-ASN1_TYPE _asn1_add_node_only (unsigned int type);
+asn1_node _asn1_add_single_node (unsigned int type);
-ASN1_TYPE _asn1_find_left (ASN1_TYPE node);
+asn1_node _asn1_find_left (asn1_node node);
#endif
diff --git a/lib/minitasn1/version.c b/lib/minitasn1/version.c
index fb17223995..83d70c9623 100644
--- a/lib/minitasn1/version.c
+++ b/lib/minitasn1/version.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <string.h> /* for strverscmp */