• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class AsnReader

Reads DER-encoded ASN.1 data (X.690). Cursor-based, forward-only. Constructed types return a new AsnReader scoped to the element's content.

Inheritance
object
AsnReader
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: DRIT.Mail.Rfc.Crypto.Asn1
Assembly: DRIT.Mail.dll
Syntax
public sealed class AsnReader

Constructors

View Source

AsnReader(byte[])

Initializes a new instance of the AsnReader class over the given byte array.

Declaration
public AsnReader(byte[] data)
Parameters
Type Name Description
byte[] data

The data to process.

View Source

AsnReader(byte[], int, int)

Initializes a new instance of the AsnReader class over a slice of the given byte array.

Declaration
public AsnReader(byte[] data, int offset, int length)
Parameters
Type Name Description
byte[] data

The data to process.

int offset

The offset within the data.

int length

The length value.

Properties

View Source

HasData

Gets a value indicating whether this reader has any data left to read.

Declaration
public bool HasData { get; }
Property Value
Type Description
bool
View Source

Position

Gets the current cursor position relative to the start of this reader's slice.

Declaration
public int Position { get; }
Property Value
Type Description
int
View Source

Remaining

Gets the number of bytes remaining in this reader.

Declaration
public int Remaining { get; }
Property Value
Type Description
int

Methods

View Source

IsContextTag(byte)

Determines whether the next tag is the given context tag number (0–30), regardless of constructed/primitive form.

Declaration
public bool IsContextTag(byte expectedTag)
Parameters
Type Name Description
byte expectedTag

The expected tag used by the operation.

Returns
Type Description
bool
View Source

PeekTag()

Peeks at the next tag byte without advancing the cursor. Throws if no data.

Declaration
public byte PeekTag()
Returns
Type Description
byte
View Source

ReadBitString()

Reads a BIT STRING, stripping the unused-bits prefix byte. Returns the bit content bytes.

Declaration
public byte[] ReadBitString()
Returns
Type Description
byte[]
View Source

ReadBoolean()

Reads a BOOLEAN.

Declaration
public bool ReadBoolean()
Returns
Type Description
bool
View Source

ReadExplicit(byte)

Reads an EXPLICIT context-tagged element [tag] and returns a new reader over its content. The tag is the context tag number (0–30).

Declaration
public AsnReader ReadExplicit(byte tag)
Parameters
Type Name Description
byte tag

Specifies the tag value.

Returns
Type Description
AsnReader
View Source

ReadGeneralizedTime()

Reads a GeneralizedTime and returns a UTC DateTime.

Declaration
public DateTime ReadGeneralizedTime()
Returns
Type Description
DateTime
View Source

ReadIa5String()

Reads an IA5String (ASCII).

Declaration
public string ReadIa5String()
Returns
Type Description
string
View Source

ReadImplicit(byte)

Reads an IMPLICIT context-tagged element and returns its raw TLV bytes (tag + length + content).

Declaration
public byte[] ReadImplicit(byte tag)
Parameters
Type Name Description
byte tag

Specifies the tag value.

Returns
Type Description
byte[]
View Source

ReadInt32()

Reads an INTEGER as a 32-bit signed value. Throws if the value is out of range.

Declaration
public int ReadInt32()
Returns
Type Description
int
View Source

ReadInteger()

Reads an INTEGER as big-endian bytes (arbitrary size). The result preserves the sign by including a leading 0x00 byte when the high bit of the most significant byte would otherwise be set for a positive value.

Declaration
public byte[] ReadInteger()
Returns
Type Description
byte[]
View Source

ReadNull()

Reads a NULL and returns nothing. Throws if the element is not NULL.

Declaration
public void ReadNull()
View Source

ReadOctetString()

Reads an OCTET STRING.

Declaration
public byte[] ReadOctetString()
Returns
Type Description
byte[]
View Source

ReadOid()

Reads an OBJECT IDENTIFIER as a dotted-decimal string.

Declaration
public string ReadOid()
Returns
Type Description
string
View Source

ReadPrintableString()

Reads a PrintableString.

Declaration
public string ReadPrintableString()
Returns
Type Description
string
View Source

ReadRawTlv()

Reads a full Tag-Length-Value triple and returns the complete raw bytes (tag + length + content). Advances the cursor past the element.

Declaration
public byte[] ReadRawTlv()
Returns
Type Description
byte[]
View Source

ReadSequence()

Reads a SEQUENCE and returns a new reader over its content.

Declaration
public AsnReader ReadSequence()
Returns
Type Description
AsnReader
View Source

ReadSet()

Reads a SET and returns a new reader over its content.

Declaration
public AsnReader ReadSet()
Returns
Type Description
AsnReader
View Source

ReadTlv()

Reads a full Tag-Length-Value triple, returning the tag byte and the content bytes (a copy). Advances the cursor past the element.

Declaration
public (byte tag, byte[] content) ReadTlv()
Returns
Type Description
(byte tag, byte[] content)
View Source

ReadUtcTime()

Reads a UTCTime and returns a UTC DateTime.

Declaration
public DateTime ReadUtcTime()
Returns
Type Description
DateTime
View Source

ReadUtf8String()

Reads a UTF8String.

Declaration
public string ReadUtf8String()
Returns
Type Description
string
View Source

Skip()

Skips the next element without parsing it.

Declaration
public void Skip()
  • View Source
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX