diff options
-rw-r--r-- | lib/ASN1.c | 4 | ||||
-rw-r--r-- | lib/coding.c | 12 | ||||
-rw-r--r-- | lib/decoding.c | 22 | ||||
-rw-r--r-- | lib/element.c | 10 | ||||
-rw-r--r-- | lib/element.h | 4 | ||||
-rw-r--r-- | lib/errors.c | 4 | ||||
-rw-r--r-- | lib/libtasn1.h | 48 | ||||
-rw-r--r-- | lib/parser_aux.c | 10 | ||||
-rw-r--r-- | lib/parser_aux.h | 10 | ||||
-rw-r--r-- | lib/structure.c | 22 | ||||
-rw-r--r-- | lib/structure.h | 2 |
11 files changed, 75 insertions, 73 deletions
@@ -109,7 +109,7 @@ #include <structure.h> static FILE *file_asn1; /* Pointer to file to parse */ -static asn1_retCode result_parse; /* result of the parser +static int result_parse; /* result of the parser algorithm */ static ASN1_TYPE p_tree; /* pointer to the root of the structure created by the @@ -2809,7 +2809,7 @@ _asn1_create_errorDescription(int error,char *errorDescription) * file there is an identifier whith more than %ASN1_MAX_NAME_SIZE * characters. **/ -asn1_retCode +int asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions, char *errorDescription){ diff --git a/lib/coding.c b/lib/coding.c index 11f8f48..8b1b7f0 100644 --- a/lib/coding.c +++ b/lib/coding.c @@ -177,7 +177,7 @@ asn1_octet_der (const unsigned char *str, int str_len, /* ASN1_MEM_ERROR when DER isn't big enough */ /* ASN1_SUCCESS otherwise */ /******************************************************/ -static asn1_retCode +static int _asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) { int len_len; @@ -249,7 +249,7 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str) /* ASN1_MEM_ERROR when DER isn't big enough */ /* ASN1_SUCCESS otherwise */ /******************************************************/ -static asn1_retCode +static int _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) { int len_len, counter, k, first, max_len; @@ -372,7 +372,7 @@ asn1_bit_der (const unsigned char *str, int bit_len, /* ASN1_MEM_ERROR if der vector isn't big enough, */ /* otherwise ASN1_SUCCESS. */ /******************************************************/ -static asn1_retCode +static int _asn1_complete_explicit_tag (ASN1_TYPE node, unsigned char *der, int *counter, int *max_len) { @@ -445,7 +445,7 @@ _asn1_complete_explicit_tag (ASN1_TYPE node, unsigned char *der, /* ASN1_MEM_ERROR if der vector isn't big enough, */ /* otherwise ASN1_SUCCESS. */ /******************************************************/ -static asn1_retCode +static int _asn1_insert_tag_der (ASN1_TYPE node, unsigned char *der, int *counter, int *max_len) { @@ -866,14 +866,14 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node) * vector isn't big enough and in this case @len will contain the * length needed. **/ -asn1_retCode +int asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, char *ErrorDescription) { ASN1_TYPE node, p, p2; unsigned char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1]; int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old; - asn1_retCode err; + int err; unsigned char *der = ider; node = asn1_find_node (element, name); diff --git a/lib/decoding.c b/lib/decoding.c index 717112b..d98a13a 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -32,7 +32,7 @@ #include "element.h" #include <limits.h> -static asn1_retCode +static int _asn1_get_indefinite_length_string (const unsigned char *der, int *len); static void @@ -625,7 +625,7 @@ _asn1_delete_not_used (ASN1_TYPE node) return ASN1_SUCCESS; } -static asn1_retCode +static int _asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der, int der_len) { @@ -670,7 +670,7 @@ _asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der, return ASN1_SUCCESS; } -static asn1_retCode +static int _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len) { int len2, len3, counter, tot_len, indefinite; @@ -750,7 +750,7 @@ _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len) } -static asn1_retCode +static int _asn1_get_indefinite_length_string (const unsigned char *der, int *len) { int len2, len3, counter, indefinite; @@ -819,7 +819,7 @@ _asn1_get_indefinite_length_string (const unsigned char *der, int *len) * %ASN1_DER_ERROR if the der encoding doesn't match the structure * name (*@ELEMENT deleted). **/ -asn1_retCode +int asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, char *errorDescription) { @@ -1397,7 +1397,7 @@ cleanup: * %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding doesn't * match the structure @structure (*ELEMENT deleted). **/ -asn1_retCode +int asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, const void *ider, int len, char *errorDescription) { @@ -2211,7 +2211,7 @@ cleanup: * element, %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding * doesn't match the structure ELEMENT. **/ -asn1_retCode +int asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, const char *name_element, int *start, int *end) { @@ -2562,12 +2562,12 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, * problem in OBJECT_ID -> TYPE association, or other error codes * depending on DER decoding. **/ -asn1_retCode +int asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) { char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE]; - asn1_retCode retCode = ASN1_SUCCESS, result; + int retCode = ASN1_SUCCESS, result; int len, len2, len3; ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY; char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; @@ -2792,12 +2792,12 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) * %ASN1_VALUE_NOT_VALID if it wasn't possible to find the type to * use for expansion, or other errors depending on DER decoding. **/ -asn1_retCode +int asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, const char *octetName, const char *objectName) { char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE]; - asn1_retCode retCode = ASN1_SUCCESS, result; + int retCode = ASN1_SUCCESS, result; int len, len2, len3; ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY; ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY; diff --git a/lib/element.c b/lib/element.c index 2ee4950..b60606a 100644 --- a/lib/element.c +++ b/lib/element.c @@ -74,7 +74,7 @@ _asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size) /* len: number of significant byte of value_out. */ /* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_convert_integer (const unsigned char *value, unsigned char *value_out, int value_out_size, int *len) { @@ -267,7 +267,7 @@ _asn1_append_sequence_set (ASN1_TYPE node) * %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element, and * %ASN1_VALUE_NOT_VALID if @ivalue has a wrong format. **/ -asn1_retCode +int asn1_write_value (ASN1_TYPE node_root, const char *name, const void *ivalue, int len) { @@ -693,7 +693,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, * to store the result, and in this case @len will contain the number of * bytes needed. **/ -asn1_retCode +int asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) { ASN1_TYPE node, p, p2; @@ -871,7 +871,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if * @name is not a valid element. **/ -asn1_retCode +int asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue, int *classValue) { @@ -981,7 +981,7 @@ asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue, * * Returns: %ASN1_SUCCESS if the node exists. **/ -asn1_retCode asn1_read_node_value (ASN1_TYPE node, ASN1_DATA_NODE* data) +int asn1_read_node_value (ASN1_TYPE node, ASN1_DATA_NODE* data) { data->name = node->name; data->value = node->value; diff --git a/lib/element.h b/lib/element.h index 9cad46e..cc48433 100644 --- a/lib/element.h +++ b/lib/element.h @@ -23,9 +23,9 @@ #define _ELEMENT_H -asn1_retCode _asn1_append_sequence_set (ASN1_TYPE node); +int _asn1_append_sequence_set (ASN1_TYPE node); -asn1_retCode _asn1_convert_integer (const unsigned char *value, +int _asn1_convert_integer (const unsigned char *value, unsigned char *value_out, int value_out_size, int *len); diff --git a/lib/errors.c b/lib/errors.c index 8b6e5e4..e01c3ee 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -68,7 +68,7 @@ static const libtasn1_error_entry error_algorithms[] = { * Since: 1.6 **/ void -asn1_perror (asn1_retCode error) +asn1_perror (int error) { const char *str = asn1_strerror (error); fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)"); @@ -90,7 +90,7 @@ asn1_perror (asn1_retCode error) * Since: 1.6 **/ const char * -asn1_strerror (asn1_retCode error) +asn1_strerror (int error) { const libtasn1_error_entry *p; diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 6293e7d..5e936e6 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -46,7 +46,6 @@ extern "C" #define ASN1_VERSION "3.0" - typedef int asn1_retCode; /* type returned by libtasn1 functions */ /*****************************************/ /* Errors returned by libtasn1 functions */ @@ -176,16 +175,16 @@ extern "C" /* Functions definitions */ /***********************************/ - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_parser2tree (const char *file_name, ASN1_TYPE * definitions, char *errorDescription); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_parser2array (const char *inputFileName, const char *outputFileName, const char *vectorName, char *errorDescription); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, char *errorDescription); @@ -193,58 +192,58 @@ extern "C" asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name, int mode); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_create_element (ASN1_TYPE definitions, const char *source_name, ASN1_TYPE * element); - extern ASN1_API asn1_retCode asn1_delete_structure (ASN1_TYPE * structure); + extern ASN1_API int asn1_delete_structure (ASN1_TYPE * structure); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_delete_element (ASN1_TYPE structure, const char *element_name); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_write_value (ASN1_TYPE node_root, const char *name, const void *ivalue, int len); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_read_node_value (ASN1_TYPE node, ASN1_DATA_NODE* data); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, char *ErrorDescription); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, char *errorDescription); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, const void *ider, int len, char *errorDescription); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, const char *name_element, int *start, int *end); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, const char *octetName, const char *objectName); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue, int *classValue); @@ -255,9 +254,9 @@ extern "C" extern ASN1_API const char *asn1_check_version (const char *req_version); - extern ASN1_API const char *asn1_strerror (asn1_retCode error); + extern ASN1_API const char *asn1_strerror (int error); - extern ASN1_API void asn1_perror (asn1_retCode error); + extern ASN1_API void asn1_perror (int error); /* DER utility functions. */ @@ -269,7 +268,7 @@ extern "C" asn1_octet_der (const unsigned char *str, int str_len, unsigned char *der, int *der_len); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_get_octet_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, int str_size, int *str_len); @@ -277,7 +276,7 @@ extern "C" extern ASN1_API void asn1_bit_der (const unsigned char *str, int bit_len, unsigned char *der, int *der_len); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_get_bit_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, int str_size, int *bit_len); @@ -296,10 +295,13 @@ extern "C" extern ASN1_API ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name); - extern ASN1_API asn1_retCode + extern ASN1_API int asn1_copy_node (ASN1_TYPE dst, const char *dst_name, ASN1_TYPE src, const char *src_name); +/* Compatibility types */ + typedef int int; /* type returned by libtasn1 functions */ + #ifdef __cplusplus } #endif diff --git a/lib/parser_aux.c b/lib/parser_aux.c index ff701bc..5fd4096 100644 --- a/lib/parser_aux.c +++ b/lib/parser_aux.c @@ -568,7 +568,7 @@ _asn1_ltostr (long v, char *str) /* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ /* otherwise ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_change_integer_value (ASN1_TYPE node) { ASN1_TYPE p; @@ -635,7 +635,7 @@ _asn1_change_integer_value (ASN1_TYPE node) /* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ /* otherwise ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_expand_object_id (ASN1_TYPE node) { ASN1_TYPE p, p2, p3, p4, p5; @@ -818,7 +818,7 @@ _asn1_expand_object_id (ASN1_TYPE node) /* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ /* otherwise ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_type_set_config (ASN1_TYPE node) { ASN1_TYPE p, p2; @@ -891,7 +891,7 @@ _asn1_type_set_config (ASN1_TYPE node) /* ASN1_IDENTIFIER_NOT_FOUND if an identifier is not defined, */ /* otherwise ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_check_identifier (ASN1_TYPE node) { ASN1_TYPE p, p2; @@ -998,7 +998,7 @@ _asn1_check_identifier (ASN1_TYPE node) /* a DEFINITIONS element, */ /* otherwise ASN1_SUCCESS */ /******************************************************************/ -asn1_retCode +int _asn1_set_default_tag (ASN1_TYPE node) { ASN1_TYPE p; diff --git a/lib/parser_aux.h b/lib/parser_aux.h index f3aeb54..b3f34ee 100644 --- a/lib/parser_aux.h +++ b/lib/parser_aux.h @@ -58,15 +58,15 @@ char *_asn1_ltostr (long v, char *str); ASN1_TYPE _asn1_find_up (ASN1_TYPE node); -asn1_retCode _asn1_change_integer_value (ASN1_TYPE node); +int _asn1_change_integer_value (ASN1_TYPE node); -asn1_retCode _asn1_expand_object_id (ASN1_TYPE node); +int _asn1_expand_object_id (ASN1_TYPE node); -asn1_retCode _asn1_type_set_config (ASN1_TYPE node); +int _asn1_type_set_config (ASN1_TYPE node); -asn1_retCode _asn1_check_identifier (ASN1_TYPE node); +int _asn1_check_identifier (ASN1_TYPE node); -asn1_retCode _asn1_set_default_tag (ASN1_TYPE node); +int _asn1_set_default_tag (ASN1_TYPE node); /******************************************************************/ /* Function : _asn1_get_right */ diff --git a/lib/structure.c b/lib/structure.c index 7d622ce..80f9b3f 100644 --- a/lib/structure.c +++ b/lib/structure.c @@ -77,7 +77,7 @@ _asn1_find_left (ASN1_TYPE node) } -asn1_retCode +int _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name, char *vector_name) { @@ -173,14 +173,14 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name, * that is not defined (see @errorDescription for more information), * %ASN1_ARRAY_ERROR if the array pointed by @array is wrong. **/ -asn1_retCode +int asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, char *errorDescription) { ASN1_TYPE p, p_last = NULL; unsigned long k; int move; - asn1_retCode result; + int result; if (*definitions != ASN1_TYPE_EMPTY) @@ -281,7 +281,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if * *@structure was ASN1_TYPE_EMPTY. **/ -asn1_retCode +int asn1_delete_structure (ASN1_TYPE * structure) { ASN1_TYPE p, p2, p3; @@ -345,7 +345,7 @@ asn1_delete_structure (ASN1_TYPE * structure) * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if * the @element_name was not found. **/ -asn1_retCode +int asn1_delete_element (ASN1_TYPE structure, const char *element_name) { ASN1_TYPE p2, p3, source_node; @@ -441,7 +441,7 @@ _asn1_copy_structure2 (ASN1_TYPE root, const char *source_name) } -static asn1_retCode +static int _asn1_type_choice_config (ASN1_TYPE node) { ASN1_TYPE p, p2, p3, p4; @@ -526,7 +526,7 @@ _asn1_type_choice_config (ASN1_TYPE node) } -static asn1_retCode +static int _asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root) { ASN1_TYPE p, p2, p3; @@ -648,7 +648,7 @@ _asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root) * Returns: %ASN1_SUCCESS if creation OK, %ASN1_ELEMENT_NOT_FOUND if * @source_name is not known. **/ -asn1_retCode +int asn1_create_element (ASN1_TYPE definitions, const char *source_name, ASN1_TYPE * element) { @@ -1047,7 +1047,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name, * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if * @name is not known, %ASN1_GENERIC_ERROR if pointer @num is %NULL. **/ -asn1_retCode +int asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num) { ASN1_TYPE node, p; @@ -1092,7 +1092,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) char value[ASN1_MAX_NAME_SIZE]; ASN1_TYPE p; int len; - asn1_retCode result; + int result; if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL)) return NULL; /* ASN1_ELEMENT_NOT_FOUND; */ @@ -1140,7 +1140,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) * * Returns: Return %ASN1_SUCCESS on success. **/ -asn1_retCode +int asn1_copy_node (ASN1_TYPE dst, const char *dst_name, ASN1_TYPE src, const char *src_name) { diff --git a/lib/structure.h b/lib/structure.h index cf4205b..96584ff 100644 --- a/lib/structure.h +++ b/lib/structure.h @@ -28,7 +28,7 @@ #ifndef _STRUCTURE_H #define _STRUCTURE_H -asn1_retCode _asn1_create_static_structure (ASN1_TYPE pointer, +int _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name, char *vector_name); |