#include <int.h>
#include "parser_aux.h"
#include <gstr.h>
#include "structure.h"
#include "element.h"
Go to the source code of this file.
Functions | |
static void | MHD__asn1_error_description_tag_error (node_asn *node, char *ErrorDescription) |
signed long | MHD__asn1_get_length_der (const unsigned char *der, int der_len, int *len) |
int | MHD__asn1_get_tag_der (const unsigned char *der, int der_len, unsigned char *cls, int *len, unsigned long *tag) |
int | MHD__asn1_get_octet_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, int str_size, int *str_len) |
static int | MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, char *str, int str_size) |
static void | MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, char *str, int str_size) |
int | MHD__asn1_get_bit_der (const unsigned char *der, int der_len, int *ret_len, unsigned char *str, int str_size, int *bit_len) |
static int | MHD__asn1_extract_tag_der (node_asn *node, const unsigned char *der, int der_len, int *ret_len) |
static int | MHD__asn1_delete_not_used (node_asn *node) |
static MHD__asn1_retCode | MHD__asn1_get_octet_string (const unsigned char *der, node_asn *node, int *len) |
static MHD__asn1_retCode | MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len) |
MHD__asn1_retCode | MHD__asn1_der_decoding (ASN1_TYPE *element, const void *ider, int len, char *errorDescription) |
MHD__asn1_retCode | MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, const char *name_element, int *start, int *end) |
static int MHD__asn1_delete_not_used | ( | node_asn * | node | ) | [static] |
Definition at line 511 of file decoding.c.
References ASN1_ELEMENT_NOT_FOUND, ASN1_SUCCESS, CONST_NOT_USED, node_asn_struct::down, MHD__asn1_delete_structure(), MHD__asn1_find_left(), MHD__asn1_find_up(), node_asn_struct::right, and node_asn_struct::type.
Referenced by MHD__asn1_der_decoding().
MHD__asn1_retCode MHD__asn1_der_decoding | ( | ASN1_TYPE * | element, | |
const void * | ider, | |||
int | len, | |||
char * | errorDescription | |||
) |
MHD__asn1_der_decoding - Fill the structure *ELEMENT with values of a DER encoding string. : pointer to an ASN1 structure. : vector that contains the DER encoding. : number of bytes of *: [0]..[len-1]. : null-terminated string contains details when an error occurred.
Fill the structure *ELEMENT with values of a DER encoding string. The sructure must just be created with function 'create_stucture'. If an error occurs during the decoding procedure, the *ELEMENT is deleted and set equal to ASN1_TYPE_EMPTY.
Returns:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY.
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match the structure NAME. *ELEMENT deleted.
Definition at line 763 of file decoding.c.
References ASN1_DER_ERROR, ASN1_ELEMENT_NOT_FOUND, ASN1_ERROR_TYPE_ANY, ASN1_GENERIC_ERROR, ASN1_MEM_ALLOC_ERROR, ASN1_SUCCESS, ASN1_TAG_ERROR, ASN1_TYPE_EMPTY, CONST_DEFAULT, CONST_NOT_USED, CONST_OPTION, CONST_SET, CONST_TAG, node_asn_struct::down, DOWN, MHD__asn1_afree, MHD__asn1_alloca, MHD__asn1_append_sequence_set(), MHD__asn1_delete_not_used(), MHD__asn1_delete_structure(), MHD__asn1_error_description_tag_error(), MHD__asn1_extract_tag_der(), MHD__asn1_find_up(), MHD__asn1_get_indefinite_length_string(), MHD__asn1_get_length_der(), MHD__asn1_get_objectid_der(), MHD__asn1_get_octet_string(), MHD__asn1_get_tag_der(), MHD__asn1_get_time_der(), MHD__asn1_length_der(), MHD__asn1_ltostr(), MHD__asn1_octet_der(), MHD__asn1_set_value(), RIGHT, node_asn_struct::right, node_asn_struct::type, TYPE_ANY, TYPE_BIT_STRING, TYPE_BOOLEAN, TYPE_CHOICE, TYPE_ENUMERATED, type_field, TYPE_GENERALSTRING, TYPE_INTEGER, TYPE_NULL, TYPE_OBJECT_ID, TYPE_OCTET_STRING, TYPE_SEQUENCE, TYPE_SEQUENCE_OF, TYPE_SET, TYPE_SET_OF, TYPE_SIZE, TYPE_TAG, TYPE_TIME, UP, and node_asn_struct::value.
Referenced by MHD__gnutls_cert_get_issuer_dn(), MHD__gnutls_privkey_decode_pkcs1_rsa_key(), MHD__gnutls_x509_decode_octet_string(), MHD__gnutls_x509_ext_extract_keyUsage(), MHD__gnutls_x509_read_rsa_params(), and MHD_gnutls_x509_crt_import().
MHD__asn1_retCode MHD__asn1_der_decoding_startEnd | ( | ASN1_TYPE | element, | |
const void * | ider, | |||
int | len, | |||
const char * | name_element, | |||
int * | start, | |||
int * | end | |||
) |
MHD__asn1_der_decoding_startEnd - Find the start and end point of an element in a DER encoding string. : pointer to an ASN1 element : vector that contains the DER encoding. : number of bytes of *: [0]..[len-1] : an element of NAME structure. : the position of the first byte of NAME_ELEMENT decoding ([*start]) : the position of the last byte of NAME_ELEMENT decoding ([*end])
Find the start and end point of an element in a DER encoding string. I mean that if you have a der encoding and you have already used the function "MHD__asn1_der_decoding" to fill a structure, it may happen that you want to find the piece of string concerning an element of the structure.
Example: the sequence "tbsCertificate" inside an X509 certificate.
Returns:
ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE EMPTY or NAME_ELEMENT is not a valid element.
ASN1_TAG_ERROR,ASN1_DER_ERROR: the der encoding doesn't match the structure ELEMENT.
Definition at line 1345 of file decoding.c.
References ASN1_DER_ERROR, ASN1_ELEMENT_NOT_FOUND, ASN1_GENERIC_ERROR, ASN1_SUCCESS, ASN1_TAG_ERROR, ASN1_TYPE_EMPTY, CONST_DEFAULT, CONST_NOT_USED, CONST_OPTION, CONST_SET, CONST_TAG, node_asn_struct::down, DOWN, MHD__asn1_extract_tag_der(), MHD__asn1_find_node(), MHD__asn1_find_up(), MHD__asn1_get_indefinite_length_string(), MHD__asn1_get_length_der(), MHD__asn1_get_octet_string(), MHD__asn1_get_tag_der(), RIGHT, node_asn_struct::right, node_asn_struct::type, TYPE_ANY, TYPE_BIT_STRING, TYPE_BOOLEAN, TYPE_CHOICE, TYPE_ENUMERATED, type_field, TYPE_GENERALSTRING, TYPE_INTEGER, TYPE_NULL, TYPE_OBJECT_ID, TYPE_OCTET_STRING, TYPE_SEQUENCE, TYPE_SEQUENCE_OF, TYPE_SET, TYPE_SET_OF, TYPE_SIZE, TYPE_TAG, TYPE_TIME, UP, and node_asn_struct::value.
Referenced by MHD__gnutls_cert_get_issuer_dn().
static void MHD__asn1_error_description_tag_error | ( | node_asn * | node, | |
char * | ErrorDescription | |||
) | [static] |
Definition at line 37 of file decoding.c.
References Estrcat, Estrcpy, MAX_ERROR_DESCRIPTION_SIZE, and MHD__asn1_hierarchical_name().
Referenced by MHD__asn1_der_decoding().
static int MHD__asn1_extract_tag_der | ( | node_asn * | node, | |
const unsigned char * | der, | |||
int | der_len, | |||
int * | ret_len | |||
) | [static] |
Definition at line 318 of file decoding.c.
References ASN1_CLASS_APPLICATION, ASN1_CLASS_CONTEXT_SPECIFIC, ASN1_CLASS_PRIVATE, ASN1_CLASS_STRUCTURED, ASN1_CLASS_UNIVERSAL, ASN1_DER_ERROR, ASN1_GENERIC_ERROR, ASN1_SUCCESS, ASN1_TAG_BIT_STRING, ASN1_TAG_BOOLEAN, ASN1_TAG_ENUMERATED, ASN1_TAG_ERROR, ASN1_TAG_GENERALIZEDTime, ASN1_TAG_GENERALSTRING, ASN1_TAG_INTEGER, ASN1_TAG_NULL, ASN1_TAG_OBJECT_ID, ASN1_TAG_OCTET_STRING, ASN1_TAG_SEQUENCE, ASN1_TAG_SET, ASN1_TAG_UTCTime, CONST_APPLICATION, CONST_EXPLICIT, CONST_PRIVATE, CONST_TAG, CONST_UNIVERSAL, CONST_UTC, node_asn_struct::down, MHD__asn1_get_length_der(), MHD__asn1_get_tag_der(), node_asn_struct::right, node_asn_struct::type, TYPE_ANY, TYPE_BIT_STRING, TYPE_BOOLEAN, TYPE_ENUMERATED, type_field, TYPE_GENERALSTRING, TYPE_INTEGER, TYPE_NULL, TYPE_OBJECT_ID, TYPE_OCTET_STRING, TYPE_SEQUENCE, TYPE_SEQUENCE_OF, TYPE_SET, TYPE_SET_OF, TYPE_TAG, TYPE_TIME, and node_asn_struct::value.
Referenced by MHD__asn1_der_decoding(), and MHD__asn1_der_decoding_startEnd().
int MHD__asn1_get_bit_der | ( | const unsigned char * | der, | |
int | der_len, | |||
int * | ret_len, | |||
unsigned char * | str, | |||
int | str_size, | |||
int * | bit_len | |||
) |
MHD__asn1_get_bit_der: : DER data to decode containing the BIT SEQUENCE. : Length of DER data to decode. : Output variable containing the length of the DER data. : Pre-allocated output buffer to put decoded BIT SEQUENCE in. : Length of pre-allocated output buffer. : Output variable containing the size of the BIT SEQUENCE.
Extract a BIT SEQUENCE from DER data.
Return value: Return ASN1_SUCCESS on success, or an error.
Definition at line 289 of file decoding.c.
References ASN1_DER_ERROR, ASN1_GENERIC_ERROR, ASN1_MEM_ERROR, ASN1_SUCCESS, and MHD__asn1_get_length_der().
Referenced by MHD__asn1_read_value().
static MHD__asn1_retCode MHD__asn1_get_indefinite_length_string | ( | const unsigned char * | der, | |
int * | len | |||
) | [static] |
Definition at line 688 of file decoding.c.
References ASN1_DER_ERROR, ASN1_SUCCESS, MHD__asn1_get_length_der(), and MHD__asn1_get_tag_der().
Referenced by MHD__asn1_der_decoding(), and MHD__asn1_der_decoding_startEnd().
signed long MHD__asn1_get_length_der | ( | const unsigned char * | der, | |
int | der_len, | |||
int * | len | |||
) |
MHD__asn1_get_length_der: : DER data to decode. : Length of DER data to decode. : Output variable containing the length of the DER length field.
Extract a length field from DER data.
Return value: Return the decoded length value, or -1 on indefinite length, or -2 when the value was too big.
Definition at line 61 of file decoding.c.
Referenced by MHD__asn1_der_coding(), MHD__asn1_der_decoding(), MHD__asn1_der_decoding_startEnd(), MHD__asn1_extract_tag_der(), MHD__asn1_get_bit_der(), MHD__asn1_get_indefinite_length_string(), MHD__asn1_get_objectid_der(), MHD__asn1_get_octet_der(), MHD__asn1_get_octet_string(), MHD__asn1_get_time_der(), MHD__asn1_ordering_set(), MHD__asn1_ordering_set_of(), and MHD__asn1_read_value().
static void MHD__asn1_get_objectid_der | ( | const unsigned char * | der, | |
int | der_len, | |||
int * | ret_len, | |||
char * | str, | |||
int | str_size | |||
) | [static] |
Definition at line 232 of file decoding.c.
References MHD__asn1_get_length_der(), MHD__asn1_ltostr(), MHD__asn1_str_cat(), and MHD__asn1_str_cpy().
Referenced by MHD__asn1_der_decoding().
int MHD__asn1_get_octet_der | ( | const unsigned char * | der, | |
int | der_len, | |||
int * | ret_len, | |||
unsigned char * | str, | |||
int | str_size, | |||
int * | str_len | |||
) |
MHD__asn1_get_octet_der: : DER data to decode containing the OCTET SEQUENCE. : Length of DER data to decode. : Output variable containing the length of the DER data. : Pre-allocated output buffer to put decoded OCTET SEQUENCE in. : Length of pre-allocated output buffer. : Output variable containing the length of the OCTET SEQUENCE.
Extract an OCTET SEQUENCE from DER data.
Return value: Returns ASN1_SUCCESS on success, or an error.
Definition at line 181 of file decoding.c.
References ASN1_DER_ERROR, ASN1_GENERIC_ERROR, ASN1_MEM_ERROR, ASN1_SUCCESS, and MHD__asn1_get_length_der().
Referenced by MHD__asn1_read_value().
static MHD__asn1_retCode MHD__asn1_get_octet_string | ( | const unsigned char * | der, | |
node_asn * | node, | |||
int * | len | |||
) | [static] |
Definition at line 571 of file decoding.c.
References ASN1_CLASS_STRUCTURED, ASN1_DER_ERROR, ASN1_MEM_ALLOC_ERROR, ASN1_SUCCESS, ASN1_TAG_OCTET_STRING, MHD__asn1_afree, MHD__asn1_alloca, MHD__asn1_get_length_der(), MHD__asn1_length_der(), and MHD__asn1_set_value().
Referenced by MHD__asn1_der_decoding(), and MHD__asn1_der_decoding_startEnd().
int MHD__asn1_get_tag_der | ( | const unsigned char * | der, | |
int | der_len, | |||
unsigned char * | cls, | |||
int * | len, | |||
unsigned long * | tag | |||
) |
MHD__asn1_get_tag_der: : DER data to decode. : Length of DER data to decode. : Output variable containing decoded class. : Output variable containing the length of the DER TAG data. : Output variable containing the decoded tag.
Decode the class and TAG from DER code.
Return value: Returns ASN1_SUCCESS on success, or an error.
Definition at line 120 of file decoding.c.
References ASN1_DER_ERROR, and ASN1_SUCCESS.
Referenced by MHD__asn1_der_decoding(), MHD__asn1_der_decoding_startEnd(), MHD__asn1_extract_tag_der(), MHD__asn1_get_indefinite_length_string(), MHD__asn1_ordering_set(), and MHD__asn1_ordering_set_of().
static int MHD__asn1_get_time_der | ( | const unsigned char * | der, | |
int | der_len, | |||
int * | ret_len, | |||
char * | str, | |||
int | str_size | |||
) | [static] |
Definition at line 212 of file decoding.c.
References ASN1_DER_ERROR, ASN1_SUCCESS, and MHD__asn1_get_length_der().
Referenced by MHD__asn1_der_decoding().