libisdn
asn1.h File Reference

Go to the source code of this file.

Defines

#define ASN1_MINSIZE   2
#define ASN1_MAXDEPTH   10

Enumerations

enum  asn1_codec_t { ASN1_CODEC_NONE = 0, ASN1_CODEC_BER, ASN1_CODEC_MAX }
enum  asn1_loglevel_t {
  ASN1_LOG_NONE = 0, ASN1_LOG_CRIT, ASN1_LOG_ERROR, ASN1_LOG_WARNING,
  ASN1_LOG_NOTICE, ASN1_LOG_INFO, ASN1_LOG_DEBUG, ASN1_LOG_TRACE,
  ASN1_LOG_MAX
}
enum  asn1_class_t { ASN1_CLASS_UNIVERSAL = 0, ASN1_CLASS_APPLICATION, ASN1_CLASS_CONTEXT, ASN1_CLASS_PRIVATE }
enum  asn1_type_t {
  ASN1_TYPE_EOC = 0, ASN1_TYPE_BOOLEAN, ASN1_TYPE_INTEGER, ASN1_TYPE_BIT_STRING,
  ASN1_TYPE_OCTET_STRING, ASN1_TYPE_NULL, ASN1_TYPE_OID, ASN1_TYPE_OBJECTDESC,
  ASN1_TYPE_EXTERNAL, ASN1_TYPE_REAL, ASN1_TYPE_ENUMERATED, ASN1_TYPE_EMBEDDED_PDV,
  ASN1_TYPE_UTF8_STRING, ASN1_TYPE_RELATIVE_OID, ASN1_TYPE_SEQUENCE = 16, ASN1_TYPE_SET,
  ASN1_TYPE_NUMERIC_STRING, ASN1_TYPE_PRINTABLE_STRING, ASN1_TYPE_T61_STRING, ASN1_TYPE_VIDEOTEX_STRING,
  ASN1_TYPE_IA5_STRING, ASN1_TYPE_UTC_TIME, ASN1_TYPE_GENERALIZED_TIME, ASN1_TYPE_GRAPHIC_STRING,
  ASN1_TYPE_VISIBLE_STRING, ASN1_TYPE_GENERAL_STRING, ASN1_TYPE_UNIVERSAL_STRING, ASN1_TYPE_CHARACTER_STRING,
  ASN1_TYPE_BMP_STRING
}

Functions

const char * asn1_class_name (const asn1_class_t id)
const char * asn1_type_name (const asn1_type_t id)
const char * asn1_get_codec_name (const struct asn1_tree *tree)
asn1_codec_t asn1_get_codec_id (const struct asn1_tree *tree)
int asn1_set_codec_by_name (struct asn1_tree *tree, const char *name)
int asn1_set_codec_by_id (struct asn1_tree *tree, const asn1_codec_t id)
int asn1_get_class (const struct asn1_object *elem)
int asn1_get_type (const struct asn1_object *elem)
int asn1_get_size (const struct asn1_object *elem)
int asn1_eq_class (const struct asn1_object *elem, const asn1_class_t asn_class)
int asn1_eq_type (const struct asn1_object *elem, const asn1_type_t asn_type)
struct asn1_treeasn1_create (void)
int asn1_destroy (struct asn1_tree *tree)
int asn1_encode (const struct asn1_tree *tree, char *output, int *size)
int asn1_decode (struct asn1_tree *tree, const char *input, const int size)
int asn1_print (struct asn1_tree *tree, FILE *fp)

Define Documentation

#define ASN1_MAXDEPTH   10

Maximum depth of ASN.1 structure

Definition at line 9 of file asn1.h.

Referenced by asn1_print().

#define ASN1_MINSIZE   2

Minimum size of any ASN.1 element

Definition at line 8 of file asn1.h.

Referenced by asn1_decode().


Enumeration Type Documentation

ASN.1 classes

Enumerator:
ASN1_CLASS_UNIVERSAL 
ASN1_CLASS_APPLICATION 
ASN1_CLASS_CONTEXT 
ASN1_CLASS_PRIVATE 

Definition at line 34 of file asn1.h.

Enumerator:
ASN1_CODEC_NONE 
ASN1_CODEC_BER 
ASN1_CODEC_MAX 

Definition at line 11 of file asn1.h.

Enumerator:
ASN1_LOG_NONE 
ASN1_LOG_CRIT 
ASN1_LOG_ERROR 
ASN1_LOG_WARNING 
ASN1_LOG_NOTICE 
ASN1_LOG_INFO 
ASN1_LOG_DEBUG 
ASN1_LOG_TRACE 
ASN1_LOG_MAX 

Definition at line 18 of file asn1.h.

ASN.1 primitives

Enumerator:
ASN1_TYPE_EOC 
ASN1_TYPE_BOOLEAN 
ASN1_TYPE_INTEGER 
ASN1_TYPE_BIT_STRING 
ASN1_TYPE_OCTET_STRING 
ASN1_TYPE_NULL 
ASN1_TYPE_OID 
ASN1_TYPE_OBJECTDESC 
ASN1_TYPE_EXTERNAL 
ASN1_TYPE_REAL 
ASN1_TYPE_ENUMERATED 
ASN1_TYPE_EMBEDDED_PDV 
ASN1_TYPE_UTF8_STRING 
ASN1_TYPE_RELATIVE_OID 
ASN1_TYPE_SEQUENCE 
ASN1_TYPE_SET 
ASN1_TYPE_NUMERIC_STRING 
ASN1_TYPE_PRINTABLE_STRING 
ASN1_TYPE_T61_STRING 
ASN1_TYPE_VIDEOTEX_STRING 
ASN1_TYPE_IA5_STRING 
ASN1_TYPE_UTC_TIME 
ASN1_TYPE_GENERALIZED_TIME 
ASN1_TYPE_GRAPHIC_STRING 
ASN1_TYPE_VISIBLE_STRING 
ASN1_TYPE_GENERAL_STRING 
ASN1_TYPE_UNIVERSAL_STRING 
ASN1_TYPE_CHARACTER_STRING 
ASN1_TYPE_BMP_STRING 

Definition at line 44 of file asn1.h.


Function Documentation

const char* asn1_class_name ( const asn1_class_t  id)

Definition at line 24 of file asn1_types.c.

References ASN1_CLASS_PRIVATE, and id.

Referenced by ____asn1_ptr_check(), and asn1_print().

struct asn1_tree* asn1_create ( void  ) [read]

Create new empty ASN.1 tree object

Returns:
new tree object on success, NULL on error

Definition at line 597 of file asn1.c.

References ASN1_CODEC_BER, ASN1_INIT_HEAD, asn1_set_codec_by_id(), and asn1_tree::root.

int asn1_destroy ( struct asn1_tree tree)

Free tree structure (recursively)

Parameters:
[in]treeASN.1 tree to release
Returns:
0 on success, -1 on error

Definition at line 611 of file asn1.c.

References __asn1_ptr_check, asn1_free, asn1_header::asn_complex, container_of, asn1_object::hdr, asn1_list::next, asn1_tree::root, and asn1_object::siblings.

int asn1_eq_class ( const struct asn1_object elem,
const asn1_class_t  asn_class 
)

Definition at line 97 of file asn1_types.c.

References asn1_header::asn_class, and asn1_object::hdr.

int asn1_eq_type ( const struct asn1_object elem,
const asn1_type_t  asn_type 
)

Definition at line 102 of file asn1_types.c.

References asn1_header::asn_type, and asn1_object::hdr.

Referenced by asn1_decode().

int asn1_get_class ( const struct asn1_object elem)

Definition at line 82 of file asn1_types.c.

References asn1_header::asn_class, and asn1_object::hdr.

Referenced by ____asn1_ptr_check(), and asn1_print().

asn1_codec_t asn1_get_codec_id ( const struct asn1_tree tree)

Definition at line 40 of file asn1_codec.c.

References ASN1_CODEC_NONE, asn1_tree::codec, and asn1_codec::id.

const char* asn1_get_codec_name ( const struct asn1_tree tree)

Definition at line 32 of file asn1_codec.c.

References asn1_tree::codec, and asn1_codec::name.

int asn1_get_size ( const struct asn1_object elem)

Definition at line 92 of file asn1_types.c.

References asn1_object::hdr, and asn1_header::size.

int asn1_get_type ( const struct asn1_object elem)

Definition at line 87 of file asn1_types.c.

References asn1_header::asn_type, and asn1_object::hdr.

Referenced by ____asn1_ptr_check(), and asn1_print().

int asn1_set_codec_by_id ( struct asn1_tree tree,
const asn1_codec_t  id 
)

Definition at line 62 of file asn1_codec.c.

References ARRAY_SIZE, ASN1_CODEC_MAX, and asn1_tree::codec.

Referenced by asn1_create().

int asn1_set_codec_by_name ( struct asn1_tree tree,
const char *  name 
)

Definition at line 48 of file asn1_codec.c.

References ARRAY_SIZE, and asn1_tree::codec.

const char* asn1_type_name ( const asn1_type_t  id)

Definition at line 67 of file asn1_types.c.

References ARRAY_SIZE, and ASN1_TYPE_BMP_STRING.

Referenced by ____asn1_ptr_check(), asn1_decode(), and asn1_print().