From: Simon Josefsson Date: Wed, 8 Mar 2006 14:40:39 +0000 (+0000) Subject: Update. X-Git-Tag: gnutls_1_3_5~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6bf9777821ef28e4e4572e9ad840c8d445d8a6a;p=thirdparty%2Fgnutls.git Update. --- diff --git a/lib/minitasn1/coding.c b/lib/minitasn1/coding.c index 41c01d9afc..96ccb99d25 100644 --- a/lib/minitasn1/coding.c +++ b/lib/minitasn1/coding.c @@ -756,7 +756,7 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len, asn1_retCode ris; unsigned char* der = ider; - node=_asn1_find_node(element,name); + node=asn1_find_node(element,name); if(node==NULL) return ASN1_ELEMENT_NOT_FOUND; max_len=*len; @@ -937,7 +937,7 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len, move=RIGHT; continue; } - else p=_asn1_find_up(p); + else p=asn1_find_up(p); move=UP; } if(move==UP){ @@ -988,7 +988,7 @@ asn1_der_coding(ASN1_TYPE element,const char *name,void *ider,int *len, if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } *len=counter; diff --git a/lib/minitasn1/decoding.c b/lib/minitasn1/decoding.c index cfed98f5f1..f0e3e974e2 100644 --- a/lib/minitasn1/decoding.c +++ b/lib/minitasn1/decoding.c @@ -447,7 +447,7 @@ _asn1_delete_not_used(node_asn *node) p2=NULL; if(p!=node){ p2=_asn1_find_left(p); - if(!p2) p2=_asn1_find_up(p); + if(!p2) p2=asn1_find_up(p); } asn1_delete_structure(&p); p=p2; @@ -463,7 +463,7 @@ _asn1_delete_not_used(node_asn *node) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==node){ p=NULL; break; @@ -661,7 +661,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len, ris=ASN1_SUCCESS; if(move!=UP){ if(p->type&CONST_SET){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(len2==-1){ if(!der[counter] && !der[counter+1]){ @@ -708,7 +708,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len, } if((p->type&CONST_OPTION) || (p->type&CONST_DEFAULT)){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(counter==len2){ if(p->right){ @@ -758,7 +758,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len, } if((p->type&CONST_OPTION) || (p->type&CONST_DEFAULT)){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if((len2!=-1) && (counter>len2)) ris=ASN1_TAG_ERROR; } @@ -1035,7 +1035,7 @@ asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len, if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } _asn1_delete_not_used(*element); @@ -1144,7 +1144,7 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName, if(move!=UP){ if(p->type&CONST_SET){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(counter==len2){ p=p2; @@ -1183,7 +1183,7 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName, } if((p->type&CONST_OPTION) || (p->type&CONST_DEFAULT)){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(counter==len2){ if(p->right){ @@ -1233,7 +1233,7 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName, } if((p->type&CONST_OPTION) || (p->type&CONST_DEFAULT)){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(counter>len2) ris=ASN1_TAG_ERROR; } @@ -1628,7 +1628,7 @@ asn1_der_decoding_element(ASN1_TYPE *structure,const char *elementName, } if(move==UP){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(state != FOUND){ dot_p=char_p=currentName; @@ -1709,7 +1709,7 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len, if(node==ASN1_TYPE_EMPTY) return ASN1_ELEMENT_NOT_FOUND; - node_to_find=_asn1_find_node(node,name_element); + node_to_find=asn1_find_node(node,name_element); if(node_to_find==NULL) return ASN1_ELEMENT_NOT_FOUND; @@ -1729,7 +1729,7 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len, if(move!=UP){ if(p->type&CONST_SET){ - p2=_asn1_find_up(p); + p2=asn1_find_up(p); len2=strtol(p2->value,NULL,10); if(len2==-1){ if(!der[counter] && !der[counter+1]){ @@ -1929,7 +1929,7 @@ asn1_der_decoding_startEnd(ASN1_TYPE element,const void *ider,int len, if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } return ASN1_ELEMENT_NOT_FOUND; @@ -1989,7 +1989,7 @@ asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element) break; } - p3=_asn1_find_up(p); + p3=asn1_find_up(p); if(!p3){ retCode=ASN1_ERROR_TYPE_ANY; @@ -2005,8 +2005,8 @@ asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element) if((!p3) || (type_field(p3->type)!=TYPE_OBJECT_ID) || (p3->value==NULL)){ - p3=_asn1_find_up(p); - p3=_asn1_find_up(p3); + p3=asn1_find_up(p); + p3=asn1_find_up(p3); if(!p3){ retCode=ASN1_ERROR_TYPE_ANY; @@ -2114,7 +2114,7 @@ asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==*element){ p=NULL; break; @@ -2170,7 +2170,7 @@ asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element, if((definitions==ASN1_TYPE_EMPTY) || (*element==ASN1_TYPE_EMPTY)) return ASN1_ELEMENT_NOT_FOUND; - octetNode=_asn1_find_node(*element,octetName); + octetNode=asn1_find_node(*element,octetName); if(octetNode==ASN1_TYPE_EMPTY) return ASN1_ELEMENT_NOT_FOUND; if(type_field(octetNode->type)!=TYPE_OCTET_STRING) @@ -2178,7 +2178,7 @@ asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element, if(octetNode->value==NULL) return ASN1_VALUE_NOT_FOUND; - objectNode=_asn1_find_node(*element,objectName); + objectNode=asn1_find_node(*element,objectName); if(objectNode==ASN1_TYPE_EMPTY) return ASN1_ELEMENT_NOT_FOUND; diff --git a/lib/minitasn1/element.c b/lib/minitasn1/element.c index 6ec30d08e3..dc98c2fc9b 100644 --- a/lib/minitasn1/element.c +++ b/lib/minitasn1/element.c @@ -51,7 +51,7 @@ _asn1_hierarchical_name(node_asn *node,char *name,int name_size) _asn1_str_cat(name,name_size,"."); _asn1_str_cat(name,name_size,tmp_name); } - p=_asn1_find_up(p); + p=asn1_find_up(p); } if(name[0]==0) _asn1_str_cpy(name,name_size,"ROOT"); @@ -268,7 +268,7 @@ asn1_write_value(ASN1_TYPE node_root,const char *name, int len2,k,k2,negative; const unsigned char* value = ivalue; - node=_asn1_find_node(node_root,name); + node=asn1_find_node(node_root,name); if(node==NULL) return ASN1_ELEMENT_NOT_FOUND; if((node->type & CONST_OPTION) && (value==NULL) && (len==0)){ @@ -621,7 +621,7 @@ asn1_read_value(ASN1_TYPE root,const char *name,void* ivalue, int *len) int value_size = *len; unsigned char* value = ivalue; - node=_asn1_find_node(root,name); + node=asn1_find_node(root,name); if(node==NULL) return ASN1_ELEMENT_NOT_FOUND; if((type_field(node->type)!=TYPE_NULL) && @@ -760,7 +760,7 @@ asn1_read_tag(node_asn *root,const char *name,int *tagValue, int *classValue) { node_asn *node,*p,*pTag; - node=_asn1_find_node(root,name); + node=asn1_find_node(root,name); if(node==NULL) return ASN1_ELEMENT_NOT_FOUND; p=node->down; diff --git a/lib/minitasn1/int.h b/lib/minitasn1/int.h index 0851689a87..79d9d9f71f 100644 --- a/lib/minitasn1/int.h +++ b/lib/minitasn1/int.h @@ -42,72 +42,53 @@ #define RIGHT 2 #define DOWN 3 -/****************************************/ -/* Returns the first 8 bits. */ -/* Used with the field type of node_asn */ -/****************************************/ -#define type_field(x) (x&0xFF) - -/* List of constants for field type of typedef node_asn */ -#define TYPE_CONSTANT 1 -#define TYPE_IDENTIFIER 2 -#define TYPE_INTEGER 3 -#define TYPE_BOOLEAN 4 -#define TYPE_SEQUENCE 5 -#define TYPE_BIT_STRING 6 -#define TYPE_OCTET_STRING 7 -#define TYPE_TAG 8 -#define TYPE_DEFAULT 9 -#define TYPE_SIZE 10 -#define TYPE_SEQUENCE_OF 11 -#define TYPE_OBJECT_ID 12 -#define TYPE_ANY 13 -#define TYPE_SET 14 -#define TYPE_SET_OF 15 -#define TYPE_DEFINITIONS 16 -#define TYPE_TIME 17 -#define TYPE_CHOICE 18 -#define TYPE_IMPORTS 19 -#define TYPE_NULL 20 -#define TYPE_ENUMERATED 21 -#define TYPE_GENERALSTRING 27 - - -/***********************************************************************/ -/* List of constants to better specify the type of typedef node_asn. */ -/***********************************************************************/ -/* Used with TYPE_TAG */ -#define CONST_UNIVERSAL (1<<8) -#define CONST_PRIVATE (1<<9) -#define CONST_APPLICATION (1<<10) -#define CONST_EXPLICIT (1<<11) -#define CONST_IMPLICIT (1<<12) - -#define CONST_TAG (1<<13) /* Used in ASN.1 assignement */ -#define CONST_OPTION (1<<14) -#define CONST_DEFAULT (1<<15) -#define CONST_TRUE (1<<16) -#define CONST_FALSE (1<<17) - -#define CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */ -#define CONST_MIN_MAX (1<<19) - -#define CONST_1_PARAM (1<<20) - -#define CONST_SIZE (1<<21) - -#define CONST_DEFINED_BY (1<<22) - -#define CONST_GENERALIZED (1<<23) -#define CONST_UTC (1<<24) - -/* #define CONST_IMPORTS (1<<25) */ - -#define CONST_NOT_USED (1<<26) -#define CONST_SET (1<<27) -#define CONST_ASSIGN (1<<28) - -#define CONST_DOWN (1<<29) -#define CONST_RIGHT (1<<30) +#define type_field(x) ASN1_TYPE_FIELD(x) + +#define TYPE_CONSTANT ASN1_TYPE_CONSTANT +#define TYPE_IDENTIFIER ASN1_TYPE_IDENTIFIER +#define TYPE_INTEGER ASN1_TYPE_INTEGER +#define TYPE_BOOLEAN ASN1_TYPE_BOOLEAN +#define TYPE_SEQUENCE ASN1_TYPE_SEQUENCE +#define TYPE_BIT_STRING ASN1_TYPE_BIT_STRING +#define TYPE_OCTET_STRING ASN1_TYPE_OCTET_STRING +#define TYPE_TAG ASN1_TYPE_TAG +#define TYPE_DEFAULT ASN1_TYPE_DEFAULT +#define TYPE_SIZE ASN1_TYPE_SIZE +#define TYPE_SEQUENCE_OF ASN1_TYPE_SEQUENCE_OF +#define TYPE_OBJECT_ID ASN1_TYPE_OBJECT_ID +#define TYPE_ANY ASN1_TYPE_ANY +#define TYPE_SET ASN1_TYPE_SET +#define TYPE_SET_OF ASN1_TYPE_SET_OF +#define TYPE_DEFINITIONS ASN1_TYPE_DEFINITIONS +#define TYPE_TIME ASN1_TYPE_TIME +#define TYPE_CHOICE ASN1_TYPE_CHOICE +#define TYPE_IMPORTS ASN1_TYPE_IMPORTS +#define TYPE_NULL ASN1_TYPE_NULL +#define TYPE_ENUMERATED ASN1_TYPE_ENUMERATED +#define TYPE_GENERALSTRING ASN1_TYPE_GENERALSTRING + +#define CONST_UNIVERSAL ASN1_CONST_UNIVERSAL +#define CONST_PRIVATE ASN1_CONST_PRIVATE +#define CONST_APPLICATION ASN1_CONST_APPLICATION +#define CONST_EXPLICIT ASN1_CONST_EXPLICIT +#define CONST_IMPLICIT ASN1_CONST_IMPLICIT +#define CONST_TAG ASN1_CONST_TAG +#define CONST_OPTION ASN1_CONST_OPTION +#define CONST_DEFAULT ASN1_CONST_DEFAULT +#define CONST_TRUE ASN1_CONST_TRUE +#define CONST_FALSE ASN1_CONST_FALSE +#define CONST_LIST ASN1_CONST_LIST +#define CONST_MIN_MAX ASN1_CONST_MIN_MAX +#define CONST_1_PARAM ASN1_CONST_1_PARAM +#define CONST_SIZE ASN1_CONST_SIZE +#define CONST_DEFINED_BY ASN1_CONST_DEFINED_BY +#define CONST_GENERALIZED ASN1_CONST_GENERALIZED +#define CONST_UTC ASN1_CONST_UTC +/* #define CONST_IMPORTS ASN1_CONST_IMPORTS */ +#define CONST_NOT_USED ASN1_CONST_NOT_USED +#define CONST_SET ASN1_CONST_SET +#define CONST_ASSIGN ASN1_CONST_ASSIGN +#define CONST_DOWN ASN1_CONST_DOWN +#define CONST_RIGHT ASN1_CONST_RIGHT #endif /* INT_H */ diff --git a/lib/minitasn1/libtasn1.h b/lib/minitasn1/libtasn1.h index 9bde3418aa..ee02990264 100644 --- a/lib/minitasn1/libtasn1.h +++ b/lib/minitasn1/libtasn1.h @@ -24,25 +24,26 @@ #ifndef LIBTASN1_H # define LIBTASN1_H -#include /* for FILE* */ +#include /* for FILE* */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -#define LIBTASN1_VERSION "0.3.0" +#define LIBTASN1_VERSION "0.3.1" #include #include -#define MAX_NAME_SIZE 128 /* maximum number of characters of a name */ - /* inside a file with ASN1 definitons */ -#define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters */ - /* of a description message */ - /* (null character included) */ +#define MAX_NAME_SIZE 128 /* maximum number of characters of a name */ + /* inside a file with ASN1 definitons */ +#define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters */ + /* of a description message */ + /* (null character included) */ -typedef int asn1_retCode; /* type returned by libtasn1 functions */ + typedef int asn1_retCode; /* type returned by libtasn1 functions */ /*****************************************/ /* Errors returned by libtasn1 functions */ @@ -77,10 +78,10 @@ typedef int asn1_retCode; /* type returned by libtasn1 functions */ /*****************************************/ /* Constants returned by asn1_read_tag */ /*****************************************/ -#define ASN1_CLASS_UNIVERSAL 0x00 /* old: 1 */ -#define ASN1_CLASS_APPLICATION 0x40 /* old: 2 */ -#define ASN1_CLASS_CONTEXT_SPECIFIC 0x80 /* old: 3 */ -#define ASN1_CLASS_PRIVATE 0xC0 /* old: 4 */ +#define ASN1_CLASS_UNIVERSAL 0x00 /* old: 1 */ +#define ASN1_CLASS_APPLICATION 0x40 /* old: 2 */ +#define ASN1_CLASS_CONTEXT_SPECIFIC 0x80 /* old: 3 */ +#define ASN1_CLASS_PRIVATE 0xC0 /* old: 4 */ #define ASN1_CLASS_STRUCTURED 0x20 /*****************************************/ @@ -99,32 +100,93 @@ typedef int asn1_retCode; /* type returned by libtasn1 functions */ #define ASN1_TAG_NULL 0x05 #define ASN1_TAG_GENERALSTRING 0x1B +/******************************************************/ +/* List of constants for field type of typedef node_asn */ +/********************************************************/ +#define ASN1_TYPE_CONSTANT 1 +#define ASN1_TYPE_IDENTIFIER 2 +#define ASN1_TYPE_INTEGER 3 +#define ASN1_TYPE_BOOLEAN 4 +#define ASN1_TYPE_SEQUENCE 5 +#define ASN1_TYPE_BIT_STRING 6 +#define ASN1_TYPE_OCTET_STRING 7 +#define ASN1_TYPE_TAG 8 +#define ASN1_TYPE_DEFAULT 9 +#define ASN1_TYPE_SIZE 10 +#define ASN1_TYPE_SEQUENCE_OF 11 +#define ASN1_TYPE_OBJECT_ID 12 +#define ASN1_TYPE_ANY 13 +#define ASN1_TYPE_SET 14 +#define ASN1_TYPE_SET_OF 15 +#define ASN1_TYPE_DEFINITIONS 16 +#define ASN1_TYPE_TIME 17 +#define ASN1_TYPE_CHOICE 18 +#define ASN1_TYPE_IMPORTS 19 +#define ASN1_TYPE_NULL 20 +#define ASN1_TYPE_ENUMERATED 21 +#define ASN1_TYPE_GENERALSTRING 27 + +/***********************************************************************/ +/* List of constants to better specify the type of typedef node_asn. */ +/* Used with TYPE_TAG. */ +/***********************************************************************/ +#define ASN1_CONST_UNIVERSAL (1<<8) +#define ASN1_CONST_PRIVATE (1<<9) +#define ASN1_CONST_APPLICATION (1<<10) +#define ASN1_CONST_EXPLICIT (1<<11) +#define ASN1_CONST_IMPLICIT (1<<12) +#define ASN1_CONST_TAG (1<<13) /* Used in ASN.1 assignement */ +#define ASN1_CONST_OPTION (1<<14) +#define ASN1_CONST_DEFAULT (1<<15) +#define ASN1_CONST_TRUE (1<<16) +#define ASN1_CONST_FALSE (1<<17) +#define ASN1_CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */ +#define ASN1_CONST_MIN_MAX (1<<19) +#define ASN1_CONST_1_PARAM (1<<20) +#define ASN1_CONST_SIZE (1<<21) +#define ASN1_CONST_DEFINED_BY (1<<22) +#define ASN1_CONST_GENERALIZED (1<<23) +#define ASN1_CONST_UTC (1<<24) + /* #define ASN1_CONST_IMPORTS (1<<25) */ +#define ASN1_CONST_NOT_USED (1<<26) +#define ASN1_CONST_SET (1<<27) +#define ASN1_CONST_ASSIGN (1<<28) +#define ASN1_CONST_DOWN (1<<29) +#define ASN1_CONST_RIGHT (1<<30) + +/****************************************/ +/* Returns the first 8 bits. */ +/* Used with the field type of node_asn */ +/****************************************/ +#define ASN1_TYPE_FIELD(x) (x&0xFF) /******************************************************/ /* Structure definition used for the node of the tree */ /* that represent an ASN.1 DEFINITION. */ /******************************************************/ -typedef struct node_asn_struct{ - char *name; /* Node name */ - unsigned int type; /* Node type */ - unsigned char *value; /* Node value */ - int value_len; - struct node_asn_struct *down; /* Pointer to the son node */ - struct node_asn_struct *right; /* Pointer to the brother node */ - struct node_asn_struct *left; /* Pointer to the next list element */ -} node_asn; - -typedef node_asn* ASN1_TYPE; + typedef struct node_asn_struct + { + char *name; /* Node name */ + unsigned int type; /* Node type */ + unsigned char *value; /* Node value */ + int value_len; + struct node_asn_struct *down; /* Pointer to the son node */ + struct node_asn_struct *right; /* Pointer to the brother node */ + struct node_asn_struct *left; /* Pointer to the next list element */ + } node_asn; + + typedef node_asn *ASN1_TYPE; #define ASN1_TYPE_EMPTY NULL -struct static_struct_asn{ - char *name; /* Node name */ - unsigned int type; /* Node type */ - unsigned char *value; /* Node value */ -}; + struct static_struct_asn + { + char *name; /* Node name */ + unsigned int type; /* Node type */ + unsigned char *value; /* Node value */ + }; -typedef struct static_struct_asn ASN1_ARRAY_TYPE; + typedef struct static_struct_asn ASN1_ARRAY_TYPE; @@ -132,94 +194,108 @@ typedef struct static_struct_asn ASN1_ARRAY_TYPE; /* Functions definitions */ /***********************************/ -asn1_retCode asn1_parser2tree(const char *file_name,ASN1_TYPE *definitions, - char *errorDescription); + asn1_retCode asn1_parser2tree (const char *file_name, + ASN1_TYPE * definitions, + char *errorDescription); -asn1_retCode asn1_parser2array(const char *inputFileName,const char *outputFileName, - const char *vectorName,char *errorDescription); + asn1_retCode asn1_parser2array (const char *inputFileName, + const char *outputFileName, + const char *vectorName, + char *errorDescription); -asn1_retCode asn1_array2tree(const ASN1_ARRAY_TYPE *array, - ASN1_TYPE *definitions,char *errorDescription); + asn1_retCode asn1_array2tree (const ASN1_ARRAY_TYPE * array, + ASN1_TYPE * definitions, + char *errorDescription); -void asn1_print_structure(FILE *out,ASN1_TYPE structure,const char *name,int mode); + void asn1_print_structure (FILE *out, ASN1_TYPE structure, const char *name, + int mode); -asn1_retCode asn1_create_element(ASN1_TYPE definitions,const char *source_name, - ASN1_TYPE *element); + asn1_retCode asn1_create_element (ASN1_TYPE definitions, + const char *source_name, + ASN1_TYPE * element); -asn1_retCode asn1_delete_structure(ASN1_TYPE *structure); + asn1_retCode asn1_delete_structure (ASN1_TYPE * structure); -asn1_retCode asn1_delete_element(ASN1_TYPE structure,const char *element_name); + asn1_retCode asn1_delete_element (ASN1_TYPE structure, + const char *element_name); -asn1_retCode asn1_write_value(ASN1_TYPE node_root,const char *name, - const void *ivalue,int len); + asn1_retCode asn1_write_value (ASN1_TYPE node_root, const char *name, + const void *ivalue, int len); -asn1_retCode asn1_read_value(ASN1_TYPE root,const char *name, - void* ivalue,int *len); + asn1_retCode asn1_read_value (ASN1_TYPE root, const char *name, + void *ivalue, int *len); -asn1_retCode asn1_number_of_elements(ASN1_TYPE element,const char *name,int *num); + asn1_retCode asn1_number_of_elements (ASN1_TYPE element, const char *name, + int *num); -asn1_retCode asn1_der_coding(ASN1_TYPE element,const char *name, - void *ider,int *len, - char *ErrorDescription); + asn1_retCode asn1_der_coding (ASN1_TYPE element, const char *name, + void *ider, int *len, char *ErrorDescription); -asn1_retCode asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len, - char *errorDescription); + asn1_retCode asn1_der_decoding (ASN1_TYPE * element, const void *ider, + int len, char *errorDescription); -asn1_retCode asn1_der_decoding_element(ASN1_TYPE *structure, - const char *elementName, - const void *ider,int len, - char *errorDescription); + asn1_retCode asn1_der_decoding_element (ASN1_TYPE * structure, + const char *elementName, + const void *ider, int len, + char *errorDescription); -asn1_retCode asn1_der_decoding_startEnd(ASN1_TYPE element, - const void *ider,int len, - const char *name_element, - int *start,int *end); + asn1_retCode asn1_der_decoding_startEnd (ASN1_TYPE element, + const void *ider, int len, + const char *name_element, + int *start, int *end); -asn1_retCode asn1_expand_any_defined_by(ASN1_TYPE definitions, - ASN1_TYPE *element); + asn1_retCode asn1_expand_any_defined_by (ASN1_TYPE definitions, + ASN1_TYPE * element); -asn1_retCode asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element, - const char *octetName,const char *objectName); + asn1_retCode asn1_expand_octet_string (ASN1_TYPE definitions, + ASN1_TYPE * element, + const char *octetName, + const char *objectName); -asn1_retCode asn1_read_tag(node_asn *root,const char *name,int *tagValue, - int *classValue); + asn1_retCode asn1_read_tag (node_asn * root, const char *name, + int *tagValue, int *classValue); -const char* asn1_find_structure_from_oid(ASN1_TYPE definitions, - const char *oidValue); + const char *asn1_find_structure_from_oid (ASN1_TYPE definitions, + const char *oidValue); -const char *asn1_check_version( const char *req_version ); + const char *asn1_check_version (const char *req_version); -const char* libtasn1_strerror(asn1_retCode error); + const char *libtasn1_strerror (asn1_retCode error); -void libtasn1_perror(asn1_retCode error); + void libtasn1_perror (asn1_retCode error); /* DER utility functions. */ - int asn1_get_tag_der(const unsigned char *der, int der_len, - unsigned char *class,int *len, unsigned long *tag); + int asn1_get_tag_der (const unsigned char *der, int der_len, + unsigned char *class, int *len, unsigned long *tag); + + void asn1_octet_der (const unsigned char *str, int str_len, + unsigned char *der, int *der_len); + + asn1_retCode asn1_get_octet_der (const unsigned char *der, int der_len, + int *ret_len, unsigned char *str, + int str_size, int *str_len); - void asn1_octet_der(const unsigned char *str,int str_len, - unsigned char *der,int *der_len); + void asn1_bit_der (const unsigned char *str, int bit_len, + unsigned char *der, int *der_len); - asn1_retCode asn1_get_octet_der(const unsigned char *der, int der_len, - int *ret_len,unsigned char *str, - int str_size, int *str_len); + asn1_retCode asn1_get_bit_der (const unsigned char *der, int der_len, + int *ret_len, unsigned char *str, + int str_size, int *bit_len); - void asn1_bit_der(const unsigned char *str,int bit_len, - unsigned char *der,int *der_len); + signed long asn1_get_length_der (const unsigned char *der, int der_len, + int *len); - asn1_retCode asn1_get_bit_der(const unsigned char *der, int der_len, - int *ret_len,unsigned char *str, - int str_size, int *bit_len); + void asn1_length_der (unsigned long len, unsigned char *ans, int *ans_len); - signed long asn1_get_length_der(const unsigned char *der, int der_len, - int *len); +/* Other utility functions. */ - void asn1_length_der(unsigned long len,unsigned char *ans, int *ans_len); + ASN1_TYPE asn1_find_up (ASN1_TYPE node); + ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name); #ifdef __cplusplus } #endif -#endif /* LIBTASN1_H */ +#endif /* LIBTASN1_H */ diff --git a/lib/minitasn1/parser_aux.c b/lib/minitasn1/parser_aux.c index 75576231b0..464ad5010c 100644 --- a/lib/minitasn1/parser_aux.c +++ b/lib/minitasn1/parser_aux.c @@ -81,21 +81,20 @@ _asn1_add_node(unsigned int type) return punt; } -/******************************************************************/ -/* Function : _asn1_find_mode */ -/* Description: searches an element called NAME starting from */ -/* POINTER. The name is composed by differents */ -/* identifiers separated by dots.When *POINTER has a */ -/* name, the first identifier must be the name of */ -/* *POINTER, otherwise it must be the name of one */ -/* child of *POINTER. */ -/* Parameters: */ -/* pointer: NODE_ASN element pointer. */ -/* name: null terminated string with the element's name to find.*/ -/* Return: the searching result. NULL if not found. */ -/******************************************************************/ -node_asn * -_asn1_find_node(node_asn *pointer,const char *name) +/** + * asn1_find_node: + * @pointer: NODE_ASN element pointer. + * @name: null terminated string with the element's name to find. + * + * Searches for an element called NAME starting from POINTER. The + * name is composed by differents identifiers separated by dots. When + * *POINTER has a name, the first identifier must be the name of + * *POINTER, otherwise it must be the name of one child of *POINTER. + * + * Return value: the searching result. NULL if not found. + **/ +ASN1_TYPE +asn1_find_node(ASN1_TYPE pointer, const char *name) { node_asn *p; char *n_end,n[MAX_NAME_SIZE+1]; @@ -366,15 +365,16 @@ _asn1_remove_node(node_asn *node) _asn1_free(node); } -/******************************************************************/ -/* Function : _asn1_find_up */ -/* Description: return the father of the NODE_ASN element. */ -/* Parameters: */ -/* node: NODE_ASN element pointer. */ -/* Return: Null if not found. */ -/******************************************************************/ -node_asn * -_asn1_find_up(node_asn *node) +/** + * asn1_find_up: + * @node: NODE_ASN element pointer. + * + * Return the father of the NODE_ASN element. + * + * Return value: Return the father of the node, or %NULL if not found. + **/ +ASN1_TYPE +asn1_find_up(ASN1_TYPE node) { node_asn *p; @@ -490,7 +490,7 @@ _asn1_change_integer_value(ASN1_TYPE node) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==node){ p=NULL; break; @@ -540,7 +540,7 @@ _asn1_expand_object_id(ASN1_TYPE node) _asn1_str_cpy(name2, sizeof(name2), name_root); _asn1_str_cat(name2, sizeof(name2), "."); _asn1_str_cat(name2, sizeof(name2), p2->value); - p3=_asn1_find_node(node,name2); + p3=asn1_find_node(node,name2); if(!p3 || (type_field(p3->type)!=TYPE_OBJECT_ID) || !(p3->type&CONST_ASSIGN)) return ASN1_ELEMENT_NOT_FOUND; _asn1_set_down(p,p2->right); @@ -586,7 +586,7 @@ _asn1_expand_object_id(ASN1_TYPE node) if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } @@ -605,7 +605,7 @@ _asn1_expand_object_id(ASN1_TYPE node) _asn1_str_cpy(name2, sizeof(name2), name_root); _asn1_str_cat(name2, sizeof(name2), "."); _asn1_str_cat(name2, sizeof(name2), p2->value); - p3=_asn1_find_node(node,name2); + p3=asn1_find_node(node,name2); if(!p3 || (type_field(p3->type)!=TYPE_OBJECT_ID) || !(p3->type&CONST_ASSIGN)) return ASN1_ELEMENT_NOT_FOUND; p4=p3->down; @@ -637,7 +637,7 @@ _asn1_expand_object_id(ASN1_TYPE node) if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } return ASN1_SUCCESS; @@ -690,7 +690,7 @@ _asn1_type_set_config(ASN1_TYPE node) if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } return ASN1_SUCCESS; @@ -724,7 +724,7 @@ _asn1_check_identifier(ASN1_TYPE node) _asn1_str_cpy(name2, sizeof(name2), node->name); _asn1_str_cat(name2, sizeof(name2), "."); _asn1_str_cat(name2, sizeof(name2), p->value); - p2=_asn1_find_node(node,name2); + p2=asn1_find_node(node,name2); if(p2==NULL){ strcpy(_asn1_identifierMissing,p->value); return ASN1_IDENTIFIER_NOT_FOUND; @@ -738,7 +738,7 @@ _asn1_check_identifier(ASN1_TYPE node) _asn1_str_cat(name2, sizeof(name2), "."); _asn1_str_cat(name2, sizeof(name2), p2->value); strcpy(_asn1_identifierMissing,p2->value); - p2=_asn1_find_node(node,name2); + p2=asn1_find_node(node,name2); if(!p2 || (type_field(p2->type)!=TYPE_OBJECT_ID) || !(p2->type&CONST_ASSIGN)) return ASN1_IDENTIFIER_NOT_FOUND; @@ -755,7 +755,7 @@ _asn1_check_identifier(ASN1_TYPE node) _asn1_str_cat(name2, sizeof(name2), "."); _asn1_str_cat(name2, sizeof(name2), p2->value); strcpy(_asn1_identifierMissing,p2->value); - p2=_asn1_find_node(node,name2); + p2=asn1_find_node(node,name2); if(!p2 || (type_field(p2->type)!=TYPE_OBJECT_ID) || !(p2->type&CONST_ASSIGN)) return ASN1_IDENTIFIER_NOT_FOUND; @@ -771,7 +771,7 @@ _asn1_check_identifier(ASN1_TYPE node) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==node){ p=NULL; break; @@ -822,7 +822,7 @@ _asn1_set_default_tag(ASN1_TYPE node) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==node){ p=NULL; break; diff --git a/lib/minitasn1/parser_aux.h b/lib/minitasn1/parser_aux.h index 08dcd7d21b..7b14e11b48 100644 --- a/lib/minitasn1/parser_aux.h +++ b/lib/minitasn1/parser_aux.h @@ -45,10 +45,6 @@ void _asn1_delete_list_and_nodes(void); char * _asn1_ltostr(long v,char *str); -node_asn * _asn1_find_up(node_asn *node); - -node_asn * _asn1_find_node(node_asn *pointer,const char *name); - asn1_retCode _asn1_change_integer_value(ASN1_TYPE node); asn1_retCode _asn1_expand_object_id(ASN1_TYPE node); diff --git a/lib/minitasn1/structure.c b/lib/minitasn1/structure.c index 0df57e0e6c..e6262b7258 100644 --- a/lib/minitasn1/structure.c +++ b/lib/minitasn1/structure.c @@ -122,7 +122,7 @@ _asn1_create_static_structure(ASN1_TYPE pointer,char* output_file_name,char *vec } else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==pointer){ p=NULL; break; @@ -199,7 +199,7 @@ asn1_array2tree(const ASN1_ARRAY_TYPE *array,ASN1_TYPE *definitions, while(1){ if(p_last==*definitions) break; - p_last= _asn1_find_up(p_last); + p_last= asn1_find_up(p_last); if(p_last==NULL) break; @@ -274,7 +274,7 @@ asn1_delete_structure(ASN1_TYPE *structure) else{ /* no down */ p2=p->right; if(p!=*structure){ - p3=_asn1_find_up(p); + p3=asn1_find_up(p); _asn1_set_down(p3,p2); _asn1_remove_node(p); p=p3; @@ -282,7 +282,7 @@ asn1_delete_structure(ASN1_TYPE *structure) else{ /* p==root */ p3=_asn1_find_left(p); if(!p3){ - p3=_asn1_find_up(p); + p3=asn1_find_up(p); if(p3) _asn1_set_down(p3,p2); else{ if(p->right) p->right->left=NULL; @@ -320,14 +320,14 @@ asn1_delete_element(ASN1_TYPE structure,const char *element_name) { node_asn *p2,*p3,*source_node; - source_node=_asn1_find_node(structure,element_name); + source_node=asn1_find_node(structure,element_name); if(source_node==ASN1_TYPE_EMPTY) return ASN1_ELEMENT_NOT_FOUND; p2=source_node->right; p3=_asn1_find_left(source_node); if(!p3){ - p3=_asn1_find_up(source_node); + p3=asn1_find_up(source_node); if(p3) _asn1_set_down(p3,p2); else @@ -399,8 +399,8 @@ _asn1_copy_structure3(node_asn *source_node) else move=UP; } if(move==UP){ - p_s=_asn1_find_up(p_s); - p_d=_asn1_find_up(p_d); + p_s=asn1_find_up(p_s); + p_d=asn1_find_up(p_d); } }while(p_s!=source_node); @@ -413,7 +413,7 @@ _asn1_copy_structure2(node_asn *root,const char *source_name) { node_asn *source_node; - source_node=_asn1_find_node(root,source_name); + source_node=asn1_find_node(root,source_name); return _asn1_copy_structure3(source_node); @@ -477,7 +477,7 @@ _asn1_type_choice_config(node_asn *node) if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } return ASN1_SUCCESS; @@ -520,7 +520,7 @@ _asn1_expand_identifier(node_asn **node,node_asn *root) p3=_asn1_find_left(p); if(p3) _asn1_set_right(p3,p2); else{ - p3=_asn1_find_up(p); + p3=asn1_find_up(p); if(p3) _asn1_set_down(p3,p2); else { p2->left=NULL; @@ -555,7 +555,7 @@ _asn1_expand_identifier(node_asn **node,node_asn *root) if(p->right) p=p->right; else move=UP; } - if(move==UP) p=_asn1_find_up(p); + if(move==UP) p=asn1_find_up(p); } return ASN1_SUCCESS; @@ -623,7 +623,7 @@ asn1_print_structure(FILE *out,ASN1_TYPE structure,const char *name,int mode) if(out==NULL) return; - root=_asn1_find_node(structure,name); + root=asn1_find_node(structure,name); if(root==NULL) return; @@ -856,7 +856,7 @@ asn1_print_structure(FILE *out,ASN1_TYPE structure,const char *name,int mode) else if(p->right) p=p->right; else{ while(1){ - p=_asn1_find_up(p); + p=asn1_find_up(p); if(p==root){ p=NULL; break; @@ -900,7 +900,7 @@ asn1_number_of_elements(ASN1_TYPE element,const char *name,int *num) *num=0; - node=_asn1_find_node(element,name); + node=asn1_find_node(element,name); if(node==NULL) return ASN1_ELEMENT_NOT_FOUND; p=node->down;