vdchunk-asn1.cpp File Reference

#include "vdchunk-asn1.h"
#include "known_tags.cpp"

Go to the source code of this file.

Functions

string return_vdc_global_string1 ()
int parse_asn1 (vdchunk_base *tag)
int parse_asn1 (vdchunk_base *tag, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
int parse_asn1 (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
string asn1_simple_spaces (int depth)
bool is_asn1_tag (vdchunk_base *tag)
 Check whether the buffer content might be a valid ASN1 tag.
long int parse_asn1_length (vdchunk_base *tag)
 Parse BER-encoded length (parsing position).
long int parse_asn1_length_of_eoc_terminated_sequence (vdchunk_base *tag)
long int parse_asn1_tag_number (vdchunk_base *tag)
 Parses the next tag number (parsing position).
unsigned long int tlv_length (vdchunk_base *tag, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
long int tlv_length2 (vdchunk_base *tag)
bool is_sequence_of_asn1_tags_not_strict (vdchunk_base *tag, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_sequence_of_asn1_tags (vdchunk_base *tag, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_string_tag (char c)
 Returns true if input is the identifier of an ASN1 string.
bool is_asn1_string (vdchunk_base *tag)
bool is_asn1_UTCTime_tag (char c)
 Returns true if input is the identifier of an ASN1 "UTCTime".
bool is_asn1_UTCTime (vdchunk_base *tag)
bool is_asn1_set_tag (char c)
 Returns true if input is the identifier of an ASN1 "SET".
bool is_asn1_set (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) begins with an ASN1 "SET".
bool is_asn1_sequence_tag (char c)
 Returns true if input is the identifier of an ASN1 "SEQUENCE".
bool is_asn1_sequence (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) begins with an ASN1 "SEQUENCE".
bool is_asn1_oid_tag (char c)
 Returns true if input is the identifier of an OID.
bool is_asn1_oid (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) begins with an OID.
bool check_and_parse_asn1_oid (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_asn1_oid (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_null_tag (char c)
 Returns true if input is an ASN1 NULL tag.
bool is_asn1_null (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) begins with an ASN1 NULL.
bool is_eoc_tag (vdchunk_base *tag)
 Returns true if input is a eoc tag.
bool is_zero_tag (vdchunk_base *tag)
 Returns true if input is a zero tag.
bool is_asn1_high_tag_number_form (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) is in high tag number form.
bool check_and_parse_sequence_of_asn1_tags (vdchunk_base *tag, int depth, bool strict, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_known_asn1_tag (vdchunk_base *tag, string tagname, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_known_asn1_tag_as_hex (vdchunk_base *tag, string tagname, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
 Parses the next tag (parsing position, name given) and displays it as hex code.
int parse_known_asn1_tag_as_sequence_or_hex (vdchunk_base *tag, string tagname, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_integer_tag (char c)
 Returns true if input is the identifier of an ASN1 Integer.
bool is_asn1_integer (vdchunk_base *tag)
bool check_and_parse_asn1_integer (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_asn1_integer (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_bit_string_tag (char c)
 Returns true if input is the identifier of an ASN1 octet string.
bool is_asn1_bit_string (vdchunk_base *tag)
bool check_and_parse_asn1_bit_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_asn1_bit_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_octet_string_tag (char c)
 Returns true if input is the identifier of an ASN1 octet string.
bool is_asn1_octet_string (vdchunk_base *tag)
 Returns true if next tag in buffer (parsing position) begins with an ASN1 octet string.
bool check_and_parse_asn1_octet_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_asn1_octet_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
bool is_asn1_boo_string_tag (char c)
bool is_asn1_boo_string (vdchunk_base *tag)
bool check_and_parse_asn1_boo_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void parse_asn1_boo_string (vdchunk_base *tag, int depth, long int *taglength, VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *action)
void vdchunk_asn1_write_hex (vdchunk_base *tag, int depth)
string dumpasn1 (string oid)

Variables

string vdc_global_string1

Function Documentation

string asn1_simple_spaces ( int  depth  ) 
bool check_and_parse_asn1_bit_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether first tag in buffer (parsing position) begins with an ASN1 integer and parses it, if so. All subsequent tags in buffer will be ignored.

Definition at line 1708 of file vdchunk-asn1.cpp.

References is_asn1_bit_string(), and parse_asn1_bit_string().

Referenced by parse_asn1().

bool check_and_parse_asn1_boo_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether first tag in buffer (parsing position) begins with an ASN1 Octet String OR an ASN1 Bit String and parses it, if so. All subsequent tags in buffer will be ignored.

Definition at line 1826 of file vdchunk-asn1.cpp.

References is_asn1_octet_string(), and parse_asn1_boo_string().

bool check_and_parse_asn1_integer ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether tag is an ASN1 integer tag (parsing position) and parses it, if so.

Parameters:
tag Tag to be parsed
depth Parse depth
taglength Returns pointer to tag length
action Actions to be performed
Returns:
TRUE, if tag is an ASN1 integer tag, FALSE otherwise

Definition at line 1637 of file vdchunk-asn1.cpp.

References is_asn1_integer(), and parse_asn1_integer().

Referenced by parse_asn1().

bool check_and_parse_asn1_octet_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether first tag in buffer (parsing position) begins with an ASN1 octet string and parses it, if so. All subsequent tags in buffer will be ignored.

Definition at line 1774 of file vdchunk-asn1.cpp.

References is_asn1_octet_string(), and parse_asn1_octet_string().

Referenced by parse_asn1().

bool check_and_parse_asn1_oid ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether first tag in buffer (parsing position) begins with an ASN1 object identifier (OID) and parses it, if so. All subsequent tags in the buffer will be ignored.

Definition at line 1077 of file vdchunk-asn1.cpp.

References is_asn1_oid(), and parse_asn1_oid().

bool check_and_parse_sequence_of_asn1_tags ( vdchunk_base *  tag,
int  depth,
bool  strict,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the buffer (zero position) under the assumption that it might contain a sequence of tags or otherwise has to be displayed as hex code. In principle, this function parses the "V" part of a tag (TLV) that contains a sequence of nested tags. Please note: Resets parse counter (XXYa)

Parameters:
tag Buffer to be parsed
depth Number of spaces for indention
action Actions to be performed
Returns:
TRUE, if sequence/set; FALSE, otherwise

Definition at line 1234 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), is_sequence_of_asn1_tags(), parse_asn1(), tlv_length(), VDCHUNK_ASN1_ACTION_COMMENTS4, VDCHUNK_ASN1_ACTION_COMMENTS6, VDCHUNK_ASN1_ACTION_DISPLAY_LEAD0, VDCHUNK_ASN1_DEBUG_STREAM, VDCHUNK_ASN1_STREAM, and vdchunk_asn1_write_hex().

Referenced by parse_known_asn1_tag_as_sequence_or_hex().

string dumpasn1 ( string  oid  ) 

Parses the file "dumpasn1.cfg" from Peter Gutmann (if it exists) and returns the string value of the comment corresponding to the OID

Parameters:
oid OID

Definition at line 1877 of file vdchunk-asn1.cpp.

References VDCHUNK_ASN1_DUMPASN1CFG_FILENAME.

Referenced by parse_asn1_oid().

bool is_asn1_bit_string ( vdchunk_base *  tag  ) 

Checks whether tag is an ASN1 integer tag (parsing position) and parses it, if so.

Parameters:
tag Tag to be parsed
depth Parse depth
taglength Returns pointer to tag length
action Actions to be performed
Returns:
TRUE, if tag is an ASN1 bit string, FALSE otherwise

Definition at line 1684 of file vdchunk-asn1.cpp.

References is_asn1_bit_string_tag().

Referenced by check_and_parse_asn1_bit_string().

bool is_asn1_bit_string_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 octet string.

Definition at line 1675 of file vdchunk-asn1.cpp.

Referenced by is_asn1_bit_string().

bool is_asn1_boo_string ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 Octet String OR an ASN1 Bit String

Definition at line 1815 of file vdchunk-asn1.cpp.

References is_asn1_boo_string_tag().

bool is_asn1_boo_string_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 Octet String OR an ASN1 Bit String

Definition at line 1805 of file vdchunk-asn1.cpp.

Referenced by is_asn1_boo_string().

bool is_asn1_high_tag_number_form ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) is in high tag number form.

Identifier octets. There are two forms: low tag number (for tag numbers between 0 and 30) and high tag number (for tag numbers 31 and greater).

Low-tag-number form. One octet. Bits 8 and 7 specify the class (see Table 2), bit 6 has value "0," indicating that the encoding is primitive, and bits 5-1 give the tag number.

High-tag-number form. Two or more octets. First octet is as in low-tag- number form, except that bits 5-1 all have value "1." Second and following octets give the tag number, base 128, most significant digit first, with as few digits as possible, and with the bit 8 of each octet except the last set to "1."

(Source: A Layman's Guide to a Subset of ASN.1, BER, and DER An RSA Laboratories Technical Note Burton S. Kaliski Jr. Revised November 1, 1993)

Definition at line 1203 of file vdchunk-asn1.cpp.

bool is_asn1_integer ( vdchunk_base *  tag  ) 

Checks whether tag is an ASN1 integer tag (parsing position)

Parameters:
tag Tag to be parsed
Returns:
TRUE, if tag is an ASN1 integer tag, FALSE otherwise

Definition at line 1616 of file vdchunk-asn1.cpp.

References is_asn1_integer_tag().

Referenced by check_and_parse_asn1_integer().

bool is_asn1_integer_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 Integer.

Definition at line 1607 of file vdchunk-asn1.cpp.

Referenced by is_asn1_integer().

bool is_asn1_null ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 NULL.

Please note: For this purpose, we distinguish between "ASN1 NULL tags", EOC tags, and zero tags which are non-ASN1 compliant and who might or might not be accepted, depending on VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS. (ASN1 NULL tag: "05 00"; zero tag: "00", EOC tag: "00 00")

Definition at line 1154 of file vdchunk-asn1.cpp.

References is_asn1_null_tag().

Referenced by parse_asn1().

bool is_asn1_null_tag ( char  c  ) 

Returns true if input is an ASN1 NULL tag.

Please note: For this purpose, we distinguish between "ASN1 NULL tags" and zero tags which are non-ASN1 compliant and who might or might not be accepted, depending on VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS. (ASN1 NULL tag: "05 00"; zero tag: "00")

Definition at line 1140 of file vdchunk-asn1.cpp.

Referenced by is_asn1_null().

bool is_asn1_octet_string ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 octet string.

Definition at line 1764 of file vdchunk-asn1.cpp.

References is_asn1_octet_string_tag().

Referenced by check_and_parse_asn1_boo_string(), and check_and_parse_asn1_octet_string().

bool is_asn1_octet_string_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 octet string.

Definition at line 1755 of file vdchunk-asn1.cpp.

Referenced by is_asn1_octet_string().

bool is_asn1_oid ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an OID.

Definition at line 1067 of file vdchunk-asn1.cpp.

References is_asn1_oid_tag().

Referenced by check_and_parse_asn1_oid(), and parse_asn1().

bool is_asn1_oid_tag ( char  c  ) 

Returns true if input is the identifier of an OID.

Definition at line 1057 of file vdchunk-asn1.cpp.

Referenced by is_asn1_oid().

bool is_asn1_sequence ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 "SEQUENCE".

Definition at line 1047 of file vdchunk-asn1.cpp.

References is_asn1_sequence_tag().

Referenced by parse_asn1().

bool is_asn1_sequence_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 "SEQUENCE".

Definition at line 1037 of file vdchunk-asn1.cpp.

Referenced by is_asn1_sequence().

bool is_asn1_set ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 "SET".

Definition at line 1027 of file vdchunk-asn1.cpp.

References is_asn1_set_tag().

Referenced by parse_asn1().

bool is_asn1_set_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 "SET".

Definition at line 1018 of file vdchunk-asn1.cpp.

Referenced by is_asn1_set().

bool is_asn1_string ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 string.

Definition at line 983 of file vdchunk-asn1.cpp.

References is_asn1_string_tag().

Referenced by parse_asn1().

bool is_asn1_string_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 string.

Definition at line 972 of file vdchunk-asn1.cpp.

Referenced by is_asn1_string().

bool is_asn1_tag ( vdchunk_base *  tag  ) 

Check whether the buffer content might be a valid ASN1 tag.

Definition at line 421 of file vdchunk-asn1.cpp.

References parse_asn1_length(), pp_asn1_high_tag_number_form, and VDCHUNK_ASN1_DEBUG_STREAM.

bool is_asn1_UTCTime ( vdchunk_base *  tag  ) 

Returns true if next tag in buffer (parsing position) begins with an ASN1 "UTCTime".

Definition at line 1002 of file vdchunk-asn1.cpp.

References is_asn1_UTCTime_tag().

Referenced by parse_asn1().

bool is_asn1_UTCTime_tag ( char  c  ) 

Returns true if input is the identifier of an ASN1 "UTCTime".

Definition at line 994 of file vdchunk-asn1.cpp.

Referenced by is_asn1_UTCTime().

bool is_eoc_tag ( vdchunk_base *  tag  ) 

Returns true if input is a eoc tag.

Please note: For this purpose, we distinguish between "ASN1 NULL tags", EOC tags, and zero tags which are non-ASN1 compliant and who might or might not be accepted, depending on VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS. (ASN1 NULL tag: "05 00"; zero tag: "00", EOC tag: "00 00")

Definition at line 1169 of file vdchunk-asn1.cpp.

Referenced by parse_asn1().

bool is_sequence_of_asn1_tags ( vdchunk_base *  tag,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether the buffer contains a sequence of valid ASN1 tags. Please note: Resets parse counter. XXYa

Parameters:
tag Tag to be parsed
action Actions to be performed

Definition at line 872 of file vdchunk-asn1.cpp.

References is_sequence_of_asn1_tags(), parse_asn1_length(), pp_asn1_high_tag_number_form, VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS, and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by check_and_parse_sequence_of_asn1_tags(), is_sequence_of_asn1_tags(), and is_sequence_of_asn1_tags_not_strict().

bool is_sequence_of_asn1_tags_not_strict ( vdchunk_base *  tag,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Checks whether the buffer contains a sequence of valid ASN1 tags. Not strict: Single zero tags (00) and single tags in low-tag form with zero length (xx 00) do XXX Does that make sense? not count as a valid sequence here. Please note: Resets parse counter. XXYa

Parameters:
tag Tag to be parsed
action Actions to be performed

Definition at line 838 of file vdchunk-asn1.cpp.

References is_sequence_of_asn1_tags(), and VDCHUNK_ASN1_DEBUG_STREAM.

bool is_zero_tag ( vdchunk_base *  tag  ) 

Returns true if input is a zero tag.

Please note: For this purpose, we distinguish between "ASN1 NULL tags", EOC tags, and zero tags which are non-ASN1 compliant and who might or might not be accepted, depending on VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS. (ASN1 NULL tag: "05 00"; zero tag: "00", EOC tag: "00 00")

Definition at line 1185 of file vdchunk-asn1.cpp.

Referenced by parse_asn1().

int parse_asn1 ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)
int parse_asn1 ( vdchunk_base *  tag,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses ASN1 tag.

Parameters:
tag Tag to be parsed
action Actions to be performed
Returns:
0, if all is ok

Definition at line 75 of file vdchunk-asn1.cpp.

References parse_asn1(), VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS, and VDCHUNK_ASN1_DEBUG_STREAM.

int parse_asn1 ( vdchunk_base *  tag  ) 

Parses ASN1 tag.

Parameters:
tag Tag to be parsed
Returns:
0, if all is ok

Definition at line 49 of file vdchunk-asn1.cpp.

References parse_asn1(), VDCHUNK_ASN1_ACTION_MAX, and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by check_and_parse_sequence_of_asn1_tags(), main(), and parse_asn1().

void parse_asn1_bit_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the first tag of the buffer und the assumption that it is an ASN1 Bit String. All subsequent tags in buffer will be ignored.

Parameters:
tag Tag to be parsed
depth Parse depth (for output)
taglength Returns the tag length (length of T+L+V)

Definition at line 1723 of file vdchunk-asn1.cpp.

References parse_known_asn1_tag_as_sequence_or_hex(), VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS, and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by check_and_parse_asn1_bit_string().

void parse_asn1_boo_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the first tag of the buffer under the assumption that it is an ASN1 Octet String OR an ASN1 Bit String All subsequent tags in buffer will be ignored.

Definition at line 1841 of file vdchunk-asn1.cpp.

References parse_known_asn1_tag_as_sequence_or_hex().

Referenced by check_and_parse_asn1_boo_string().

void parse_asn1_integer ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the next tag (parsing position) assuming that it is an ASN1 integer. All subsequent tags in buffer will be ignored.

Definition at line 1657 of file vdchunk-asn1.cpp.

References parse_known_asn1_tag_as_hex(), and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by check_and_parse_asn1_integer().

long int parse_asn1_length ( vdchunk_base *  tag  ) 

Parse BER-encoded length (parsing position).

Result: -1 -- if DER length is encoded incorrectly -2 -- if DER encoding is corrupt due to EOF resulting length -- otherwise

Documentation: a) ISO 7816-4, 5.2.2.2, BER-TLV length fields b) ITU-T X.690

Definition at line 476 of file vdchunk-asn1.cpp.

References parse_asn1_length_of_eoc_terminated_sequence().

Referenced by is_asn1_tag(), is_sequence_of_asn1_tags(), parse_asn1(), parse_known_asn1_tag(), parse_known_asn1_tag_as_hex(), parse_known_asn1_tag_as_sequence_or_hex(), tlv_length(), and tlv_length2().

long int parse_asn1_length_of_eoc_terminated_sequence ( vdchunk_base *  tag  ) 

Returns the length of a sequence of ASN1 tags terminated by an EOC (00 00). Please note: Does not change the parse counter.

Parameters:
tag Tag to be parsed
Returns:
Length or -9, if error

Definition at line 513 of file vdchunk-asn1.cpp.

References parse_asn1_length_of_eoc_terminated_sequence(), tlv_length2(), and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by parse_asn1_length(), and parse_asn1_length_of_eoc_terminated_sequence().

void parse_asn1_octet_string ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the first tag of the buffer under the assumption that it is an ASN1 Octet String. All subsequent tags in buffer will be ignored.

Definition at line 1789 of file vdchunk-asn1.cpp.

References parse_known_asn1_tag_as_sequence_or_hex().

Referenced by check_and_parse_asn1_octet_string().

void parse_asn1_oid ( vdchunk_base *  tag,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the buffer (parsing position) under the assumption that it is an ASN1 object identifier (OID). All subsequent tags in buffer will be ignored.

Definition at line 1093 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), dumpasn1(), vdc_global_string1, VDCHUNK_ASN1_ACTION_COMMENTS3, VDCHUNK_ASN1_ACTION_OID_IN_STRING, and VDCHUNK_ASN1_STREAM.

Referenced by check_and_parse_asn1_oid(), and parse_asn1().

long int parse_asn1_tag_number ( vdchunk_base *  tag  ) 

Parses the next tag number (parsing position).

Parameters:
tag Tag to be parsed
Returns:
Tag number, -1 if error

Definition at line 615 of file vdchunk-asn1.cpp.

References pp_asn1_high_tag_number_form.

void parse_known_asn1_tag ( vdchunk_base *  tag,
string  tagname,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the first tag (name given). Content will be displayed depending on the "action". All subsequent tags in buffer will be ignored.

Definition at line 1354 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), parse_asn1_length(), pp_asn1_high_tag_number_form, VDCHUNK_ASN1_ACTION_COMMENTS4, and VDCHUNK_ASN1_STREAM.

void parse_known_asn1_tag_as_hex ( vdchunk_base *  tag,
string  tagname,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the next tag (parsing position, name given) and displays it as hex code.

Parameters:
tag Tag to be parsed
tagname Name of the tag
depth Number of spaces for indention
taglength Return value: tag length

Definition at line 1405 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), parse_asn1_length(), pp_asn1_high_tag_number_form, VDCHUNK_ASN1_ACTION_COMMENTS4, VDCHUNK_ASN1_ACTION_DISPLAY_LEAD0, VDCHUNK_ASN1_DEBUG_STREAM, VDCHUNK_ASN1_STREAM, and vdchunk_asn1_write_hex().

Referenced by parse_asn1_integer().

int parse_known_asn1_tag_as_sequence_or_hex ( vdchunk_base *  tag,
string  tagname,
int  depth,
long int *  taglength,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Parses the next tag (parsing position) under the assumption that it might contain a sequence of tags or otherwise has to be displayed as hex code.

Parameters:
tag Tag to be parsed
tagname Name of the tag (will be displayed)
depth Number of spaces for indention
taglength Return value: tag length (T + L + V) XXYd
action Actions to be performed
Returns:
-1 : Error; 0: Ok, sequence; 1: Ok, Hex

Definition at line 1494 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), check_and_parse_sequence_of_asn1_tags(), parse_asn1_length(), pp_asn1_high_tag_number_form, VDCHUNK_ASN1_ACTION_COMMENTS3, VDCHUNK_ASN1_DEBUG_STREAM, and VDCHUNK_ASN1_STREAM.

Referenced by parse_asn1(), parse_asn1_bit_string(), parse_asn1_boo_string(), and parse_asn1_octet_string().

string return_vdc_global_string1 (  ) 

Definition at line 44 of file vdchunk-asn1.cpp.

References vdc_global_string1.

unsigned long int tlv_length ( vdchunk_base *  tag,
VDCHUNK_ASN1_ACTION_TYPE_ABSTRACT *  action 
)

Returns the length of an entire ANS1 tag (T + L + V) at parsing position. If the content of the buffer is not a tag, it returns the number of entries. Please note: Does not change the parse counter.

Parameters:
tag Tag to be parsed
action Actions to be performed

Definition at line 658 of file vdchunk-asn1.cpp.

References parse_asn1_length(), pp_asn1_high_tag_number_form, VDCHUNK_ASN1_ACTION_ACCEPT_ZERO_TAGS, and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by check_and_parse_sequence_of_asn1_tags().

long int tlv_length2 ( vdchunk_base *  tag  ) 

Alternative version: Returns the length of an entire ANS1 tag (T + L + V) at parsing position. If the content of the buffer is not a tag, it returns -1. Please note: Does not change the parse counter.

Parameters:
tag Tag to be parsed
action Actions to be performed

Definition at line 739 of file vdchunk-asn1.cpp.

References parse_asn1_length(), pp_asn1_high_tag_number_form, and VDCHUNK_ASN1_DEBUG_STREAM.

Referenced by parse_asn1_length_of_eoc_terminated_sequence().

void vdchunk_asn1_write_hex ( vdchunk_base *  tag,
int  depth 
)

Prints the tag as hex; indents spaces according to OMOSAP output format; the number of bytes per line, the number of bytes not skipped is as well as the output stream are defined in "vdchunk_asn1.h"

Parameters:
tag Tag to be displayed
depth Parse depth

Definition at line 1855 of file vdchunk-asn1.cpp.

References asn1_simple_spaces(), VDCHUNK_ASN1_CHARPERLINE, VDCHUNK_ASN1_CHARTOTAL, and VDCHUNK_ASN1_STREAM.

Referenced by check_and_parse_sequence_of_asn1_tags(), and parse_known_asn1_tag_as_hex().


Variable Documentation

Definition at line 42 of file vdchunk-asn1.cpp.

Referenced by parse_asn1_oid(), and return_vdc_global_string1().

Generated on Thu Dec 8 09:46:11 2011 for OMOSAP by  doxygen 1.6.3