|
|
@@ -37,7 +37,7 @@
|
|
|
#define MAX_TAG_LEN 16
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_error_description_value_not_found */
|
|
|
+/* Function : MHD__asn1_error_description_value_not_found */
|
|
|
/* Description: creates the ErrorDescription string */
|
|
|
/* for the ASN1_VALUE_NOT_FOUND error. */
|
|
|
/* Parameters: */
|
|
|
@@ -46,7 +46,7 @@
|
|
|
/* Return: */
|
|
|
/******************************************************/
|
|
|
void
|
|
|
-_asn1_error_description_value_not_found (node_asn * node,
|
|
|
+MHD__asn1_error_description_value_not_found (node_asn * node,
|
|
|
char *ErrorDescription)
|
|
|
{
|
|
|
|
|
|
@@ -54,14 +54,14 @@ _asn1_error_description_value_not_found (node_asn * node,
|
|
|
return;
|
|
|
|
|
|
Estrcpy (ErrorDescription, ":: value of element '");
|
|
|
- _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
|
|
|
+ MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
|
|
|
MAX_ERROR_DESCRIPTION_SIZE - 40);
|
|
|
Estrcat (ErrorDescription, "' not found");
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * asn1_length_der:
|
|
|
+ * MHD__asn1_length_der:
|
|
|
* @len: value to convert.
|
|
|
* @ans: string returned.
|
|
|
* @ans_len: number of meaningful bytes of ANS (ans[0]..ans[ans_len-1]).
|
|
|
@@ -70,7 +70,7 @@ _asn1_error_description_value_not_found (node_asn * node,
|
|
|
* The @ans buffer is pre-allocated and must have room for the output.
|
|
|
**/
|
|
|
void
|
|
|
-asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
|
|
|
+MHD__asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
|
|
|
{
|
|
|
int k;
|
|
|
unsigned char temp[SIZEOF_UNSIGNED_LONG_INT];
|
|
|
@@ -102,7 +102,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
|
|
|
}
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_tag_der */
|
|
|
+/* Function : MHD__asn1_tag_der */
|
|
|
/* Description: creates the DER coding for the CLASS */
|
|
|
/* and TAG parameters. */
|
|
|
/* Parameters: */
|
|
|
@@ -114,7 +114,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
|
|
|
/* Return: */
|
|
|
/******************************************************/
|
|
|
void
|
|
|
-_asn1_tag_der (unsigned char class, unsigned int tag_value,
|
|
|
+MHD__asn1_tag_der (unsigned char class, unsigned int tag_value,
|
|
|
unsigned char *ans, int *ans_len)
|
|
|
{
|
|
|
int k;
|
|
|
@@ -144,7 +144,7 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * asn1_octet_der:
|
|
|
+ * MHD__asn1_octet_der:
|
|
|
* @str: OCTET string.
|
|
|
* @str_len: STR length (str[0]..str[str_len-1]).
|
|
|
* @der: string returned.
|
|
|
@@ -153,20 +153,20 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
|
|
|
* Creates the DER coding for an OCTET type (length included).
|
|
|
**/
|
|
|
void
|
|
|
-asn1_octet_der (const unsigned char *str, int str_len,
|
|
|
+MHD__asn1_octet_der (const unsigned char *str, int str_len,
|
|
|
unsigned char *der, int *der_len)
|
|
|
{
|
|
|
int len_len;
|
|
|
|
|
|
if (der == NULL || str_len < 0)
|
|
|
return;
|
|
|
- asn1_length_der (str_len, der, &len_len);
|
|
|
+ MHD__asn1_length_der (str_len, der, &len_len);
|
|
|
memcpy (der + len_len, str, str_len);
|
|
|
*der_len = str_len + len_len;
|
|
|
}
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_time_der */
|
|
|
+/* Function : MHD__asn1_time_der */
|
|
|
/* Description: creates the DER coding for a TIME */
|
|
|
/* type (length included). */
|
|
|
/* Parameters: */
|
|
|
@@ -179,15 +179,15 @@ asn1_octet_der (const unsigned char *str, int str_len,
|
|
|
/* ASN1_MEM_ERROR when DER isn't big enough */
|
|
|
/* ASN1_SUCCESS otherwise */
|
|
|
/******************************************************/
|
|
|
-asn1_retCode
|
|
|
-_asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
+MHD__asn1_retCode
|
|
|
+MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
{
|
|
|
int len_len;
|
|
|
int max_len;
|
|
|
|
|
|
max_len = *der_len;
|
|
|
|
|
|
- asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
|
|
|
+ MHD__asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
|
|
|
|
|
|
if ((len_len + (int) strlen (str)) <= max_len)
|
|
|
memcpy (der + len_len, str, strlen (str));
|
|
|
@@ -202,13 +202,13 @@ _asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
|
|
|
/*
|
|
|
void
|
|
|
-_asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
|
|
|
+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=asn1_get_length_der(der,*der_len,&len_len);
|
|
|
+ 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;
|
|
|
@@ -237,7 +237,7 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
|
|
|
*/
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_objectid_der */
|
|
|
+/* Function : MHD__asn1_objectid_der */
|
|
|
/* Description: creates the DER coding for an */
|
|
|
/* OBJECT IDENTIFIER type (length included). */
|
|
|
/* Parameters: */
|
|
|
@@ -250,8 +250,8 @@ _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 */
|
|
|
/******************************************************/
|
|
|
-asn1_retCode
|
|
|
-_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
+MHD__asn1_retCode
|
|
|
+MHD__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;
|
|
|
@@ -260,7 +260,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
|
|
|
max_len = *der_len;
|
|
|
|
|
|
- temp = (char *) _asn1_alloca (strlen (str) + 2);
|
|
|
+ temp = (char *) MHD__asn1_alloca (strlen (str) + 2);
|
|
|
if (temp == NULL)
|
|
|
return ASN1_MEM_ALLOC_ERROR;
|
|
|
|
|
|
@@ -304,15 +304,15 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
n_start = n_end + 1;
|
|
|
}
|
|
|
|
|
|
- asn1_length_der (*der_len, NULL, &len_len);
|
|
|
+ MHD__asn1_length_der (*der_len, NULL, &len_len);
|
|
|
if (max_len >= (*der_len + len_len))
|
|
|
{
|
|
|
memmove (der + len_len, der, *der_len);
|
|
|
- asn1_length_der (*der_len, der, &len_len);
|
|
|
+ MHD__asn1_length_der (*der_len, der, &len_len);
|
|
|
}
|
|
|
*der_len += len_len;
|
|
|
|
|
|
- _asn1_afree (temp);
|
|
|
+ MHD__asn1_afree (temp);
|
|
|
|
|
|
if (max_len < (*der_len))
|
|
|
return ASN1_MEM_ERROR;
|
|
|
@@ -324,7 +324,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
|
|
|
const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
|
|
|
|
|
|
/**
|
|
|
- * asn1_bit_der:
|
|
|
+ * MHD__asn1_bit_der:
|
|
|
* @str: BIT string.
|
|
|
* @bit_len: number of meaningful bits in STR.
|
|
|
* @der: string returned.
|
|
|
@@ -335,7 +335,7 @@ const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
|
|
|
* included).
|
|
|
**/
|
|
|
void
|
|
|
-asn1_bit_der (const unsigned char *str, int bit_len,
|
|
|
+MHD__asn1_bit_der (const unsigned char *str, int bit_len,
|
|
|
unsigned char *der, int *der_len)
|
|
|
{
|
|
|
int len_len, len_byte, len_pad;
|
|
|
@@ -348,7 +348,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
|
|
|
len_pad = 0;
|
|
|
else
|
|
|
len_byte++;
|
|
|
- asn1_length_der (len_byte + 1, der, &len_len);
|
|
|
+ MHD__asn1_length_der (len_byte + 1, der, &len_len);
|
|
|
der[len_len] = len_pad;
|
|
|
memcpy (der + len_len + 1, str, len_byte);
|
|
|
der[len_len + len_byte] &= bit_mask[len_pad];
|
|
|
@@ -357,7 +357,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
|
|
|
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_complete_explicit_tag */
|
|
|
+/* Function : MHD__asn1_complete_explicit_tag */
|
|
|
/* Description: add the length coding to the EXPLICIT */
|
|
|
/* tags. */
|
|
|
/* Parameters: */
|
|
|
@@ -370,8 +370,8 @@ asn1_bit_der (const unsigned char *str, int bit_len,
|
|
|
/* ASN1_MEM_ERROR if der vector isn't big enough, */
|
|
|
/* otherwise ASN1_SUCCESS. */
|
|
|
/******************************************************/
|
|
|
-asn1_retCode
|
|
|
-_asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
|
|
|
+MHD__asn1_retCode
|
|
|
+MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
|
|
|
int *counter, int *max_len)
|
|
|
{
|
|
|
node_asn *p;
|
|
|
@@ -397,8 +397,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
|
|
|
if (p->type & CONST_EXPLICIT)
|
|
|
{
|
|
|
len2 = strtol (p->name, NULL, 10);
|
|
|
- _asn1_set_name (p, NULL);
|
|
|
- asn1_length_der (*counter - len2, temp, &len3);
|
|
|
+ MHD__asn1_set_name (p, NULL);
|
|
|
+ MHD__asn1_length_der (*counter - len2, temp, &len3);
|
|
|
if (len3 <= (*max_len))
|
|
|
{
|
|
|
memmove (der + len2 + len3, der + len2,
|
|
|
@@ -429,7 +429,7 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
|
|
|
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_insert_tag_der */
|
|
|
+/* Function : MHD__asn1_insert_tag_der */
|
|
|
/* Description: creates the DER coding of tags of one */
|
|
|
/* NODE. */
|
|
|
/* Parameters: */
|
|
|
@@ -443,8 +443,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
|
|
|
/* ASN1_MEM_ERROR if der vector isn't big enough, */
|
|
|
/* otherwise ASN1_SUCCESS. */
|
|
|
/******************************************************/
|
|
|
-asn1_retCode
|
|
|
-_asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
+MHD__asn1_retCode
|
|
|
+MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
int *max_len)
|
|
|
{
|
|
|
node_asn *p;
|
|
|
@@ -474,10 +474,10 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
if (p->type & CONST_EXPLICIT)
|
|
|
{
|
|
|
if (is_tag_implicit)
|
|
|
- _asn1_tag_der (class_implicit, tag_implicit, tag_der,
|
|
|
+ MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der,
|
|
|
&tag_len);
|
|
|
else
|
|
|
- _asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
|
|
|
+ MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
|
|
|
strtoul (p->value, NULL, 10), tag_der,
|
|
|
&tag_len);
|
|
|
|
|
|
@@ -486,8 +486,8 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
memcpy (der + *counter, tag_der, tag_len);
|
|
|
*counter += tag_len;
|
|
|
|
|
|
- _asn1_ltostr (*counter, temp);
|
|
|
- _asn1_set_name (p, temp);
|
|
|
+ MHD__asn1_ltostr (*counter, temp);
|
|
|
+ MHD__asn1_set_name (p, temp);
|
|
|
|
|
|
is_tag_implicit = 0;
|
|
|
}
|
|
|
@@ -512,62 +512,62 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
|
|
|
if (is_tag_implicit)
|
|
|
{
|
|
|
- _asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
|
|
|
+ MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
switch (type_field (node->type))
|
|
|
{
|
|
|
case TYPE_NULL:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_BOOLEAN:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_INTEGER:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_ENUMERATED:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_OBJECT_ID:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_TIME:
|
|
|
if (node->type & CONST_UTC)
|
|
|
{
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
|
|
|
&tag_len);
|
|
|
}
|
|
|
else
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
|
|
|
tag_der, &tag_len);
|
|
|
break;
|
|
|
case TYPE_OCTET_STRING:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_GENERALSTRING:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
|
|
|
tag_der, &tag_len);
|
|
|
break;
|
|
|
case TYPE_BIT_STRING:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
|
|
|
&tag_len);
|
|
|
break;
|
|
|
case TYPE_SEQUENCE:
|
|
|
case TYPE_SEQUENCE_OF:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
|
|
|
ASN1_TAG_SEQUENCE, tag_der, &tag_len);
|
|
|
break;
|
|
|
case TYPE_SET:
|
|
|
case TYPE_SET_OF:
|
|
|
- _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
|
|
|
+ MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
|
|
|
ASN1_TAG_SET, tag_der, &tag_len);
|
|
|
break;
|
|
|
case TYPE_TAG:
|
|
|
@@ -596,7 +596,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
}
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_ordering_set */
|
|
|
+/* Function : MHD__asn1_ordering_set */
|
|
|
/* Description: puts the elements of a SET type in */
|
|
|
/* the correct order according to DER rules. */
|
|
|
/* Parameters: */
|
|
|
@@ -605,7 +605,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
|
|
|
/* Return: */
|
|
|
/******************************************************/
|
|
|
void
|
|
|
-_asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
+MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
{
|
|
|
struct vet
|
|
|
{
|
|
|
@@ -637,7 +637,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
first = last = NULL;
|
|
|
while (p)
|
|
|
{
|
|
|
- p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet));
|
|
|
+ p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
|
|
|
if (p_vet == NULL)
|
|
|
return;
|
|
|
|
|
|
@@ -650,7 +650,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
last = p_vet;
|
|
|
|
|
|
/* tag value calculation */
|
|
|
- if (asn1_get_tag_der
|
|
|
+ if (MHD__asn1_get_tag_der
|
|
|
(der + counter, der_len - counter, &class, &len2,
|
|
|
&tag) != ASN1_SUCCESS)
|
|
|
return;
|
|
|
@@ -658,7 +658,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
counter += len2;
|
|
|
|
|
|
/* extraction and length */
|
|
|
- len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
|
|
|
+ len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
|
|
|
if (len2 < 0)
|
|
|
return;
|
|
|
counter += len + len2;
|
|
|
@@ -678,7 +678,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
if (p_vet->value > p2_vet->value)
|
|
|
{
|
|
|
/* change position */
|
|
|
- temp = (unsigned char *) _asn1_alloca (p_vet->end - counter);
|
|
|
+ temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
|
|
|
if (temp == NULL)
|
|
|
return;
|
|
|
|
|
|
@@ -687,7 +687,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
p2_vet->end - p_vet->end);
|
|
|
memcpy (der + counter + p2_vet->end - p_vet->end, temp,
|
|
|
p_vet->end - counter);
|
|
|
- _asn1_afree (temp);
|
|
|
+ MHD__asn1_afree (temp);
|
|
|
|
|
|
tag = p_vet->value;
|
|
|
p_vet->value = p2_vet->value;
|
|
|
@@ -705,13 +705,13 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
p_vet->prev->next = NULL;
|
|
|
else
|
|
|
first = NULL;
|
|
|
- _asn1_afree (p_vet);
|
|
|
+ MHD__asn1_afree (p_vet);
|
|
|
p_vet = first;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/******************************************************/
|
|
|
-/* Function : _asn1_ordering_set_of */
|
|
|
+/* Function : MHD__asn1_ordering_set_of */
|
|
|
/* Description: puts the elements of a SET OF type in */
|
|
|
/* the correct order according to DER rules. */
|
|
|
/* Parameters: */
|
|
|
@@ -720,7 +720,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
|
|
|
/* Return: */
|
|
|
/******************************************************/
|
|
|
void
|
|
|
-_asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
+MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
{
|
|
|
struct vet
|
|
|
{
|
|
|
@@ -751,7 +751,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
first = last = NULL;
|
|
|
while (p)
|
|
|
{
|
|
|
- p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet));
|
|
|
+ p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
|
|
|
if (p_vet == NULL)
|
|
|
return;
|
|
|
|
|
|
@@ -767,13 +767,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
if (der_len - counter > 0)
|
|
|
{
|
|
|
|
|
|
- if (asn1_get_tag_der
|
|
|
+ if (MHD__asn1_get_tag_der
|
|
|
(der + counter, der_len - counter, &class, &len,
|
|
|
NULL) != ASN1_SUCCESS)
|
|
|
return;
|
|
|
counter += len;
|
|
|
|
|
|
- len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
|
|
|
+ len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
|
|
|
if (len2 < 0)
|
|
|
return;
|
|
|
counter += len + len2;
|
|
|
@@ -816,7 +816,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
if (change == 1)
|
|
|
{
|
|
|
/* change position */
|
|
|
- temp = (unsigned char *) _asn1_alloca (p_vet->end - counter);
|
|
|
+ temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
|
|
|
if (temp == NULL)
|
|
|
return;
|
|
|
|
|
|
@@ -825,7 +825,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
(p2_vet->end) - (p_vet->end));
|
|
|
memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
|
|
|
(p_vet->end) - counter);
|
|
|
- _asn1_afree (temp);
|
|
|
+ MHD__asn1_afree (temp);
|
|
|
|
|
|
p_vet->end = counter + (p2_vet->end - p_vet->end);
|
|
|
}
|
|
|
@@ -839,13 +839,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
p_vet->prev->next = NULL;
|
|
|
else
|
|
|
first = NULL;
|
|
|
- _asn1_afree (p_vet);
|
|
|
+ MHD__asn1_afree (p_vet);
|
|
|
p_vet = first;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * asn1_der_coding - Creates the DER encoding for the NAME structure
|
|
|
+ * MHD__asn1_der_coding - Creates the DER encoding for the NAME structure
|
|
|
* @element: pointer to an ASN1 element
|
|
|
* @name: the name of the structure you want to encode (it must be
|
|
|
* inside *POINTER).
|
|
|
@@ -871,17 +871,17 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
|
|
|
* LEN will contain the length needed.
|
|
|
*
|
|
|
**/
|
|
|
-asn1_retCode
|
|
|
-asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
+MHD__asn1_retCode
|
|
|
+MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
char *ErrorDescription)
|
|
|
{
|
|
|
node_asn *node, *p, *p2;
|
|
|
char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
|
|
|
int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
|
|
|
- asn1_retCode err;
|
|
|
+ MHD__asn1_retCode err;
|
|
|
unsigned char *der = ider;
|
|
|
|
|
|
- node = asn1_find_node (element, name);
|
|
|
+ node = MHD__asn1_find_node (element, name);
|
|
|
if (node == NULL)
|
|
|
return ASN1_ELEMENT_NOT_FOUND;
|
|
|
|
|
|
@@ -889,7 +889,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
* That is because in some point we modify the
|
|
|
* structure, and I don't know why! --nmav
|
|
|
*/
|
|
|
- node = _asn1_copy_structure3 (node);
|
|
|
+ node = MHD__asn1_copy_structure3 (node);
|
|
|
if (node == NULL)
|
|
|
return ASN1_ELEMENT_NOT_FOUND;
|
|
|
|
|
|
@@ -905,7 +905,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
max_len_old = max_len;
|
|
|
if (move != UP)
|
|
|
{
|
|
|
- err = _asn1_insert_tag_der (p, der, &counter, &max_len);
|
|
|
+ err = MHD__asn1_insert_tag_der (p, der, &counter, &max_len);
|
|
|
if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
|
|
|
goto error;
|
|
|
}
|
|
|
@@ -928,7 +928,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
{
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p,
|
|
|
+ MHD__asn1_error_description_value_not_found (p,
|
|
|
ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
@@ -958,12 +958,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
{
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p,
|
|
|
+ MHD__asn1_error_description_value_not_found (p,
|
|
|
ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
+ len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
if (len2 < 0)
|
|
|
{
|
|
|
err = ASN1_DER_ERROR;
|
|
|
@@ -986,13 +986,13 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
{
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p,
|
|
|
+ MHD__asn1_error_description_value_not_found (p,
|
|
|
ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
len2 = max_len;
|
|
|
- err = _asn1_objectid_der (p->value, der + counter, &len2);
|
|
|
+ err = MHD__asn1_objectid_der (p->value, der + counter, &len2);
|
|
|
if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
|
|
|
goto error;
|
|
|
|
|
|
@@ -1004,12 +1004,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_TIME:
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
+ MHD__asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
len2 = max_len;
|
|
|
- err = _asn1_time_der (p->value, der + counter, &len2);
|
|
|
+ err = MHD__asn1_time_der (p->value, der + counter, &len2);
|
|
|
if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
|
|
|
goto error;
|
|
|
|
|
|
@@ -1020,11 +1020,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_OCTET_STRING:
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
+ MHD__asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
+ len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
if (len2 < 0)
|
|
|
{
|
|
|
err = ASN1_DER_ERROR;
|
|
|
@@ -1039,11 +1039,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_GENERALSTRING:
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
+ MHD__asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
+ len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
if (len2 < 0)
|
|
|
{
|
|
|
err = ASN1_DER_ERROR;
|
|
|
@@ -1058,11 +1058,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_BIT_STRING:
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
+ MHD__asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
+ len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
if (len2 < 0)
|
|
|
{
|
|
|
err = ASN1_DER_ERROR;
|
|
|
@@ -1078,10 +1078,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_SET:
|
|
|
if (move != UP)
|
|
|
{
|
|
|
- _asn1_ltostr (counter, temp);
|
|
|
+ MHD__asn1_ltostr (counter, temp);
|
|
|
tlen = strlen (temp);
|
|
|
if (tlen > 0)
|
|
|
- _asn1_set_value (p, temp, tlen + 1);
|
|
|
+ MHD__asn1_set_value (p, temp, tlen + 1);
|
|
|
if (p->down == NULL)
|
|
|
{
|
|
|
move = UP;
|
|
|
@@ -1105,10 +1105,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
else
|
|
|
{ /* move==UP */
|
|
|
len2 = strtol (p->value, NULL, 10);
|
|
|
- _asn1_set_value (p, NULL, 0);
|
|
|
+ MHD__asn1_set_value (p, NULL, 0);
|
|
|
if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
|
|
|
- _asn1_ordering_set (der + len2, max_len - len2, p);
|
|
|
- asn1_length_der (counter - len2, temp, &len3);
|
|
|
+ MHD__asn1_ordering_set (der + len2, max_len - len2, p);
|
|
|
+ MHD__asn1_length_der (counter - len2, temp, &len3);
|
|
|
max_len -= len3;
|
|
|
if (max_len >= 0)
|
|
|
{
|
|
|
@@ -1123,11 +1123,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_SET_OF:
|
|
|
if (move != UP)
|
|
|
{
|
|
|
- _asn1_ltostr (counter, temp);
|
|
|
+ MHD__asn1_ltostr (counter, temp);
|
|
|
tlen = strlen (temp);
|
|
|
|
|
|
if (tlen > 0)
|
|
|
- _asn1_set_value (p, temp, tlen + 1);
|
|
|
+ MHD__asn1_set_value (p, temp, tlen + 1);
|
|
|
p = p->down;
|
|
|
while ((type_field (p->type) == TYPE_TAG)
|
|
|
|| (type_field (p->type) == TYPE_SIZE))
|
|
|
@@ -1139,19 +1139,19 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
- p = _asn1_find_up (p);
|
|
|
+ p = MHD__asn1_find_up (p);
|
|
|
move = UP;
|
|
|
}
|
|
|
if (move == UP)
|
|
|
{
|
|
|
len2 = strtol (p->value, NULL, 10);
|
|
|
- _asn1_set_value (p, NULL, 0);
|
|
|
+ MHD__asn1_set_value (p, NULL, 0);
|
|
|
if ((type_field (p->type) == TYPE_SET_OF)
|
|
|
&& (max_len - len2 > 0))
|
|
|
{
|
|
|
- _asn1_ordering_set_of (der + len2, max_len - len2, p);
|
|
|
+ MHD__asn1_ordering_set_of (der + len2, max_len - len2, p);
|
|
|
}
|
|
|
- asn1_length_der (counter - len2, temp, &len3);
|
|
|
+ MHD__asn1_length_der (counter - len2, temp, &len3);
|
|
|
max_len -= len3;
|
|
|
if (max_len >= 0)
|
|
|
{
|
|
|
@@ -1165,11 +1165,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
case TYPE_ANY:
|
|
|
if (p->value == NULL)
|
|
|
{
|
|
|
- _asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
+ MHD__asn1_error_description_value_not_found (p, ErrorDescription);
|
|
|
err = ASN1_VALUE_NOT_FOUND;
|
|
|
goto error;
|
|
|
}
|
|
|
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
+ len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
|
|
|
if (len2 < 0)
|
|
|
{
|
|
|
err = ASN1_DER_ERROR;
|
|
|
@@ -1188,7 +1188,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
|
|
|
if ((move != DOWN) && (counter != counter_old))
|
|
|
{
|
|
|
- err = _asn1_complete_explicit_tag (p, der, &counter, &max_len);
|
|
|
+ err = MHD__asn1_complete_explicit_tag (p, der, &counter, &max_len);
|
|
|
if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
|
|
|
goto error;
|
|
|
}
|
|
|
@@ -1211,7 +1211,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
move = UP;
|
|
|
}
|
|
|
if (move == UP)
|
|
|
- p = _asn1_find_up (p);
|
|
|
+ p = MHD__asn1_find_up (p);
|
|
|
}
|
|
|
|
|
|
*len = counter;
|
|
|
@@ -1225,6 +1225,6 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
|
|
|
err = ASN1_SUCCESS;
|
|
|
|
|
|
error:
|
|
|
- asn1_delete_structure (&node);
|
|
|
+ MHD__asn1_delete_structure (&node);
|
|
|
return err;
|
|
|
}
|