element.c

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2004, 2006 Free Software Foundation
00003  *      Copyright (C) 2000, 2001, 2002, 2003 Fabio Fiorina
00004  *
00005  * This file is part of LIBTASN1.
00006  *
00007  * The LIBTASN1 library is free software; you can redistribute it
00008  * and/or modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301, USA
00021  */
00022 
00023 /*****************************************************/
00024 /* File: element.c                                   */
00025 /* Description: Functions with the read and write    */
00026 /*   functions.                                      */
00027 /*****************************************************/
00028 
00029 
00030 #include <int.h>
00031 #include "parser_aux.h"
00032 #include <gstr.h>
00033 #include "structure.h"
00034 
00035 void
00036 MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size)
00037 {
00038   node_asn *p;
00039   char tmp_name[64];
00040 
00041   p = node;
00042 
00043   name[0] = 0;
00044 
00045   while (p != NULL)
00046     {
00047       if (p->name != NULL)
00048         {
00049           MHD__asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
00050             MHD__asn1_str_cpy (name, name_size, p->name);
00051           MHD__asn1_str_cat (name, name_size, ".");
00052           MHD__asn1_str_cat (name, name_size, tmp_name);
00053         }
00054       p = MHD__asn1_find_up (p);
00055     }
00056 
00057   if (name[0] == 0)
00058     MHD__asn1_str_cpy (name, name_size, "ROOT");
00059 }
00060 
00061 
00062 /******************************************************************/
00063 /* Function : MHD__asn1_convert_integer                               */
00064 /* Description: converts an integer from a null terminated string */
00065 /*              to der decoding. The convertion from a null       */
00066 /*              terminated string to an integer is made with      */
00067 /*              the 'strtol' function.                            */
00068 /* Parameters:                                                    */
00069 /*   value: null terminated string to convert.                    */
00070 /*   value_out: convertion result (memory must be already         */
00071 /*              allocated).                                       */
00072 /*   value_out_size: number of bytes of value_out.                */
00073 /*   len: number of significant byte of value_out.                */
00074 /* Return: ASN1_MEM_ERROR or ASN1_SUCCESS                         */
00075 /******************************************************************/
00076 MHD__asn1_retCode
00077 MHD__asn1_convert_integer (const char *value, unsigned char *value_out,
00078                            int value_out_size, int *len)
00079 {
00080   char negative;
00081   unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
00082   long valtmp;
00083   int k, k2;
00084 
00085   valtmp = strtol (value, NULL, 10);
00086 
00087   for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
00088     {
00089       val[SIZEOF_UNSIGNED_LONG_INT - k - 1] = (valtmp >> (8 * k)) & 0xFF;
00090     }
00091 
00092   if (val[0] & 0x80)
00093     negative = 1;
00094   else
00095     negative = 0;
00096 
00097   for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT - 1; k++)
00098     {
00099       if (negative && (val[k] != 0xFF))
00100         break;
00101       else if (!negative && val[k])
00102         break;
00103     }
00104 
00105   if ((negative && !(val[k] & 0x80)) || (!negative && (val[k] & 0x80)))
00106     k--;
00107 
00108   *len = SIZEOF_UNSIGNED_LONG_INT - k;
00109 
00110   if (SIZEOF_UNSIGNED_LONG_INT - k > value_out_size)
00111     /* VALUE_OUT is too short to contain the value conversion */
00112     return ASN1_MEM_ERROR;
00113 
00114   for (k2 = k; k2 < SIZEOF_UNSIGNED_LONG_INT; k2++)
00115     value_out[k2 - k] = val[k2];
00116 
00117   return ASN1_SUCCESS;
00118 }
00119 
00120 
00121 int
00122 MHD__asn1_append_sequence_set (node_asn * node)
00123 {
00124   node_asn *p, *p2;
00125   char temp[10];
00126   long n;
00127 
00128   if (!node || !(node->down))
00129     return ASN1_GENERIC_ERROR;
00130 
00131   p = node->down;
00132   while ((type_field (p->type) == TYPE_TAG)
00133          || (type_field (p->type) == TYPE_SIZE))
00134     p = p->right;
00135   p2 = MHD__asn1_copy_structure3 (p);
00136   while (p->right)
00137     p = p->right;
00138   MHD__asn1_set_right (p, p2);
00139 
00140   if (p->name == NULL)
00141     MHD__asn1_str_cpy (temp, sizeof (temp), "?1");
00142   else
00143     {
00144       n = strtol (p->name + 1, NULL, 0);
00145       n++;
00146       temp[0] = '?';
00147       MHD__asn1_ltostr (n, temp + 1);
00148     }
00149   MHD__asn1_set_name (p2, temp);
00150   /*  p2->type |= CONST_OPTION; */
00151 
00152   return ASN1_SUCCESS;
00153 }
00154 
00155 
00267 MHD__asn1_retCode
00268 MHD__asn1_write_value (ASN1_TYPE node_root, const char *name,
00269                        const void *ivalue, int len)
00270 {
00271   node_asn *node, *p, *p2;
00272   unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
00273   int len2, k, k2, negative;
00274   const char *value = ivalue;
00275 
00276   node = MHD__asn1_find_node (node_root, name);
00277   if (node == NULL)
00278     return ASN1_ELEMENT_NOT_FOUND;
00279 
00280   if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0))
00281     {
00282       MHD__asn1_delete_structure (&node);
00283       return ASN1_SUCCESS;
00284     }
00285 
00286   if ((type_field (node->type) == TYPE_SEQUENCE_OF) && (value == NULL)
00287       && (len == 0))
00288     {
00289       p = node->down;
00290       while ((type_field (p->type) == TYPE_TAG)
00291              || (type_field (p->type) == TYPE_SIZE))
00292         p = p->right;
00293 
00294       while (p->right)
00295         MHD__asn1_delete_structure (&p->right);
00296 
00297       return ASN1_SUCCESS;
00298     }
00299 
00300   switch (type_field (node->type))
00301     {
00302     case TYPE_BOOLEAN:
00303       if (!strcmp (value, "TRUE"))
00304         {
00305           if (node->type & CONST_DEFAULT)
00306             {
00307               p = node->down;
00308               while (type_field (p->type) != TYPE_DEFAULT)
00309                 p = p->right;
00310               if (p->type & CONST_TRUE)
00311                 MHD__asn1_set_value (node, NULL, 0);
00312               else
00313                 MHD__asn1_set_value (node, "T", 1);
00314             }
00315           else
00316             MHD__asn1_set_value (node, "T", 1);
00317         }
00318       else if (!strcmp (value, "FALSE"))
00319         {
00320           if (node->type & CONST_DEFAULT)
00321             {
00322               p = node->down;
00323               while (type_field (p->type) != TYPE_DEFAULT)
00324                 p = p->right;
00325               if (p->type & CONST_FALSE)
00326                 MHD__asn1_set_value (node, NULL, 0);
00327               else
00328                 MHD__asn1_set_value (node, "F", 1);
00329             }
00330           else
00331             MHD__asn1_set_value (node, "F", 1);
00332         }
00333       else
00334         return ASN1_VALUE_NOT_VALID;
00335       break;
00336     case TYPE_INTEGER:
00337     case TYPE_ENUMERATED:
00338       if (len == 0)
00339         {
00340           if ((isdigit (value[0])) || (value[0] == '-'))
00341             {
00342               value_temp =
00343                 (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
00344               if (value_temp == NULL)
00345                 return ASN1_MEM_ALLOC_ERROR;
00346 
00347               MHD__asn1_convert_integer (value, value_temp,
00348                                          SIZEOF_UNSIGNED_LONG_INT, &len);
00349             }
00350           else
00351             {                   /* is an identifier like v1 */
00352               if (!(node->type & CONST_LIST))
00353                 return ASN1_VALUE_NOT_VALID;
00354               p = node->down;
00355               while (p)
00356                 {
00357                   if (type_field (p->type) == TYPE_CONSTANT)
00358                     {
00359                       if ((p->name) && (!strcmp (p->name, value)))
00360                         {
00361                           value_temp =
00362                             (unsigned char *)
00363                             MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
00364                           if (value_temp == NULL)
00365                             return ASN1_MEM_ALLOC_ERROR;
00366 
00367                           MHD__asn1_convert_integer ((const char *) p->value,
00368                                                      value_temp,
00369                                                      SIZEOF_UNSIGNED_LONG_INT,
00370                                                      &len);
00371                           break;
00372                         }
00373                     }
00374                   p = p->right;
00375                 }
00376               if (p == NULL)
00377                 return ASN1_VALUE_NOT_VALID;
00378             }
00379         }
00380       else
00381         {                       /* len != 0 */
00382           value_temp = (unsigned char *) MHD__asn1_alloca (len);
00383           if (value_temp == NULL)
00384             return ASN1_MEM_ALLOC_ERROR;
00385           memcpy (value_temp, value, len);
00386         }
00387 
00388 
00389       if (value_temp[0] & 0x80)
00390         negative = 1;
00391       else
00392         negative = 0;
00393 
00394       if (negative && (type_field (node->type) == TYPE_ENUMERATED))
00395         {
00396           MHD__asn1_afree (value_temp);
00397           return ASN1_VALUE_NOT_VALID;
00398         }
00399 
00400       for (k = 0; k < len - 1; k++)
00401         if (negative && (value_temp[k] != 0xFF))
00402           break;
00403         else if (!negative && value_temp[k])
00404           break;
00405 
00406       if ((negative && !(value_temp[k] & 0x80)) ||
00407           (!negative && (value_temp[k] & 0x80)))
00408         k--;
00409 
00410       MHD__asn1_length_der (len - k, NULL, &len2);
00411       temp = (unsigned char *) MHD__asn1_alloca (len - k + len2);
00412       if (temp == NULL)
00413         {
00414           MHD__asn1_afree (value_temp);
00415           return ASN1_MEM_ALLOC_ERROR;
00416         }
00417 
00418       MHD__asn1_octet_der (value_temp + k, len - k, temp, &len2);
00419       MHD__asn1_set_value (node, temp, len2);
00420 
00421       MHD__asn1_afree (temp);
00422 
00423 
00424       if (node->type & CONST_DEFAULT)
00425         {
00426           p = node->down;
00427           while (type_field (p->type) != TYPE_DEFAULT)
00428             p = p->right;
00429           if ((isdigit (p->value[0])) || (p->value[0] == '-'))
00430             {
00431               default_temp =
00432                 (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
00433               if (default_temp == NULL)
00434                 {
00435                   MHD__asn1_afree (value_temp);
00436                   return ASN1_MEM_ALLOC_ERROR;
00437                 }
00438 
00439               MHD__asn1_convert_integer ((const char *) p->value,
00440                                          default_temp,
00441                                          SIZEOF_UNSIGNED_LONG_INT, &len2);
00442             }
00443           else
00444             {                   /* is an identifier like v1 */
00445               if (!(node->type & CONST_LIST))
00446                 {
00447                   MHD__asn1_afree (value_temp);
00448                   return ASN1_VALUE_NOT_VALID;
00449                 }
00450               p2 = node->down;
00451               while (p2)
00452                 {
00453                   if (type_field (p2->type) == TYPE_CONSTANT)
00454                     {
00455                       if ((p2->name)
00456                           && (!strcmp (p2->name, (const char *) p->value)))
00457                         {
00458                           default_temp =
00459                             (unsigned char *)
00460                             MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
00461                           if (default_temp == NULL)
00462                             {
00463                               MHD__asn1_afree (value_temp);
00464                               return ASN1_MEM_ALLOC_ERROR;
00465                             }
00466 
00467                           MHD__asn1_convert_integer ((const char *) p2->value,
00468                                                      default_temp,
00469                                                      SIZEOF_UNSIGNED_LONG_INT,
00470                                                      &len2);
00471                           break;
00472                         }
00473                     }
00474                   p2 = p2->right;
00475                 }
00476               if (p2 == NULL)
00477                 {
00478                   MHD__asn1_afree (value_temp);
00479                   return ASN1_VALUE_NOT_VALID;
00480                 }
00481             }
00482 
00483 
00484           if ((len - k) == len2)
00485             {
00486               for (k2 = 0; k2 < len2; k2++)
00487                 if (value_temp[k + k2] != default_temp[k2])
00488                   {
00489                     break;
00490                   }
00491               if (k2 == len2)
00492                 MHD__asn1_set_value (node, NULL, 0);
00493             }
00494           MHD__asn1_afree (default_temp);
00495         }
00496       MHD__asn1_afree (value_temp);
00497       break;
00498     case TYPE_OBJECT_ID:
00499       for (k = 0; k < strlen (value); k++)
00500         if ((!isdigit (value[k])) && (value[k] != '.') && (value[k] != '+'))
00501           return ASN1_VALUE_NOT_VALID;
00502       if (node->type & CONST_DEFAULT)
00503         {
00504           p = node->down;
00505           while (type_field (p->type) != TYPE_DEFAULT)
00506             p = p->right;
00507           if (!strcmp (value, (const char *) p->value))
00508             {
00509               MHD__asn1_set_value (node, NULL, 0);
00510               break;
00511             }
00512         }
00513       MHD__asn1_set_value (node, value, strlen (value) + 1);
00514       break;
00515     case TYPE_TIME:
00516       if (node->type & CONST_UTC)
00517         {
00518           if (strlen (value) < 11)
00519             return ASN1_VALUE_NOT_VALID;
00520           for (k = 0; k < 10; k++)
00521             if (!isdigit (value[k]))
00522               return ASN1_VALUE_NOT_VALID;
00523           switch (strlen (value))
00524             {
00525             case 11:
00526               if (value[10] != 'Z')
00527                 return ASN1_VALUE_NOT_VALID;
00528               break;
00529             case 13:
00530               if ((!isdigit (value[10])) || (!isdigit (value[11])) ||
00531                   (value[12] != 'Z'))
00532                 return ASN1_VALUE_NOT_VALID;
00533               break;
00534             case 15:
00535               if ((value[10] != '+') && (value[10] != '-'))
00536                 return ASN1_VALUE_NOT_VALID;
00537               for (k = 11; k < 15; k++)
00538                 if (!isdigit (value[k]))
00539                   return ASN1_VALUE_NOT_VALID;
00540               break;
00541             case 17:
00542               if ((!isdigit (value[10])) || (!isdigit (value[11])))
00543                 return ASN1_VALUE_NOT_VALID;
00544               if ((value[12] != '+') && (value[12] != '-'))
00545                 return ASN1_VALUE_NOT_VALID;
00546               for (k = 13; k < 17; k++)
00547                 if (!isdigit (value[k]))
00548                   return ASN1_VALUE_NOT_VALID;
00549               break;
00550             default:
00551               return ASN1_VALUE_NOT_FOUND;
00552             }
00553           MHD__asn1_set_value (node, value, strlen (value) + 1);
00554         }
00555       else
00556         {                       /* GENERALIZED TIME */
00557           if (value)
00558             MHD__asn1_set_value (node, value, strlen (value) + 1);
00559         }
00560       break;
00561     case TYPE_OCTET_STRING:
00562       if (len == 0)
00563         len = strlen (value);
00564       MHD__asn1_length_der (len, NULL, &len2);
00565       temp = (unsigned char *) MHD__asn1_alloca (len + len2);
00566       if (temp == NULL)
00567         return ASN1_MEM_ALLOC_ERROR;
00568 
00569       MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2);
00570       MHD__asn1_set_value (node, temp, len2);
00571       MHD__asn1_afree (temp);
00572       break;
00573     case TYPE_GENERALSTRING:
00574       if (len == 0)
00575         len = strlen (value);
00576       MHD__asn1_length_der (len, NULL, &len2);
00577       temp = (unsigned char *) MHD__asn1_alloca (len + len2);
00578       if (temp == NULL)
00579         return ASN1_MEM_ALLOC_ERROR;
00580 
00581       MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2);
00582       MHD__asn1_set_value (node, temp, len2);
00583       MHD__asn1_afree (temp);
00584       break;
00585     case TYPE_BIT_STRING:
00586       if (len == 0)
00587         len = strlen (value);
00588       MHD__asn1_length_der ((len >> 3) + 2, NULL, &len2);
00589       temp = (unsigned char *) MHD__asn1_alloca ((len >> 3) + 2 + len2);
00590       if (temp == NULL)
00591         return ASN1_MEM_ALLOC_ERROR;
00592 
00593       MHD__asn1_bit_der ((const unsigned char *) value, len, temp, &len2);
00594       MHD__asn1_set_value (node, temp, len2);
00595       MHD__asn1_afree (temp);
00596       break;
00597     case TYPE_CHOICE:
00598       p = node->down;
00599       while (p)
00600         {
00601           if (!strcmp (p->name, value))
00602             {
00603               p2 = node->down;
00604               while (p2)
00605                 {
00606                   if (p2 != p)
00607                     {
00608                       MHD__asn1_delete_structure (&p2);
00609                       p2 = node->down;
00610                     }
00611                   else
00612                     p2 = p2->right;
00613                 }
00614               break;
00615             }
00616           p = p->right;
00617         }
00618       if (!p)
00619         return ASN1_ELEMENT_NOT_FOUND;
00620       break;
00621     case TYPE_ANY:
00622       MHD__asn1_length_der (len, NULL, &len2);
00623       temp = (unsigned char *) MHD__asn1_alloca (len + len2);
00624       if (temp == NULL)
00625         return ASN1_MEM_ALLOC_ERROR;
00626 
00627       MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2);
00628       MHD__asn1_set_value (node, temp, len2);
00629       MHD__asn1_afree (temp);
00630       break;
00631     case TYPE_SEQUENCE_OF:
00632     case TYPE_SET_OF:
00633       if (strcmp (value, "NEW"))
00634         return ASN1_VALUE_NOT_VALID;
00635       MHD__asn1_append_sequence_set (node);
00636       break;
00637     default:
00638       return ASN1_ELEMENT_NOT_FOUND;
00639       break;
00640     }
00641 
00642   return ASN1_SUCCESS;
00643 }
00644 
00645 
00646 #define PUT_VALUE( ptr, ptr_size, data, data_size) \
00647         *len = data_size; \
00648         if (ptr_size < data_size) { \
00649                 return ASN1_MEM_ERROR; \
00650         } else { \
00651                 memcpy( ptr, data, data_size); \
00652         }
00653 
00654 #define PUT_STR_VALUE( ptr, ptr_size, data) \
00655         *len = strlen(data) + 1; \
00656         if (ptr_size < *len) { \
00657                 return ASN1_MEM_ERROR; \
00658         } else { \
00659                 /* this strcpy is checked */ \
00660                 strcpy(ptr, data); \
00661         }
00662 
00663 #define ADD_STR_VALUE( ptr, ptr_size, data) \
00664         *len = strlen(data) + 1; \
00665         if (ptr_size < strlen(ptr)+(*len)) { \
00666                 return ASN1_MEM_ERROR; \
00667         } else { \
00668                 /* this strcat is checked */ \
00669                 strcat(ptr, data); \
00670         }
00671 
00738 MHD__asn1_retCode
00739 MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue,
00740                       int *len)
00741 {
00742   node_asn *node, *p, *p2;
00743   int len2, len3;
00744   int value_size = *len;
00745   char *value = ivalue;
00746 
00747   node = MHD__asn1_find_node (root, name);
00748   if (node == NULL)
00749     return ASN1_ELEMENT_NOT_FOUND;
00750 
00751   if ((type_field (node->type) != TYPE_NULL) &&
00752       (type_field (node->type) != TYPE_CHOICE) &&
00753       !(node->type & CONST_DEFAULT) && !(node->type & CONST_ASSIGN) &&
00754       (node->value == NULL))
00755     return ASN1_VALUE_NOT_FOUND;
00756 
00757   switch (type_field (node->type))
00758     {
00759     case TYPE_NULL:
00760       PUT_STR_VALUE (value, value_size, "NULL");
00761       break;
00762     case TYPE_BOOLEAN:
00763       if ((node->type & CONST_DEFAULT) && (node->value == NULL))
00764         {
00765           p = node->down;
00766           while (type_field (p->type) != TYPE_DEFAULT)
00767             p = p->right;
00768           if (p->type & CONST_TRUE)
00769             {
00770               PUT_STR_VALUE (value, value_size, "TRUE");
00771             }
00772           else
00773             {
00774               PUT_STR_VALUE (value, value_size, "FALSE");
00775             }
00776         }
00777       else if (node->value[0] == 'T')
00778         {
00779           PUT_STR_VALUE (value, value_size, "TRUE");
00780         }
00781       else
00782         {
00783           PUT_STR_VALUE (value, value_size, "FALSE");
00784         }
00785       break;
00786     case TYPE_INTEGER:
00787     case TYPE_ENUMERATED:
00788       if ((node->type & CONST_DEFAULT) && (node->value == NULL))
00789         {
00790           p = node->down;
00791           while (type_field (p->type) != TYPE_DEFAULT)
00792             p = p->right;
00793           if ((isdigit (p->value[0])) || (p->value[0] == '-')
00794               || (p->value[0] == '+'))
00795             {
00796               if (MHD__asn1_convert_integer
00797                   ((const char *) p->value, (unsigned char *) value,
00798                    value_size, len) != ASN1_SUCCESS)
00799                 return ASN1_MEM_ERROR;
00800             }
00801           else
00802             {                   /* is an identifier like v1 */
00803               p2 = node->down;
00804               while (p2)
00805                 {
00806                   if (type_field (p2->type) == TYPE_CONSTANT)
00807                     {
00808                       if ((p2->name)
00809                           && (!strcmp (p2->name, (const char *) p->value)))
00810                         {
00811                           if (MHD__asn1_convert_integer
00812                               ((const char *) p2->value,
00813                                (unsigned char *) value, value_size,
00814                                len) != ASN1_SUCCESS)
00815                             return ASN1_MEM_ERROR;
00816                           break;
00817                         }
00818                     }
00819                   p2 = p2->right;
00820                 }
00821             }
00822         }
00823       else
00824         {
00825           len2 = -1;
00826           if (MHD__asn1_get_octet_der
00827               (node->value, node->value_len, &len2, (unsigned char *) value,
00828                value_size, len) != ASN1_SUCCESS)
00829             return ASN1_MEM_ERROR;
00830         }
00831       break;
00832     case TYPE_OBJECT_ID:
00833       if (node->type & CONST_ASSIGN)
00834         {
00835           value[0] = 0;
00836           p = node->down;
00837           while (p)
00838             {
00839               if (type_field (p->type) == TYPE_CONSTANT)
00840                 {
00841                   ADD_STR_VALUE (value, value_size, (const char *) p->value);
00842                   if (p->right)
00843                     {
00844                       ADD_STR_VALUE (value, value_size, ".");
00845                     }
00846                 }
00847               p = p->right;
00848             }
00849           *len = strlen (value) + 1;
00850         }
00851       else if ((node->type & CONST_DEFAULT) && (node->value == NULL))
00852         {
00853           p = node->down;
00854           while (type_field (p->type) != TYPE_DEFAULT)
00855             p = p->right;
00856           PUT_STR_VALUE (value, value_size, (const char *) p->value);
00857         }
00858       else
00859         {
00860           PUT_STR_VALUE (value, value_size, (const char *) node->value);
00861         }
00862       break;
00863     case TYPE_TIME:
00864       PUT_STR_VALUE (value, value_size, (const char *) node->value);
00865       break;
00866     case TYPE_OCTET_STRING:
00867       len2 = -1;
00868       if (MHD__asn1_get_octet_der
00869           (node->value, node->value_len, &len2, (unsigned char *) value,
00870            value_size, len) != ASN1_SUCCESS)
00871         return ASN1_MEM_ERROR;
00872       break;
00873     case TYPE_GENERALSTRING:
00874       len2 = -1;
00875       if (MHD__asn1_get_octet_der
00876           (node->value, node->value_len, &len2, (unsigned char *) value,
00877            value_size, len) != ASN1_SUCCESS)
00878         return ASN1_MEM_ERROR;
00879       break;
00880     case TYPE_BIT_STRING:
00881       len2 = -1;
00882       if (MHD__asn1_get_bit_der
00883           (node->value, node->value_len, &len2, (unsigned char *) value,
00884            value_size, len) != ASN1_SUCCESS)
00885         return ASN1_MEM_ERROR;
00886       break;
00887     case TYPE_CHOICE:
00888       PUT_STR_VALUE (value, value_size, node->down->name);
00889       break;
00890     case TYPE_ANY:
00891       len3 = -1;
00892       len2 = MHD__asn1_get_length_der (node->value, node->value_len, &len3);
00893       if (len2 < 0)
00894         return ASN1_DER_ERROR;
00895       PUT_VALUE (value, value_size, node->value + len3, len2);
00896       break;
00897     default:
00898       return ASN1_ELEMENT_NOT_FOUND;
00899       break;
00900     }
00901   return ASN1_SUCCESS;
00902 }

Generated on Fri Feb 27 18:32:18 2009 for GNU libmicrohttpd by  doxygen 1.5.7.1