public List <object> ReadConstructedType(int length) { var values = new List <object>(); long endPosition = Position + length; while (Position < endPosition) { Asn1Type type = ReadType(); if (type.Byte == 0) { break; } length = ReadLength(); if (type.IsPrimitive) { values.Add(ReadPrimiveType(type, length)); } else { values.Add(ReadConstructedType(length)); } } return(values); }
public string ReadOctetString() { Asn1Type type = ReadType(); if (!type.IsPrimitive && type.Tag == Asn1Tag.OctetString) { throw new Exception("Expected OctetString"); } int length = ReadLength(); return(ReadOctetString(length)); }
public int ReadInteger() { Asn1Type type = ReadType(); if (!type.IsPrimitive && type.Tag == Asn1Tag.Integer) { throw new Exception("Expected integer"); } int length = ReadLength(); return(ReadInteger(length)); }
public object ReadPrimiveType(Asn1Type type, int length) { switch (type.Tag) { case Asn1Tag.Null: return(null); case Asn1Tag.Integer: return(ReadInteger(length)); case Asn1Tag.OctetString: return(ReadOctetString(length)); case Asn1Tag.ObjectIdentifier: return(ReadOID(length)); default: Skip(length); return("NYI: " + type.Tag); } }
public object ReadPrimiveType(Asn1Type type, int length) { switch (type.Tag) { case Asn1Tag.Null: return null; case Asn1Tag.Integer: return ReadInteger(length); case Asn1Tag.OctetString: return ReadOctetString(length); case Asn1Tag.ObjectIdentifier: return ReadOID(length); default: Skip(length); return "NYI: " + type.Tag; } }