static X509ExtensionAsn() { X509ExtensionAsn decoded = default; AsnValueReader reader; reader = new AsnValueReader(DefaultCritical, AsnEncodingRules.DER); decoded.Critical = reader.ReadBoolean(); reader.ThrowIfNotEmpty(); }
public static void Decode(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory<byte> rebind, out X509ExtensionAsn decoded) { decoded = default; AsnValueReader sequenceReader = reader.ReadSequence(expectedTag); AsnValueReader defaultReader; ReadOnlySpan<byte> rebindSpan = rebind.Span; int offset; ReadOnlySpan<byte> tmpSpan; decoded.ExtnId = sequenceReader.ReadObjectIdentifier(); if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(Asn1Tag.Boolean)) { decoded.Critical = sequenceReader.ReadBoolean(); } else { defaultReader = new AsnValueReader(DefaultCritical, AsnEncodingRules.DER); decoded.Critical = defaultReader.ReadBoolean(); } if (sequenceReader.TryReadPrimitiveOctetStringBytes(out tmpSpan)) { decoded.ExtnValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); } else { decoded.ExtnValue = sequenceReader.ReadOctetString(); } sequenceReader.ThrowIfNotEmpty(); }
public static void Decode(ref AsnValueReader reader, ReadOnlyMemory<byte> rebind, out X509ExtensionAsn decoded) { Decode(ref reader, Asn1Tag.Sequence, rebind, out decoded); }