<PackageReference Include="System.Formats.Asn1" Version="8.0.0-rc.2.23479.6" />

AsnReader

public class AsnReader
A stateful, forward-only reader for BER-, CER-, or DER-encoded ASN.1 data.
public bool HasData { get; }

Gets an indication of whether the reader has remaining data available to process.

public AsnEncodingRules RuleSet { get; }

Gets the encoding rules in use by this reader.

public AsnReader(ReadOnlyMemory<byte> data, AsnEncodingRules ruleSet, AsnReaderOptions options = default)

Construct an AsnReader over data with a given ruleset.

public AsnReader Clone()

Clones the current reader.

Get a ReadOnlyMemory<T> view of the content octets (bytes) of the next encoded value without advancing the reader.

Get a ReadOnlyMemory<T> view of the next encoded value without advancing the reader. For indefinite length encodings this includes the End of Contents marker.

public Asn1Tag PeekTag()

Read the encoded tag at the next data position, without advancing the reader.

public byte[] ReadBitString(out int unusedBitCount, Asn1Tag? expectedTag = default)

Reads the next value as a BIT STRING with a specified tag, returning the value in a byte array.

public bool ReadBoolean(Asn1Tag? expectedTag = default)

Reads the next value as a Boolean with a specified tag.

public string ReadCharacterString(UniversalTagNumber encodingType, Asn1Tag? expectedTag = default)

Reads the next value as character string with the specified tag and encoding type, returning the decoded value as a string.

Get a ReadOnlyMemory<T> view of the next encoded value, and advance the reader past it. For an indefinite length encoding this includes the End of Contents marker.

public ReadOnlyMemory<byte> ReadEnumeratedBytes(Asn1Tag? expectedTag = default)

Reads the next value as a Enumerated with a specified tag, returning the contents as a ReadOnlyMemory<T> over the original data.

public TEnum ReadEnumeratedValue<TEnum>(Asn1Tag? expectedTag = default) where TEnum : Enum

Reads the next value as an Enumerated with a specified tag, converting it to the non-[ FlagsAttribute] enum specified by TEnum.

public Enum ReadEnumeratedValue(Type enumType, Asn1Tag? expectedTag = default)

Reads the next value as an Enumerated with a specified tag, converting it to the non-[ FlagsAttribute] enum specified by enumType.

public DateTimeOffset ReadGeneralizedTime(Asn1Tag? expectedTag = default)

Reads the next value as a GeneralizedTime with a specified tag.

public BigInteger ReadInteger(Asn1Tag? expectedTag = default)

Reads the next value as an Integer with a specified tag.

public ReadOnlyMemory<byte> ReadIntegerBytes(Asn1Tag? expectedTag = default)

Reads the next value as a Integer with a specified tag, returning the contents as a ReadOnlyMemory<T> over the original data.

public BitArray ReadNamedBitList(Asn1Tag? expectedTag = default)

Reads the next value as a NamedBitList with a specified tag.

public TFlagsEnum ReadNamedBitListValue<TFlagsEnum>(Asn1Tag? expectedTag = default) where TFlagsEnum : Enum

Reads the next value as a NamedBitList with a specified tag, converting it to the [ FlagsAttribute] enum specified by TFlagsEnum.

public Enum ReadNamedBitListValue(Type flagsEnumType, Asn1Tag? expectedTag = default)

Reads the next value as a NamedBitList with a specified tag, converting it to the [ FlagsAttribute] enum specified by flagsEnumType.

public void ReadNull(Asn1Tag? expectedTag = default)

Reads the next value as a NULL with a specified tag.

public string ReadObjectIdentifier(Asn1Tag? expectedTag = default)

Reads the next value as an OBJECT IDENTIFIER with a specified tag, returning the value in a dotted decimal format string.

public byte[] ReadOctetString(Asn1Tag? expectedTag = default)

Reads the next value as an OCTET STRING with tag UNIVERSAL 4, returning the value in a byte array.

public AsnReader ReadSequence(Asn1Tag? expectedTag = default)

Reads the next value as a SEQUENCE or SEQUENCE-OF with the specified tag and returns the result as a new reader positioned at the first value in the sequence (or with HasData == false).

public AsnReader ReadSetOf(Asn1Tag? expectedTag = default)

Reads the next value as a SET-OF with the specified tag and returns the result as a new reader positioned at the first value in the set-of (or with HasData == false), using the SkipSetSortOrderVerification value from the constructor (default false).

public AsnReader ReadSetOf(bool skipSortOrderValidation, Asn1Tag? expectedTag = default)

Reads the next value as a SET-OF with the specified tag and returns the result as a new reader positioned at the first value in the set-of (or with HasData == false).

public DateTimeOffset ReadUtcTime(Asn1Tag? expectedTag = default)

Reads the next value as a UTCTime with a specified tag using the UtcTimeTwoDigitYearMax value from options passed to the constructor (with a default of 2049).

public DateTimeOffset ReadUtcTime(int twoDigitYearMax, Asn1Tag? expectedTag = default)

Reads the next value as a UTCTime with a specified tag.

public void ThrowIfNotEmpty()

Throws a standardized AsnContentException if the reader has remaining data, performs no function if HasData returns false.

public bool TryReadBitString(Span<byte> destination, out int unusedBitCount, out int bytesWritten, Asn1Tag? expectedTag = default)

Reads the next value as a BIT STRING with a specified tag, copying the value into a provided destination buffer.

public bool TryReadCharacterString(Span<char> destination, UniversalTagNumber encodingType, out int charsWritten, Asn1Tag? expectedTag = default)

Reads the next value as character string with the specified tag and encoding type, copying the decoded value into a provided destination buffer.

public bool TryReadCharacterStringBytes(Span<byte> destination, Asn1Tag expectedTag, out int bytesWritten)

Reads the next value as character string with the specified tag, copying the unprocessed bytes into a provided destination buffer.

public bool TryReadInt32(out int value, Asn1Tag? expectedTag = default)

Attempts to read the next value as an Integer with a specified tag, as a signed 32-bit value.

public bool TryReadInt64(out long value, Asn1Tag? expectedTag = default)

Attempts to read the next value as an Integer with a specified tag, as a signed 64-bit value.

public bool TryReadOctetString(Span<byte> destination, out int bytesWritten, Asn1Tag? expectedTag = default)

Reads the next value as an OCTET STRING with a specified tag, copying the value into a provided destination buffer.

public bool TryReadPrimitiveBitString(out int unusedBitCount, out ReadOnlyMemory value, Asn1Tag? expectedTag = default)

Reads the next value as a BIT STRING with a specified tag, returning the contents as a ReadOnlyMemory<T> over the original data.

public bool TryReadPrimitiveCharacterStringBytes(Asn1Tag expectedTag, out ReadOnlyMemory contents)

Reads the next value as a character with a specified tag, returning the contents as an unprocessed ReadOnlyMemory<T> over the original data.

public bool TryReadPrimitiveOctetString(out ReadOnlyMemory contents, Asn1Tag? expectedTag = default)

Attempts to read the next value as an OCTET STRING with a specified tag, returning the contents as a ReadOnlyMemory<T> over the original data.

public bool TryReadUInt32(out uint value, Asn1Tag? expectedTag = default)

Attempts to read the next value as an Integer with a specified tag, as an unsigned 32-bit value.

public bool TryReadUInt64(out ulong value, Asn1Tag? expectedTag = default)

Attempts to read the next value as an Integer with a specified tag, as an unsigned 64-bit value.