[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7760 - libmicrohttpd/src/daemon/https/minitasn1
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7760 - libmicrohttpd/src/daemon/https/minitasn1 |
Date: |
Sun, 12 Oct 2008 14:22:10 -0600 (MDT) |
Author: grothoff
Date: 2008-10-12 14:22:09 -0600 (Sun, 12 Oct 2008)
New Revision: 7760
Modified:
libmicrohttpd/src/daemon/https/minitasn1/coding.c
libmicrohttpd/src/daemon/https/minitasn1/decoding.c
libmicrohttpd/src/daemon/https/minitasn1/element.c
libmicrohttpd/src/daemon/https/minitasn1/libtasn1.h
libmicrohttpd/src/daemon/https/minitasn1/parser_aux.c
libmicrohttpd/src/daemon/https/minitasn1/parser_aux.h
libmicrohttpd/src/daemon/https/minitasn1/structure.c
libmicrohttpd/src/daemon/https/minitasn1/structure.h
Log:
eliminating dead code and warnings in minitasn1
Modified: libmicrohttpd/src/daemon/https/minitasn1/coding.c
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/coding.c 2008-10-12 18:47:44 UTC
(rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/coding.c 2008-10-12 20:22:09 UTC
(rev 7760)
@@ -45,7 +45,7 @@
/* ErrorDescription: string returned. */
/* Return: */
/******************************************************/
-void
+static void
MHD__asn1_error_description_value_not_found (node_asn * node,
char *ErrorDescription)
{
@@ -113,7 +113,7 @@
/* (ans[0]..ans[ans_len-1]). */
/* Return: */
/******************************************************/
-void
+static void
MHD__asn1_tag_der (unsigned char class, unsigned int tag_value,
unsigned char *ans, int *ans_len)
{
@@ -179,7 +179,7 @@
/* ASN1_MEM_ERROR when DER isn't big enough */
/* ASN1_SUCCESS otherwise */
/******************************************************/
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
{
int len_len;
@@ -187,11 +187,11 @@
max_len = *der_len;
- MHD__asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
+ MHD__asn1_length_der (strlen ((const char*) str), (max_len > 0) ? der :
NULL, &len_len);
- if ((len_len + (int) strlen (str)) <= max_len)
- memcpy (der + len_len, str, strlen (str));
- *der_len = len_len + strlen (str);
+ if ((len_len + (int) strlen ((const char*) str)) <= max_len)
+ memcpy (der + len_len, str, strlen ((const char*) str));
+ *der_len = len_len + strlen ((const char*) str);
if ((*der_len) > max_len)
return ASN1_MEM_ERROR;
@@ -199,43 +199,6 @@
return ASN1_SUCCESS;
}
-
-/*
-void
-MHD__asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
-{
- int len_len,str_len;
- char temp[20];
-
- if(str==NULL) return;
- str_len=MHD__asn1_get_length_der(der,*der_len,&len_len);
- if (str_len<0) return;
- memcpy(temp,der+len_len,str_len);
- *der_len=str_len+len_len;
- switch(str_len){
- case 11:
- temp[10]=0;
- strcat(temp,"00+0000");
- break;
- case 13:
- temp[12]=0;
- strcat(temp,"+0000");
- break;
- case 15:
- temp[15]=0;
- memmove(temp+12,temp+10,6);
- temp[10]=temp[11]='0';
- break;
- case 17:
- temp[17]=0;
- break;
- default:
- return;
- }
- strcpy(str,temp);
-}
-*/
-
/******************************************************/
/* Function : MHD__asn1_objectid_der */
/* Description: creates the DER coding for an */
@@ -250,7 +213,7 @@
/* ASN1_MEM_ERROR when DER isn't big enough */
/* ASN1_SUCCESS otherwise */
/******************************************************/
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
{
int len_len, counter, k, first, max_len;
@@ -260,11 +223,11 @@
max_len = *der_len;
- temp = (char *) MHD__asn1_alloca (strlen (str) + 2);
+ temp = (char *) MHD__asn1_alloca (strlen ((const char*)str) + 2);
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- strcpy (temp, str);
+ strcpy (temp, (const char*) str);
strcat (temp, ".");
counter = 0;
@@ -370,7 +333,7 @@
/* ASN1_MEM_ERROR if der vector isn't big enough, */
/* otherwise ASN1_SUCCESS. */
/******************************************************/
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
int *counter, int *max_len)
{
@@ -443,7 +406,7 @@
/* ASN1_MEM_ERROR if der vector isn't big enough, */
/* otherwise ASN1_SUCCESS. */
/******************************************************/
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
int *max_len)
{
@@ -474,20 +437,22 @@
if (p->type & CONST_EXPLICIT)
{
if (is_tag_implicit)
- MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der,
- &tag_len);
+ MHD__asn1_tag_der (class_implicit, tag_implicit,
+ (unsigned char*) tag_der,
+ &tag_len);
else
MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
- strtoul (p->value, NULL, 10), tag_der,
- &tag_len);
+ strtoul ( (const char*) p->value, NULL,
10),
+ (unsigned char*) tag_der,
+ &tag_len);
*max_len -= tag_len;
if (*max_len >= 0)
memcpy (der + *counter, tag_der, tag_len);
*counter += tag_len;
- MHD__asn1_ltostr (*counter, temp);
- MHD__asn1_set_name (p, temp);
+ MHD__asn1_ltostr (*counter, (char*) temp);
+ MHD__asn1_set_name (p, (const char*) temp);
is_tag_implicit = 0;
}
@@ -501,7 +466,7 @@
(type_field (node->type) == TYPE_SET_OF))
class |= ASN1_CLASS_STRUCTURED;
class_implicit = class;
- tag_implicit = strtoul (p->value, NULL, 10);
+ tag_implicit = strtoul ( (const char*) p->value, NULL,
10);
is_tag_implicit = 1;
}
}
@@ -512,63 +477,63 @@
if (is_tag_implicit)
{
- MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
+ MHD__asn1_tag_der (class_implicit, tag_implicit, (unsigned char*)
tag_der, &tag_len);
}
else
{
switch (type_field (node->type))
{
case TYPE_NULL:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, (unsigned
char*) tag_der,
&tag_len);
break;
case TYPE_BOOLEAN:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, (unsigned
char*) tag_der,
&tag_len);
break;
case TYPE_INTEGER:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, (unsigned
char*) tag_der,
&tag_len);
break;
case TYPE_ENUMERATED:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED,
tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED,
(unsigned char*) tag_der,
&tag_len);
break;
case TYPE_OBJECT_ID:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID,
(unsigned char*) tag_der,
&tag_len);
break;
case TYPE_TIME:
if (node->type & CONST_UTC)
{
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime,
tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime,
(unsigned char*) tag_der,
&tag_len);
}
else
MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
- tag_der, &tag_len);
+ (unsigned char*) tag_der, &tag_len);
break;
case TYPE_OCTET_STRING:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING,
tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING,
(unsigned char*) tag_der,
&tag_len);
break;
case TYPE_GENERALSTRING:
MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
- tag_der, &tag_len);
+ (unsigned char*) tag_der, &tag_len);
break;
case TYPE_BIT_STRING:
- MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING,
tag_der,
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING,
(unsigned char*) tag_der,
&tag_len);
break;
case TYPE_SEQUENCE:
case TYPE_SEQUENCE_OF:
MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
- ASN1_TAG_SEQUENCE, tag_der, &tag_len);
+ ASN1_TAG_SEQUENCE, (unsigned char*) tag_der,
&tag_len);
break;
case TYPE_SET:
case TYPE_SET_OF:
MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
- ASN1_TAG_SET, tag_der, &tag_len);
+ ASN1_TAG_SET, (unsigned char*) tag_der, &tag_len);
break;
case TYPE_TAG:
tag_len = 0;
@@ -604,7 +569,7 @@
/* node: pointer to the SET element. */
/* Return: */
/******************************************************/
-void
+static void
MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
{
struct vet
@@ -719,7 +684,7 @@
/* node: pointer to the SET OF element. */
/* Return: */
/******************************************************/
-void
+static void
MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
{
struct vet
@@ -1104,11 +1069,11 @@
}
else
{ /* move==UP */
- len2 = strtol (p->value, NULL, 10);
+ len2 = strtol ( (const char*) p->value, NULL, 10);
MHD__asn1_set_value (p, NULL, 0);
if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
MHD__asn1_ordering_set (der + len2, max_len - len2, p);
- MHD__asn1_length_der (counter - len2, temp, &len3);
+ MHD__asn1_length_der (counter - len2, (unsigned char*) temp,
&len3);
max_len -= len3;
if (max_len >= 0)
{
@@ -1144,14 +1109,14 @@
}
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = strtol ( (const char*) p->value, NULL, 10);
MHD__asn1_set_value (p, NULL, 0);
if ((type_field (p->type) == TYPE_SET_OF)
&& (max_len - len2 > 0))
{
MHD__asn1_ordering_set_of (der + len2, max_len - len2, p);
}
- MHD__asn1_length_der (counter - len2, temp, &len3);
+ MHD__asn1_length_der (counter - len2, (unsigned char*) temp,
&len3);
max_len -= len3;
if (max_len >= 0)
{
Modified: libmicrohttpd/src/daemon/https/minitasn1/decoding.c
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/decoding.c 2008-10-12 18:47:44 UTC
(rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/decoding.c 2008-10-12 20:22:09 UTC
(rev 7760)
@@ -34,7 +34,7 @@
#include "element.h"
-void
+static void
MHD__asn1_error_description_tag_error (node_asn * node, char *ErrorDescription)
{
@@ -207,7 +207,7 @@
/* Returns ASN1_SUCCESS on success or an error code on error.
*/
-int
+static int
MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
@@ -227,7 +227,7 @@
-void
+static void
MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int
*ret_len,
char *str, int str_size)
{
@@ -313,7 +313,7 @@
-int
+static int
MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int
der_len,
int *ret_len)
{
@@ -506,7 +506,7 @@
}
-int
+static int
MHD__asn1_delete_not_used (node_asn * node)
{
node_asn *p, *p2;
@@ -566,7 +566,7 @@
}
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int
*len)
{
int len2, len3, counter, counter2, counter_end, tot_len, indefinite;
@@ -680,7 +680,7 @@
}
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len)
{
int len2, len3, counter, indefinite;
@@ -789,7 +789,7 @@
if (p->type & CONST_SET)
{
p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = strtol ((const char*) p2->value, NULL, 10);
if (len2 == -1)
{
if (!der[counter] && !der[counter + 1])
@@ -852,7 +852,7 @@
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = strtol ((const char*) p2->value, NULL, 10);
if (counter == len2)
{
if (p->right)
@@ -917,7 +917,7 @@
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = strtol ((const char*) p2->value, NULL, 10);
if ((len2 != -1) && (counter > len2))
ris = ASN1_TAG_ERROR;
}
@@ -1045,7 +1045,7 @@
case TYPE_SET:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = strtol ( (const char*) p->value, NULL, 10);
MHD__asn1_set_value (p, NULL, 0);
if (len2 == -1)
{ /* indefinite length method */
@@ -1113,7 +1113,7 @@
case TYPE_SET_OF:
if (move == UP)
{
- len2 = strtol (p->value, NULL, 10);
+ len2 = strtol ( (const char*) p->value, NULL, 10);
if (len2 == -1)
{ /* indefinite length method */
if ((counter + 2) > len)
@@ -1296,801 +1296,7 @@
}
-#define FOUND 1
-#define SAME_BRANCH 2
-#define OTHER_BRANCH 3
-#define EXIT 4
-
/**
- * MHD__asn1_der_decoding_element - Fill the element named ELEMENTNAME of the
structure STRUCTURE with values of a DER encoding string.
- * @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.
- *
- * 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.
- *
- * 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.
- *
- **/
-MHD__asn1_retCode
-MHD__asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
- const void *ider, int len, char *errorDescription)
-{
- node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY;
- char temp[128], currentName[MAX_NAME_SIZE * 10], *dot_p, *char_p;
- int nameLen = MAX_NAME_SIZE * 10 - 1, state;
- int counter, len2, len3, len4, move, ris, tlen;
- unsigned char class, *temp2;
- unsigned long tag;
- int indefinite, result;
- const unsigned char *der = ider;
-
- node = *structure;
-
- if (node == ASN1_TYPE_EMPTY)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (elementName == NULL)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_ELEMENT_NOT_FOUND;
- }
-
- if (node->type & CONST_OPTION)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_GENERIC_ERROR;
- }
-
- if ((*structure)->name)
- { /* Has *structure got a name? */
- nameLen -= strlen ((*structure)->name);
- if (nameLen > 0)
- strcpy (currentName, (*structure)->name);
- else
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_MEM_ERROR;
- }
- if (!(strcmp (currentName, elementName)))
- {
- state = FOUND;
- nodeFound = *structure;
- }
- else if (!memcmp (currentName, elementName, strlen (currentName)))
- state = SAME_BRANCH;
- else
- state = OTHER_BRANCH;
- }
- else
- { /* *structure doesn't have a name? */
- currentName[0] = 0;
- if (elementName[0] == 0)
- {
- state = FOUND;
- nodeFound = *structure;
- }
- else
- {
- state = SAME_BRANCH;
- }
- }
-
- counter = 0;
- move = DOWN;
- p = node;
- while (1)
- {
-
- ris = ASN1_SUCCESS;
-
- if (move != UP)
- {
- if (p->type & CONST_SET)
- {
- p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
- if (counter == len2)
- {
- p = p2;
- move = UP;
- continue;
- }
- else if (counter > len2)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- p2 = p2->down;
- while (p2)
- {
- if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
- {
- if (type_field (p2->type) != TYPE_CHOICE)
- ris =
- MHD__asn1_extract_tag_der (p2, der + counter,
- len - counter, &len2);
- else
- {
- p3 = p2->down;
- while (p3)
- {
- ris =
- MHD__asn1_extract_tag_der (p3, der + counter,
- len - counter, &len2);
- if (ris == ASN1_SUCCESS)
- break;
- p3 = p3->right;
- }
- }
- if (ris == ASN1_SUCCESS)
- {
- p2->type &= ~CONST_NOT_USED;
- p = p2;
- break;
- }
- }
- p2 = p2->right;
- }
- if (p2 == NULL)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- }
-
- if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
- {
- p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
- if (counter == len2)
- {
- if (p->right)
- {
- p2 = p->right;
- move = RIGHT;
- }
- else
- move = UP;
-
- if (p->type & CONST_OPTION)
- MHD__asn1_delete_structure (&p);
-
- p = p2;
- continue;
- }
- }
-
- if (type_field (p->type) == TYPE_CHOICE)
- {
- while (p->down)
- {
- if (counter < len)
- ris =
- MHD__asn1_extract_tag_der (p->down, der + counter,
- len - counter, &len2);
- else
- ris = ASN1_DER_ERROR;
- if (ris == ASN1_SUCCESS)
- {
- while (p->down->right)
- {
- p2 = p->down->right;
- MHD__asn1_delete_structure (&p2);
- }
- break;
- }
- else if (ris == ASN1_ERROR_TYPE_ANY)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_ERROR_TYPE_ANY;
- }
- else
- {
- p2 = p->down;
- MHD__asn1_delete_structure (&p2);
- }
- }
-
- if (p->down == NULL)
- {
- if (!(p->type & CONST_OPTION))
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- }
- else
- p = p->down;
- }
-
- if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
- {
- p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
- if (counter > len2)
- ris = ASN1_TAG_ERROR;
- }
-
- if (ris == ASN1_SUCCESS)
- ris =
- MHD__asn1_extract_tag_der (p, der + counter, len - counter,
&len2);
- if (ris != ASN1_SUCCESS)
- {
- if (p->type & CONST_OPTION)
- {
- p->type |= CONST_NOT_USED;
- move = RIGHT;
- }
- else if (p->type & CONST_DEFAULT)
- {
- MHD__asn1_set_value (p, NULL, 0);
- move = RIGHT;
- }
- else
- {
- if (errorDescription != NULL)
- MHD__asn1_error_description_tag_error (p,
errorDescription);
-
- MHD__asn1_delete_structure (structure);
- return ASN1_TAG_ERROR;
- }
- }
- else
- counter += len2;
- }
-
- if (ris == ASN1_SUCCESS)
- {
- switch (type_field (p->type))
- {
- case TYPE_NULL:
- if (der[counter])
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
-
- if (p == nodeFound)
- state = EXIT;
-
- counter++;
- move = RIGHT;
- break;
- case TYPE_BOOLEAN:
- if (der[counter++] != 1)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
-
- if (state == FOUND)
- {
- if (der[counter++] == 0)
- MHD__asn1_set_value (p, "F", 1);
- else
- MHD__asn1_set_value (p, "T", 1);
-
- if (p == nodeFound)
- state = EXIT;
-
- }
- else
- counter++;
-
- move = RIGHT;
- break;
- case TYPE_INTEGER:
- case TYPE_ENUMERATED:
- len2 =
- MHD__asn1_get_length_der (der + counter, len - counter, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- if (state == FOUND)
- {
- if (len3 + len2 > len - counter)
- return ASN1_DER_ERROR;
- MHD__asn1_set_value (p, der + counter, len3 + len2);
-
- if (p == nodeFound)
- state = EXIT;
- }
- counter += len3 + len2;
- move = RIGHT;
- break;
- case TYPE_OBJECT_ID:
- if (state == FOUND)
- {
- MHD__asn1_get_objectid_der (der + counter, len - counter,
&len2,
- temp, sizeof (temp));
- tlen = strlen (temp);
-
- if (tlen > 0)
- MHD__asn1_set_value (p, temp, tlen + 1);
-
- if (p == nodeFound)
- state = EXIT;
- }
- else
- {
- len2 =
- MHD__asn1_get_length_der (der + counter, len - counter,
&len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- len2 += len3;
- }
-
- counter += len2;
- move = RIGHT;
- break;
- case TYPE_TIME:
- if (state == FOUND)
- {
- result =
- MHD__asn1_get_time_der (der + counter, len - counter,
&len2,
- temp, sizeof (temp) - 1);
- if (result != ASN1_SUCCESS)
- {
- MHD__asn1_delete_structure (structure);
- return result;
- }
-
- tlen = strlen (temp);
- if (tlen > 0)
- MHD__asn1_set_value (p, temp, tlen + 1);
-
- if (p == nodeFound)
- state = EXIT;
- }
- else
- {
- len2 =
- MHD__asn1_get_length_der (der + counter, len - counter,
&len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- len2 += len3;
- }
-
- counter += len2;
- move = RIGHT;
- break;
- case TYPE_OCTET_STRING:
- len3 = len - counter;
- if (state == FOUND)
- {
- ris = MHD__asn1_get_octet_string (der + counter, p, &len3);
- if (p == nodeFound)
- state = EXIT;
- }
- else
- ris = MHD__asn1_get_octet_string (der + counter, NULL, &len3);
-
- if (ris != ASN1_SUCCESS)
- return ris;
- counter += len3;
- move = RIGHT;
- break;
- case TYPE_GENERALSTRING:
- len2 =
- MHD__asn1_get_length_der (der + counter, len - counter, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- if (state == FOUND)
- {
- if (len3 + len2 > len - counter)
- return ASN1_DER_ERROR;
- MHD__asn1_set_value (p, der + counter, len3 + len2);
-
- if (p == nodeFound)
- state = EXIT;
- }
- counter += len3 + len2;
- move = RIGHT;
- break;
- case TYPE_BIT_STRING:
- len2 =
- MHD__asn1_get_length_der (der + counter, len - counter, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- if (state == FOUND)
- {
- if (len3 + len2 > len - counter)
- return ASN1_DER_ERROR;
- MHD__asn1_set_value (p, der + counter, len3 + len2);
-
- if (p == nodeFound)
- state = EXIT;
- }
- counter += len3 + len2;
- move = RIGHT;
- break;
- case TYPE_SEQUENCE:
- case TYPE_SET:
- if (move == UP)
- {
- len2 = strtol (p->value, NULL, 10);
- MHD__asn1_set_value (p, NULL, 0);
- if (len2 == -1)
- { /* indefinite length method */
- if ((der[counter]) || der[counter + 1])
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- counter += 2;
- }
- else
- { /* definite length method */
- if (len2 != counter)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- }
- if (p == nodeFound)
- state = EXIT;
- move = RIGHT;
- }
- else
- { /* move==DOWN || move==RIGHT */
- if (state == OTHER_BRANCH)
- {
- len3 =
- MHD__asn1_get_length_der (der + counter, len - counter,
- &len2);
- if (len3 < 0)
- return ASN1_DER_ERROR;
- counter += len2 + len3;
- move = RIGHT;
- }
- else
- { /* state==SAME_BRANCH or state==FOUND */
- len3 =
- MHD__asn1_get_length_der (der + counter, len - counter,
- &len2);
- if (len3 < 0)
- return ASN1_DER_ERROR;
- counter += len2;
- if (len3 > 0)
- {
- MHD__asn1_ltostr (counter + len3, temp);
- tlen = strlen (temp);
-
- if (tlen > 0)
- MHD__asn1_set_value (p, temp, tlen + 1);
- move = DOWN;
- }
- else if (len3 == 0)
- {
- p2 = p->down;
- while (p2)
- {
- if (type_field (p2->type) != TYPE_TAG)
- {
- p3 = p2->right;
- MHD__asn1_delete_structure (&p2);
- p2 = p3;
- }
- else
- p2 = p2->right;
- }
- move = RIGHT;
- }
- else
- { /* indefinite length method */
- MHD__asn1_set_value (p, "-1", 3);
- move = DOWN;
- }
- }
- }
- break;
- case TYPE_SEQUENCE_OF:
- case TYPE_SET_OF:
- if (move == UP)
- {
- len2 = strtol (p->value, NULL, 10);
- if (len2 > counter)
- {
- MHD__asn1_append_sequence_set (p);
- p = p->down;
- while (p->right)
- p = p->right;
- move = RIGHT;
- continue;
- }
- MHD__asn1_set_value (p, NULL, 0);
- if (len2 != counter)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
-
- if (p == nodeFound)
- state = EXIT;
- }
- else
- { /* move==DOWN || move==RIGHT */
- if (state == OTHER_BRANCH)
- {
- len3 =
- MHD__asn1_get_length_der (der + counter, len - counter,
- &len2);
- if (len3 < 0)
- return ASN1_DER_ERROR;
- counter += len2 + len3;
- move = RIGHT;
- }
- else
- { /* state==FOUND or state==SAME_BRANCH */
- len3 =
- MHD__asn1_get_length_der (der + counter, len - counter,
- &len2);
- if (len3 < 0)
- return ASN1_DER_ERROR;
- counter += len2;
- if (len3)
- {
- MHD__asn1_ltostr (counter + len3, temp);
- tlen = strlen (temp);
-
- if (tlen > 0)
- MHD__asn1_set_value (p, temp, tlen + 1);
- p2 = p->down;
- while ((type_field (p2->type) == TYPE_TAG)
- || (type_field (p2->type) == TYPE_SIZE))
- p2 = p2->right;
- if (p2->right == NULL)
- MHD__asn1_append_sequence_set (p);
- p = p2;
- state = FOUND;
- }
- }
- }
-
- break;
- case TYPE_ANY:
- if (MHD__asn1_get_tag_der
- (der + counter, len - counter, &class, &len2,
- &tag) != ASN1_SUCCESS)
- return ASN1_DER_ERROR;
- if (counter + len2 > len)
- return ASN1_DER_ERROR;
-
- len4 =
- MHD__asn1_get_length_der (der + counter + len2,
- len - counter - len2, &len3);
- if (len4 < -1)
- return ASN1_DER_ERROR;
-
- if (len4 != -1)
- {
- len2 += len4;
- if (state == FOUND)
- {
- MHD__asn1_length_der (len2 + len3, NULL, &len4);
- temp2 =
- (unsigned char *) MHD__asn1_alloca (len2 + len3 +
len4);
- if (temp2 == NULL)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_MEM_ALLOC_ERROR;
- }
-
- MHD__asn1_octet_der (der + counter, len2 + len3, temp2,
- &len4);
- MHD__asn1_set_value (p, temp2, len4);
- MHD__asn1_afree (temp2);
-
- if (p == nodeFound)
- state = EXIT;
- }
- counter += len2 + len3;
- }
- else
- { /* indefinite length */
- /* Check indefinite lenth method in an EXPLICIT TAG */
- if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
- indefinite = 1;
- else
- indefinite = 0;
-
- len2 = len - counter;
- ris =
- MHD__asn1_get_indefinite_length_string (der + counter,
&len2);
- if (ris != ASN1_SUCCESS)
- {
- MHD__asn1_delete_structure (structure);
- return ris;
- }
-
- if (state == FOUND)
- {
- MHD__asn1_length_der (len2, NULL, &len4);
- temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len4);
- if (temp2 == NULL)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_MEM_ALLOC_ERROR;
- }
-
- MHD__asn1_octet_der (der + counter, len2, temp2, &len4);
- MHD__asn1_set_value (p, temp2, len4);
- MHD__asn1_afree (temp2);
-
- if (p == nodeFound)
- state = EXIT;
- }
-
- counter += len2;
-
- /* Check if a couple of 0x00 are present due to an EXPLICIT
TAG with
- an indefinite length method. */
- if (indefinite)
- {
- if (!der[counter] && !der[counter + 1])
- {
- counter += 2;
- }
- else
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
- }
- }
- move = RIGHT;
- break;
-
- default:
- move = (move == UP) ? RIGHT : DOWN;
- break;
- }
- }
-
- if ((p == node && move != DOWN) || (state == EXIT))
- break;
-
- if (move == DOWN)
- {
- if (p->down)
- {
- p = p->down;
-
- if (state != FOUND)
- {
- nameLen -= strlen (p->name) + 1;
- if (nameLen > 0)
- {
- if (currentName[0])
- strcat (currentName, ".");
- strcat (currentName, p->name);
- }
- else
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_MEM_ERROR;
- }
- if (!(strcmp (currentName, elementName)))
- {
- state = FOUND;
- nodeFound = p;
- }
- else
- if (!memcmp
- (currentName, elementName, strlen (currentName)))
- state = SAME_BRANCH;
- else
- state = OTHER_BRANCH;
- }
- }
- else
- move = RIGHT;
- }
-
- if ((move == RIGHT) && !(p->type & CONST_SET))
- {
- if (p->right)
- {
- p = p->right;
-
- if (state != FOUND)
- {
- dot_p = char_p = currentName;
- while ((char_p = strchr (char_p, '.')))
- {
- dot_p = char_p++;
- dot_p++;
- }
-
- nameLen += strlen (currentName) - (dot_p - currentName);
- *dot_p = 0;
-
- nameLen -= strlen (p->name);
- if (nameLen > 0)
- strcat (currentName, p->name);
- else
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_MEM_ERROR;
- }
-
- if (!(strcmp (currentName, elementName)))
- {
- state = FOUND;
- nodeFound = p;
- }
- else
- if (!memcmp
- (currentName, elementName, strlen (currentName)))
- state = SAME_BRANCH;
- else
- state = OTHER_BRANCH;
- }
- }
- else
- move = UP;
- }
-
- if (move == UP)
- {
- p = MHD__asn1_find_up (p);
-
- if (state != FOUND)
- {
- dot_p = char_p = currentName;
- while ((char_p = strchr (char_p, '.')))
- {
- dot_p = char_p++;
- dot_p++;
- }
-
- nameLen += strlen (currentName) - (dot_p - currentName);
- *dot_p = 0;
-
- if (!(strcmp (currentName, elementName)))
- {
- state = FOUND;
- nodeFound = p;
- }
- else
- if (!memcmp (currentName, elementName, strlen (currentName)))
- state = SAME_BRANCH;
- else
- state = OTHER_BRANCH;
- }
- }
- }
-
- MHD__asn1_delete_not_used (*structure);
-
- if (counter > len)
- {
- MHD__asn1_delete_structure (structure);
- return ASN1_DER_ERROR;
- }
-
- return ASN1_SUCCESS;
-}
-
-
-
-/**
* MHD__asn1_der_decoding_startEnd - Find the start and end point of an
element in a DER encoding string.
* @element: pointer to an ASN1 element
* @ider: vector that contains the DER encoding.
@@ -2163,7 +1369,7 @@
if (p->type & CONST_SET)
{
p2 = MHD__asn1_find_up (p);
- len2 = strtol (p2->value, NULL, 10);
+ len2 = strtol ( (const char* ) p2->value, NULL, 10);
if (len2 == -1)
{
if (!der[counter] && !der[counter + 1])
@@ -2442,386 +1648,3 @@
}
-/**
- * MHD__asn1_expand_any_defined_by - Expand "ANY DEFINED BY" fields in
structure.
- * @definitions: ASN1 definitions
- * @element: pointer to an ASN1 structure
- *
- * Expands every "ANY DEFINED BY" element of a structure created from
- * a DER decoding process (MHD__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.
- *
- *
- * 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.
- **/
-
-MHD__asn1_retCode
-MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
-{
- char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1],
- value[MAX_NAME_SIZE];
- MHD__asn1_retCode retCode = ASN1_SUCCESS, result;
- int len, len2, len3;
- ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY;
- char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
-
- if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
- return ASN1_ELEMENT_NOT_FOUND;
-
- strcpy (definitionsName, definitions->name);
- strcat (definitionsName, ".");
-
- p = *element;
- while (p)
- {
-
- switch (type_field (p->type))
- {
- case TYPE_ANY:
- if ((p->type & CONST_DEFINED_BY) && (p->value))
- {
- /* search the "DEF_BY" element */
- p2 = p->down;
- while ((p2) && (type_field (p2->type) != TYPE_CONSTANT))
- p2 = p2->right;
-
- if (!p2)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = MHD__asn1_find_up (p);
-
- if (!p3)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = p3->down;
- while (p3)
- {
- if ((p3->name) && !(strcmp (p3->name, p2->name)))
- break;
- p3 = p3->right;
- }
-
- if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) ||
- (p3->value == NULL))
- {
-
- p3 = MHD__asn1_find_up (p);
- p3 = MHD__asn1_find_up (p3);
-
- if (!p3)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = p3->down;
-
- while (p3)
- {
- if ((p3->name) && !(strcmp (p3->name, p2->name)))
- break;
- p3 = p3->right;
- }
-
- if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) ||
- (p3->value == NULL))
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
- }
-
- /* search the OBJECT_ID into definitions */
- p2 = definitions->down;
- while (p2)
- {
- if ((type_field (p2->type) == TYPE_OBJECT_ID) &&
- (p2->type & CONST_ASSIGN))
- {
- strcpy (name, definitionsName);
- strcat (name, p2->name);
-
- len = MAX_NAME_SIZE;
- result =
- MHD__asn1_read_value (definitions, name, value, &len);
-
- if ((result == ASN1_SUCCESS)
- && (!strcmp (p3->value, value)))
- {
- p2 = p2->right; /* pointer to the structure to
- use for expansion */
- while ((p2) && (p2->type & CONST_ASSIGN))
- p2 = p2->right;
-
- if (p2)
- {
- strcpy (name, definitionsName);
- strcat (name, p2->name);
-
- result =
- MHD__asn1_create_element (definitions, name,
&aux);
- if (result == ASN1_SUCCESS)
- {
- MHD__asn1_set_name (aux, p->name);
- len2 =
- MHD__asn1_get_length_der (p->value,
- p->value_len, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
-
- result =
- MHD__asn1_der_decoding (&aux, p->value +
len3,
- len2,
- errorDescription);
- if (result == ASN1_SUCCESS)
- {
-
- MHD__asn1_set_right (aux, p->right);
- MHD__asn1_set_right (p, aux);
-
- result = MHD__asn1_delete_structure (&p);
- if (result == ASN1_SUCCESS)
- {
- p = aux;
- aux = ASN1_TYPE_EMPTY;
- break;
- }
- else
- { /* error with
MHD__asn1_delete_structure */
- MHD__asn1_delete_structure (&aux);
- retCode = result;
- break;
- }
- }
- else
- { /* error with MHD__asn1_der_decoding */
- retCode = result;
- break;
- }
- }
- else
- { /* error with MHD__asn1_create_element
*/
- retCode = result;
- break;
- }
- }
- else
- { /* error with the pointer to the structure to
exapand */
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
- }
- }
- p2 = p2->right;
- } /* end while */
-
- if (!p2)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- }
- break;
- default:
- break;
- }
-
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p == *element)
- {
- p = NULL;
- break;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = MHD__asn1_find_up (p);
- if (p == *element)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- return retCode;
-}
-
-
-
-/**
- * MHD__asn1_expand_octet_string - Expand "OCTET STRING" fields in structure.
- * @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.
- *
- * Expands an "OCTET STRING" element of a structure created from a
- * DER decoding process (MHD__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.
- *
- * 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.
- **/
-MHD__asn1_retCode
-MHD__asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
- const char *octetName, const char *objectName)
-{
- char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE];
- MHD__asn1_retCode 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;
- char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
-
- if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
- return ASN1_ELEMENT_NOT_FOUND;
-
- octetNode = MHD__asn1_find_node (*element, octetName);
- if (octetNode == ASN1_TYPE_EMPTY)
- return ASN1_ELEMENT_NOT_FOUND;
- if (type_field (octetNode->type) != TYPE_OCTET_STRING)
- return ASN1_ELEMENT_NOT_FOUND;
- if (octetNode->value == NULL)
- return ASN1_VALUE_NOT_FOUND;
-
- objectNode = MHD__asn1_find_node (*element, objectName);
- if (objectNode == ASN1_TYPE_EMPTY)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (type_field (objectNode->type) != TYPE_OBJECT_ID)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (objectNode->value == NULL)
- return ASN1_VALUE_NOT_FOUND;
-
-
- /* search the OBJECT_ID into definitions */
- p2 = definitions->down;
- while (p2)
- {
- if ((type_field (p2->type) == TYPE_OBJECT_ID) &&
- (p2->type & CONST_ASSIGN))
- {
- strcpy (name, definitions->name);
- strcat (name, ".");
- strcat (name, p2->name);
-
- len = sizeof (value);
- result = MHD__asn1_read_value (definitions, name, value, &len);
-
- if ((result == ASN1_SUCCESS)
- && (!strcmp (objectNode->value, value)))
- {
-
- p2 = p2->right; /* pointer to the structure to
- use for expansion */
- while ((p2) && (p2->type & CONST_ASSIGN))
- p2 = p2->right;
-
- if (p2)
- {
- strcpy (name, definitions->name);
- strcat (name, ".");
- strcat (name, p2->name);
-
- result = MHD__asn1_create_element (definitions, name, &aux);
- if (result == ASN1_SUCCESS)
- {
- MHD__asn1_set_name (aux, octetNode->name);
- len2 =
- MHD__asn1_get_length_der (octetNode->value,
- octetNode->value_len, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
-
- result =
- MHD__asn1_der_decoding (&aux, octetNode->value + len3,
- len2, errorDescription);
- if (result == ASN1_SUCCESS)
- {
-
- MHD__asn1_set_right (aux, octetNode->right);
- MHD__asn1_set_right (octetNode, aux);
-
- result = MHD__asn1_delete_structure (&octetNode);
- if (result == ASN1_SUCCESS)
- {
- aux = ASN1_TYPE_EMPTY;
- break;
- }
- else
- { /* error with MHD__asn1_delete_structure */
- MHD__asn1_delete_structure (&aux);
- retCode = result;
- break;
- }
- }
- else
- { /* error with MHD__asn1_der_decoding */
- retCode = result;
- break;
- }
- }
- else
- { /* error with MHD__asn1_create_element */
- retCode = result;
- break;
- }
- }
- else
- { /* error with the pointer to the structure to
exapand */
- retCode = ASN1_VALUE_NOT_VALID;
- break;
- }
- }
- }
-
- p2 = p2->right;
-
- }
-
- if (!p2)
- retCode = ASN1_VALUE_NOT_VALID;
-
- return retCode;
-}
Modified: libmicrohttpd/src/daemon/https/minitasn1/element.c
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/element.c 2008-10-12 18:47:44 UTC
(rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/element.c 2008-10-12 20:22:09 UTC
(rev 7760)
@@ -281,7 +281,7 @@
node_asn *node, *p, *p2;
unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
int len2, k, k2, negative;
- const unsigned char *value = ivalue;
+ const char *value = ivalue;
node = MHD__asn1_find_node (node_root, name);
if (node == NULL)
@@ -374,10 +374,10 @@
if (value_temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- MHD__asn1_convert_integer (p->value,
- value_temp,
- SIZEOF_UNSIGNED_LONG_INT,
- &len);
+ MHD__asn1_convert_integer ((const char*) p->value,
+ value_temp,
+ SIZEOF_UNSIGNED_LONG_INT,
+ &len);
break;
}
}
@@ -446,7 +446,7 @@
return ASN1_MEM_ALLOC_ERROR;
}
- MHD__asn1_convert_integer (p->value, default_temp,
+ MHD__asn1_convert_integer ((const char*) p->value, default_temp,
SIZEOF_UNSIGNED_LONG_INT, &len2);
}
else
@@ -461,7 +461,7 @@
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!strcmp (p2->name, p->value)))
+ if ((p2->name) && (!strcmp (p2->name,(const char*)
p->value)))
{
default_temp =
(unsigned char *)
@@ -472,7 +472,7 @@
return ASN1_MEM_ALLOC_ERROR;
}
- MHD__asn1_convert_integer (p2->value,
+ MHD__asn1_convert_integer ((const char*) p2->value,
default_temp,
SIZEOF_UNSIGNED_LONG_INT,
&len2);
@@ -512,7 +512,7 @@
p = node->down;
while (type_field (p->type) != TYPE_DEFAULT)
p = p->right;
- if (!strcmp (value, p->value))
+ if (!strcmp (value,(const char*) p->value))
{
MHD__asn1_set_value (node, NULL, 0);
break;
@@ -574,7 +574,7 @@
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- MHD__asn1_octet_der (value, len, temp, &len2);
+ MHD__asn1_octet_der ((const unsigned char*) value, len, temp, &len2);
MHD__asn1_set_value (node, temp, len2);
MHD__asn1_afree (temp);
break;
@@ -586,7 +586,7 @@
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- MHD__asn1_octet_der (value, len, temp, &len2);
+ MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2);
MHD__asn1_set_value (node, temp, len2);
MHD__asn1_afree (temp);
break;
@@ -598,7 +598,7 @@
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- MHD__asn1_bit_der (value, len, temp, &len2);
+ MHD__asn1_bit_der ((const unsigned char*)value, len, temp, &len2);
MHD__asn1_set_value (node, temp, len2);
MHD__asn1_afree (temp);
break;
@@ -632,7 +632,7 @@
if (temp == NULL)
return ASN1_MEM_ALLOC_ERROR;
- MHD__asn1_octet_der (value, len, temp, &len2);
+ MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2);
MHD__asn1_set_value (node, temp, len2);
MHD__asn1_afree (temp);
break;
@@ -749,7 +749,7 @@
node_asn *node, *p, *p2;
int len2, len3;
int value_size = *len;
- unsigned char *value = ivalue;
+ char *value = ivalue;
node = MHD__asn1_find_node (root, name);
if (node == NULL)
@@ -801,7 +801,7 @@
|| (p->value[0] == '+'))
{
if (MHD__asn1_convert_integer
- (p->value, value, value_size, len) != ASN1_SUCCESS)
+ ((const char*) p->value, (unsigned char*) value, value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
}
else
@@ -811,10 +811,10 @@
{
if (type_field (p2->type) == TYPE_CONSTANT)
{
- if ((p2->name) && (!strcmp (p2->name, p->value)))
+ if ((p2->name) && (!strcmp (p2->name, (const char*)
p->value)))
{
if (MHD__asn1_convert_integer
- (p2->value, value, value_size,
+ ((const char*) p2->value, (unsigned char*)
value, value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
break;
@@ -828,7 +828,7 @@
{
len2 = -1;
if (MHD__asn1_get_octet_der
- (node->value, node->value_len, &len2, value, value_size,
+ (node->value, node->value_len, &len2, (unsigned char*) value,
value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
}
@@ -842,7 +842,7 @@
{
if (type_field (p->type) == TYPE_CONSTANT)
{
- ADD_STR_VALUE (value, value_size, p->value);
+ ADD_STR_VALUE (value, value_size, (const char*) p->value);
if (p->right)
{
ADD_STR_VALUE (value, value_size, ".");
@@ -857,34 +857,34 @@
p = node->down;
while (type_field (p->type) != TYPE_DEFAULT)
p = p->right;
- PUT_STR_VALUE (value, value_size, p->value);
+ PUT_STR_VALUE (value, value_size, (const char*) p->value);
}
else
{
- PUT_STR_VALUE (value, value_size, node->value);
+ PUT_STR_VALUE (value, value_size, (const char*) node->value);
}
break;
case TYPE_TIME:
- PUT_STR_VALUE (value, value_size, node->value);
+ PUT_STR_VALUE (value, value_size, (const char*) node->value);
break;
case TYPE_OCTET_STRING:
len2 = -1;
if (MHD__asn1_get_octet_der
- (node->value, node->value_len, &len2, value, value_size,
+ (node->value, node->value_len, &len2, (unsigned char*) value,
value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
break;
case TYPE_GENERALSTRING:
len2 = -1;
if (MHD__asn1_get_octet_der
- (node->value, node->value_len, &len2, value, value_size,
+ (node->value, node->value_len, &len2, (unsigned char*) value,
value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
break;
case TYPE_BIT_STRING:
len2 = -1;
if (MHD__asn1_get_bit_der
- (node->value, node->value_len, &len2, value, value_size,
+ (node->value, node->value_len, &len2, (unsigned char*) value,
value_size,
len) != ASN1_SUCCESS)
return ASN1_MEM_ERROR;
break;
@@ -906,123 +906,3 @@
}
-/**
- * MHD__asn1_read_tag - Returns the TAG of one element inside a structure
- * @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 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.
- *
- * Returns:
- *
- * ASN1_SUCCESS: Set value OK.
- *
- * ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
- *
- **/
-MHD__asn1_retCode
-MHD__asn1_read_tag (node_asn * root, const char *name, int *tagValue,
- int *classValue)
-{
- node_asn *node, *p, *pTag;
-
- node = MHD__asn1_find_node (root, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node->down;
-
- /* pTag will points to the IMPLICIT TAG */
- pTag = NULL;
- if (node->type & CONST_TAG)
- {
- while (p)
- {
- if (type_field (p->type) == TYPE_TAG)
- {
- if ((p->type & CONST_IMPLICIT) && (pTag == NULL))
- pTag = p;
- else if (p->type & CONST_EXPLICIT)
- pTag = NULL;
- }
- p = p->right;
- }
- }
-
- if (pTag)
- {
- *tagValue = strtoul (pTag->value, NULL, 10);
-
- if (pTag->type & CONST_APPLICATION)
- *classValue = ASN1_CLASS_APPLICATION;
- else if (pTag->type & CONST_UNIVERSAL)
- *classValue = ASN1_CLASS_UNIVERSAL;
- else if (pTag->type & CONST_PRIVATE)
- *classValue = ASN1_CLASS_PRIVATE;
- else
- *classValue = ASN1_CLASS_CONTEXT_SPECIFIC;
- }
- else
- {
- *classValue = ASN1_CLASS_UNIVERSAL;
-
- switch (type_field (node->type))
- {
- case TYPE_NULL:
- *tagValue = ASN1_TAG_NULL;
- break;
- case TYPE_BOOLEAN:
- *tagValue = ASN1_TAG_BOOLEAN;
- break;
- case TYPE_INTEGER:
- *tagValue = ASN1_TAG_INTEGER;
- break;
- case TYPE_ENUMERATED:
- *tagValue = ASN1_TAG_ENUMERATED;
- break;
- case TYPE_OBJECT_ID:
- *tagValue = ASN1_TAG_OBJECT_ID;
- break;
- case TYPE_TIME:
- if (node->type & CONST_UTC)
- {
- *tagValue = ASN1_TAG_UTCTime;
- }
- else
- *tagValue = ASN1_TAG_GENERALIZEDTime;
- break;
- case TYPE_OCTET_STRING:
- *tagValue = ASN1_TAG_OCTET_STRING;
- break;
- case TYPE_GENERALSTRING:
- *tagValue = ASN1_TAG_GENERALSTRING;
- break;
- case TYPE_BIT_STRING:
- *tagValue = ASN1_TAG_BIT_STRING;
- break;
- case TYPE_SEQUENCE:
- case TYPE_SEQUENCE_OF:
- *tagValue = ASN1_TAG_SEQUENCE;
- break;
- case TYPE_SET:
- case TYPE_SET_OF:
- *tagValue = ASN1_TAG_SET;
- break;
- case TYPE_TAG:
- case TYPE_CHOICE:
- case TYPE_ANY:
- break;
- default:
- break;
- }
- }
-
-
- return ASN1_SUCCESS;
-
-}
Modified: libmicrohttpd/src/daemon/https/minitasn1/libtasn1.h
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/libtasn1.h 2008-10-12 18:47:44 UTC
(rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/libtasn1.h 2008-10-12 20:22:09 UTC
(rev 7760)
@@ -150,9 +150,6 @@
ASN1_TYPE * definitions,
char *errorDescription);
- void MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure,
- const char *name, int mode);
-
MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions,
const char *source_name,
ASN1_TYPE * element);
@@ -177,32 +174,14 @@
MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void
*ider,
int len, char *errorDescription);
- MHD__asn1_retCode MHD__asn1_der_decoding_element (ASN1_TYPE * structure,
- const char *elementName,
- const void *ider, int len,
- char *errorDescription);
-
MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element,
const void *ider, int len,
const char *name_element,
int *start, int *end);
- MHD__asn1_retCode MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions,
- ASN1_TYPE * element);
-
- MHD__asn1_retCode MHD__asn1_expand_octet_string (ASN1_TYPE definitions,
- ASN1_TYPE * element,
- const char *octetName,
- const char *objectName);
-
- MHD__asn1_retCode MHD__asn1_read_tag (node_asn * root, const char *name,
- int *tagValue, int *classValue);
-
const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions,
const char *oidValue);
- const char *MHD__asn1_check_version (const char *req_version);
-
const char *MHD__libtasn1_strerror (MHD__asn1_retCode error);
void MHD__libtasn1_perror (MHD__asn1_retCode error);
Modified: libmicrohttpd/src/daemon/https/minitasn1/parser_aux.c
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/parser_aux.c 2008-10-12
18:47:44 UTC (rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/parser_aux.c 2008-10-12
20:22:09 UTC (rev 7760)
@@ -27,6 +27,8 @@
#include "structure.h"
#include "element.h"
+
+
char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name
not found */
/***********************************************/
@@ -279,42 +281,6 @@
}
/******************************************************************/
-/* Function : MHD__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. */
-/******************************************************************/
-node_asn *
-MHD__asn1_get_right (node_asn * node)
-{
- if (node == NULL)
- return NULL;
- return node->right;
-}
-
-/******************************************************************/
-/* Function : MHD__asn1_get_last_right */
-/* Description: return the last element along the right chain. */
-/* Parameters: */
-/* node: starting element pointer. */
-/* Return: pointer to the last element along the right chain. */
-/******************************************************************/
-node_asn *
-MHD__asn1_get_last_right (node_asn * node)
-{
- node_asn *p;
-
- if (node == NULL)
- return NULL;
- p = node;
- while (p->right)
- p = p->right;
- return p;
-}
-
-/******************************************************************/
/* Function : MHD__asn1_set_down */
/* Description: sets the field DOWN in a NODE_ASN element. */
/* Parameters: */
@@ -335,58 +301,6 @@
}
/******************************************************************/
-/* Function : MHD__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. */
-/******************************************************************/
-node_asn *
-MHD__asn1_get_down (node_asn * node)
-{
- if (node == NULL)
- return NULL;
- return node->down;
-}
-
-/******************************************************************/
-/* Function : MHD__asn1_get_name */
-/* Description: returns the name of a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: a null terminated string. */
-/******************************************************************/
-char *
-MHD__asn1_get_name (node_asn * node)
-{
- if (node == NULL)
- return NULL;
- return node->name;
-}
-
-/******************************************************************/
-/* Function : MHD__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. */
-/******************************************************************/
-node_asn *
-MHD__asn1_mod_type (node_asn * node, unsigned int value)
-{
- if (node == NULL)
- return node;
- node->type |= value;
- return node;
-}
-
-
-/******************************************************************/
/* Function : MHD__asn1_remove_node */
/* Description: gets free the memory allocated for an NODE_ASN */
/* element (not the elements pointed by it). */
@@ -529,7 +443,7 @@
{
if (p->value)
{
- MHD__asn1_convert_integer (p->value, val, sizeof (val), &len);
+ MHD__asn1_convert_integer ((const char*) p->value, val, sizeof
(val), &len);
MHD__asn1_octet_der (val, len, val2, &len);
MHD__asn1_set_value (p, val2, len);
}
@@ -607,7 +521,7 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*)
p2->value);
p3 = MHD__asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
!(p3->type & CONST_ASSIGN))
@@ -622,7 +536,7 @@
{
p5 = MHD__asn1_add_node_only (TYPE_CONSTANT);
MHD__asn1_set_name (p5, p4->name);
- tlen = strlen (p4->value);
+ tlen = strlen ( (const char*) p4->value);
if (tlen > 0)
MHD__asn1_set_value (p5, p4->value, tlen + 1);
if (p2 == p)
@@ -693,7 +607,7 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*)
p2->value);
p3 = MHD__asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
!(p3->type & CONST_ASSIGN))
@@ -706,7 +620,7 @@
{
if (name2[0])
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p4->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const
char*) p4->value);
}
p4 = p4->right;
}
@@ -748,78 +662,7 @@
return ASN1_SUCCESS;
}
-
/******************************************************************/
-/* Function : MHD__asn1_type_set_config */
-/* Description: sets the CONST_SET and CONST_NOT_USED properties */
-/* in the fields of the SET elements. */
-/* Parameters: */
-/* node: root of an ASN1 element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-MHD__asn1_retCode
-MHD__asn1_type_set_config (ASN1_TYPE node)
-{
- node_asn *p, *p2;
- int move;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- move = DOWN;
-
- while (!((p == node) && (move == UP)))
- {
- if (move != UP)
- {
- if (type_field (p->type) == TYPE_SET)
- {
- p2 = p->down;
- while (p2)
- {
- if (type_field (p2->type) != TYPE_TAG)
- p2->type |= CONST_SET | CONST_NOT_USED;
- p2 = p2->right;
- }
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = MHD__asn1_find_up (p);
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
/* Function : MHD__asn1_check_identifier */
/* Description: checks the definitions of all the identifiers */
/* and the first element of an OBJECT_ID (e.g. {pkix 0 4}). */
@@ -848,11 +691,11 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p->value);
p2 = MHD__asn1_find_node (node, name2);
if (p2 == NULL)
{
- strcpy (MHD__asn1_identifierMissing, p->value);
+ strcpy (MHD__asn1_identifierMissing, (const char*) p->value);
return ASN1_IDENTIFIER_NOT_FOUND;
}
}
@@ -864,8 +707,8 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
- strcpy (MHD__asn1_identifierMissing, p2->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*)
p2->value);
+ strcpy (MHD__asn1_identifierMissing, (const char*) p2->value);
p2 = MHD__asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
@@ -884,8 +727,8 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
- strcpy (MHD__asn1_identifierMissing, p2->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*)
p2->value);
+ strcpy (MHD__asn1_identifierMissing, (const char*)
p2->value);
p2 = MHD__asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
@@ -923,150 +766,3 @@
return ASN1_SUCCESS;
}
-
-
-/******************************************************************/
-/* Function : MHD__asn1_set_default_tag */
-/* Description: sets the default IMPLICIT or EXPLICIT property in */
-/* the tagged elements that don't have this declaration. */
-/* Parameters: */
-/* node: pointer to a DEFINITIONS element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL or not a pointer to */
-/* a DEFINITIONS element, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-MHD__asn1_retCode
-MHD__asn1_set_default_tag (ASN1_TYPE node)
-{
- node_asn *p;
-
- if ((node == NULL) || (type_field (node->type) != TYPE_DEFINITIONS))
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- while (p)
- {
- if ((type_field (p->type) == TYPE_TAG) &&
- !(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT))
- {
- if (node->type & CONST_EXPLICIT)
- p->type |= CONST_EXPLICIT;
- else
- p->type |= CONST_IMPLICIT;
- }
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = MHD__asn1_find_up (p);
- if (p == node)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- return ASN1_SUCCESS;
-}
-
-
-
-static const char *
-parse_version_number (const char *s, int *number)
-{
- int val = 0;
-
- if (*s == '0' && isdigit (s[1]))
- return NULL; /* leading zeros are not allowed */
- for (; isdigit (*s); s++)
- {
- val *= 10;
- val += *s - '0';
- }
- *number = val;
- return val < 0 ? NULL : s;
-}
-
-/* The parse version functions were copied from libgcrypt.
- */
-static const char *
-parse_version_string (const char *s, int *major, int *minor, int *micro)
-{
- s = parse_version_number (s, major);
- if (!s || *s != '.')
- return NULL;
- s++;
- s = parse_version_number (s, minor);
- if (!s)
- return NULL;
- if (*s != '.')
- {
- *micro = 0;
- return s;
- }
- s++;
- s = parse_version_number (s, micro);
- if (!s)
- return NULL;
- return s; /* patchlevel */
-}
-
-/**
- * MHD__asn1_check_version - check for library version
- * @req_version: Required version number, or NULL.
- *
- * 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.
- *
- * Return value: Version string of run-time library, or %NULL if the
- * run-time library does not meet the required version number.
- */
-const char *
-MHD__asn1_check_version (const char *req_version)
-{
- const char *ver = LIBTASN1_VERSION;
- int my_major, my_minor, my_micro;
- int rq_major, rq_minor, rq_micro;
- const char *my_plvl, *rq_plvl;
-
- if (!req_version)
- return ver;
-
- my_plvl = parse_version_string (ver, &my_major, &my_minor, &my_micro);
- if (!my_plvl)
- return NULL; /* very strange our own version is bogus */
- rq_plvl = parse_version_string (req_version, &rq_major, &rq_minor,
- &rq_micro);
- if (!rq_plvl)
- return NULL; /* req version string is invalid */
-
- if (my_major > rq_major
- || (my_major == rq_major && my_minor > rq_minor)
- || (my_major == rq_major && my_minor == rq_minor
- && my_micro > rq_micro)
- || (my_major == rq_major && my_minor == rq_minor
- && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0))
- {
- return ver;
- }
- return NULL;
-}
Modified: libmicrohttpd/src/daemon/https/minitasn1/parser_aux.h
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/parser_aux.h 2008-10-12
18:47:44 UTC (rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/parser_aux.h 2008-10-12
20:22:09 UTC (rev 7760)
@@ -15,18 +15,8 @@
node_asn *MHD__asn1_set_right (node_asn * node, node_asn * right);
-node_asn *MHD__asn1_get_right (node_asn * node);
-
-node_asn *MHD__asn1_get_last_right (node_asn * node);
-
node_asn *MHD__asn1_set_down (node_asn * node, node_asn * down);
-char *MHD__asn1_get_name (node_asn * node);
-
-node_asn *MHD__asn1_get_down (node_asn * node);
-
-node_asn *MHD__asn1_mod_type (node_asn * node, unsigned int value);
-
void MHD__asn1_remove_node (node_asn * node);
void MHD__asn1_delete_list (void);
@@ -41,10 +31,7 @@
MHD__asn1_retCode MHD__asn1_expand_object_id (ASN1_TYPE node);
-MHD__asn1_retCode MHD__asn1_type_set_config (ASN1_TYPE node);
-
MHD__asn1_retCode MHD__asn1_check_identifier (ASN1_TYPE node);
-MHD__asn1_retCode MHD__asn1_set_default_tag (ASN1_TYPE node);
#endif
Modified: libmicrohttpd/src/daemon/https/minitasn1/structure.c
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/structure.c 2008-10-12
18:47:44 UTC (rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/structure.c 2008-10-12
20:22:09 UTC (rev 7760)
@@ -37,7 +37,10 @@
extern char MHD__asn1_identifierMissing[];
+static node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char
*source_name);
+
+
/******************************************************/
/* Function : MHD__asn1_add_node_only */
/* Description: creates a new NODE_ASN element. */
@@ -79,86 +82,7 @@
}
-MHD__asn1_retCode
-MHD__asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
- char *vector_name)
-{
- FILE *file;
- node_asn *p;
- unsigned long t;
- file = fopen (output_file_name, "w");
-
- if (file == NULL)
- return ASN1_FILE_NOT_FOUND;
-
- fprintf (file, "#if HAVE_CONFIG_H\n");
- fprintf (file, "# include \"config.h\"\n");
- fprintf (file, "#endif\n\n");
-
- fprintf (file, "#include <libtasn1.h>\n\n");
-
- fprintf (file, "extern const ASN1_ARRAY_TYPE %s[]={\n", vector_name);
-
- p = pointer;
-
- while (p)
- {
- fprintf (file, " {");
-
- if (p->name)
- fprintf (file, "\"%s\",", p->name);
- else
- fprintf (file, "0,");
-
- t = p->type;
- if (p->down)
- t |= CONST_DOWN;
- if (p->right)
- t |= CONST_RIGHT;
-
- fprintf (file, "%lu,", t);
-
- if (p->value)
- fprintf (file, "\"%s\"},\n", p->value);
- else
- fprintf (file, "0},\n");
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p->right)
- {
- p = p->right;
- }
- else
- {
- while (1)
- {
- p = MHD__asn1_find_up (p);
- if (p == pointer)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- fprintf (file, " {0,0,0}\n};\n");
-
- fclose (file);
-
- return ASN1_SUCCESS;
-}
-
-
/**
* MHD__asn1_array2tree - Creates the structures needed to manage the ASN1
definitions.
* @array: specify the array that contains ASN.1 declarations
@@ -455,7 +379,7 @@
}
-node_asn *
+static node_asn *
MHD__asn1_copy_structure2 (node_asn * root, const char *source_name)
{
node_asn *source_node;
@@ -467,7 +391,7 @@
}
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_type_choice_config (node_asn * node)
{
node_asn *p, *p2, *p3, *p4;
@@ -497,7 +421,7 @@
if (type_field (p3->type) == TYPE_TAG)
{
p4 = MHD__asn1_add_node_only (p3->type);
- tlen = strlen (p3->value);
+ tlen = strlen ((const char*) p3->value);
if (tlen > 0)
MHD__asn1_set_value (p4, p3->value, tlen + 1);
MHD__asn1_set_right (p4, p2->down);
@@ -552,7 +476,7 @@
}
-MHD__asn1_retCode
+static MHD__asn1_retCode
MHD__asn1_expand_identifier (node_asn ** node, node_asn * root)
{
node_asn *p, *p2, *p3;
@@ -573,7 +497,7 @@
{
MHD__asn1_str_cpy (name2, sizeof (name2), root->name);
MHD__asn1_str_cat (name2, sizeof (name2), ".");
- MHD__asn1_str_cat (name2, sizeof (name2), p->value);
+ MHD__asn1_str_cat (name2, sizeof (name2), (const char*)
p->value);
p2 = MHD__asn1_copy_structure2 (root, name2);
if (p2 == NULL)
{
@@ -704,370 +628,6 @@
/**
- * MHD__asn1_print_structure - Prints on the standard output the structure's
tree
- * @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.
- *
- * Prints on the @out file descriptor the structure's tree starting
- * from the @name element inside the structure @structure.
- **/
-void
-MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
- int mode)
-{
- node_asn *p, *root;
- int k, indent = 0, len, len2, len3;
-
- if (out == NULL)
- return;
-
- root = MHD__asn1_find_node (structure, name);
-
- if (root == NULL)
- return;
-
- p = root;
- while (p)
- {
- if (mode == ASN1_PRINT_ALL)
- {
- for (k = 0; k < indent; k++)
- fprintf (out, " ");
- fprintf (out, "name:");
- if (p->name)
- fprintf (out, "%s ", p->name);
- else
- fprintf (out, "NULL ");
- }
- else
- {
- switch (type_field (p->type))
- {
- case TYPE_CONSTANT:
- case TYPE_TAG:
- case TYPE_SIZE:
- break;
- default:
- for (k = 0; k < indent; k++)
- fprintf (out, " ");
- fprintf (out, "name:");
- if (p->name)
- fprintf (out, "%s ", p->name);
- else
- fprintf (out, "NULL ");
- }
- }
-
- if (mode != ASN1_PRINT_NAME)
- {
- switch (type_field (p->type))
- {
- case TYPE_CONSTANT:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:CONST");
- break;
- case TYPE_TAG:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:TAG");
- break;
- case TYPE_SIZE:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:SIZE");
- break;
- case TYPE_DEFAULT:
- fprintf (out, "type:DEFAULT");
- break;
- case TYPE_NULL:
- fprintf (out, "type:NULL");
- break;
- case TYPE_IDENTIFIER:
- fprintf (out, "type:IDENTIFIER");
- break;
- case TYPE_INTEGER:
- fprintf (out, "type:INTEGER");
- break;
- case TYPE_ENUMERATED:
- fprintf (out, "type:ENUMERATED");
- break;
- case TYPE_TIME:
- fprintf (out, "type:TIME");
- break;
- case TYPE_BOOLEAN:
- fprintf (out, "type:BOOLEAN");
- break;
- case TYPE_SEQUENCE:
- fprintf (out, "type:SEQUENCE");
- break;
- case TYPE_BIT_STRING:
- fprintf (out, "type:BIT_STR");
- break;
- case TYPE_OCTET_STRING:
- fprintf (out, "type:OCT_STR");
- break;
- case TYPE_GENERALSTRING:
- fprintf (out, "type:GENERALSTRING");
- break;
- case TYPE_SEQUENCE_OF:
- fprintf (out, "type:SEQ_OF");
- break;
- case TYPE_OBJECT_ID:
- fprintf (out, "type:OBJ_ID");
- break;
- case TYPE_ANY:
- fprintf (out, "type:ANY");
- break;
- case TYPE_SET:
- fprintf (out, "type:SET");
- break;
- case TYPE_SET_OF:
- fprintf (out, "type:SET_OF");
- break;
- case TYPE_CHOICE:
- fprintf (out, "type:CHOICE");
- break;
- case TYPE_DEFINITIONS:
- fprintf (out, "type:DEFINITIONS");
- break;
- default:
- break;
- }
- }
-
- if ((mode == ASN1_PRINT_NAME_TYPE_VALUE) || (mode == ASN1_PRINT_ALL))
- {
- switch (type_field (p->type))
- {
- case TYPE_CONSTANT:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_TAG:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_SIZE:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_DEFAULT:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- else if (p->type & CONST_TRUE)
- fprintf (out, " value:TRUE");
- else if (p->type & CONST_FALSE)
- fprintf (out, " value:FALSE");
- break;
- case TYPE_IDENTIFIER:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_INTEGER:
- if (p->value)
- {
- len2 = -1;
- len = MHD__asn1_get_length_der (p->value, p->value_len,
&len2);
- fprintf (out, " value:0x");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (p->value)[k + len2]);
- }
- break;
- case TYPE_ENUMERATED:
- if (p->value)
- {
- len2 = -1;
- len = MHD__asn1_get_length_der (p->value, p->value_len,
&len2);
- fprintf (out, " value:0x");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (p->value)[k + len2]);
- }
- break;
- case TYPE_TIME:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_BOOLEAN:
- if (p->value)
- {
- if (p->value[0] == 'T')
- fprintf (out, " value:TRUE");
- else if (p->value[0] == 'F')
- fprintf (out, " value:FALSE");
- }
- break;
- case TYPE_BIT_STRING:
- if (p->value)
- {
- len2 = -1;
- len = MHD__asn1_get_length_der (p->value, p->value_len,
&len2);
- if (len > 0)
- {
- fprintf (out, " value(%i):",
- (len - 1) * 8 - (p->value[len2]));
- for (k = 1; k < len; k++)
- fprintf (out, "%02x", (p->value)[k + len2]);
- }
- }
- break;
- case TYPE_OCTET_STRING:
- if (p->value)
- {
- len2 = -1;
- len = MHD__asn1_get_length_der (p->value, p->value_len,
&len2);
- fprintf (out, " value:");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (p->value)[k + len2]);
- }
- break;
- case TYPE_GENERALSTRING:
- if (p->value)
- {
- len2 = -1;
- len = MHD__asn1_get_length_der (p->value, p->value_len,
&len2);
- fprintf (out, " value:");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (p->value)[k + len2]);
- }
- break;
- case TYPE_OBJECT_ID:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case TYPE_ANY:
- if (p->value)
- {
- len3 = -1;
- len2 = MHD__asn1_get_length_der (p->value, p->value_len,
&len3);
- fprintf (out, " value:");
- if (len2 > 0)
- for (k = 0; k < len2; k++)
- fprintf (out, "%02x", (p->value)[k + len3]);
- }
- break;
- case TYPE_SET:
- case TYPE_SET_OF:
- case TYPE_CHOICE:
- case TYPE_DEFINITIONS:
- case TYPE_SEQUENCE_OF:
- case TYPE_SEQUENCE:
- case TYPE_NULL:
- break;
- default:
- break;
- }
- }
-
- if (mode == ASN1_PRINT_ALL)
- {
- if (p->type & 0x1FFFFF00)
- {
- fprintf (out, " attr:");
- if (p->type & CONST_UNIVERSAL)
- fprintf (out, "UNIVERSAL,");
- if (p->type & CONST_PRIVATE)
- fprintf (out, "PRIVATE,");
- if (p->type & CONST_APPLICATION)
- fprintf (out, "APPLICATION,");
- if (p->type & CONST_EXPLICIT)
- fprintf (out, "EXPLICIT,");
- if (p->type & CONST_IMPLICIT)
- fprintf (out, "IMPLICIT,");
- if (p->type & CONST_TAG)
- fprintf (out, "TAG,");
- if (p->type & CONST_DEFAULT)
- fprintf (out, "DEFAULT,");
- if (p->type & CONST_TRUE)
- fprintf (out, "TRUE,");
- if (p->type & CONST_FALSE)
- fprintf (out, "FALSE,");
- if (p->type & CONST_LIST)
- fprintf (out, "LIST,");
- if (p->type & CONST_MIN_MAX)
- fprintf (out, "MIN_MAX,");
- if (p->type & CONST_OPTION)
- fprintf (out, "OPTION,");
- if (p->type & CONST_1_PARAM)
- fprintf (out, "1_PARAM,");
- if (p->type & CONST_SIZE)
- fprintf (out, "SIZE,");
- if (p->type & CONST_DEFINED_BY)
- fprintf (out, "DEF_BY,");
- if (p->type & CONST_GENERALIZED)
- fprintf (out, "GENERALIZED,");
- if (p->type & CONST_UTC)
- fprintf (out, "UTC,");
- if (p->type & CONST_SET)
- fprintf (out, "SET,");
- if (p->type & CONST_NOT_USED)
- fprintf (out, "NOT_USED,");
- if (p->type & CONST_ASSIGN)
- fprintf (out, "ASSIGNMENT,");
- }
- }
-
- if (mode == ASN1_PRINT_ALL)
- {
- fprintf (out, "\n");
- }
- else
- {
- switch (type_field (p->type))
- {
- case TYPE_CONSTANT:
- case TYPE_TAG:
- case TYPE_SIZE:
- break;
- default:
- fprintf (out, "\n");
- }
- }
-
- if (p->down)
- {
- p = p->down;
- indent += 2;
- }
- else if (p == root)
- {
- p = NULL;
- break;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = MHD__asn1_find_up (p);
- if (p == root)
- {
- p = NULL;
- break;
- }
- indent -= 2;
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-}
-
-
-
-/**
* MHD__asn1_number_of_elements - Counts the number of elements of a
structure.
* @element: pointer to the root of an ASN1 structure.
* @name: the name of a sub-structure of ROOT.
Modified: libmicrohttpd/src/daemon/https/minitasn1/structure.h
===================================================================
--- libmicrohttpd/src/daemon/https/minitasn1/structure.h 2008-10-12
18:47:44 UTC (rev 7759)
+++ libmicrohttpd/src/daemon/https/minitasn1/structure.h 2008-10-12
20:22:09 UTC (rev 7760)
@@ -8,13 +8,8 @@
#ifndef _STRUCTURE_H
#define _STRUCTURE_H
-MHD__asn1_retCode MHD__asn1_create_static_structure (node_asn * pointer,
- char *output_file_name,
- char *vector_name);
-
node_asn *MHD__asn1_copy_structure3 (node_asn * source_node);
-node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name);
node_asn *MHD__asn1_add_node_only (unsigned int type);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7760 - libmicrohttpd/src/daemon/https/minitasn1,
gnunet <=