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

Class AsnWriter

Writes DER-encoded ASN.1 data (X.690). Constructed types use callback scoping so that the length is computed automatically after the content is written.

Inheritance
object
AsnWriter
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 AsnWriter

Methods

View Source

ToArray()

Gets the encoded bytes as a new array.

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

WriteBitString(byte[], int)

Writes a BIT STRING with the given content bytes and unused-bits count.

Declaration
public void WriteBitString(byte[] value, int unusedBits = 0)
Parameters
Type Name Description
byte[] value

The value to process.

int unusedBits

The unused bits used by the operation.

View Source

WriteBoolean(bool)

Writes a BOOLEAN.

Declaration
public void WriteBoolean(bool value)
Parameters
Type Name Description
bool value

The value to process.

View Source

WriteEncoded(byte[])

Writes a pre-encoded TLV (tag + length + content) verbatim.

Declaration
public void WriteEncoded(byte[] tlv)
Parameters
Type Name Description
byte[] tlv

Specifies the tlv value.

View Source

WriteExplicit(byte, Action<AsnWriter>)

Writes an EXPLICIT context-tagged element [tag] wrapping the content produced by the callback.

Declaration
public void WriteExplicit(byte tag, Action<AsnWriter> content)
Parameters
Type Name Description
byte tag

Specifies the tag value.

Action<AsnWriter> content

Specifies the content value.

View Source

WriteGeneralizedTime(DateTime)

Writes a GeneralizedTime. The value must be UTC and at year 2050 or later.

Declaration
public void WriteGeneralizedTime(DateTime value)
Parameters
Type Name Description
DateTime value

The value to process.

View Source

WriteIa5String(string)

Writes an IA5String.

Declaration
public void WriteIa5String(string value)
Parameters
Type Name Description
string value

The value to process.

View Source

WriteImplicit(byte, byte[])

Writes an IMPLICIT context-tagged element using pre-encoded content bytes (already including the inner length+value, but not the implicit tag).

Declaration
public void WriteImplicit(byte tag, byte[] content)
Parameters
Type Name Description
byte tag

Specifies the tag value.

byte[] content

Specifies the content value.

View Source

WriteImplicitConstructed(byte, byte[])

Writes a constructed IMPLICIT context-tagged element using pre-encoded content bytes. The constructed bit is set on the tag (0xA0 | tag).

Declaration
public void WriteImplicitConstructed(byte tag, byte[] content)
Parameters
Type Name Description
byte tag

Specifies the tag value.

byte[] content

Specifies the content value.

View Source

WriteInt32(int)

Writes a 32-bit signed INTEGER.

Declaration
public void WriteInt32(int value)
Parameters
Type Name Description
int value

The value to process.

View Source

WriteInteger(byte[])

Writes an INTEGER from big-endian bytes. A leading 0x00 byte is added when needed to keep the value positive (per DER).

Declaration
public void WriteInteger(byte[] bigEndianValue)
Parameters
Type Name Description
byte[] bigEndianValue

The big endian value used by the operation.

View Source

WriteNull()

Writes a NULL.

Declaration
public void WriteNull()
View Source

WriteOctetString(byte[])

Writes an OCTET STRING.

Declaration
public void WriteOctetString(byte[] value)
Parameters
Type Name Description
byte[] value

The value to process.

View Source

WriteOid(string)

Writes an OBJECT IDENTIFIER from a dotted-decimal string.

Declaration
public void WriteOid(string oid)
Parameters
Type Name Description
string oid

The oid identifier.

View Source

WritePrintableString(string)

Writes a PrintableString.

Declaration
public void WritePrintableString(string value)
Parameters
Type Name Description
string value

The value to process.

View Source

WriteSequence(Action<AsnWriter>)

Writes a SEQUENCE, invoking content to populate the body.

Declaration
public void WriteSequence(Action<AsnWriter> content)
Parameters
Type Name Description
Action<AsnWriter> content

Specifies the content value.

View Source

WriteSet(Action<AsnWriter>)

Writes a SET, invoking content to populate the body. DER requires SET elements to be sorted by tag; the caller is responsible for ordering.

Declaration
public void WriteSet(Action<AsnWriter> content)
Parameters
Type Name Description
Action<AsnWriter> content

Specifies the content value.

View Source

WriteUtcTime(DateTime)

Writes a UTCTime. The value must be UTC and within the year range 1950–2049.

Declaration
public void WriteUtcTime(DateTime value)
Parameters
Type Name Description
DateTime value

The value to process.

View Source

WriteUtf8String(string)

Writes a UTF8String.

Declaration
public void WriteUtf8String(string value)
Parameters
Type Name Description
string value

The value to process.

  • View Source
Back to top

DR-IT Software documentation

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

Generated by DocFX