diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/https/minitasn1/coding.c | 115 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/decoding.c | 1203 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/element.c | 170 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/libtasn1.h | 21 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/parser_aux.c | 330 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/parser_aux.h | 13 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/structure.c | 456 | ||||
-rw-r--r-- | src/daemon/https/minitasn1/structure.h | 5 |
8 files changed, 99 insertions, 2214 deletions
diff --git a/src/daemon/https/minitasn1/coding.c b/src/daemon/https/minitasn1/coding.c index 6124c859..350828b3 100644 --- a/src/daemon/https/minitasn1/coding.c +++ b/src/daemon/https/minitasn1/coding.c | |||
@@ -45,7 +45,7 @@ | |||
45 | /* ErrorDescription: string returned. */ | 45 | /* ErrorDescription: string returned. */ |
46 | /* Return: */ | 46 | /* Return: */ |
47 | /******************************************************/ | 47 | /******************************************************/ |
48 | void | 48 | static void |
49 | MHD__asn1_error_description_value_not_found (node_asn * node, | 49 | MHD__asn1_error_description_value_not_found (node_asn * node, |
50 | char *ErrorDescription) | 50 | char *ErrorDescription) |
51 | { | 51 | { |
@@ -113,7 +113,7 @@ MHD__asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len) | |||
113 | /* (ans[0]..ans[ans_len-1]). */ | 113 | /* (ans[0]..ans[ans_len-1]). */ |
114 | /* Return: */ | 114 | /* Return: */ |
115 | /******************************************************/ | 115 | /******************************************************/ |
116 | void | 116 | static void |
117 | MHD__asn1_tag_der (unsigned char class, unsigned int tag_value, | 117 | MHD__asn1_tag_der (unsigned char class, unsigned int tag_value, |
118 | unsigned char *ans, int *ans_len) | 118 | unsigned char *ans, int *ans_len) |
119 | { | 119 | { |
@@ -179,7 +179,7 @@ MHD__asn1_octet_der (const unsigned char *str, int str_len, | |||
179 | /* ASN1_MEM_ERROR when DER isn't big enough */ | 179 | /* ASN1_MEM_ERROR when DER isn't big enough */ |
180 | /* ASN1_SUCCESS otherwise */ | 180 | /* ASN1_SUCCESS otherwise */ |
181 | /******************************************************/ | 181 | /******************************************************/ |
182 | MHD__asn1_retCode | 182 | static MHD__asn1_retCode |
183 | MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) | 183 | MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) |
184 | { | 184 | { |
185 | int len_len; | 185 | int len_len; |
@@ -187,11 +187,11 @@ MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) | |||
187 | 187 | ||
188 | max_len = *der_len; | 188 | max_len = *der_len; |
189 | 189 | ||
190 | MHD__asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len); | 190 | MHD__asn1_length_der (strlen ((const char*) str), (max_len > 0) ? der : NULL, &len_len); |
191 | 191 | ||
192 | if ((len_len + (int) strlen (str)) <= max_len) | 192 | if ((len_len + (int) strlen ((const char*) str)) <= max_len) |
193 | memcpy (der + len_len, str, strlen (str)); | 193 | memcpy (der + len_len, str, strlen ((const char*) str)); |
194 | *der_len = len_len + strlen (str); | 194 | *der_len = len_len + strlen ((const char*) str); |
195 | 195 | ||
196 | if ((*der_len) > max_len) | 196 | if ((*der_len) > max_len) |
197 | return ASN1_MEM_ERROR; | 197 | return ASN1_MEM_ERROR; |
@@ -199,43 +199,6 @@ MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) | |||
199 | return ASN1_SUCCESS; | 199 | return ASN1_SUCCESS; |
200 | } | 200 | } |
201 | 201 | ||
202 | |||
203 | /* | ||
204 | void | ||
205 | MHD__asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str) | ||
206 | { | ||
207 | int len_len,str_len; | ||
208 | char temp[20]; | ||
209 | |||
210 | if(str==NULL) return; | ||
211 | str_len=MHD__asn1_get_length_der(der,*der_len,&len_len); | ||
212 | if (str_len<0) return; | ||
213 | memcpy(temp,der+len_len,str_len); | ||
214 | *der_len=str_len+len_len; | ||
215 | switch(str_len){ | ||
216 | case 11: | ||
217 | temp[10]=0; | ||
218 | strcat(temp,"00+0000"); | ||
219 | break; | ||
220 | case 13: | ||
221 | temp[12]=0; | ||
222 | strcat(temp,"+0000"); | ||
223 | break; | ||
224 | case 15: | ||
225 | temp[15]=0; | ||
226 | memmove(temp+12,temp+10,6); | ||
227 | temp[10]=temp[11]='0'; | ||
228 | break; | ||
229 | case 17: | ||
230 | temp[17]=0; | ||
231 | break; | ||
232 | default: | ||
233 | return; | ||
234 | } | ||
235 | strcpy(str,temp); | ||
236 | } | ||
237 | */ | ||
238 | |||
239 | /******************************************************/ | 202 | /******************************************************/ |
240 | /* Function : MHD__asn1_objectid_der */ | 203 | /* Function : MHD__asn1_objectid_der */ |
241 | /* Description: creates the DER coding for an */ | 204 | /* Description: creates the DER coding for an */ |
@@ -250,7 +213,7 @@ MHD__asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str) | |||
250 | /* ASN1_MEM_ERROR when DER isn't big enough */ | 213 | /* ASN1_MEM_ERROR when DER isn't big enough */ |
251 | /* ASN1_SUCCESS otherwise */ | 214 | /* ASN1_SUCCESS otherwise */ |
252 | /******************************************************/ | 215 | /******************************************************/ |
253 | MHD__asn1_retCode | 216 | static MHD__asn1_retCode |
254 | MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) | 217 | MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) |
255 | { | 218 | { |
256 | int len_len, counter, k, first, max_len; | 219 | int len_len, counter, k, first, max_len; |
@@ -260,11 +223,11 @@ MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) | |||
260 | 223 | ||
261 | max_len = *der_len; | 224 | max_len = *der_len; |
262 | 225 | ||
263 | temp = (char *) MHD__asn1_alloca (strlen (str) + 2); | 226 | temp = (char *) MHD__asn1_alloca (strlen ((const char*)str) + 2); |
264 | if (temp == NULL) | 227 | if (temp == NULL) |
265 | return ASN1_MEM_ALLOC_ERROR; | 228 | return ASN1_MEM_ALLOC_ERROR; |
266 | 229 | ||
267 | strcpy (temp, str); | 230 | strcpy (temp, (const char*) str); |
268 | strcat (temp, "."); | 231 | strcat (temp, "."); |
269 | 232 | ||
270 | counter = 0; | 233 | counter = 0; |
@@ -370,7 +333,7 @@ MHD__asn1_bit_der (const unsigned char *str, int bit_len, | |||
370 | /* ASN1_MEM_ERROR if der vector isn't big enough, */ | 333 | /* ASN1_MEM_ERROR if der vector isn't big enough, */ |
371 | /* otherwise ASN1_SUCCESS. */ | 334 | /* otherwise ASN1_SUCCESS. */ |
372 | /******************************************************/ | 335 | /******************************************************/ |
373 | MHD__asn1_retCode | 336 | static MHD__asn1_retCode |
374 | MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der, | 337 | MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der, |
375 | int *counter, int *max_len) | 338 | int *counter, int *max_len) |
376 | { | 339 | { |
@@ -443,7 +406,7 @@ MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der, | |||
443 | /* ASN1_MEM_ERROR if der vector isn't big enough, */ | 406 | /* ASN1_MEM_ERROR if der vector isn't big enough, */ |
444 | /* otherwise ASN1_SUCCESS. */ | 407 | /* otherwise ASN1_SUCCESS. */ |
445 | /******************************************************/ | 408 | /******************************************************/ |
446 | MHD__asn1_retCode | 409 | static MHD__asn1_retCode |
447 | MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, | 410 | MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, |
448 | int *max_len) | 411 | int *max_len) |
449 | { | 412 | { |
@@ -474,20 +437,22 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, | |||
474 | if (p->type & CONST_EXPLICIT) | 437 | if (p->type & CONST_EXPLICIT) |
475 | { | 438 | { |
476 | if (is_tag_implicit) | 439 | if (is_tag_implicit) |
477 | MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, | 440 | MHD__asn1_tag_der (class_implicit, tag_implicit, |
478 | &tag_len); | 441 | (unsigned char*) tag_der, |
442 | &tag_len); | ||
479 | else | 443 | else |
480 | MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED, | 444 | MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED, |
481 | strtoul (p->value, NULL, 10), tag_der, | 445 | strtoul ( (const char*) p->value, NULL, 10), |
482 | &tag_len); | 446 | (unsigned char*) tag_der, |
447 | &tag_len); | ||
483 | 448 | ||
484 | *max_len -= tag_len; | 449 | *max_len -= tag_len; |
485 | if (*max_len >= 0) | 450 | if (*max_len >= 0) |
486 | memcpy (der + *counter, tag_der, tag_len); | 451 | memcpy (der + *counter, tag_der, tag_len); |
487 | *counter += tag_len; | 452 | *counter += tag_len; |
488 | 453 | ||
489 | MHD__asn1_ltostr (*counter, temp); | 454 | MHD__asn1_ltostr (*counter, (char*) temp); |
490 | MHD__asn1_set_name (p, temp); | 455 | MHD__asn1_set_name (p, (const char*) temp); |
491 | 456 | ||
492 | is_tag_implicit = 0; | 457 | is_tag_implicit = 0; |
493 | } | 458 | } |
@@ -501,7 +466,7 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, | |||
501 | (type_field (node->type) == TYPE_SET_OF)) | 466 | (type_field (node->type) == TYPE_SET_OF)) |
502 | class |= ASN1_CLASS_STRUCTURED; | 467 | class |= ASN1_CLASS_STRUCTURED; |
503 | class_implicit = class; | 468 | class_implicit = class; |
504 | tag_implicit = strtoul (p->value, NULL, 10); | 469 | tag_implicit = strtoul ( (const char*) p->value, NULL, 10); |
505 | is_tag_implicit = 1; | 470 | is_tag_implicit = 1; |
506 | } | 471 | } |
507 | } | 472 | } |
@@ -512,63 +477,63 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, | |||
512 | 477 | ||
513 | if (is_tag_implicit) | 478 | if (is_tag_implicit) |
514 | { | 479 | { |
515 | MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len); | 480 | MHD__asn1_tag_der (class_implicit, tag_implicit, (unsigned char*) tag_der, &tag_len); |
516 | } | 481 | } |
517 | else | 482 | else |
518 | { | 483 | { |
519 | switch (type_field (node->type)) | 484 | switch (type_field (node->type)) |
520 | { | 485 | { |
521 | case TYPE_NULL: | 486 | case TYPE_NULL: |
522 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der, | 487 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, (unsigned char*) tag_der, |
523 | &tag_len); | 488 | &tag_len); |
524 | break; | 489 | break; |
525 | case TYPE_BOOLEAN: | 490 | case TYPE_BOOLEAN: |
526 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der, | 491 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, (unsigned char*) tag_der, |
527 | &tag_len); | 492 | &tag_len); |
528 | break; | 493 | break; |
529 | case TYPE_INTEGER: | 494 | case TYPE_INTEGER: |
530 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der, | 495 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, (unsigned char*) tag_der, |
531 | &tag_len); | 496 | &tag_len); |
532 | break; | 497 | break; |
533 | case TYPE_ENUMERATED: | 498 | case TYPE_ENUMERATED: |
534 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der, | 499 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, (unsigned char*) tag_der, |
535 | &tag_len); | 500 | &tag_len); |
536 | break; | 501 | break; |
537 | case TYPE_OBJECT_ID: | 502 | case TYPE_OBJECT_ID: |
538 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der, | 503 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, (unsigned char*) tag_der, |
539 | &tag_len); | 504 | &tag_len); |
540 | break; | 505 | break; |
541 | case TYPE_TIME: | 506 | case TYPE_TIME: |
542 | if (node->type & CONST_UTC) | 507 | if (node->type & CONST_UTC) |
543 | { | 508 | { |
544 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der, | 509 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, (unsigned char*) tag_der, |
545 | &tag_len); | 510 | &tag_len); |
546 | } | 511 | } |
547 | else | 512 | else |
548 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime, | 513 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime, |
549 | tag_der, &tag_len); | 514 | (unsigned char*) tag_der, &tag_len); |
550 | break; | 515 | break; |
551 | case TYPE_OCTET_STRING: | 516 | case TYPE_OCTET_STRING: |
552 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der, | 517 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, (unsigned char*) tag_der, |
553 | &tag_len); | 518 | &tag_len); |
554 | break; | 519 | break; |
555 | case TYPE_GENERALSTRING: | 520 | case TYPE_GENERALSTRING: |
556 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING, | 521 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING, |
557 | tag_der, &tag_len); | 522 | (unsigned char*) tag_der, &tag_len); |
558 | break; | 523 | break; |
559 | case TYPE_BIT_STRING: | 524 | case TYPE_BIT_STRING: |
560 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der, | 525 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, (unsigned char*) tag_der, |
561 | &tag_len); | 526 | &tag_len); |
562 | break; | 527 | break; |
563 | case TYPE_SEQUENCE: | 528 | case TYPE_SEQUENCE: |
564 | case TYPE_SEQUENCE_OF: | 529 | case TYPE_SEQUENCE_OF: |
565 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, | 530 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, |
566 | ASN1_TAG_SEQUENCE, tag_der, &tag_len); | 531 | ASN1_TAG_SEQUENCE, (unsigned char*) tag_der, &tag_len); |
567 | break; | 532 | break; |
568 | case TYPE_SET: | 533 | case TYPE_SET: |
569 | case TYPE_SET_OF: | 534 | case TYPE_SET_OF: |
570 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, | 535 | MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, |
571 | ASN1_TAG_SET, tag_der, &tag_len); | 536 | ASN1_TAG_SET, (unsigned char*) tag_der, &tag_len); |
572 | break; | 537 | break; |
573 | case TYPE_TAG: | 538 | case TYPE_TAG: |
574 | tag_len = 0; | 539 | tag_len = 0; |
@@ -604,7 +569,7 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, | |||
604 | /* node: pointer to the SET element. */ | 569 | /* node: pointer to the SET element. */ |
605 | /* Return: */ | 570 | /* Return: */ |
606 | /******************************************************/ | 571 | /******************************************************/ |
607 | void | 572 | static void |
608 | MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) | 573 | MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) |
609 | { | 574 | { |
610 | struct vet | 575 | struct vet |
@@ -719,7 +684,7 @@ MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) | |||
719 | /* node: pointer to the SET OF element. */ | 684 | /* node: pointer to the SET OF element. */ |
720 | /* Return: */ | 685 | /* Return: */ |
721 | /******************************************************/ | 686 | /******************************************************/ |
722 | void | 687 | static void |
723 | MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) | 688 | MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) |
724 | { | 689 | { |
725 | struct vet | 690 | struct vet |
@@ -1104,11 +1069,11 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, | |||
1104 | } | 1069 | } |
1105 | else | 1070 | else |
1106 | { /* move==UP */ | 1071 | { /* move==UP */ |
1107 | len2 = strtol (p->value, NULL, 10); | 1072 | len2 = strtol ( (const char*) p->value, NULL, 10); |
1108 | MHD__asn1_set_value (p, NULL, 0); | 1073 | MHD__asn1_set_value (p, NULL, 0); |
1109 | if ((type_field (p->type) == TYPE_SET) && (max_len >= 0)) | 1074 | if ((type_field (p->type) == TYPE_SET) && (max_len >= 0)) |
1110 | MHD__asn1_ordering_set (der + len2, max_len - len2, p); | 1075 | MHD__asn1_ordering_set (der + len2, max_len - len2, p); |
1111 | MHD__asn1_length_der (counter - len2, temp, &len3); | 1076 | MHD__asn1_length_der (counter - len2, (unsigned char*) temp, &len3); |
1112 | max_len -= len3; | 1077 | max_len -= len3; |
1113 | if (max_len >= 0) | 1078 | if (max_len >= 0) |
1114 | { | 1079 | { |
@@ -1144,14 +1109,14 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, | |||
1144 | } | 1109 | } |
1145 | if (move == UP) | 1110 | if (move == UP) |
1146 | { | 1111 | { |
1147 | len2 = strtol (p->value, NULL, 10); | 1112 | len2 = strtol ( (const char*) p->value, NULL, 10); |
1148 | MHD__asn1_set_value (p, NULL, 0); | 1113 | MHD__asn1_set_value (p, NULL, 0); |
1149 | if ((type_field (p->type) == TYPE_SET_OF) | 1114 | if ((type_field (p->type) == TYPE_SET_OF) |
1150 | && (max_len - len2 > 0)) | 1115 | && (max_len - len2 > 0)) |
1151 | { | 1116 | { |
1152 | MHD__asn1_ordering_set_of (der + len2, max_len - len2, p); | 1117 | MHD__asn1_ordering_set_of (der + len2, max_len - len2, p); |
1153 | } | 1118 | } |
1154 | MHD__asn1_length_der (counter - len2, temp, &len3); | 1119 | MHD__asn1_length_der (counter - len2, (unsigned char*) temp, &len3); |
1155 | max_len -= len3; | 1120 | max_len -= len3; |
1156 | if (max_len >= 0) | 1121 | if (max_len >= 0) |
1157 | { | 1122 | { |
diff --git a/src/daemon/https/minitasn1/decoding.c b/src/daemon/https/minitasn1/decoding.c index 27586b5e..fcee0797 100644 --- a/src/daemon/https/minitasn1/decoding.c +++ b/src/daemon/https/minitasn1/decoding.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "element.h" | 34 | #include "element.h" |
35 | 35 | ||
36 | 36 | ||
37 | void | 37 | static void |
38 | MHD__asn1_error_description_tag_error (node_asn * node, char *ErrorDescription) | 38 | MHD__asn1_error_description_tag_error (node_asn * node, char *ErrorDescription) |
39 | { | 39 | { |
40 | 40 | ||
@@ -207,7 +207,7 @@ MHD__asn1_get_octet_der (const unsigned char *der, int der_len, | |||
207 | 207 | ||
208 | /* Returns ASN1_SUCCESS on success or an error code on error. | 208 | /* Returns ASN1_SUCCESS on success or an error code on error. |
209 | */ | 209 | */ |
210 | int | 210 | static int |
211 | MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, | 211 | MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, |
212 | char *str, int str_size) | 212 | char *str, int str_size) |
213 | { | 213 | { |
@@ -227,7 +227,7 @@ MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, | |||
227 | 227 | ||
228 | 228 | ||
229 | 229 | ||
230 | void | 230 | static void |
231 | MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, | 231 | MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, |
232 | char *str, int str_size) | 232 | char *str, int str_size) |
233 | { | 233 | { |
@@ -313,7 +313,7 @@ MHD__asn1_get_bit_der (const unsigned char *der, int der_len, | |||
313 | 313 | ||
314 | 314 | ||
315 | 315 | ||
316 | int | 316 | static int |
317 | MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len, | 317 | MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len, |
318 | int *ret_len) | 318 | int *ret_len) |
319 | { | 319 | { |
@@ -506,7 +506,7 @@ MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_le | |||
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | int | 509 | static int |
510 | MHD__asn1_delete_not_used (node_asn * node) | 510 | MHD__asn1_delete_not_used (node_asn * node) |
511 | { | 511 | { |
512 | node_asn *p, *p2; | 512 | node_asn *p, *p2; |
@@ -566,7 +566,7 @@ MHD__asn1_delete_not_used (node_asn * node) | |||
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | MHD__asn1_retCode | 569 | static MHD__asn1_retCode |
570 | MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) | 570 | MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) |
571 | { | 571 | { |
572 | int len2, len3, counter, counter2, counter_end, tot_len, indefinite; | 572 | int len2, len3, counter, counter2, counter_end, tot_len, indefinite; |
@@ -680,7 +680,7 @@ MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) | |||
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
683 | MHD__asn1_retCode | 683 | static MHD__asn1_retCode |
684 | MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len) | 684 | MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len) |
685 | { | 685 | { |
686 | int len2, len3, counter, indefinite; | 686 | int len2, len3, counter, indefinite; |
@@ -789,7 +789,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
789 | if (p->type & CONST_SET) | 789 | if (p->type & CONST_SET) |
790 | { | 790 | { |
791 | p2 = MHD__asn1_find_up (p); | 791 | p2 = MHD__asn1_find_up (p); |
792 | len2 = strtol (p2->value, NULL, 10); | 792 | len2 = strtol ((const char*) p2->value, NULL, 10); |
793 | if (len2 == -1) | 793 | if (len2 == -1) |
794 | { | 794 | { |
795 | if (!der[counter] && !der[counter + 1]) | 795 | if (!der[counter] && !der[counter + 1]) |
@@ -852,7 +852,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
852 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) | 852 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) |
853 | { | 853 | { |
854 | p2 = MHD__asn1_find_up (p); | 854 | p2 = MHD__asn1_find_up (p); |
855 | len2 = strtol (p2->value, NULL, 10); | 855 | len2 = strtol ((const char*) p2->value, NULL, 10); |
856 | if (counter == len2) | 856 | if (counter == len2) |
857 | { | 857 | { |
858 | if (p->right) | 858 | if (p->right) |
@@ -917,7 +917,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
917 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) | 917 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) |
918 | { | 918 | { |
919 | p2 = MHD__asn1_find_up (p); | 919 | p2 = MHD__asn1_find_up (p); |
920 | len2 = strtol (p2->value, NULL, 10); | 920 | len2 = strtol ((const char*) p2->value, NULL, 10); |
921 | if ((len2 != -1) && (counter > len2)) | 921 | if ((len2 != -1) && (counter > len2)) |
922 | ris = ASN1_TAG_ERROR; | 922 | ris = ASN1_TAG_ERROR; |
923 | } | 923 | } |
@@ -1045,7 +1045,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
1045 | case TYPE_SET: | 1045 | case TYPE_SET: |
1046 | if (move == UP) | 1046 | if (move == UP) |
1047 | { | 1047 | { |
1048 | len2 = strtol (p->value, NULL, 10); | 1048 | len2 = strtol ( (const char*) p->value, NULL, 10); |
1049 | MHD__asn1_set_value (p, NULL, 0); | 1049 | MHD__asn1_set_value (p, NULL, 0); |
1050 | if (len2 == -1) | 1050 | if (len2 == -1) |
1051 | { /* indefinite length method */ | 1051 | { /* indefinite length method */ |
@@ -1113,7 +1113,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
1113 | case TYPE_SET_OF: | 1113 | case TYPE_SET_OF: |
1114 | if (move == UP) | 1114 | if (move == UP) |
1115 | { | 1115 | { |
1116 | len2 = strtol (p->value, NULL, 10); | 1116 | len2 = strtol ( (const char*) p->value, NULL, 10); |
1117 | if (len2 == -1) | 1117 | if (len2 == -1) |
1118 | { /* indefinite length method */ | 1118 | { /* indefinite length method */ |
1119 | if ((counter + 2) > len) | 1119 | if ((counter + 2) > len) |
@@ -1296,800 +1296,6 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, | |||
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | 1298 | ||
1299 | #define FOUND 1 | ||
1300 | #define SAME_BRANCH 2 | ||
1301 | #define OTHER_BRANCH 3 | ||
1302 | #define EXIT 4 | ||
1303 | |||
1304 | /** | ||
1305 | * MHD__asn1_der_decoding_element - Fill the element named ELEMENTNAME of the structure STRUCTURE with values of a DER encoding string. | ||
1306 | * @structure: pointer to an ASN1 structure | ||
1307 | * @elementName: name of the element to fill | ||
1308 | * @ider: vector that contains the DER encoding of the whole structure. | ||
1309 | * @len: number of bytes of *der: der[0]..der[len-1] | ||
1310 | * @errorDescription: null-terminated string contains details when an | ||
1311 | * error occurred. | ||
1312 | * | ||
1313 | * Fill the element named ELEMENTNAME with values of a DER encoding | ||
1314 | * string. The sructure must just be created with function | ||
1315 | * 'create_stucture'. The DER vector must contain the encoding | ||
1316 | * string of the whole STRUCTURE. If an error occurs during the | ||
1317 | * decoding procedure, the *STRUCTURE is deleted and set equal to | ||
1318 | * %ASN1_TYPE_EMPTY. | ||
1319 | * | ||
1320 | * Returns: | ||
1321 | * | ||
1322 | * ASN1_SUCCESS: DER encoding OK. | ||
1323 | * | ||
1324 | * ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY or | ||
1325 | * elementName == NULL. | ||
1326 | * | ||
1327 | * ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match | ||
1328 | * the structure STRUCTURE. *ELEMENT deleted. | ||
1329 | * | ||
1330 | **/ | ||
1331 | MHD__asn1_retCode | ||
1332 | MHD__asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, | ||
1333 | const void *ider, int len, char *errorDescription) | ||
1334 | { | ||
1335 | node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY; | ||
1336 | char temp[128], currentName[MAX_NAME_SIZE * 10], *dot_p, *char_p; | ||
1337 | int nameLen = MAX_NAME_SIZE * 10 - 1, state; | ||
1338 | int counter, len2, len3, len4, move, ris, tlen; | ||
1339 | unsigned char class, *temp2; | ||
1340 | unsigned long tag; | ||
1341 | int indefinite, result; | ||
1342 | const unsigned char *der = ider; | ||
1343 | |||
1344 | node = *structure; | ||
1345 | |||
1346 | if (node == ASN1_TYPE_EMPTY) | ||
1347 | return ASN1_ELEMENT_NOT_FOUND; | ||
1348 | |||
1349 | if (elementName == NULL) | ||
1350 | { | ||
1351 | MHD__asn1_delete_structure (structure); | ||
1352 | return ASN1_ELEMENT_NOT_FOUND; | ||
1353 | } | ||
1354 | |||
1355 | if (node->type & CONST_OPTION) | ||
1356 | { | ||
1357 | MHD__asn1_delete_structure (structure); | ||
1358 | return ASN1_GENERIC_ERROR; | ||
1359 | } | ||
1360 | |||
1361 | if ((*structure)->name) | ||
1362 | { /* Has *structure got a name? */ | ||
1363 | nameLen -= strlen ((*structure)->name); | ||
1364 | if (nameLen > 0) | ||
1365 | strcpy (currentName, (*structure)->name); | ||
1366 | else | ||
1367 | { | ||
1368 | MHD__asn1_delete_structure (structure); | ||
1369 | return ASN1_MEM_ERROR; | ||
1370 | } | ||
1371 | if (!(strcmp (currentName, elementName))) | ||
1372 | { | ||
1373 | state = FOUND; | ||
1374 | nodeFound = *structure; | ||
1375 | } | ||
1376 | else if (!memcmp (currentName, elementName, strlen (currentName))) | ||
1377 | state = SAME_BRANCH; | ||
1378 | else | ||
1379 | state = OTHER_BRANCH; | ||
1380 | } | ||
1381 | else | ||
1382 | { /* *structure doesn't have a name? */ | ||
1383 | currentName[0] = 0; | ||
1384 | if (elementName[0] == 0) | ||
1385 | { | ||
1386 | state = FOUND; | ||
1387 | nodeFound = *structure; | ||
1388 | } | ||
1389 | else | ||
1390 | { | ||
1391 | state = SAME_BRANCH; | ||
1392 | } | ||
1393 | } | ||
1394 | |||
1395 | counter = 0; | ||
1396 | move = DOWN; | ||
1397 | p = node; | ||
1398 | while (1) | ||
1399 | { | ||
1400 | |||
1401 | ris = ASN1_SUCCESS; | ||
1402 | |||
1403 | if (move != UP) | ||
1404 | { | ||
1405 | if (p->type & CONST_SET) | ||
1406 | { | ||
1407 | p2 = MHD__asn1_find_up (p); | ||
1408 | len2 = strtol (p2->value, NULL, 10); | ||
1409 | if (counter == len2) | ||
1410 | { | ||
1411 | p = p2; | ||
1412 | move = UP; | ||
1413 | continue; | ||
1414 | } | ||
1415 | else if (counter > len2) | ||
1416 | { | ||
1417 | MHD__asn1_delete_structure (structure); | ||
1418 | return ASN1_DER_ERROR; | ||
1419 | } | ||
1420 | p2 = p2->down; | ||
1421 | while (p2) | ||
1422 | { | ||
1423 | if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED)) | ||
1424 | { | ||
1425 | if (type_field (p2->type) != TYPE_CHOICE) | ||
1426 | ris = | ||
1427 | MHD__asn1_extract_tag_der (p2, der + counter, | ||
1428 | len - counter, &len2); | ||
1429 | else | ||
1430 | { | ||
1431 | p3 = p2->down; | ||
1432 | while (p3) | ||
1433 | { | ||
1434 | ris = | ||
1435 | MHD__asn1_extract_tag_der (p3, der + counter, | ||
1436 | len - counter, &len2); | ||
1437 | if (ris == ASN1_SUCCESS) | ||
1438 | break; | ||
1439 | p3 = p3->right; | ||
1440 | } | ||
1441 | } | ||
1442 | if (ris == ASN1_SUCCESS) | ||
1443 | { | ||
1444 | p2->type &= ~CONST_NOT_USED; | ||
1445 | p = p2; | ||
1446 | break; | ||
1447 | } | ||
1448 | } | ||
1449 | p2 = p2->right; | ||
1450 | } | ||
1451 | if (p2 == NULL) | ||
1452 | { | ||
1453 | MHD__asn1_delete_structure (structure); | ||
1454 | return ASN1_DER_ERROR; | ||
1455 | } | ||
1456 | } | ||
1457 | |||
1458 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) | ||
1459 | { | ||
1460 | p2 = MHD__asn1_find_up (p); | ||
1461 | len2 = strtol (p2->value, NULL, 10); | ||
1462 | if (counter == len2) | ||
1463 | { | ||
1464 | if (p->right) | ||
1465 | { | ||
1466 | p2 = p->right; | ||
1467 | move = RIGHT; | ||
1468 | } | ||
1469 | else | ||
1470 | move = UP; | ||
1471 | |||
1472 | if (p->type & CONST_OPTION) | ||
1473 | MHD__asn1_delete_structure (&p); | ||
1474 | |||
1475 | p = p2; | ||
1476 | continue; | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1480 | if (type_field (p->type) == TYPE_CHOICE) | ||
1481 | { | ||
1482 | while (p->down) | ||
1483 | { | ||
1484 | if (counter < len) | ||
1485 | ris = | ||
1486 | MHD__asn1_extract_tag_der (p->down, der + counter, | ||
1487 | len - counter, &len2); | ||
1488 | else | ||
1489 | ris = ASN1_DER_ERROR; | ||
1490 | if (ris == ASN1_SUCCESS) | ||
1491 | { | ||
1492 | while (p->down->right) | ||
1493 | { | ||
1494 | p2 = p->down->right; | ||
1495 | MHD__asn1_delete_structure (&p2); | ||
1496 | } | ||
1497 | break; | ||
1498 | } | ||
1499 | else if (ris == ASN1_ERROR_TYPE_ANY) | ||
1500 | { | ||
1501 | MHD__asn1_delete_structure (structure); | ||
1502 | return ASN1_ERROR_TYPE_ANY; | ||
1503 | } | ||
1504 | else | ||
1505 | { | ||
1506 | p2 = p->down; | ||
1507 | MHD__asn1_delete_structure (&p2); | ||
1508 | } | ||
1509 | } | ||
1510 | |||
1511 | if (p->down == NULL) | ||
1512 | { | ||
1513 | if (!(p->type & CONST_OPTION)) | ||
1514 | { | ||
1515 | MHD__asn1_delete_structure (structure); | ||
1516 | return ASN1_DER_ERROR; | ||
1517 | } | ||
1518 | } | ||
1519 | else | ||
1520 | p = p->down; | ||
1521 | } | ||
1522 | |||
1523 | if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) | ||
1524 | { | ||
1525 | p2 = MHD__asn1_find_up (p); | ||
1526 | len2 = strtol (p2->value, NULL, 10); | ||
1527 | if (counter > len2) | ||
1528 | ris = ASN1_TAG_ERROR; | ||
1529 | } | ||
1530 | |||
1531 | if (ris == ASN1_SUCCESS) | ||
1532 | ris = | ||
1533 | MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2); | ||
1534 | if (ris != ASN1_SUCCESS) | ||
1535 | { | ||
1536 | if (p->type & CONST_OPTION) | ||
1537 | { | ||
1538 | p->type |= CONST_NOT_USED; | ||
1539 | move = RIGHT; | ||
1540 | } | ||
1541 | else if (p->type & CONST_DEFAULT) | ||
1542 | { | ||
1543 | MHD__asn1_set_value (p, NULL, 0); | ||
1544 | move = RIGHT; | ||
1545 | } | ||
1546 | else | ||
1547 | { | ||
1548 | if (errorDescription != NULL) | ||
1549 | MHD__asn1_error_description_tag_error (p, errorDescription); | ||
1550 | |||
1551 | MHD__asn1_delete_structure (structure); | ||
1552 | return ASN1_TAG_ERROR; | ||
1553 | } | ||
1554 | } | ||
1555 | else | ||
1556 | counter += len2; | ||
1557 | } | ||
1558 | |||
1559 | if (ris == ASN1_SUCCESS) | ||
1560 | { | ||
1561 | switch (type_field (p->type)) | ||
1562 | { | ||
1563 | case TYPE_NULL: | ||
1564 | if (der[counter]) | ||
1565 | { | ||
1566 | MHD__asn1_delete_structure (structure); | ||
1567 | return ASN1_DER_ERROR; | ||
1568 | } | ||
1569 | |||
1570 | if (p == nodeFound) | ||
1571 | state = EXIT; | ||
1572 | |||
1573 | counter++; | ||
1574 | move = RIGHT; | ||
1575 | break; | ||
1576 | case TYPE_BOOLEAN: | ||
1577 | if (der[counter++] != 1) | ||
1578 | { | ||
1579 | MHD__asn1_delete_structure (structure); | ||
1580 | return ASN1_DER_ERROR; | ||
1581 | } | ||
1582 | |||
1583 | if (state == FOUND) | ||
1584 | { | ||
1585 | if (der[counter++] == 0) | ||
1586 | MHD__asn1_set_value (p, "F", 1); | ||
1587 | else | ||
1588 | MHD__asn1_set_value (p, "T", 1); | ||
1589 | |||
1590 | if (p == nodeFound) | ||
1591 | state = EXIT; | ||
1592 | |||
1593 | } | ||
1594 | else | ||
1595 | counter++; | ||
1596 | |||
1597 | move = RIGHT; | ||
1598 | break; | ||
1599 | case TYPE_INTEGER: | ||
1600 | case TYPE_ENUMERATED: | ||
1601 | len2 = | ||
1602 | MHD__asn1_get_length_der (der + counter, len - counter, &len3); | ||
1603 | if (len2 < 0) | ||
1604 | return ASN1_DER_ERROR; | ||
1605 | if (state == FOUND) | ||
1606 | { | ||
1607 | if (len3 + len2 > len - counter) | ||
1608 | return ASN1_DER_ERROR; | ||
1609 | MHD__asn1_set_value (p, der + counter, len3 + len2); | ||
1610 | |||
1611 | if (p == nodeFound) | ||
1612 | state = EXIT; | ||
1613 | } | ||
1614 | counter += len3 + len2; | ||
1615 | move = RIGHT; | ||
1616 | break; | ||
1617 | case TYPE_OBJECT_ID: | ||
1618 | if (state == FOUND) | ||
1619 | { | ||
1620 | MHD__asn1_get_objectid_der (der + counter, len - counter, &len2, | ||
1621 | temp, sizeof (temp)); | ||
1622 | tlen = strlen (temp); | ||
1623 | |||
1624 | if (tlen > 0) | ||
1625 | MHD__asn1_set_value (p, temp, tlen + 1); | ||
1626 | |||
1627 | if (p == nodeFound) | ||
1628 | state = EXIT; | ||
1629 | } | ||
1630 | else | ||
1631 | { | ||
1632 | len2 = | ||
1633 | MHD__asn1_get_length_der (der + counter, len - counter, &len3); | ||
1634 | if (len2 < 0) | ||
1635 | return ASN1_DER_ERROR; | ||
1636 | len2 += len3; | ||
1637 | } | ||
1638 | |||
1639 | counter += len2; | ||
1640 | move = RIGHT; | ||
1641 | break; | ||
1642 | case TYPE_TIME: | ||
1643 | if (state == FOUND) | ||
1644 | { | ||
1645 | result = | ||
1646 | MHD__asn1_get_time_der (der + counter, len - counter, &len2, | ||
1647 | temp, sizeof (temp) - 1); | ||
1648 | if (result != ASN1_SUCCESS) | ||
1649 | { | ||
1650 | MHD__asn1_delete_structure (structure); | ||
1651 | return result; | ||
1652 | } | ||
1653 | |||
1654 | tlen = strlen (temp); | ||
1655 | if (tlen > 0) | ||
1656 | MHD__asn1_set_value (p, temp, tlen + 1); | ||
1657 | |||
1658 | if (p == nodeFound) | ||
1659 | state = EXIT; | ||
1660 | } | ||
1661 | else | ||
1662 | { | ||
1663 | len2 = | ||
1664 | MHD__asn1_get_length_der (der + counter, len - counter, &len3); | ||
1665 | if (len2 < 0) | ||
1666 | return ASN1_DER_ERROR; | ||
1667 | len2 += len3; | ||
1668 | } | ||
1669 | |||
1670 | counter += len2; | ||
1671 | move = RIGHT; | ||
1672 | break; | ||
1673 | case TYPE_OCTET_STRING: | ||
1674 | len3 = len - counter; | ||
1675 | if (state == FOUND) | ||
1676 | { | ||
1677 | ris = MHD__asn1_get_octet_string (der + counter, p, &len3); | ||
1678 | if (p == nodeFound) | ||
1679 | state = EXIT; | ||
1680 | } | ||
1681 | else | ||
1682 | ris = MHD__asn1_get_octet_string (der + counter, NULL, &len3); | ||
1683 | |||
1684 | if (ris != ASN1_SUCCESS) | ||
1685 | return ris; | ||
1686 | counter += len3; | ||
1687 | move = RIGHT; | ||
1688 | break; | ||
1689 | case TYPE_GENERALSTRING: | ||
1690 | len2 = | ||
1691 | MHD__asn1_get_length_der (der + counter, len - counter, &len3); | ||
1692 | if (len2 < 0) | ||
1693 | return ASN1_DER_ERROR; | ||
1694 | if (state == FOUND) | ||
1695 | { | ||
1696 | if (len3 + len2 > len - counter) | ||
1697 | return ASN1_DER_ERROR; | ||
1698 | MHD__asn1_set_value (p, der + counter, len3 + len2); | ||
1699 | |||
1700 | if (p == nodeFound) | ||
1701 | state = EXIT; | ||
1702 | } | ||
1703 | counter += len3 + len2; | ||
1704 | move = RIGHT; | ||
1705 | break; | ||
1706 | case TYPE_BIT_STRING: | ||
1707 | len2 = | ||
1708 | MHD__asn1_get_length_der (der + counter, len - counter, &len3); | ||
1709 | if (len2 < 0) | ||
1710 | return ASN1_DER_ERROR; | ||
1711 | if (state == FOUND) | ||
1712 | { | ||
1713 | if (len3 + len2 > len - counter) | ||
1714 | return ASN1_DER_ERROR; | ||
1715 | MHD__asn1_set_value (p, der + counter, len3 + len2); | ||
1716 | |||
1717 | if (p == nodeFound) | ||
1718 | state = EXIT; | ||
1719 | } | ||
1720 | counter += len3 + len2; | ||
1721 | move = RIGHT; | ||
1722 | break; | ||
1723 | case TYPE_SEQUENCE: | ||
1724 | case TYPE_SET: | ||
1725 | if (move == UP) | ||
1726 | { | ||
1727 | len2 = strtol (p->value, NULL, 10); | ||
1728 | MHD__asn1_set_value (p, NULL, 0); | ||
1729 | if (len2 == -1) | ||
1730 | { /* indefinite length method */ | ||
1731 | if ((der[counter]) || der[counter + 1]) | ||
1732 | { | ||
1733 | MHD__asn1_delete_structure (structure); | ||
1734 | return ASN1_DER_ERROR; | ||
1735 | } | ||
1736 | counter += 2; | ||
1737 | } | ||
1738 | else | ||
1739 | { /* definite length method */ | ||
1740 | if (len2 != counter) | ||
1741 | { | ||
1742 | MHD__asn1_delete_structure (structure); | ||
1743 | return ASN1_DER_ERROR; | ||
1744 | } | ||
1745 | } | ||
1746 | if (p == nodeFound) | ||
1747 | state = EXIT; | ||
1748 | move = RIGHT; | ||
1749 | } | ||
1750 | else | ||
1751 | { /* move==DOWN || move==RIGHT */ | ||
1752 | if (state == OTHER_BRANCH) | ||
1753 | { | ||
1754 | len3 = | ||
1755 | MHD__asn1_get_length_der (der + counter, len - counter, | ||
1756 | &len2); | ||
1757 | if (len3 < 0) | ||
1758 | return ASN1_DER_ERROR; | ||
1759 | counter += len2 + len3; | ||
1760 | move = RIGHT; | ||
1761 | } | ||
1762 | else | ||
1763 | { /* state==SAME_BRANCH or state==FOUND */ | ||
1764 | len3 = | ||
1765 | MHD__asn1_get_length_der (der + counter, len - counter, | ||
1766 | &len2); | ||
1767 | if (len3 < 0) | ||
1768 | return ASN1_DER_ERROR; | ||
1769 | counter += len2; | ||
1770 | if (len3 > 0) | ||
1771 | { | ||
1772 | MHD__asn1_ltostr (counter + len3, temp); | ||
1773 | tlen = strlen (temp); | ||
1774 | |||
1775 | if (tlen > 0) | ||
1776 | MHD__asn1_set_value (p, temp, tlen + 1); | ||
1777 | move = DOWN; | ||
1778 | } | ||
1779 | else if (len3 == 0) | ||
1780 | { | ||
1781 | p2 = p->down; | ||
1782 | while (p2) | ||
1783 | { | ||
1784 | if (type_field (p2->type) != TYPE_TAG) | ||
1785 | { | ||
1786 | p3 = p2->right; | ||
1787 | MHD__asn1_delete_structure (&p2); | ||
1788 | p2 = p3; | ||
1789 | } | ||
1790 | else | ||
1791 | p2 = p2->right; | ||
1792 | } | ||
1793 | move = RIGHT; | ||
1794 | } | ||
1795 | else | ||
1796 | { /* indefinite length method */ | ||
1797 | MHD__asn1_set_value (p, "-1", 3); | ||
1798 | move = DOWN; | ||
1799 | } | ||
1800 | } | ||
1801 | } | ||
1802 | break; | ||
1803 | case TYPE_SEQUENCE_OF: | ||
1804 | case TYPE_SET_OF: | ||
1805 | if (move == UP) | ||
1806 | { | ||
1807 | len2 = strtol (p->value, NULL, 10); | ||
1808 | if (len2 > counter) | ||
1809 | { | ||
1810 | MHD__asn1_append_sequence_set (p); | ||
1811 | p = p->down; | ||
1812 | while (p->right) | ||
1813 | p = p->right; | ||
1814 | move = RIGHT; | ||
1815 | continue; | ||
1816 | } | ||
1817 | MHD__asn1_set_value (p, NULL, 0); | ||
1818 | if (len2 != counter) | ||
1819 | { | ||
1820 | MHD__asn1_delete_structure (structure); | ||
1821 | return ASN1_DER_ERROR; | ||
1822 | } | ||
1823 | |||
1824 | if (p == nodeFound) | ||
1825 | state = EXIT; | ||
1826 | } | ||
1827 | else | ||
1828 | { /* move==DOWN || move==RIGHT */ | ||
1829 | if (state == OTHER_BRANCH) | ||
1830 | { | ||
1831 | len3 = | ||
1832 | MHD__asn1_get_length_der (der + counter, len - counter, | ||
1833 | &len2); | ||
1834 | if (len3 < 0) | ||
1835 | return ASN1_DER_ERROR; | ||
1836 | counter += len2 + len3; | ||
1837 | move = RIGHT; | ||
1838 | } | ||
1839 | else | ||
1840 | { /* state==FOUND or state==SAME_BRANCH */ | ||
1841 | len3 = | ||
1842 | MHD__asn1_get_length_der (der + counter, len - counter, | ||
1843 | &len2); | ||
1844 | if (len3 < 0) | ||
1845 | return ASN1_DER_ERROR; | ||
1846 | counter += len2; | ||
1847 | if (len3) | ||
1848 | { | ||
1849 | MHD__asn1_ltostr (counter + len3, temp); | ||
1850 | tlen = strlen (temp); | ||
1851 | |||
1852 | if (tlen > 0) | ||
1853 | MHD__asn1_set_value (p, temp, tlen + 1); | ||
1854 | p2 = p->down; | ||
1855 | while ((type_field (p2->type) == TYPE_TAG) | ||
1856 | || (type_field (p2->type) == TYPE_SIZE)) | ||
1857 | p2 = p2->right; | ||
1858 | if (p2->right == NULL) | ||
1859 | MHD__asn1_append_sequence_set (p); | ||
1860 | p = p2; | ||
1861 | state = FOUND; | ||
1862 | } | ||
1863 | } | ||
1864 | } | ||
1865 | |||
1866 | break; | ||
1867 | case TYPE_ANY: | ||
1868 | if (MHD__asn1_get_tag_der | ||
1869 | (der + counter, len - counter, &class, &len2, | ||
1870 | &tag) != ASN1_SUCCESS) | ||
1871 | return ASN1_DER_ERROR; | ||
1872 | if (counter + len2 > len) | ||
1873 | return ASN1_DER_ERROR; | ||
1874 | |||
1875 | len4 = | ||
1876 | MHD__asn1_get_length_der (der + counter + len2, | ||
1877 | len - counter - len2, &len3); | ||
1878 | if (len4 < -1) | ||
1879 | return ASN1_DER_ERROR; | ||
1880 | |||
1881 | if (len4 != -1) | ||
1882 | { | ||
1883 | len2 += len4; | ||
1884 | if (state == FOUND) | ||
1885 | { | ||
1886 | MHD__asn1_length_der (len2 + len3, NULL, &len4); | ||
1887 | temp2 = | ||
1888 | (unsigned char *) MHD__asn1_alloca (len2 + len3 + len4); | ||
1889 | if (temp2 == NULL) | ||
1890 | { | ||
1891 | MHD__asn1_delete_structure (structure); | ||
1892 | return ASN1_MEM_ALLOC_ERROR; | ||
1893 | } | ||
1894 | |||
1895 | MHD__asn1_octet_der (der + counter, len2 + len3, temp2, | ||
1896 | &len4); | ||
1897 | MHD__asn1_set_value (p, temp2, len4); | ||
1898 | MHD__asn1_afree (temp2); | ||
1899 | |||
1900 | if (p == nodeFound) | ||
1901 | state = EXIT; | ||
1902 | } | ||
1903 | counter += len2 + len3; | ||
1904 | } | ||
1905 | else | ||
1906 | { /* indefinite length */ | ||
1907 | /* Check indefinite lenth method in an EXPLICIT TAG */ | ||
1908 | if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80)) | ||
1909 | indefinite = 1; | ||
1910 | else | ||
1911 | indefinite = 0; | ||
1912 | |||
1913 | len2 = len - counter; | ||
1914 | ris = | ||
1915 | MHD__asn1_get_indefinite_length_string (der + counter, &len2); | ||
1916 | if (ris != ASN1_SUCCESS) | ||
1917 | { | ||
1918 | MHD__asn1_delete_structure (structure); | ||
1919 | return ris; | ||
1920 | } | ||
1921 | |||
1922 | if (state == FOUND) | ||
1923 | { | ||
1924 | MHD__asn1_length_der (len2, NULL, &len4); | ||
1925 | temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len4); | ||
1926 | if (temp2 == NULL) | ||
1927 | { | ||
1928 | MHD__asn1_delete_structure (structure); | ||
1929 | return ASN1_MEM_ALLOC_ERROR; | ||
1930 | } | ||
1931 | |||
1932 | MHD__asn1_octet_der (der + counter, len2, temp2, &len4); | ||
1933 | MHD__asn1_set_value (p, temp2, len4); | ||
1934 | MHD__asn1_afree (temp2); | ||
1935 | |||
1936 | if (p == nodeFound) | ||
1937 | state = EXIT; | ||
1938 | } | ||
1939 | |||
1940 | counter += len2; | ||
1941 | |||
1942 | /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with | ||
1943 | an indefinite length method. */ | ||
1944 | if (indefinite) | ||
1945 | { | ||
1946 | if (!der[counter] && !der[counter + 1]) | ||
1947 | { | ||
1948 | counter += 2; | ||
1949 | } | ||
1950 | else | ||
1951 | { | ||
1952 | MHD__asn1_delete_structure (structure); | ||
1953 | return ASN1_DER_ERROR; | ||
1954 | } | ||
1955 | } | ||
1956 | } | ||
1957 | move = RIGHT; | ||
1958 | break; | ||
1959 | |||
1960 | default: | ||
1961 | move = (move == UP) ? RIGHT : DOWN; | ||
1962 | break; | ||
1963 | } | ||
1964 | } | ||
1965 | |||
1966 | if ((p == node && move != DOWN) || (state == EXIT)) | ||
1967 | break; | ||
1968 | |||
1969 | if (move == DOWN) | ||
1970 | { | ||
1971 | if (p->down) | ||
1972 | { | ||
1973 | p = p->down; | ||
1974 | |||
1975 | if (state != FOUND) | ||
1976 | { | ||
1977 | nameLen -= strlen (p->name) + 1; | ||
1978 | if (nameLen > 0) | ||
1979 | { | ||
1980 | if (currentName[0]) | ||
1981 | strcat (currentName, "."); | ||
1982 | strcat (currentName, p->name); | ||
1983 | } | ||
1984 | else | ||
1985 | { | ||
1986 | MHD__asn1_delete_structure (structure); | ||
1987 | return ASN1_MEM_ERROR; | ||
1988 | } | ||
1989 | if (!(strcmp (currentName, elementName))) | ||
1990 | { | ||
1991 | state = FOUND; | ||
1992 | nodeFound = p; | ||
1993 | } | ||
1994 | else | ||
1995 | if (!memcmp | ||
1996 | (currentName, elementName, strlen (currentName))) | ||
1997 | state = SAME_BRANCH; | ||
1998 | else | ||
1999 | state = OTHER_BRANCH; | ||
2000 | } | ||
2001 | } | ||
2002 | else | ||
2003 | move = RIGHT; | ||
2004 | } | ||
2005 | |||
2006 | if ((move == RIGHT) && !(p->type & CONST_SET)) | ||
2007 | { | ||
2008 | if (p->right) | ||
2009 | { | ||
2010 | p = p->right; | ||
2011 | |||
2012 | if (state != FOUND) | ||
2013 | { | ||
2014 | dot_p = char_p = currentName; | ||
2015 | while ((char_p = strchr (char_p, '.'))) | ||
2016 | { | ||
2017 | dot_p = char_p++; | ||
2018 | dot_p++; | ||
2019 | } | ||
2020 | |||
2021 | nameLen += strlen (currentName) - (dot_p - currentName); | ||
2022 | *dot_p = 0; | ||
2023 | |||
2024 | nameLen -= strlen (p->name); | ||
2025 | if (nameLen > 0) | ||
2026 | strcat (currentName, p->name); | ||
2027 | else | ||
2028 | { | ||
2029 | MHD__asn1_delete_structure (structure); | ||
2030 | return ASN1_MEM_ERROR; | ||
2031 | } | ||
2032 | |||
2033 | if (!(strcmp (currentName, elementName))) | ||
2034 | { | ||
2035 | state = FOUND; | ||
2036 | nodeFound = p; | ||
2037 | } | ||
2038 | else | ||
2039 | if (!memcmp | ||
2040 | (currentName, elementName, strlen (currentName))) | ||
2041 | state = SAME_BRANCH; | ||
2042 | else | ||
2043 | state = OTHER_BRANCH; | ||
2044 | } | ||
2045 | } | ||
2046 | else | ||
2047 | move = UP; | ||
2048 | } | ||
2049 | |||
2050 | if (move == UP) | ||
2051 | { | ||
2052 | p = MHD__asn1_find_up (p); | ||
2053 | |||
2054 | if (state != FOUND) | ||
2055 | { | ||
2056 | dot_p = char_p = currentName; | ||
2057 | while ((char_p = strchr (char_p, '.'))) | ||
2058 | { | ||
2059 | dot_p = char_p++; | ||
2060 | dot_p++; | ||
2061 | } | ||
2062 | |||
2063 | nameLen += strlen (currentName) - (dot_p - currentName); | ||
2064 | *dot_p = 0; | ||
2065 | |||
2066 | if (!(strcmp (currentName, elementName))) | ||
2067 | { | ||
2068 | state = FOUND; | ||
2069 | nodeFound = p; | ||
2070 | } | ||
2071 | else | ||
2072 | if (!memcmp (currentName, elementName, strlen (currentName))) | ||
2073 | state = SAME_BRANCH; | ||
2074 | else | ||
2075 | state = OTHER_BRANCH; | ||
2076 | } | ||
2077 | } | ||
2078 | } | ||
2079 | |||
2080 | MHD__asn1_delete_not_used (*structure); | ||
2081 | |||
2082 | if (counter > len) | ||
2083 | { | ||
2084 | MHD__asn1_delete_structure (structure); | ||
2085 | return ASN1_DER_ERROR; | ||
2086 | } | ||
2087 | |||
2088 | return ASN1_SUCCESS; | ||
2089 | } | ||
2090 | |||
2091 | |||
2092 | |||
2093 | /** | 1299 | /** |
2094 | * MHD__asn1_der_decoding_startEnd - Find the start and end point of an element in a DER encoding string. | 1300 | * MHD__asn1_der_decoding_startEnd - Find the start and end point of an element in a DER encoding string. |
2095 | * @element: pointer to an ASN1 element | 1301 | * @element: pointer to an ASN1 element |
@@ -2163,7 +1369,7 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, | |||
2163 | if (p->type & CONST_SET) | 1369 | if (p->type & CONST_SET) |
2164 | { | 1370 | { |
2165 | p2 = MHD__asn1_find_up (p); | 1371 | p2 = MHD__asn1_find_up (p); |
2166 | len2 = strtol (p2->value, NULL, 10); | 1372 | len2 = strtol ( (const char* ) p2->value, NULL, 10); |
2167 | if (len2 == -1) | 1373 | if (len2 == -1) |
2168 | { | 1374 | { |
2169 | if (!der[counter] && !der[counter + 1]) | 1375 | if (!der[counter] && !der[counter + 1]) |
@@ -2442,386 +1648,3 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, | |||
2442 | } | 1648 | } |
2443 | 1649 | ||
2444 | 1650 | ||
2445 | /** | ||
2446 | * MHD__asn1_expand_any_defined_by - Expand "ANY DEFINED BY" fields in structure. | ||
2447 | * @definitions: ASN1 definitions | ||
2448 | * @element: pointer to an ASN1 structure | ||
2449 | * | ||
2450 | * Expands every "ANY DEFINED BY" element of a structure created from | ||
2451 | * a DER decoding process (MHD__asn1_der_decoding function). The element ANY | ||
2452 | * must be defined by an OBJECT IDENTIFIER. The type used to expand | ||
2453 | * the element ANY is the first one following the definition of | ||
2454 | * the actual value of the OBJECT IDENTIFIER. | ||
2455 | * | ||
2456 | * | ||
2457 | * Returns: | ||
2458 | * | ||
2459 | * ASN1_SUCCESS: Substitution OK. | ||
2460 | * | ||
2461 | * ASN1_ERROR_TYPE_ANY: Some "ANY DEFINED BY" element couldn't be | ||
2462 | * expanded due to a problem in OBJECT_ID -> TYPE association. | ||
2463 | * | ||
2464 | * other errors: Result of der decoding process. | ||
2465 | **/ | ||
2466 | |||
2467 | MHD__asn1_retCode | ||
2468 | MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) | ||
2469 | { | ||
2470 | char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1], | ||
2471 | value[MAX_NAME_SIZE]; | ||
2472 | MHD__asn1_retCode retCode = ASN1_SUCCESS, result; | ||
2473 | int len, len2, len3; | ||
2474 | ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY; | ||
2475 | char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; | ||
2476 | |||
2477 | if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY)) | ||
2478 | return ASN1_ELEMENT_NOT_FOUND; | ||
2479 | |||
2480 | strcpy (definitionsName, definitions->name); | ||
2481 | strcat (definitionsName, "."); | ||
2482 | |||
2483 | p = *element; | ||
2484 | while (p) | ||
2485 | { | ||
2486 | |||
2487 | switch (type_field (p->type)) | ||
2488 | { | ||
2489 | case TYPE_ANY: | ||
2490 | if ((p->type & CONST_DEFINED_BY) && (p->value)) | ||
2491 | { | ||
2492 | /* search the "DEF_BY" element */ | ||
2493 | p2 = p->down; | ||
2494 | while ((p2) && (type_field (p2->type) != TYPE_CONSTANT)) | ||
2495 | p2 = p2->right; | ||
2496 | |||
2497 | if (!p2) | ||
2498 | { | ||
2499 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2500 | break; | ||
2501 | } | ||
2502 | |||
2503 | p3 = MHD__asn1_find_up (p); | ||
2504 | |||
2505 | if (!p3) | ||
2506 | { | ||
2507 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2508 | break; | ||
2509 | } | ||
2510 | |||
2511 | p3 = p3->down; | ||
2512 | while (p3) | ||
2513 | { | ||
2514 | if ((p3->name) && !(strcmp (p3->name, p2->name))) | ||
2515 | break; | ||
2516 | p3 = p3->right; | ||
2517 | } | ||
2518 | |||
2519 | if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) || | ||
2520 | (p3->value == NULL)) | ||
2521 | { | ||
2522 | |||
2523 | p3 = MHD__asn1_find_up (p); | ||
2524 | p3 = MHD__asn1_find_up (p3); | ||
2525 | |||
2526 | if (!p3) | ||
2527 | { | ||
2528 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2529 | break; | ||
2530 | } | ||
2531 | |||
2532 | p3 = p3->down; | ||
2533 | |||
2534 | while (p3) | ||
2535 | { | ||
2536 | if ((p3->name) && !(strcmp (p3->name, p2->name))) | ||
2537 | break; | ||
2538 | p3 = p3->right; | ||
2539 | } | ||
2540 | |||
2541 | if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) || | ||
2542 | (p3->value == NULL)) | ||
2543 | { | ||
2544 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2545 | break; | ||
2546 | } | ||
2547 | } | ||
2548 | |||
2549 | /* search the OBJECT_ID into definitions */ | ||
2550 | p2 = definitions->down; | ||
2551 | while (p2) | ||
2552 | { | ||
2553 | if ((type_field (p2->type) == TYPE_OBJECT_ID) && | ||
2554 | (p2->type & CONST_ASSIGN)) | ||
2555 | { | ||
2556 | strcpy (name, definitionsName); | ||
2557 | strcat (name, p2->name); | ||
2558 | |||
2559 | len = MAX_NAME_SIZE; | ||
2560 | result = | ||
2561 | MHD__asn1_read_value (definitions, name, value, &len); | ||
2562 | |||
2563 | if ((result == ASN1_SUCCESS) | ||
2564 | && (!strcmp (p3->value, value))) | ||
2565 | { | ||
2566 | p2 = p2->right; /* pointer to the structure to | ||
2567 | use for expansion */ | ||
2568 | while ((p2) && (p2->type & CONST_ASSIGN)) | ||
2569 | p2 = p2->right; | ||
2570 | |||
2571 | if (p2) | ||
2572 | { | ||
2573 | strcpy (name, definitionsName); | ||
2574 | strcat (name, p2->name); | ||
2575 | |||
2576 | result = | ||
2577 | MHD__asn1_create_element (definitions, name, &aux); | ||
2578 | if (result == ASN1_SUCCESS) | ||
2579 | { | ||
2580 | MHD__asn1_set_name (aux, p->name); | ||
2581 | len2 = | ||
2582 | MHD__asn1_get_length_der (p->value, | ||
2583 | p->value_len, &len3); | ||
2584 | if (len2 < 0) | ||
2585 | return ASN1_DER_ERROR; | ||
2586 | |||
2587 | result = | ||
2588 | MHD__asn1_der_decoding (&aux, p->value + len3, | ||
2589 | len2, | ||
2590 | errorDescription); | ||
2591 | if (result == ASN1_SUCCESS) | ||
2592 | { | ||
2593 | |||
2594 | MHD__asn1_set_right (aux, p->right); | ||
2595 | MHD__asn1_set_right (p, aux); | ||
2596 | |||
2597 | result = MHD__asn1_delete_structure (&p); | ||
2598 | if (result == ASN1_SUCCESS) | ||
2599 | { | ||
2600 | p = aux; | ||
2601 | aux = ASN1_TYPE_EMPTY; | ||
2602 | break; | ||
2603 | } | ||
2604 | else | ||
2605 | { /* error with MHD__asn1_delete_structure */ | ||
2606 | MHD__asn1_delete_structure (&aux); | ||
2607 | retCode = result; | ||
2608 | break; | ||
2609 | } | ||
2610 | } | ||
2611 | else | ||
2612 | { /* error with MHD__asn1_der_decoding */ | ||
2613 | retCode = result; | ||
2614 | break; | ||
2615 | } | ||
2616 | } | ||
2617 | else | ||
2618 | { /* error with MHD__asn1_create_element */ | ||
2619 | retCode = result; | ||
2620 | break; | ||
2621 | } | ||
2622 | } | ||
2623 | else | ||
2624 | { /* error with the pointer to the structure to exapand */ | ||
2625 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2626 | break; | ||
2627 | } | ||
2628 | } | ||
2629 | } | ||
2630 | p2 = p2->right; | ||
2631 | } /* end while */ | ||
2632 | |||
2633 | if (!p2) | ||
2634 | { | ||
2635 | retCode = ASN1_ERROR_TYPE_ANY; | ||
2636 | break; | ||
2637 | } | ||
2638 | |||
2639 | } | ||
2640 | break; | ||
2641 | default: | ||
2642 | break; | ||
2643 | } | ||
2644 | |||
2645 | |||
2646 | if (p->down) | ||
2647 | { | ||
2648 | p = p->down; | ||
2649 | } | ||
2650 | else if (p == *element) | ||
2651 | { | ||
2652 | p = NULL; | ||
2653 | break; | ||
2654 | } | ||
2655 | else if (p->right) | ||
2656 | p = p->right; | ||
2657 | else | ||
2658 | { | ||
2659 | while (1) | ||
2660 | { | ||
2661 | p = MHD__asn1_find_up (p); | ||
2662 | if (p == *element) | ||
2663 | { | ||
2664 | p = NULL; | ||
2665 | break; | ||
2666 | } | ||
2667 | if (p->right) | ||
2668 | { | ||
2669 | p = p->right; | ||
2670 | break; | ||
2671 | } | ||
2672 | } | ||
2673 | } | ||
2674 | } | ||
2675 | |||
2676 | return retCode; | ||
2677 | } | ||
2678 | |||
2679 | |||
2680 | |||
2681 | /** | ||
2682 | * MHD__asn1_expand_octet_string - Expand "OCTET STRING" fields in structure. | ||
2683 | * @definitions: ASN1 definitions | ||
2684 | * @element: pointer to an ASN1 structure | ||
2685 | * @octetName: name of the OCTECT STRING field to expand. | ||
2686 | * @objectName: name of the OBJECT IDENTIFIER field to use to define | ||
2687 | * the type for expansion. | ||
2688 | * | ||
2689 | * Expands an "OCTET STRING" element of a structure created from a | ||
2690 | * DER decoding process (MHD__asn1_der_decoding function). The type used | ||
2691 | * for expansion is the first one following the definition of the | ||
2692 | * actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME. | ||
2693 | * | ||
2694 | * Returns: | ||
2695 | * | ||
2696 | * ASN1_SUCCESS: Substitution OK. | ||
2697 | * | ||
2698 | * ASN1_ELEMENT_NOT_FOUND: OBJECTNAME or OCTETNAME are not correct. | ||
2699 | * | ||
2700 | * ASN1_VALUE_NOT_VALID: Wasn't possible to find the type to use | ||
2701 | * for expansion. | ||
2702 | * | ||
2703 | * other errors: result of der decoding process. | ||
2704 | **/ | ||
2705 | MHD__asn1_retCode | ||
2706 | MHD__asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, | ||
2707 | const char *octetName, const char *objectName) | ||
2708 | { | ||
2709 | char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE]; | ||
2710 | MHD__asn1_retCode retCode = ASN1_SUCCESS, result; | ||
2711 | int len, len2, len3; | ||
2712 | ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY; | ||
2713 | ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY; | ||
2714 | char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; | ||
2715 | |||
2716 | if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY)) | ||
2717 | return ASN1_ELEMENT_NOT_FOUND; | ||
2718 | |||
2719 | octetNode = MHD__asn1_find_node (*element, octetName); | ||
2720 | if (octetNode == ASN1_TYPE_EMPTY) | ||
2721 | return ASN1_ELEMENT_NOT_FOUND; | ||
2722 | if (type_field (octetNode->type) != TYPE_OCTET_STRING) | ||
2723 | return ASN1_ELEMENT_NOT_FOUND; | ||
2724 | if (octetNode->value == NULL) | ||
2725 | return ASN1_VALUE_NOT_FOUND; | ||
2726 | |||
2727 | objectNode = MHD__asn1_find_node (*element, objectName); | ||
2728 | if (objectNode == ASN1_TYPE_EMPTY) | ||
2729 | return ASN1_ELEMENT_NOT_FOUND; | ||
2730 | |||
2731 | if (type_field (objectNode->type) != TYPE_OBJECT_ID) | ||
2732 | return ASN1_ELEMENT_NOT_FOUND; | ||
2733 | |||
2734 | if (objectNode->value == NULL) | ||
2735 | return ASN1_VALUE_NOT_FOUND; | ||
2736 | |||
2737 | |||
2738 | /* search the OBJECT_ID into definitions */ | ||
2739 | p2 = definitions->down; | ||
2740 | while (p2) | ||
2741 | { | ||
2742 | if ((type_field (p2->type) == TYPE_OBJECT_ID) && | ||
2743 | (p2->type & CONST_ASSIGN)) | ||
2744 | { | ||
2745 | strcpy (name, definitions->name); | ||
2746 | strcat (name, "."); | ||
2747 | strcat (name, p2->name); | ||
2748 | |||
2749 | len = sizeof (value); | ||
2750 | result = MHD__asn1_read_value (definitions, name, value, &len); | ||
2751 | |||
2752 | if ((result == ASN1_SUCCESS) | ||
2753 | && (!strcmp (objectNode->value, value))) | ||
2754 | { | ||
2755 | |||
2756 | p2 = p2->right; /* pointer to the structure to | ||
2757 | use for expansion */ | ||
2758 | while ((p2) && (p2->type & CONST_ASSIGN)) | ||
2759 | p2 = p2->right; | ||
2760 | |||
2761 | if (p2) | ||
2762 | { | ||
2763 | strcpy (name, definitions->name); | ||
2764 | strcat (name, "."); | ||
2765 | strcat (name, p2->name); | ||
2766 | |||
2767 | result = MHD__asn1_create_element (definitions, name, &aux); | ||
2768 | if (result == ASN1_SUCCESS) | ||
2769 | { | ||
2770 | MHD__asn1_set_name (aux, octetNode->name); | ||
2771 | len2 = | ||
2772 | MHD__asn1_get_length_der (octetNode->value, | ||
2773 | octetNode->value_len, &len3); | ||
2774 | if (len2 < 0) | ||
2775 | return ASN1_DER_ERROR; | ||
2776 | |||
2777 | result = | ||
2778 | MHD__asn1_der_decoding (&aux, octetNode->value + len3, | ||
2779 | len2, errorDescription); | ||
2780 | if (result == ASN1_SUCCESS) | ||
2781 | { | ||
2782 | |||
2783 | MHD__asn1_set_right (aux, octetNode->right); | ||
2784 | MHD__asn1_set_right (octetNode, aux); | ||
2785 | |||
2786 | result = MHD__asn1_delete_structure (&octetNode); | ||
2787 | if (result == ASN1_SUCCESS) | ||
2788 | { | ||
2789 | aux = ASN1_TYPE_EMPTY; | ||
2790 | break; | ||
2791 | } | ||
2792 | else | ||
2793 | { /* error with MHD__asn1_delete_structure */ | ||
2794 | MHD__asn1_delete_structure (&aux); | ||
2795 | retCode = result; | ||
2796 | break; | ||
2797 | } | ||
2798 | } | ||
2799 | else | ||
2800 | { /* error with MHD__asn1_der_decoding */ | ||
2801 | retCode = result; | ||
2802 | break; | ||
2803 | } | ||
2804 | } | ||
2805 | else | ||
2806 | { /* error with MHD__asn1_create_element */ | ||
2807 | retCode = result; | ||
2808 | break; | ||
2809 | } | ||
2810 | } | ||
2811 | else | ||
2812 | { /* error with the pointer to the structure to exapand */ | ||
2813 | retCode = ASN1_VALUE_NOT_VALID; | ||
2814 | break; | ||
2815 | } | ||
2816 | } | ||
2817 | } | ||
2818 | |||
2819 | p2 = p2->right; | ||
2820 | |||
2821 | } | ||
2822 | |||
2823 | if (!p2) | ||
2824 | retCode = ASN1_VALUE_NOT_VALID; | ||
2825 | |||
2826 | return retCode; | ||
2827 | } | ||
diff --git a/src/daemon/https/minitasn1/element.c b/src/daemon/https/minitasn1/element.c index dfaa05b2..4e29772e 100644 --- a/src/daemon/https/minitasn1/element.c +++ b/src/daemon/https/minitasn1/element.c | |||
@@ -281,7 +281,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
281 | node_asn *node, *p, *p2; | 281 | node_asn *node, *p, *p2; |
282 | unsigned char *temp, *value_temp = NULL, *default_temp = NULL; | 282 | unsigned char *temp, *value_temp = NULL, *default_temp = NULL; |
283 | int len2, k, k2, negative; | 283 | int len2, k, k2, negative; |
284 | const unsigned char *value = ivalue; | 284 | const char *value = ivalue; |
285 | 285 | ||
286 | node = MHD__asn1_find_node (node_root, name); | 286 | node = MHD__asn1_find_node (node_root, name); |
287 | if (node == NULL) | 287 | if (node == NULL) |
@@ -374,10 +374,10 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
374 | if (value_temp == NULL) | 374 | if (value_temp == NULL) |
375 | return ASN1_MEM_ALLOC_ERROR; | 375 | return ASN1_MEM_ALLOC_ERROR; |
376 | 376 | ||
377 | MHD__asn1_convert_integer (p->value, | 377 | MHD__asn1_convert_integer ((const char*) p->value, |
378 | value_temp, | 378 | value_temp, |
379 | SIZEOF_UNSIGNED_LONG_INT, | 379 | SIZEOF_UNSIGNED_LONG_INT, |
380 | &len); | 380 | &len); |
381 | break; | 381 | break; |
382 | } | 382 | } |
383 | } | 383 | } |
@@ -446,7 +446,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
446 | return ASN1_MEM_ALLOC_ERROR; | 446 | return ASN1_MEM_ALLOC_ERROR; |
447 | } | 447 | } |
448 | 448 | ||
449 | MHD__asn1_convert_integer (p->value, default_temp, | 449 | MHD__asn1_convert_integer ((const char*) p->value, default_temp, |
450 | SIZEOF_UNSIGNED_LONG_INT, &len2); | 450 | SIZEOF_UNSIGNED_LONG_INT, &len2); |
451 | } | 451 | } |
452 | else | 452 | else |
@@ -461,7 +461,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
461 | { | 461 | { |
462 | if (type_field (p2->type) == TYPE_CONSTANT) | 462 | if (type_field (p2->type) == TYPE_CONSTANT) |
463 | { | 463 | { |
464 | if ((p2->name) && (!strcmp (p2->name, p->value))) | 464 | if ((p2->name) && (!strcmp (p2->name,(const char*) p->value))) |
465 | { | 465 | { |
466 | default_temp = | 466 | default_temp = |
467 | (unsigned char *) | 467 | (unsigned char *) |
@@ -472,7 +472,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
472 | return ASN1_MEM_ALLOC_ERROR; | 472 | return ASN1_MEM_ALLOC_ERROR; |
473 | } | 473 | } |
474 | 474 | ||
475 | MHD__asn1_convert_integer (p2->value, | 475 | MHD__asn1_convert_integer ((const char*) p2->value, |
476 | default_temp, | 476 | default_temp, |
477 | SIZEOF_UNSIGNED_LONG_INT, | 477 | SIZEOF_UNSIGNED_LONG_INT, |
478 | &len2); | 478 | &len2); |
@@ -512,7 +512,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
512 | p = node->down; | 512 | p = node->down; |
513 | while (type_field (p->type) != TYPE_DEFAULT) | 513 | while (type_field (p->type) != TYPE_DEFAULT) |
514 | p = p->right; | 514 | p = p->right; |
515 | if (!strcmp (value, p->value)) | 515 | if (!strcmp (value,(const char*) p->value)) |
516 | { | 516 | { |
517 | MHD__asn1_set_value (node, NULL, 0); | 517 | MHD__asn1_set_value (node, NULL, 0); |
518 | break; | 518 | break; |
@@ -574,7 +574,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
574 | if (temp == NULL) | 574 | if (temp == NULL) |
575 | return ASN1_MEM_ALLOC_ERROR; | 575 | return ASN1_MEM_ALLOC_ERROR; |
576 | 576 | ||
577 | MHD__asn1_octet_der (value, len, temp, &len2); | 577 | MHD__asn1_octet_der ((const unsigned char*) value, len, temp, &len2); |
578 | MHD__asn1_set_value (node, temp, len2); | 578 | MHD__asn1_set_value (node, temp, len2); |
579 | MHD__asn1_afree (temp); | 579 | MHD__asn1_afree (temp); |
580 | break; | 580 | break; |
@@ -586,7 +586,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
586 | if (temp == NULL) | 586 | if (temp == NULL) |
587 | return ASN1_MEM_ALLOC_ERROR; | 587 | return ASN1_MEM_ALLOC_ERROR; |
588 | 588 | ||
589 | MHD__asn1_octet_der (value, len, temp, &len2); | 589 | MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2); |
590 | MHD__asn1_set_value (node, temp, len2); | 590 | MHD__asn1_set_value (node, temp, len2); |
591 | MHD__asn1_afree (temp); | 591 | MHD__asn1_afree (temp); |
592 | break; | 592 | break; |
@@ -598,7 +598,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
598 | if (temp == NULL) | 598 | if (temp == NULL) |
599 | return ASN1_MEM_ALLOC_ERROR; | 599 | return ASN1_MEM_ALLOC_ERROR; |
600 | 600 | ||
601 | MHD__asn1_bit_der (value, len, temp, &len2); | 601 | MHD__asn1_bit_der ((const unsigned char*)value, len, temp, &len2); |
602 | MHD__asn1_set_value (node, temp, len2); | 602 | MHD__asn1_set_value (node, temp, len2); |
603 | MHD__asn1_afree (temp); | 603 | MHD__asn1_afree (temp); |
604 | break; | 604 | break; |
@@ -632,7 +632,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, | |||
632 | if (temp == NULL) | 632 | if (temp == NULL) |
633 | return ASN1_MEM_ALLOC_ERROR; | 633 | return ASN1_MEM_ALLOC_ERROR; |
634 | 634 | ||
635 | MHD__asn1_octet_der (value, len, temp, &len2); | 635 | MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2); |
636 | MHD__asn1_set_value (node, temp, len2); | 636 | MHD__asn1_set_value (node, temp, len2); |
637 | MHD__asn1_afree (temp); | 637 | MHD__asn1_afree (temp); |
638 | break; | 638 | break; |
@@ -749,7 +749,7 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
749 | node_asn *node, *p, *p2; | 749 | node_asn *node, *p, *p2; |
750 | int len2, len3; | 750 | int len2, len3; |
751 | int value_size = *len; | 751 | int value_size = *len; |
752 | unsigned char *value = ivalue; | 752 | char *value = ivalue; |
753 | 753 | ||
754 | node = MHD__asn1_find_node (root, name); | 754 | node = MHD__asn1_find_node (root, name); |
755 | if (node == NULL) | 755 | if (node == NULL) |
@@ -801,7 +801,7 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
801 | || (p->value[0] == '+')) | 801 | || (p->value[0] == '+')) |
802 | { | 802 | { |
803 | if (MHD__asn1_convert_integer | 803 | if (MHD__asn1_convert_integer |
804 | (p->value, value, value_size, len) != ASN1_SUCCESS) | 804 | ((const char*) p->value, (unsigned char*) value, value_size, len) != ASN1_SUCCESS) |
805 | return ASN1_MEM_ERROR; | 805 | return ASN1_MEM_ERROR; |
806 | } | 806 | } |
807 | else | 807 | else |
@@ -811,10 +811,10 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
811 | { | 811 | { |
812 | if (type_field (p2->type) == TYPE_CONSTANT) | 812 | if (type_field (p2->type) == TYPE_CONSTANT) |
813 | { | 813 | { |
814 | if ((p2->name) && (!strcmp (p2->name, p->value))) | 814 | if ((p2->name) && (!strcmp (p2->name, (const char*) p->value))) |
815 | { | 815 | { |
816 | if (MHD__asn1_convert_integer | 816 | if (MHD__asn1_convert_integer |
817 | (p2->value, value, value_size, | 817 | ((const char*) p2->value, (unsigned char*) value, value_size, |
818 | len) != ASN1_SUCCESS) | 818 | len) != ASN1_SUCCESS) |
819 | return ASN1_MEM_ERROR; | 819 | return ASN1_MEM_ERROR; |
820 | break; | 820 | break; |
@@ -828,7 +828,7 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
828 | { | 828 | { |
829 | len2 = -1; | 829 | len2 = -1; |
830 | if (MHD__asn1_get_octet_der | 830 | if (MHD__asn1_get_octet_der |
831 | (node->value, node->value_len, &len2, value, value_size, | 831 | (node->value, node->value_len, &len2, (unsigned char*) value, value_size, |
832 | len) != ASN1_SUCCESS) | 832 | len) != ASN1_SUCCESS) |
833 | return ASN1_MEM_ERROR; | 833 | return ASN1_MEM_ERROR; |
834 | } | 834 | } |
@@ -842,7 +842,7 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
842 | { | 842 | { |
843 | if (type_field (p->type) == TYPE_CONSTANT) | 843 | if (type_field (p->type) == TYPE_CONSTANT) |
844 | { | 844 | { |
845 | ADD_STR_VALUE (value, value_size, p->value); | 845 | ADD_STR_VALUE (value, value_size, (const char*) p->value); |
846 | if (p->right) | 846 | if (p->right) |
847 | { | 847 | { |
848 | ADD_STR_VALUE (value, value_size, "."); | 848 | ADD_STR_VALUE (value, value_size, "."); |
@@ -857,34 +857,34 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
857 | p = node->down; | 857 | p = node->down; |
858 | while (type_field (p->type) != TYPE_DEFAULT) | 858 | while (type_field (p->type) != TYPE_DEFAULT) |
859 | p = p->right; | 859 | p = p->right; |
860 | PUT_STR_VALUE (value, value_size, p->value); | 860 | PUT_STR_VALUE (value, value_size, (const char*) p->value); |
861 | } | 861 | } |
862 | else | 862 | else |
863 | { | 863 | { |
864 | PUT_STR_VALUE (value, value_size, node->value); | 864 | PUT_STR_VALUE (value, value_size, (const char*) node->value); |
865 | } | 865 | } |
866 | break; | 866 | break; |
867 | case TYPE_TIME: | 867 | case TYPE_TIME: |
868 | PUT_STR_VALUE (value, value_size, node->value); | 868 | PUT_STR_VALUE (value, value_size, (const char*) node->value); |
869 | break; | 869 | break; |
870 | case TYPE_OCTET_STRING: | 870 | case TYPE_OCTET_STRING: |
871 | len2 = -1; | 871 | len2 = -1; |
872 | if (MHD__asn1_get_octet_der | 872 | if (MHD__asn1_get_octet_der |
873 | (node->value, node->value_len, &len2, value, value_size, | 873 | (node->value, node->value_len, &len2, (unsigned char*) value, value_size, |
874 | len) != ASN1_SUCCESS) | 874 | len) != ASN1_SUCCESS) |
875 | return ASN1_MEM_ERROR; | 875 | return ASN1_MEM_ERROR; |
876 | break; | 876 | break; |
877 | case TYPE_GENERALSTRING: | 877 | case TYPE_GENERALSTRING: |
878 | len2 = -1; | 878 | len2 = -1; |
879 | if (MHD__asn1_get_octet_der | 879 | if (MHD__asn1_get_octet_der |
880 | (node->value, node->value_len, &len2, value, value_size, | 880 | (node->value, node->value_len, &len2, (unsigned char*) value, value_size, |
881 | len) != ASN1_SUCCESS) | 881 | len) != ASN1_SUCCESS) |
882 | return ASN1_MEM_ERROR; | 882 | return ASN1_MEM_ERROR; |
883 | break; | 883 | break; |
884 | case TYPE_BIT_STRING: | 884 | case TYPE_BIT_STRING: |
885 | len2 = -1; | 885 | len2 = -1; |
886 | if (MHD__asn1_get_bit_der | 886 | if (MHD__asn1_get_bit_der |
887 | (node->value, node->value_len, &len2, value, value_size, | 887 | (node->value, node->value_len, &len2, (unsigned char*) value, value_size, |
888 | len) != ASN1_SUCCESS) | 888 | len) != ASN1_SUCCESS) |
889 | return ASN1_MEM_ERROR; | 889 | return ASN1_MEM_ERROR; |
890 | break; | 890 | break; |
@@ -906,123 +906,3 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) | |||
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | /** | ||
910 | * MHD__asn1_read_tag - Returns the TAG of one element inside a structure | ||
911 | * @root: pointer to a structure | ||
912 | * @name: the name of the element inside a structure. | ||
913 | * @tagValue: variable that will contain the TAG value. | ||
914 | * @classValue: variable that will specify the TAG type. | ||
915 | * | ||
916 | * Returns the TAG and the CLASS of one element inside a structure. | ||
917 | * CLASS can have one of these constants: %ASN1_CLASS_APPLICATION, | ||
918 | * %ASN1_CLASS_UNIVERSAL, %ASN1_CLASS_PRIVATE or | ||
919 | * %ASN1_CLASS_CONTEXT_SPECIFIC. | ||
920 | * | ||
921 | * Returns: | ||
922 | * | ||
923 | * ASN1_SUCCESS: Set value OK. | ||
924 | * | ||
925 | * ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element. | ||
926 | * | ||
927 | **/ | ||
928 | MHD__asn1_retCode | ||
929 | MHD__asn1_read_tag (node_asn * root, const char *name, int *tagValue, | ||
930 | int *classValue) | ||
931 | { | ||
932 | node_asn *node, *p, *pTag; | ||
933 | |||
934 | node = MHD__asn1_find_node (root, name); | ||
935 | if (node == NULL) | ||
936 | return ASN1_ELEMENT_NOT_FOUND; | ||
937 | |||
938 | p = node->down; | ||
939 | |||
940 | /* pTag will points to the IMPLICIT TAG */ | ||
941 | pTag = NULL; | ||
942 | if (node->type & CONST_TAG) | ||
943 | { | ||
944 | while (p) | ||
945 | { | ||
946 | if (type_field (p->type) == TYPE_TAG) | ||
947 | { | ||
948 | if ((p->type & CONST_IMPLICIT) && (pTag == NULL)) | ||
949 | pTag = p; | ||
950 | else if (p->type & CONST_EXPLICIT) | ||
951 | pTag = NULL; | ||
952 | } | ||
953 | p = p->right; | ||
954 | } | ||
955 | } | ||
956 | |||
957 | if (pTag) | ||
958 | { | ||
959 | *tagValue = strtoul (pTag->value, NULL, 10); | ||
960 | |||
961 | if (pTag->type & CONST_APPLICATION) | ||
962 | *classValue = ASN1_CLASS_APPLICATION; | ||
963 | else if (pTag->type & CONST_UNIVERSAL) | ||
964 | *classValue = ASN1_CLASS_UNIVERSAL; | ||
965 | else if (pTag->type & CONST_PRIVATE) | ||
966 | *classValue = ASN1_CLASS_PRIVATE; | ||
967 | else | ||
968 | *classValue = ASN1_CLASS_CONTEXT_SPECIFIC; | ||
969 | } | ||
970 | else | ||
971 | { | ||
972 | *classValue = ASN1_CLASS_UNIVERSAL; | ||
973 | |||
974 | switch (type_field (node->type)) | ||
975 | { | ||
976 | case TYPE_NULL: | ||
977 | *tagValue = ASN1_TAG_NULL; | ||
978 | break; | ||
979 | case TYPE_BOOLEAN: | ||
980 | *tagValue = ASN1_TAG_BOOLEAN; | ||
981 | break; | ||
982 | case TYPE_INTEGER: | ||
983 | *tagValue = ASN1_TAG_INTEGER; | ||
984 | break; | ||
985 | case TYPE_ENUMERATED: | ||
986 | *tagValue = ASN1_TAG_ENUMERATED; | ||
987 | break; | ||
988 | case TYPE_OBJECT_ID: | ||
989 | *tagValue = ASN1_TAG_OBJECT_ID; | ||
990 | break; | ||
991 | case TYPE_TIME: | ||
992 | if (node->type & CONST_UTC) | ||
993 | { | ||
994 | *tagValue = ASN1_TAG_UTCTime; | ||
995 | } | ||
996 | else | ||
997 | *tagValue = ASN1_TAG_GENERALIZEDTime; | ||
998 | break; | ||
999 | case TYPE_OCTET_STRING: | ||
1000 | *tagValue = ASN1_TAG_OCTET_STRING; | ||
1001 | break; | ||
1002 | case TYPE_GENERALSTRING: | ||
1003 | *tagValue = ASN1_TAG_GENERALSTRING; | ||
1004 | break; | ||
1005 | case TYPE_BIT_STRING: | ||
1006 | *tagValue = ASN1_TAG_BIT_STRING; | ||
1007 | break; | ||
1008 | case TYPE_SEQUENCE: | ||
1009 | case TYPE_SEQUENCE_OF: | ||
1010 | *tagValue = ASN1_TAG_SEQUENCE; | ||
1011 | break; | ||
1012 | case TYPE_SET: | ||
1013 | case TYPE_SET_OF: | ||
1014 | *tagValue = ASN1_TAG_SET; | ||
1015 | break; | ||
1016 | case TYPE_TAG: | ||
1017 | case TYPE_CHOICE: | ||
1018 | case TYPE_ANY: | ||
1019 | break; | ||
1020 | default: | ||
1021 | break; | ||
1022 | } | ||
1023 | } | ||
1024 | |||
1025 | |||
1026 | return ASN1_SUCCESS; | ||
1027 | |||
1028 | } | ||
diff --git a/src/daemon/https/minitasn1/libtasn1.h b/src/daemon/https/minitasn1/libtasn1.h index b9cfe610..7379db18 100644 --- a/src/daemon/https/minitasn1/libtasn1.h +++ b/src/daemon/https/minitasn1/libtasn1.h | |||
@@ -150,9 +150,6 @@ extern "C" | |||
150 | ASN1_TYPE * definitions, | 150 | ASN1_TYPE * definitions, |
151 | char *errorDescription); | 151 | char *errorDescription); |
152 | 152 | ||
153 | void MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure, | ||
154 | const char *name, int mode); | ||
155 | |||
156 | MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions, | 153 | MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions, |
157 | const char *source_name, | 154 | const char *source_name, |
158 | ASN1_TYPE * element); | 155 | ASN1_TYPE * element); |
@@ -177,32 +174,14 @@ extern "C" | |||
177 | MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, | 174 | MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, |
178 | int len, char *errorDescription); | 175 | int len, char *errorDescription); |
179 | 176 | ||
180 | MHD__asn1_retCode MHD__asn1_der_decoding_element (ASN1_TYPE * structure, | ||
181 | const char *elementName, | ||
182 | const void *ider, int len, | ||
183 | char *errorDescription); | ||
184 | |||
185 | MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, | 177 | MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, |
186 | const void *ider, int len, | 178 | const void *ider, int len, |
187 | const char *name_element, | 179 | const char *name_element, |
188 | int *start, int *end); | 180 | int *start, int *end); |
189 | 181 | ||
190 | MHD__asn1_retCode MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions, | ||
191 | ASN1_TYPE * element); | ||
192 | |||
193 | MHD__asn1_retCode MHD__asn1_expand_octet_string (ASN1_TYPE definitions, | ||
194 | ASN1_TYPE * element, | ||
195 | const char *octetName, | ||
196 | const char *objectName); | ||
197 | |||
198 | MHD__asn1_retCode MHD__asn1_read_tag (node_asn * root, const char *name, | ||
199 | int *tagValue, int *classValue); | ||
200 | |||
201 | const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, | 182 | const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, |
202 | const char *oidValue); | 183 | const char *oidValue); |
203 | 184 | ||
204 | const char *MHD__asn1_check_version (const char *req_version); | ||
205 | |||
206 | const char *MHD__libtasn1_strerror (MHD__asn1_retCode error); | 185 | const char *MHD__libtasn1_strerror (MHD__asn1_retCode error); |
207 | 186 | ||
208 | void MHD__libtasn1_perror (MHD__asn1_retCode error); | 187 | void MHD__libtasn1_perror (MHD__asn1_retCode error); |
diff --git a/src/daemon/https/minitasn1/parser_aux.c b/src/daemon/https/minitasn1/parser_aux.c index 6e82dd71..5f36a5ff 100644 --- a/src/daemon/https/minitasn1/parser_aux.c +++ b/src/daemon/https/minitasn1/parser_aux.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include "structure.h" | 27 | #include "structure.h" |
28 | #include "element.h" | 28 | #include "element.h" |
29 | 29 | ||
30 | |||
31 | |||
30 | char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ | 32 | char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ |
31 | 33 | ||
32 | /***********************************************/ | 34 | /***********************************************/ |
@@ -279,42 +281,6 @@ MHD__asn1_set_right (node_asn * node, node_asn * right) | |||
279 | } | 281 | } |
280 | 282 | ||
281 | /******************************************************************/ | 283 | /******************************************************************/ |
282 | /* Function : MHD__asn1_get_right */ | ||
283 | /* Description: returns the element pointed by the RIGHT field of */ | ||
284 | /* a NODE_ASN element. */ | ||
285 | /* Parameters: */ | ||
286 | /* node: NODE_ASN element pointer. */ | ||
287 | /* Return: field RIGHT of NODE. */ | ||
288 | /******************************************************************/ | ||
289 | node_asn * | ||
290 | MHD__asn1_get_right (node_asn * node) | ||
291 | { | ||
292 | if (node == NULL) | ||
293 | return NULL; | ||
294 | return node->right; | ||
295 | } | ||
296 | |||
297 | /******************************************************************/ | ||
298 | /* Function : MHD__asn1_get_last_right */ | ||
299 | /* Description: return the last element along the right chain. */ | ||
300 | /* Parameters: */ | ||
301 | /* node: starting element pointer. */ | ||
302 | /* Return: pointer to the last element along the right chain. */ | ||
303 | /******************************************************************/ | ||
304 | node_asn * | ||
305 | MHD__asn1_get_last_right (node_asn * node) | ||
306 | { | ||
307 | node_asn *p; | ||
308 | |||
309 | if (node == NULL) | ||
310 | return NULL; | ||
311 | p = node; | ||
312 | while (p->right) | ||
313 | p = p->right; | ||
314 | return p; | ||
315 | } | ||
316 | |||
317 | /******************************************************************/ | ||
318 | /* Function : MHD__asn1_set_down */ | 284 | /* Function : MHD__asn1_set_down */ |
319 | /* Description: sets the field DOWN in a NODE_ASN element. */ | 285 | /* Description: sets the field DOWN in a NODE_ASN element. */ |
320 | /* Parameters: */ | 286 | /* Parameters: */ |
@@ -335,58 +301,6 @@ MHD__asn1_set_down (node_asn * node, node_asn * down) | |||
335 | } | 301 | } |
336 | 302 | ||
337 | /******************************************************************/ | 303 | /******************************************************************/ |
338 | /* Function : MHD__asn1_get_down */ | ||
339 | /* Description: returns the element pointed by the DOWN field of */ | ||
340 | /* a NODE_ASN element. */ | ||
341 | /* Parameters: */ | ||
342 | /* node: NODE_ASN element pointer. */ | ||
343 | /* Return: field DOWN of NODE. */ | ||
344 | /******************************************************************/ | ||
345 | node_asn * | ||
346 | MHD__asn1_get_down (node_asn * node) | ||
347 | { | ||
348 | if (node == NULL) | ||
349 | return NULL; | ||
350 | return node->down; | ||
351 | } | ||
352 | |||
353 | /******************************************************************/ | ||
354 | /* Function : MHD__asn1_get_name */ | ||
355 | /* Description: returns the name of a NODE_ASN element. */ | ||
356 | /* Parameters: */ | ||
357 | /* node: NODE_ASN element pointer. */ | ||
358 | /* Return: a null terminated string. */ | ||
359 | /******************************************************************/ | ||
360 | char * | ||
361 | MHD__asn1_get_name (node_asn * node) | ||
362 | { | ||
363 | if (node == NULL) | ||
364 | return NULL; | ||
365 | return node->name; | ||
366 | } | ||
367 | |||
368 | /******************************************************************/ | ||
369 | /* Function : MHD__asn1_mod_type */ | ||
370 | /* Description: change the field TYPE of an NODE_ASN element. */ | ||
371 | /* The new value is the old one | (bitwise or) the */ | ||
372 | /* paramener VALUE. */ | ||
373 | /* Parameters: */ | ||
374 | /* node: NODE_ASN element pointer. */ | ||
375 | /* value: the integer value that must be or-ed with the current */ | ||
376 | /* value of field TYPE. */ | ||
377 | /* Return: NODE pointer. */ | ||
378 | /******************************************************************/ | ||
379 | node_asn * | ||
380 | MHD__asn1_mod_type (node_asn * node, unsigned int value) | ||
381 | { | ||
382 | if (node == NULL) | ||
383 | return node; | ||
384 | node->type |= value; | ||
385 | return node; | ||
386 | } | ||
387 | |||
388 | |||
389 | /******************************************************************/ | ||
390 | /* Function : MHD__asn1_remove_node */ | 304 | /* Function : MHD__asn1_remove_node */ |
391 | /* Description: gets free the memory allocated for an NODE_ASN */ | 305 | /* Description: gets free the memory allocated for an NODE_ASN */ |
392 | /* element (not the elements pointed by it). */ | 306 | /* element (not the elements pointed by it). */ |
@@ -529,7 +443,7 @@ MHD__asn1_change_integer_value (ASN1_TYPE node) | |||
529 | { | 443 | { |
530 | if (p->value) | 444 | if (p->value) |
531 | { | 445 | { |
532 | MHD__asn1_convert_integer (p->value, val, sizeof (val), &len); | 446 | MHD__asn1_convert_integer ((const char*) p->value, val, sizeof (val), &len); |
533 | MHD__asn1_octet_der (val, len, val2, &len); | 447 | MHD__asn1_octet_der (val, len, val2, &len); |
534 | MHD__asn1_set_value (p, val2, len); | 448 | MHD__asn1_set_value (p, val2, len); |
535 | } | 449 | } |
@@ -607,7 +521,7 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) | |||
607 | { | 521 | { |
608 | MHD__asn1_str_cpy (name2, sizeof (name2), name_root); | 522 | MHD__asn1_str_cpy (name2, sizeof (name2), name_root); |
609 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 523 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
610 | MHD__asn1_str_cat (name2, sizeof (name2), p2->value); | 524 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); |
611 | p3 = MHD__asn1_find_node (node, name2); | 525 | p3 = MHD__asn1_find_node (node, name2); |
612 | if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || | 526 | if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || |
613 | !(p3->type & CONST_ASSIGN)) | 527 | !(p3->type & CONST_ASSIGN)) |
@@ -622,7 +536,7 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) | |||
622 | { | 536 | { |
623 | p5 = MHD__asn1_add_node_only (TYPE_CONSTANT); | 537 | p5 = MHD__asn1_add_node_only (TYPE_CONSTANT); |
624 | MHD__asn1_set_name (p5, p4->name); | 538 | MHD__asn1_set_name (p5, p4->name); |
625 | tlen = strlen (p4->value); | 539 | tlen = strlen ( (const char*) p4->value); |
626 | if (tlen > 0) | 540 | if (tlen > 0) |
627 | MHD__asn1_set_value (p5, p4->value, tlen + 1); | 541 | MHD__asn1_set_value (p5, p4->value, tlen + 1); |
628 | if (p2 == p) | 542 | if (p2 == p) |
@@ -693,7 +607,7 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) | |||
693 | { | 607 | { |
694 | MHD__asn1_str_cpy (name2, sizeof (name2), name_root); | 608 | MHD__asn1_str_cpy (name2, sizeof (name2), name_root); |
695 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 609 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
696 | MHD__asn1_str_cat (name2, sizeof (name2), p2->value); | 610 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); |
697 | p3 = MHD__asn1_find_node (node, name2); | 611 | p3 = MHD__asn1_find_node (node, name2); |
698 | if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || | 612 | if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || |
699 | !(p3->type & CONST_ASSIGN)) | 613 | !(p3->type & CONST_ASSIGN)) |
@@ -706,7 +620,7 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) | |||
706 | { | 620 | { |
707 | if (name2[0]) | 621 | if (name2[0]) |
708 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 622 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
709 | MHD__asn1_str_cat (name2, sizeof (name2), p4->value); | 623 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p4->value); |
710 | } | 624 | } |
711 | p4 = p4->right; | 625 | p4 = p4->right; |
712 | } | 626 | } |
@@ -748,77 +662,6 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) | |||
748 | return ASN1_SUCCESS; | 662 | return ASN1_SUCCESS; |
749 | } | 663 | } |
750 | 664 | ||
751 | |||
752 | /******************************************************************/ | ||
753 | /* Function : MHD__asn1_type_set_config */ | ||
754 | /* Description: sets the CONST_SET and CONST_NOT_USED properties */ | ||
755 | /* in the fields of the SET elements. */ | ||
756 | /* Parameters: */ | ||
757 | /* node: root of an ASN1 element. */ | ||
758 | /* Return: */ | ||
759 | /* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ | ||
760 | /* otherwise ASN1_SUCCESS */ | ||
761 | /******************************************************************/ | ||
762 | MHD__asn1_retCode | ||
763 | MHD__asn1_type_set_config (ASN1_TYPE node) | ||
764 | { | ||
765 | node_asn *p, *p2; | ||
766 | int move; | ||
767 | |||
768 | if (node == NULL) | ||
769 | return ASN1_ELEMENT_NOT_FOUND; | ||
770 | |||
771 | p = node; | ||
772 | move = DOWN; | ||
773 | |||
774 | while (!((p == node) && (move == UP))) | ||
775 | { | ||
776 | if (move != UP) | ||
777 | { | ||
778 | if (type_field (p->type) == TYPE_SET) | ||
779 | { | ||
780 | p2 = p->down; | ||
781 | while (p2) | ||
782 | { | ||
783 | if (type_field (p2->type) != TYPE_TAG) | ||
784 | p2->type |= CONST_SET | CONST_NOT_USED; | ||
785 | p2 = p2->right; | ||
786 | } | ||
787 | } | ||
788 | move = DOWN; | ||
789 | } | ||
790 | else | ||
791 | move = RIGHT; | ||
792 | |||
793 | if (move == DOWN) | ||
794 | { | ||
795 | if (p->down) | ||
796 | p = p->down; | ||
797 | else | ||
798 | move = RIGHT; | ||
799 | } | ||
800 | |||
801 | if (p == node) | ||
802 | { | ||
803 | move = UP; | ||
804 | continue; | ||
805 | } | ||
806 | |||
807 | if (move == RIGHT) | ||
808 | { | ||
809 | if (p->right) | ||
810 | p = p->right; | ||
811 | else | ||
812 | move = UP; | ||
813 | } | ||
814 | if (move == UP) | ||
815 | p = MHD__asn1_find_up (p); | ||
816 | } | ||
817 | |||
818 | return ASN1_SUCCESS; | ||
819 | } | ||
820 | |||
821 | |||
822 | /******************************************************************/ | 665 | /******************************************************************/ |
823 | /* Function : MHD__asn1_check_identifier */ | 666 | /* Function : MHD__asn1_check_identifier */ |
824 | /* Description: checks the definitions of all the identifiers */ | 667 | /* Description: checks the definitions of all the identifiers */ |
@@ -848,11 +691,11 @@ MHD__asn1_check_identifier (ASN1_TYPE node) | |||
848 | { | 691 | { |
849 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); | 692 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); |
850 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 693 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
851 | MHD__asn1_str_cat (name2, sizeof (name2), p->value); | 694 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p->value); |
852 | p2 = MHD__asn1_find_node (node, name2); | 695 | p2 = MHD__asn1_find_node (node, name2); |
853 | if (p2 == NULL) | 696 | if (p2 == NULL) |
854 | { | 697 | { |
855 | strcpy (MHD__asn1_identifierMissing, p->value); | 698 | strcpy (MHD__asn1_identifierMissing, (const char*) p->value); |
856 | return ASN1_IDENTIFIER_NOT_FOUND; | 699 | return ASN1_IDENTIFIER_NOT_FOUND; |
857 | } | 700 | } |
858 | } | 701 | } |
@@ -864,8 +707,8 @@ MHD__asn1_check_identifier (ASN1_TYPE node) | |||
864 | { | 707 | { |
865 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); | 708 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); |
866 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 709 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
867 | MHD__asn1_str_cat (name2, sizeof (name2), p2->value); | 710 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); |
868 | strcpy (MHD__asn1_identifierMissing, p2->value); | 711 | strcpy (MHD__asn1_identifierMissing, (const char*) p2->value); |
869 | p2 = MHD__asn1_find_node (node, name2); | 712 | p2 = MHD__asn1_find_node (node, name2); |
870 | if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || | 713 | if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || |
871 | !(p2->type & CONST_ASSIGN)) | 714 | !(p2->type & CONST_ASSIGN)) |
@@ -884,8 +727,8 @@ MHD__asn1_check_identifier (ASN1_TYPE node) | |||
884 | { | 727 | { |
885 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); | 728 | MHD__asn1_str_cpy (name2, sizeof (name2), node->name); |
886 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 729 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
887 | MHD__asn1_str_cat (name2, sizeof (name2), p2->value); | 730 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); |
888 | strcpy (MHD__asn1_identifierMissing, p2->value); | 731 | strcpy (MHD__asn1_identifierMissing, (const char*) p2->value); |
889 | p2 = MHD__asn1_find_node (node, name2); | 732 | p2 = MHD__asn1_find_node (node, name2); |
890 | if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || | 733 | if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || |
891 | !(p2->type & CONST_ASSIGN)) | 734 | !(p2->type & CONST_ASSIGN)) |
@@ -923,150 +766,3 @@ MHD__asn1_check_identifier (ASN1_TYPE node) | |||
923 | 766 | ||
924 | return ASN1_SUCCESS; | 767 | return ASN1_SUCCESS; |
925 | } | 768 | } |
926 | |||
927 | |||
928 | /******************************************************************/ | ||
929 | /* Function : MHD__asn1_set_default_tag */ | ||
930 | /* Description: sets the default IMPLICIT or EXPLICIT property in */ | ||
931 | /* the tagged elements that don't have this declaration. */ | ||
932 | /* Parameters: */ | ||
933 | /* node: pointer to a DEFINITIONS element. */ | ||
934 | /* Return: */ | ||
935 | /* ASN1_ELEMENT_NOT_FOUND if NODE is NULL or not a pointer to */ | ||
936 | /* a DEFINITIONS element, */ | ||
937 | /* otherwise ASN1_SUCCESS */ | ||
938 | /******************************************************************/ | ||
939 | MHD__asn1_retCode | ||
940 | MHD__asn1_set_default_tag (ASN1_TYPE node) | ||
941 | { | ||
942 | node_asn *p; | ||
943 | |||
944 | if ((node == NULL) || (type_field (node->type) != TYPE_DEFINITIONS)) | ||
945 | return ASN1_ELEMENT_NOT_FOUND; | ||
946 | |||
947 | p = node; | ||
948 | while (p) | ||
949 | { | ||
950 | if ((type_field (p->type) == TYPE_TAG) && | ||
951 | !(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT)) | ||
952 | { | ||
953 | if (node->type & CONST_EXPLICIT) | ||
954 | p->type |= CONST_EXPLICIT; | ||
955 | else | ||
956 | p->type |= CONST_IMPLICIT; | ||
957 | } | ||
958 | |||
959 | if (p->down) | ||
960 | { | ||
961 | p = p->down; | ||
962 | } | ||
963 | else if (p->right) | ||
964 | p = p->right; | ||
965 | else | ||
966 | { | ||
967 | while (1) | ||
968 | { | ||
969 | p = MHD__asn1_find_up (p); | ||
970 | if (p == node) | ||
971 | { | ||
972 | p = NULL; | ||
973 | break; | ||
974 | } | ||
975 | if (p->right) | ||
976 | { | ||
977 | p = p->right; | ||
978 | break; | ||
979 | } | ||
980 | } | ||
981 | } | ||
982 | } | ||
983 | |||
984 | return ASN1_SUCCESS; | ||
985 | } | ||
986 | |||
987 | |||
988 | |||
989 | static const char * | ||
990 | parse_version_number (const char *s, int *number) | ||
991 | { | ||
992 | int val = 0; | ||
993 | |||
994 | if (*s == '0' && isdigit (s[1])) | ||
995 | return NULL; /* leading zeros are not allowed */ | ||
996 | for (; isdigit (*s); s++) | ||
997 | { | ||
998 | val *= 10; | ||
999 | val += *s - '0'; | ||
1000 | } | ||
1001 | *number = val; | ||
1002 | return val < 0 ? NULL : s; | ||
1003 | } | ||
1004 | |||
1005 | /* The parse version functions were copied from libgcrypt. | ||
1006 | */ | ||
1007 | static const char * | ||
1008 | parse_version_string (const char *s, int *major, int *minor, int *micro) | ||
1009 | { | ||
1010 | s = parse_version_number (s, major); | ||
1011 | if (!s || *s != '.') | ||
1012 | return NULL; | ||
1013 | s++; | ||
1014 | s = parse_version_number (s, minor); | ||
1015 | if (!s) | ||
1016 | return NULL; | ||
1017 | if (*s != '.') | ||
1018 | { | ||
1019 | *micro = 0; | ||
1020 | return s; | ||
1021 | } | ||
1022 | s++; | ||
1023 | s = parse_version_number (s, micro); | ||
1024 | if (!s) | ||
1025 | return NULL; | ||
1026 | return s; /* patchlevel */ | ||
1027 | } | ||
1028 | |||
1029 | /** | ||
1030 | * MHD__asn1_check_version - check for library version | ||
1031 | * @req_version: Required version number, or NULL. | ||
1032 | * | ||
1033 | * Check that the the version of the library is at minimum the | ||
1034 | * requested one and return the version string; return %NULL if the | ||
1035 | * condition is not satisfied. If a %NULL is passed to this function, | ||
1036 | * no check is done, but the version string is simply returned. | ||
1037 | * | ||
1038 | * See %LIBTASN1_VERSION for a suitable @req_version string. | ||
1039 | * | ||
1040 | * Return value: Version string of run-time library, or %NULL if the | ||
1041 | * run-time library does not meet the required version number. | ||
1042 | */ | ||
1043 | const char * | ||
1044 | MHD__asn1_check_version (const char *req_version) | ||
1045 | { | ||
1046 | const char *ver = LIBTASN1_VERSION; | ||
1047 | int my_major, my_minor, my_micro; | ||
1048 | int rq_major, rq_minor, rq_micro; | ||
1049 | const char *my_plvl, *rq_plvl; | ||
1050 | |||
1051 | if (!req_version) | ||
1052 | return ver; | ||
1053 | |||
1054 | my_plvl = parse_version_string (ver, &my_major, &my_minor, &my_micro); | ||
1055 | if (!my_plvl) | ||
1056 | return NULL; /* very strange our own version is bogus */ | ||
1057 | rq_plvl = parse_version_string (req_version, &rq_major, &rq_minor, | ||
1058 | &rq_micro); | ||
1059 | if (!rq_plvl) | ||
1060 | return NULL; /* req version string is invalid */ | ||
1061 | |||
1062 | if (my_major > rq_major | ||
1063 | || (my_major == rq_major && my_minor > rq_minor) | ||
1064 | || (my_major == rq_major && my_minor == rq_minor | ||
1065 | && my_micro > rq_micro) | ||
1066 | || (my_major == rq_major && my_minor == rq_minor | ||
1067 | && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0)) | ||
1068 | { | ||
1069 | return ver; | ||
1070 | } | ||
1071 | return NULL; | ||
1072 | } | ||
diff --git a/src/daemon/https/minitasn1/parser_aux.h b/src/daemon/https/minitasn1/parser_aux.h index 88b505bb..ae54c3be 100644 --- a/src/daemon/https/minitasn1/parser_aux.h +++ b/src/daemon/https/minitasn1/parser_aux.h | |||
@@ -15,18 +15,8 @@ node_asn *MHD__asn1_set_name (node_asn * node, const char *name); | |||
15 | 15 | ||
16 | node_asn *MHD__asn1_set_right (node_asn * node, node_asn * right); | 16 | node_asn *MHD__asn1_set_right (node_asn * node, node_asn * right); |
17 | 17 | ||
18 | node_asn *MHD__asn1_get_right (node_asn * node); | ||
19 | |||
20 | node_asn *MHD__asn1_get_last_right (node_asn * node); | ||
21 | |||
22 | node_asn *MHD__asn1_set_down (node_asn * node, node_asn * down); | 18 | node_asn *MHD__asn1_set_down (node_asn * node, node_asn * down); |
23 | 19 | ||
24 | char *MHD__asn1_get_name (node_asn * node); | ||
25 | |||
26 | node_asn *MHD__asn1_get_down (node_asn * node); | ||
27 | |||
28 | node_asn *MHD__asn1_mod_type (node_asn * node, unsigned int value); | ||
29 | |||
30 | void MHD__asn1_remove_node (node_asn * node); | 20 | void MHD__asn1_remove_node (node_asn * node); |
31 | 21 | ||
32 | void MHD__asn1_delete_list (void); | 22 | void MHD__asn1_delete_list (void); |
@@ -41,10 +31,7 @@ MHD__asn1_retCode MHD__asn1_change_integer_value (ASN1_TYPE node); | |||
41 | 31 | ||
42 | MHD__asn1_retCode MHD__asn1_expand_object_id (ASN1_TYPE node); | 32 | MHD__asn1_retCode MHD__asn1_expand_object_id (ASN1_TYPE node); |
43 | 33 | ||
44 | MHD__asn1_retCode MHD__asn1_type_set_config (ASN1_TYPE node); | ||
45 | |||
46 | MHD__asn1_retCode MHD__asn1_check_identifier (ASN1_TYPE node); | 34 | MHD__asn1_retCode MHD__asn1_check_identifier (ASN1_TYPE node); |
47 | 35 | ||
48 | MHD__asn1_retCode MHD__asn1_set_default_tag (ASN1_TYPE node); | ||
49 | 36 | ||
50 | #endif | 37 | #endif |
diff --git a/src/daemon/https/minitasn1/structure.c b/src/daemon/https/minitasn1/structure.c index af5fdf75..6a910af6 100644 --- a/src/daemon/https/minitasn1/structure.c +++ b/src/daemon/https/minitasn1/structure.c | |||
@@ -37,6 +37,9 @@ | |||
37 | 37 | ||
38 | extern char MHD__asn1_identifierMissing[]; | 38 | extern char MHD__asn1_identifierMissing[]; |
39 | 39 | ||
40 | static node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name); | ||
41 | |||
42 | |||
40 | 43 | ||
41 | /******************************************************/ | 44 | /******************************************************/ |
42 | /* Function : MHD__asn1_add_node_only */ | 45 | /* Function : MHD__asn1_add_node_only */ |
@@ -79,85 +82,6 @@ MHD__asn1_find_left (node_asn * node) | |||
79 | } | 82 | } |
80 | 83 | ||
81 | 84 | ||
82 | MHD__asn1_retCode | ||
83 | MHD__asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name, | ||
84 | char *vector_name) | ||
85 | { | ||
86 | FILE *file; | ||
87 | node_asn *p; | ||
88 | unsigned long t; | ||
89 | |||
90 | file = fopen (output_file_name, "w"); | ||
91 | |||
92 | if (file == NULL) | ||
93 | return ASN1_FILE_NOT_FOUND; | ||
94 | |||
95 | fprintf (file, "#if HAVE_CONFIG_H\n"); | ||
96 | fprintf (file, "# include \"config.h\"\n"); | ||
97 | fprintf (file, "#endif\n\n"); | ||
98 | |||
99 | fprintf (file, "#include <libtasn1.h>\n\n"); | ||
100 | |||
101 | fprintf (file, "extern const ASN1_ARRAY_TYPE %s[]={\n", vector_name); | ||
102 | |||
103 | p = pointer; | ||
104 | |||
105 | while (p) | ||
106 | { | ||
107 | fprintf (file, " {"); | ||
108 | |||
109 | if (p->name) | ||
110 | fprintf (file, "\"%s\",", p->name); | ||
111 | else | ||
112 | fprintf (file, "0,"); | ||
113 | |||
114 | t = p->type; | ||
115 | if (p->down) | ||
116 | t |= CONST_DOWN; | ||
117 | if (p->right) | ||
118 | t |= CONST_RIGHT; | ||
119 | |||
120 | fprintf (file, "%lu,", t); | ||
121 | |||
122 | if (p->value) | ||
123 | fprintf (file, "\"%s\"},\n", p->value); | ||
124 | else | ||
125 | fprintf (file, "0},\n"); | ||
126 | |||
127 | if (p->down) | ||
128 | { | ||
129 | p = p->down; | ||
130 | } | ||
131 | else if (p->right) | ||
132 | { | ||
133 | p = p->right; | ||
134 | } | ||
135 | else | ||
136 | { | ||
137 | while (1) | ||
138 | { | ||
139 | p = MHD__asn1_find_up (p); | ||
140 | if (p == pointer) | ||
141 | { | ||
142 | p = NULL; | ||
143 | break; | ||
144 | } | ||
145 | if (p->right) | ||
146 | { | ||
147 | p = p->right; | ||
148 | break; | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | fprintf (file, " {0,0,0}\n};\n"); | ||
155 | |||
156 | fclose (file); | ||
157 | |||
158 | return ASN1_SUCCESS; | ||
159 | } | ||
160 | |||
161 | 85 | ||
162 | /** | 86 | /** |
163 | * MHD__asn1_array2tree - Creates the structures needed to manage the ASN1 definitions. | 87 | * MHD__asn1_array2tree - Creates the structures needed to manage the ASN1 definitions. |
@@ -455,7 +379,7 @@ MHD__asn1_copy_structure3 (node_asn * source_node) | |||
455 | } | 379 | } |
456 | 380 | ||
457 | 381 | ||
458 | node_asn * | 382 | static node_asn * |
459 | MHD__asn1_copy_structure2 (node_asn * root, const char *source_name) | 383 | MHD__asn1_copy_structure2 (node_asn * root, const char *source_name) |
460 | { | 384 | { |
461 | node_asn *source_node; | 385 | node_asn *source_node; |
@@ -467,7 +391,7 @@ MHD__asn1_copy_structure2 (node_asn * root, const char *source_name) | |||
467 | } | 391 | } |
468 | 392 | ||
469 | 393 | ||
470 | MHD__asn1_retCode | 394 | static MHD__asn1_retCode |
471 | MHD__asn1_type_choice_config (node_asn * node) | 395 | MHD__asn1_type_choice_config (node_asn * node) |
472 | { | 396 | { |
473 | node_asn *p, *p2, *p3, *p4; | 397 | node_asn *p, *p2, *p3, *p4; |
@@ -497,7 +421,7 @@ MHD__asn1_type_choice_config (node_asn * node) | |||
497 | if (type_field (p3->type) == TYPE_TAG) | 421 | if (type_field (p3->type) == TYPE_TAG) |
498 | { | 422 | { |
499 | p4 = MHD__asn1_add_node_only (p3->type); | 423 | p4 = MHD__asn1_add_node_only (p3->type); |
500 | tlen = strlen (p3->value); | 424 | tlen = strlen ((const char*) p3->value); |
501 | if (tlen > 0) | 425 | if (tlen > 0) |
502 | MHD__asn1_set_value (p4, p3->value, tlen + 1); | 426 | MHD__asn1_set_value (p4, p3->value, tlen + 1); |
503 | MHD__asn1_set_right (p4, p2->down); | 427 | MHD__asn1_set_right (p4, p2->down); |
@@ -552,7 +476,7 @@ MHD__asn1_type_choice_config (node_asn * node) | |||
552 | } | 476 | } |
553 | 477 | ||
554 | 478 | ||
555 | MHD__asn1_retCode | 479 | static MHD__asn1_retCode |
556 | MHD__asn1_expand_identifier (node_asn ** node, node_asn * root) | 480 | MHD__asn1_expand_identifier (node_asn ** node, node_asn * root) |
557 | { | 481 | { |
558 | node_asn *p, *p2, *p3; | 482 | node_asn *p, *p2, *p3; |
@@ -573,7 +497,7 @@ MHD__asn1_expand_identifier (node_asn ** node, node_asn * root) | |||
573 | { | 497 | { |
574 | MHD__asn1_str_cpy (name2, sizeof (name2), root->name); | 498 | MHD__asn1_str_cpy (name2, sizeof (name2), root->name); |
575 | MHD__asn1_str_cat (name2, sizeof (name2), "."); | 499 | MHD__asn1_str_cat (name2, sizeof (name2), "."); |
576 | MHD__asn1_str_cat (name2, sizeof (name2), p->value); | 500 | MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p->value); |
577 | p2 = MHD__asn1_copy_structure2 (root, name2); | 501 | p2 = MHD__asn1_copy_structure2 (root, name2); |
578 | if (p2 == NULL) | 502 | if (p2 == NULL) |
579 | { | 503 | { |
@@ -704,370 +628,6 @@ MHD__asn1_create_element (ASN1_TYPE definitions, const char *source_name, | |||
704 | 628 | ||
705 | 629 | ||
706 | /** | 630 | /** |
707 | * MHD__asn1_print_structure - Prints on the standard output the structure's tree | ||
708 | * @out: pointer to the output file (e.g. stdout). | ||
709 | * @structure: pointer to the structure that you want to visit. | ||
710 | * @name: an element of the structure | ||
711 | * @mode: specify how much of the structure to print, can be | ||
712 | * %ASN1_PRINT_NAME, %ASN1_PRINT_NAME_TYPE, | ||
713 | * %ASN1_PRINT_NAME_TYPE_VALUE, or %ASN1_PRINT_ALL. | ||
714 | * | ||
715 | * Prints on the @out file descriptor the structure's tree starting | ||
716 | * from the @name element inside the structure @structure. | ||
717 | **/ | ||
718 | void | ||
719 | MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name, | ||
720 | int mode) | ||
721 | { | ||
722 | node_asn *p, *root; | ||
723 | int k, indent = 0, len, len2, len3; | ||
724 | |||
725 | if (out == NULL) | ||
726 | return; | ||
727 | |||
728 | root = MHD__asn1_find_node (structure, name); | ||
729 | |||
730 | if (root == NULL) | ||
731 | return; | ||
732 | |||
733 | p = root; | ||
734 | while (p) | ||
735 | { | ||
736 | if (mode == ASN1_PRINT_ALL) | ||
737 | { | ||
738 | for (k = 0; k < indent; k++) | ||
739 | fprintf (out, " "); | ||
740 | fprintf (out, "name:"); | ||
741 | if (p->name) | ||
742 | fprintf (out, "%s ", p->name); | ||
743 | else | ||
744 | fprintf (out, "NULL "); | ||
745 | } | ||
746 | else | ||
747 | { | ||
748 | switch (type_field (p->type)) | ||
749 | { | ||
750 | case TYPE_CONSTANT: | ||
751 | case TYPE_TAG: | ||
752 | case TYPE_SIZE: | ||
753 | break; | ||
754 | default: | ||
755 | for (k = 0; k < indent; k++) | ||
756 | fprintf (out, " "); | ||
757 | fprintf (out, "name:"); | ||
758 | if (p->name) | ||
759 | fprintf (out, "%s ", p->name); | ||
760 | else | ||
761 | fprintf (out, "NULL "); | ||
762 | } | ||
763 | } | ||
764 | |||
765 | if (mode != ASN1_PRINT_NAME) | ||
766 | { | ||
767 | switch (type_field (p->type)) | ||
768 | { | ||
769 | case TYPE_CONSTANT: | ||
770 | if (mode == ASN1_PRINT_ALL) | ||
771 | fprintf (out, "type:CONST"); | ||
772 | break; | ||
773 | case TYPE_TAG: | ||
774 | if (mode == ASN1_PRINT_ALL) | ||
775 | fprintf (out, "type:TAG"); | ||
776 | break; | ||
777 | case TYPE_SIZE: | ||
778 | if (mode == ASN1_PRINT_ALL) | ||
779 | fprintf (out, "type:SIZE"); | ||
780 | break; | ||
781 | case TYPE_DEFAULT: | ||
782 | fprintf (out, "type:DEFAULT"); | ||
783 | break; | ||
784 | case TYPE_NULL: | ||
785 | fprintf (out, "type:NULL"); | ||
786 | break; | ||
787 | case TYPE_IDENTIFIER: | ||
788 | fprintf (out, "type:IDENTIFIER"); | ||
789 | break; | ||
790 | case TYPE_INTEGER: | ||
791 | fprintf (out, "type:INTEGER"); | ||
792 | break; | ||
793 | case TYPE_ENUMERATED: | ||
794 | fprintf (out, "type:ENUMERATED"); | ||
795 | break; | ||
796 | case TYPE_TIME: | ||
797 | fprintf (out, "type:TIME"); | ||
798 | break; | ||
799 | case TYPE_BOOLEAN: | ||
800 | fprintf (out, "type:BOOLEAN"); | ||
801 | break; | ||
802 | case TYPE_SEQUENCE: | ||
803 | fprintf (out, "type:SEQUENCE"); | ||
804 | break; | ||
805 | case TYPE_BIT_STRING: | ||
806 | fprintf (out, "type:BIT_STR"); | ||
807 | break; | ||
808 | case TYPE_OCTET_STRING: | ||
809 | fprintf (out, "type:OCT_STR"); | ||
810 | break; | ||
811 | case TYPE_GENERALSTRING: | ||
812 | fprintf (out, "type:GENERALSTRING"); | ||
813 | break; | ||
814 | case TYPE_SEQUENCE_OF: | ||
815 | fprintf (out, "type:SEQ_OF"); | ||
816 | break; | ||
817 | case TYPE_OBJECT_ID: | ||
818 | fprintf (out, "type:OBJ_ID"); | ||
819 | break; | ||
820 | case TYPE_ANY: | ||
821 | fprintf (out, "type:ANY"); | ||
822 | break; | ||
823 | case TYPE_SET: | ||
824 | fprintf (out, "type:SET"); | ||
825 | break; | ||
826 | case TYPE_SET_OF: | ||
827 | fprintf (out, "type:SET_OF"); | ||
828 | break; | ||
829 | case TYPE_CHOICE: | ||
830 | fprintf (out, "type:CHOICE"); | ||
831 | break; | ||
832 | case TYPE_DEFINITIONS: | ||
833 | fprintf (out, "type:DEFINITIONS"); | ||
834 | break; | ||
835 | default: | ||
836 | break; | ||
837 | } | ||
838 | } | ||
839 | |||
840 | if ((mode == ASN1_PRINT_NAME_TYPE_VALUE) || (mode == ASN1_PRINT_ALL)) | ||
841 | { | ||
842 | switch (type_field (p->type)) | ||
843 | { | ||
844 | case TYPE_CONSTANT: | ||
845 | if (mode == ASN1_PRINT_ALL) | ||
846 | if (p->value) | ||
847 | fprintf (out, " value:%s", p->value); | ||
848 | break; | ||
849 | case TYPE_TAG: | ||
850 | if (mode == ASN1_PRINT_ALL) | ||
851 | if (p->value) | ||
852 | fprintf (out, " value:%s", p->value); | ||
853 | break; | ||
854 | case TYPE_SIZE: | ||
855 | if (mode == ASN1_PRINT_ALL) | ||
856 | if (p->value) | ||
857 | fprintf (out, " value:%s", p->value); | ||
858 | break; | ||
859 | case TYPE_DEFAULT: | ||
860 | if (p->value) | ||
861 | fprintf (out, " value:%s", p->value); | ||
862 | else if (p->type & CONST_TRUE) | ||
863 | fprintf (out, " value:TRUE"); | ||
864 | else if (p->type & CONST_FALSE) | ||
865 | fprintf (out, " value:FALSE"); | ||
866 | break; | ||
867 | case TYPE_IDENTIFIER: | ||
868 | if (p->value) | ||
869 | fprintf (out, " value:%s", p->value); | ||
870 | break; | ||
871 | case TYPE_INTEGER: | ||
872 | if (p->value) | ||
873 | { | ||
874 | len2 = -1; | ||
875 | len = MHD__asn1_get_length_der (p->value, p->value_len, &len2); | ||
876 | fprintf (out, " value:0x"); | ||
877 | if (len > 0) | ||
878 | for (k = 0; k < len; k++) | ||
879 | fprintf (out, "%02x", (p->value)[k + len2]); | ||
880 | } | ||
881 | break; | ||
882 | case TYPE_ENUMERATED: | ||
883 | if (p->value) | ||
884 | { | ||
885 | len2 = -1; | ||
886 | len = MHD__asn1_get_length_der (p->value, p->value_len, &len2); | ||
887 | fprintf (out, " value:0x"); | ||
888 | if (len > 0) | ||
889 | for (k = 0; k < len; k++) | ||
890 | fprintf (out, "%02x", (p->value)[k + len2]); | ||
891 | } | ||
892 | break; | ||
893 | case TYPE_TIME: | ||
894 | if (p->value) | ||
895 | fprintf (out, " value:%s", p->value); | ||
896 | break; | ||
897 | case TYPE_BOOLEAN: | ||
898 | if (p->value) | ||
899 | { | ||
900 | if (p->value[0] == 'T') | ||
901 | fprintf (out, " value:TRUE"); | ||
902 | else if (p->value[0] == 'F') | ||
903 | fprintf (out, " value:FALSE"); | ||
904 | } | ||
905 | break; | ||
906 | case TYPE_BIT_STRING: | ||
907 | if (p->value) | ||
908 | { | ||
909 | len2 = -1; | ||
910 | len = MHD__asn1_get_length_der (p->value, p->value_len, &len2); | ||
911 | if (len > 0) | ||
912 | { | ||
913 | fprintf (out, " value(%i):", | ||
914 | (len - 1) * 8 - (p->value[len2])); | ||
915 | for (k = 1; k < len; k++) | ||
916 | fprintf (out, "%02x", (p->value)[k + len2]); | ||
917 | } | ||
918 | } | ||
919 | break; | ||
920 | case TYPE_OCTET_STRING: | ||
921 | if (p->value) | ||
922 | { | ||
923 | len2 = -1; | ||
924 | len = MHD__asn1_get_length_der (p->value, p->value_len, &len2); | ||
925 | fprintf (out, " value:"); | ||
926 | if (len > 0) | ||
927 | for (k = 0; k < len; k++) | ||
928 | fprintf (out, "%02x", (p->value)[k + len2]); | ||
929 | } | ||
930 | break; | ||
931 | case TYPE_GENERALSTRING: | ||
932 | if (p->value) | ||
933 | { | ||
934 | len2 = -1; | ||
935 | len = MHD__asn1_get_length_der (p->value, p->value_len, &len2); | ||
936 | fprintf (out, " value:"); | ||
937 | if (len > 0) | ||
938 | for (k = 0; k < len; k++) | ||
939 | fprintf (out, "%02x", (p->value)[k + len2]); | ||
940 | } | ||
941 | break; | ||
942 | case TYPE_OBJECT_ID: | ||
943 | if (p->value) | ||
944 | fprintf (out, " value:%s", p->value); | ||
945 | break; | ||
946 | case TYPE_ANY: | ||
947 | if (p->value) | ||
948 | { | ||
949 | len3 = -1; | ||
950 | len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3); | ||
951 | fprintf (out, " value:"); | ||
952 | if (len2 > 0) | ||
953 | for (k = 0; k < len2; k++) | ||
954 | fprintf (out, "%02x", (p->value)[k + len3]); | ||
955 | } | ||
956 | break; | ||
957 | case TYPE_SET: | ||
958 | case TYPE_SET_OF: | ||
959 | case TYPE_CHOICE: | ||
960 | case TYPE_DEFINITIONS: | ||
961 | case TYPE_SEQUENCE_OF: | ||
962 | case TYPE_SEQUENCE: | ||
963 | case TYPE_NULL: | ||
964 | break; | ||
965 | default: | ||
966 | break; | ||
967 | } | ||
968 | } | ||
969 | |||
970 | if (mode == ASN1_PRINT_ALL) | ||
971 | { | ||
972 | if (p->type & 0x1FFFFF00) | ||
973 | { | ||
974 | fprintf (out, " attr:"); | ||
975 | if (p->type & CONST_UNIVERSAL) | ||
976 | fprintf (out, "UNIVERSAL,"); | ||
977 | if (p->type & CONST_PRIVATE) | ||
978 | fprintf (out, "PRIVATE,"); | ||
979 | if (p->type & CONST_APPLICATION) | ||
980 | fprintf (out, "APPLICATION,"); | ||
981 | if (p->type & CONST_EXPLICIT) | ||
982 | fprintf (out, "EXPLICIT,"); | ||
983 | if (p->type & CONST_IMPLICIT) | ||
984 | fprintf (out, "IMPLICIT,"); | ||
985 | if (p->type & CONST_TAG) | ||
986 | fprintf (out, "TAG,"); | ||
987 | if (p->type & CONST_DEFAULT) | ||
988 | fprintf (out, "DEFAULT,"); | ||
989 | if (p->type & CONST_TRUE) | ||
990 | fprintf (out, "TRUE,"); | ||
991 | if (p->type & CONST_FALSE) | ||
992 | fprintf (out, "FALSE,"); | ||
993 | if (p->type & CONST_LIST) | ||
994 | fprintf (out, "LIST,"); | ||
995 | if (p->type & CONST_MIN_MAX) | ||
996 | fprintf (out, "MIN_MAX,"); | ||
997 | if (p->type & CONST_OPTION) | ||
998 | fprintf (out, "OPTION,"); | ||
999 | if (p->type & CONST_1_PARAM) | ||
1000 | fprintf (out, "1_PARAM,"); | ||
1001 | if (p->type & CONST_SIZE) | ||
1002 | fprintf (out, "SIZE,"); | ||
1003 | if (p->type & CONST_DEFINED_BY) | ||
1004 | fprintf (out, "DEF_BY,"); | ||
1005 | if (p->type & CONST_GENERALIZED) | ||
1006 | fprintf (out, "GENERALIZED,"); | ||
1007 | if (p->type & CONST_UTC) | ||
1008 | fprintf (out, "UTC,"); | ||
1009 | if (p->type & CONST_SET) | ||
1010 | fprintf (out, "SET,"); | ||
1011 | if (p->type & CONST_NOT_USED) | ||
1012 | fprintf (out, "NOT_USED,"); | ||
1013 | if (p->type & CONST_ASSIGN) | ||
1014 | fprintf (out, "ASSIGNMENT,"); | ||
1015 | } | ||
1016 | } | ||
1017 | |||
1018 | if (mode == ASN1_PRINT_ALL) | ||
1019 | { | ||
1020 | fprintf (out, "\n"); | ||
1021 | } | ||
1022 | else | ||
1023 | { | ||
1024 | switch (type_field (p->type)) | ||
1025 | { | ||
1026 | case TYPE_CONSTANT: | ||
1027 | case TYPE_TAG: | ||
1028 | case TYPE_SIZE: | ||
1029 | break; | ||
1030 | default: | ||
1031 | fprintf (out, "\n"); | ||
1032 | } | ||
1033 | } | ||
1034 | |||
1035 | if (p->down) | ||
1036 | { | ||
1037 | p = p->down; | ||
1038 | indent += 2; | ||
1039 | } | ||
1040 | else if (p == root) | ||
1041 | { | ||
1042 | p = NULL; | ||
1043 | break; | ||
1044 | } | ||
1045 | else if (p->right) | ||
1046 | p = p->right; | ||
1047 | else | ||
1048 | { | ||
1049 | while (1) | ||
1050 | { | ||
1051 | p = MHD__asn1_find_up (p); | ||
1052 | if (p == root) | ||
1053 | { | ||
1054 | p = NULL; | ||
1055 | break; | ||
1056 | } | ||
1057 | indent -= 2; | ||
1058 | if (p->right) | ||
1059 | { | ||
1060 | p = p->right; | ||
1061 | break; | ||
1062 | } | ||
1063 | } | ||
1064 | } | ||
1065 | } | ||
1066 | } | ||
1067 | |||
1068 | |||
1069 | |||
1070 | /** | ||
1071 | * MHD__asn1_number_of_elements - Counts the number of elements of a structure. | 631 | * MHD__asn1_number_of_elements - Counts the number of elements of a structure. |
1072 | * @element: pointer to the root of an ASN1 structure. | 632 | * @element: pointer to the root of an ASN1 structure. |
1073 | * @name: the name of a sub-structure of ROOT. | 633 | * @name: the name of a sub-structure of ROOT. |
diff --git a/src/daemon/https/minitasn1/structure.h b/src/daemon/https/minitasn1/structure.h index e7941639..c447fc92 100644 --- a/src/daemon/https/minitasn1/structure.h +++ b/src/daemon/https/minitasn1/structure.h | |||
@@ -8,13 +8,8 @@ | |||
8 | #ifndef _STRUCTURE_H | 8 | #ifndef _STRUCTURE_H |
9 | #define _STRUCTURE_H | 9 | #define _STRUCTURE_H |
10 | 10 | ||
11 | MHD__asn1_retCode MHD__asn1_create_static_structure (node_asn * pointer, | ||
12 | char *output_file_name, | ||
13 | char *vector_name); | ||
14 | |||
15 | node_asn *MHD__asn1_copy_structure3 (node_asn * source_node); | 11 | node_asn *MHD__asn1_copy_structure3 (node_asn * source_node); |
16 | 12 | ||
17 | node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name); | ||
18 | 13 | ||
19 | node_asn *MHD__asn1_add_node_only (unsigned int type); | 14 | node_asn *MHD__asn1_add_node_only (unsigned int type); |
20 | 15 | ||