Asn1Reader Class

Provides a set of properties and generic methods to work with ASN.1 structures in Distinguished Encoding Rules (DER) encoding.

Definition

Namespace: SysadminsLV.Asn1Parser
Assembly: SysadminsLV.Asn1Parser (in SysadminsLV.Asn1Parser.dll) Version: 1.2.11
C#
public class Asn1Reader
Inheritance
Object    Asn1Reader

Remarks

Static methods of this class provides an encoders and decoders for the generic .NET types and unmanaged structures.

Static methods (except Encode) strictly verify whether the encoded or source data is valid for the specific ASN.1 type. If the data is not appropriate for the method, it throws InvalidDataException

Constructors

Asn1Reader(Asn1Reader) Initializes a new instance of the ASN1 class from an existing ASN1 object.
Asn1Reader(Byte) Initializes a new instance of the ASN1 class by using an ASN.1 encoded byte array.

Properties

IsConstructed Indicates whether the current tag is container, so it have children instead of explicit tag value.
Item Gets access to internal binary raw data at specified index.
Length Gets the internal ASN.1 stream length in bytes.
NextOffset Gets next structure's offset. If current element is the last element in the data, the property returns zero.
NextSiblingOffset Gets next structure's offset at same level (next sibling).
Offset Gets current position in the byte array stored in current data source.
PayloadLength Gets the length of the current structure's payload.
PayloadStartOffset Gets a position at which current structure's payload starts (excluding tag and tag length byte (or bytes)).
Tag Gets current structure's tag.
TagLength Gets current structure full length. Full length contains tag, tag length byte (or bytes) and tag payload.
TagName Gets current structure tag name.

Methods

BuildOffsetMap Recursively processes ASN tree and builds internal offset map.
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetHeader Gets current structure header. Header contains tag and tag length byte (or bytes).
GetNestedNodeCount Gets the count of nested nodes under node in the current position.
GetPayload Gets the byte array of the current structure's payload.
GetRawData Gets a copy of internal ASN.1 stream. The size of the stream is equals to Length member value.
GetRestrictedTags Gets the list of tags that can be represented in a primitive form only.
GetTagName Gets the formatted tag name.
GetTagObject Gets the appropriate primitive tag object from Universal namespace, or Asn1Universal object.
GetTagRawData Gets the raw data of the tag, which includes tag, length bytes and payload.
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
MoveNext Moves from the current type to the next type. If current type is container or constructed type (SEQUENCE, SEQUENCE OF, SET, SET OF, OCTET STRING or context-specific), MoveNext() method moves to the inner (wrapped) type which starts at the container's payload position.

If the current type is primitive type, MoveNext() method seeks over current type to the next type.

MoveNextAndExpectTags(Asn1Type) Moves from the current type to the next type in a tree and checks whether the tag number of next type matches one of specified in the expectedTags parameter. If current position is the last type in the data, or next type's tag doesn't match a list of accepted types, an exception is thrown. See exceptions for more details. If the method succeeds, it returns nothing.
MoveNextAndExpectTags(Byte) Moves from the current type to the next type in a tree and checks whether the tag number of next type matches one of specified in the expectedTags parameter. If current position is the last type in the data, or next type's tag doesn't match a list of accepted types, an exception is thrown. See exceptions for more details. If the method succeeds, it returns nothing.
MoveNextSibling Moves over current type to the next type at the same level. If the current type is a container (or constructed type), the method skips entire container.
MoveNextSiblingAndExpectTags(Asn1Type) Moves over current type to the next type at the same level and checks whether the tag number of next type matches one of specified in the expectedTags parameter. If current position is the last type in the current array, or next type's tag doesn't match a list of accepted types, an exception is thrown. See exceptions for more details. If the method succeeds, it returns nothing.
MoveNextSiblingAndExpectTags(Byte) Moves over current type to the next type at the same level and checks whether the tag number of next type matches one of specified in the expectedTags parameter. If current position is the last type in the current array, or next type's tag doesn't match a list of accepted types, an exception is thrown. See exceptions for more details. If the method succeeds, it returns nothing.
Reset Moves to the beginning of the file.
Seek Moves to a specified start offset.
ToString
(Inherited from Object)

See Also