public Asn1Object ReadObject() { int tag = ReadByte(); if (tag <= 0) { if (tag == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } // // calculate tag number // int tagNo = ReadTagNumber(this.s, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = ReadLength(this.s, limit); if (length < 0) // indefinite length method { if (!isConstructed) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(this.s, limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, limit); if ((tag & Asn1Tags.Application) != 0) { return(new BerApplicationSpecificParser(tagNo, sp).ToAsn1Object()); } if ((tag & Asn1Tags.Tagged) != 0) { return(new BerTaggedObjectParser(true, tagNo, sp).ToAsn1Object()); } // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: return(new BerOctetStringParser(sp).ToAsn1Object()); case Asn1Tags.Sequence: return(new BerSequenceParser(sp).ToAsn1Object()); case Asn1Tags.Set: return(new BerSetParser(sp).ToAsn1Object()); case Asn1Tags.External: return(new DerExternalParser(sp).ToAsn1Object()); default: throw new IOException("unknown BER object encountered"); } } else { try { return(BuildObject(tag, tagNo, length)); } catch (ArgumentException e) { throw new Asn1Exception("corrupted stream detected", e); } } }
public Asn1Object ReadObject() { int tag = ReadByte(); if (tag <= 0) { if (tag == 0) throw new IOException("unexpected end-of-contents marker"); return null; } // // calculate tag number // int tagNo = ReadTagNumber(this, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = ReadLength(this, limit); if (length < 0) // indefinite length method { if (!isConstructed) throw new IOException("indefinite length primitive encoding encountered"); IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(this); if ((tag & Asn1Tags.Application) != 0) { Asn1StreamParser sp2 = new Asn1StreamParser(indIn); return new BerApplicationSpecificParser(tagNo, sp2).ToAsn1Object(); } if ((tag & Asn1Tags.Tagged) != 0) { // TODO Investigate passing an Asn1StreamParser into this constructor return new BerTaggedObjectParser(tag, tagNo, indIn).ToAsn1Object(); } Asn1StreamParser sp = new Asn1StreamParser(indIn); // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: return new BerOctetStringParser(sp).ToAsn1Object(); case Asn1Tags.Sequence: return new BerSequenceParser(sp).ToAsn1Object(); case Asn1Tags.Set: return new BerSetParser(sp).ToAsn1Object(); default: throw new IOException("unknown BER object encountered"); } } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(this, length); if ((tag & Asn1Tags.Application) != 0) { return new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray()); } if ((tag & Asn1Tags.Tagged) != 0) { return new BerTaggedObjectParser(tag, tagNo, defIn).ToAsn1Object(); } if (isConstructed) { // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: // // yes, people actually do this... // return new BerOctetString(BuildDerEncodableVector(defIn)); case Asn1Tags.Sequence: return CreateDerSequence(defIn); case Asn1Tags.Set: return CreateDerSet(defIn); default: return new DerUnknownTag(true, tagNo, defIn.ToArray()); } } return CreatePrimitiveDerObject(tagNo, defIn.ToArray()); } }
public virtual IAsn1Convertible ReadObject() { int tag = _in.ReadByte(); if (tag == -1) { return(null); } // turn of looking for "00" while we resolve the tag Set00Check(false); // // calculate tag number // int tagNo = Asn1InputStream.ReadTagNumber(_in, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = Asn1InputStream.ReadLength(_in, _limit); if (length < 0) // indefinite length method { if (!isConstructed) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, _limit); if ((tag & Asn1Tags.Application) != 0) { return(new BerApplicationSpecificParser(tagNo, sp)); } if ((tag & Asn1Tags.Tagged) != 0) { return(new BerTaggedObjectParser(true, tagNo, sp)); } return(sp.ReadIndef(tagNo)); } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length); if ((tag & Asn1Tags.Application) != 0) { return(new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray())); } if ((tag & Asn1Tags.Tagged) != 0) { return(new BerTaggedObjectParser(isConstructed, tagNo, new Asn1StreamParser(defIn))); } if (isConstructed) { // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: // // yes, people actually do this... // return(new BerOctetStringParser(new Asn1StreamParser(defIn))); case Asn1Tags.Sequence: return(new DerSequenceParser(new Asn1StreamParser(defIn))); case Asn1Tags.Set: return(new DerSetParser(new Asn1StreamParser(defIn))); case Asn1Tags.External: return(new DerExternalParser(new Asn1StreamParser(defIn))); default: throw new IOException("unknown tag " + tagNo + " encountered"); } } // Some primitive encodings can be handled by parsers too... switch (tagNo) { case Asn1Tags.OctetString: return(new DerOctetStringParser(defIn)); } try { return(Asn1InputStream.CreatePrimitiveDerObject(tagNo, defIn, tmpBuffers)); } catch (ArgumentException e) { throw new Asn1Exception("corrupted stream detected", e); } } }
public virtual IAsn1Convertible ReadObject() { int tag = _in.ReadByte(); if (tag == -1) return null; // turn of looking for "00" while we resolve the tag Set00Check(false); // // calculate tag number // int tagNo = Asn1InputStream.ReadTagNumber(_in, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = Asn1InputStream.ReadLength(_in, _limit); if (length < 0) // indefinite length method { if (!isConstructed) throw new IOException("indefinite length primitive encoding encountered"); IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, _limit); if ((tag & Asn1Tags.Application) != 0) { return new BerApplicationSpecificParser(tagNo, sp); } if ((tag & Asn1Tags.Tagged) != 0) { return new BerTaggedObjectParser(true, tagNo, sp); } return sp.ReadIndef(tagNo); } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length); if ((tag & Asn1Tags.Application) != 0) { return new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray()); } if ((tag & Asn1Tags.Tagged) != 0) { return new BerTaggedObjectParser(isConstructed, tagNo, new Asn1StreamParser(defIn)); } if (isConstructed) { // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: // // yes, people actually do this... // return new BerOctetStringParser(new Asn1StreamParser(defIn)); case Asn1Tags.Sequence: return new DerSequenceParser(new Asn1StreamParser(defIn)); case Asn1Tags.Set: return new DerSetParser(new Asn1StreamParser(defIn)); case Asn1Tags.External: return new DerExternalParser(new Asn1StreamParser(defIn)); default: // TODO Add DerUnknownTagParser class? return new DerUnknownTag(true, tagNo, defIn.ToArray()); } } // Some primitive encodings can be handled by parsers too... switch (tagNo) { case Asn1Tags.OctetString: return new DerOctetStringParser(defIn); } try { return Asn1InputStream.CreatePrimitiveDerObject(tagNo, defIn.ToArray()); } catch (ArgumentException e) { throw new Asn1Exception("corrupted stream detected", e); } } }
public Asn1Object ReadObject() { int tag = ReadByte(); if (tag <= 0) { if (tag == 0) throw new IOException("unexpected end-of-contents marker"); return null; } // // calculate tag number // int tagNo = ReadTagNumber(this.s, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = ReadLength(this.s, limit); if (length < 0) // indefinite length method { if (!isConstructed) throw new IOException("indefinite length primitive encoding encountered"); IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(this.s, limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, limit); if ((tag & Asn1Tags.Application) != 0) { return new BerApplicationSpecificParser(tagNo, sp).ToAsn1Object(); } if ((tag & Asn1Tags.Tagged) != 0) { return new BerTaggedObjectParser(true, tagNo, sp).ToAsn1Object(); } // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: return new BerOctetStringParser(sp).ToAsn1Object(); case Asn1Tags.Sequence: return new BerSequenceParser(sp).ToAsn1Object(); case Asn1Tags.Set: return new BerSetParser(sp).ToAsn1Object(); case Asn1Tags.External: return new DerExternalParser(sp).ToAsn1Object(); default: throw new IOException("unknown BER object encountered"); } } else { try { return BuildObject(tag, tagNo, length); } catch (ArgumentException e) { throw new Asn1Exception("corrupted stream detected", e); } } }
public virtual IAsn1Convertible ReadObject() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown int num = _in.ReadByte(); if (num == -1) { return(null); } Set00Check(enabled: false); int num2 = Asn1InputStream.ReadTagNumber(_in, num); bool flag = (num & 0x20) != 0; int num3 = Asn1InputStream.ReadLength(_in, _limit); if (num3 < 0) { if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser asn1StreamParser = new Asn1StreamParser((Stream)(object)inStream, _limit); if (((uint)num & 0x40u) != 0) { return(new BerApplicationSpecificParser(num2, asn1StreamParser)); } if (((uint)num & 0x80u) != 0) { return(new BerTaggedObjectParser(constructed: true, num2, asn1StreamParser)); } return(asn1StreamParser.ReadIndef(num2)); } DefiniteLengthInputStream definiteLengthInputStream = new DefiniteLengthInputStream(_in, num3); if (((uint)num & 0x40u) != 0) { return(new DerApplicationSpecific(flag, num2, definiteLengthInputStream.ToArray())); } if (((uint)num & 0x80u) != 0) { return(new BerTaggedObjectParser(flag, num2, new Asn1StreamParser((Stream)(object)definiteLengthInputStream))); } if (flag) { switch (num2) { case 4: return(new BerOctetStringParser(new Asn1StreamParser((Stream)(object)definiteLengthInputStream))); case 16: return(new DerSequenceParser(new Asn1StreamParser((Stream)(object)definiteLengthInputStream))); case 17: return(new DerSetParser(new Asn1StreamParser((Stream)(object)definiteLengthInputStream))); case 8: return(new DerExternalParser(new Asn1StreamParser((Stream)(object)definiteLengthInputStream))); default: throw new IOException(string.Concat((object)"unknown tag ", (object)num2, (object)" encountered")); } } int num4 = num2; if (num4 == 4) { return(new DerOctetStringParser(definiteLengthInputStream)); } try { return(Asn1InputStream.CreatePrimitiveDerObject(num2, definiteLengthInputStream, tmpBuffers)); } catch (ArgumentException val) { ArgumentException exception = val; throw new Asn1Exception("corrupted stream detected", (global::System.Exception)(object) exception); } }
public IAsn1Convertible ReadObject() { int tag = _in.ReadByte(); if (tag == -1) { if (_eofFound) { throw new EndOfStreamException("attempt to read past end of file."); } _eofFound = true; return(null); } // // turn of looking for "00" while we resolve the tag // if (_in is IndefiniteLengthInputStream) { ((IndefiniteLengthInputStream)_in).SetEofOn00(false); } // // calculate tag number // int baseTagNo = tag & ~Asn1Tags.Constructed; int tagNo = baseTagNo; if ((tag & Asn1Tags.Tagged) != 0) { tagNo = tag & 0x1f; // // with tagged object tag number is bottom 5 bits, or stored at the start of the content // if (tagNo == 0x1f) { tagNo = 0; int b = _in.ReadByte(); while ((b >= 0) && ((b & 0x80) != 0)) { tagNo |= (b & 0x7f); tagNo <<= 7; b = _in.ReadByte(); } if (b < 0) { _eofFound = true; throw new EndOfStreamException("EOF encountered inside tag value."); } tagNo |= (b & 0x7f); } } // // calculate length // int length = ReadLength(); if (length < 0) // indefinite length { IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in); if (baseTagNo == Asn1Tags.Null) { return(BerNull.Instance); } switch (baseTagNo) { case Asn1Tags.OctetString: return(new BerOctetStringParser(new Asn1ObjectParser(tag, tagNo, indIn))); case Asn1Tags.Sequence: return(new BerSequenceParser(new Asn1ObjectParser(tag, tagNo, indIn))); case Asn1Tags.Set: return(new BerSetParser(new Asn1ObjectParser(tag, tagNo, indIn))); default: return(new BerTaggedObjectParser(tag, tagNo, indIn)); } } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length); switch (baseTagNo) { case Asn1Tags.Integer: return(new DerInteger(defIn.ToArray())); case Asn1Tags.Null: return(DerNull.Instance); case Asn1Tags.ObjectIdentifier: return(new DerObjectIdentifier(defIn.ToArray())); case Asn1Tags.OctetString: return(new DerOctetString(defIn.ToArray())); case Asn1Tags.Sequence: return(new DerSequence(loadVector(defIn.ToArray())).Parser); case Asn1Tags.Set: return(new DerSet(loadVector(defIn.ToArray())).Parser); default: return(new BerTaggedObjectParser(tag, tagNo, defIn)); } } }
public virtual IAsn1Convertible ReadObject() { IAsn1Convertible convertible; int tag = this._in.ReadByte(); if (tag == -1) { return(null); } this.Set00Check(false); int num2 = Asn1InputStream.ReadTagNumber(this._in, tag); bool isConstructed = (tag & 0x20) != 0; int length = Asn1InputStream.ReadLength(this._in, this._limit); if (length < 0) { if (!isConstructed) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream stream = new IndefiniteLengthInputStream(this._in, this._limit); Asn1StreamParser parser = new Asn1StreamParser(stream, this._limit); if ((tag & 0x40) != 0) { return(new BerApplicationSpecificParser(num2, parser)); } if ((tag & 0x80) != 0) { return(new BerTaggedObjectParser(true, num2, parser)); } return(parser.ReadIndef(num2)); } DefiniteLengthInputStream inStream = new DefiniteLengthInputStream(this._in, length); if ((tag & 0x40) != 0) { return(new DerApplicationSpecific(isConstructed, num2, inStream.ToArray())); } if ((tag & 0x80) != 0) { return(new BerTaggedObjectParser(isConstructed, num2, new Asn1StreamParser(inStream))); } if (isConstructed) { switch (num2) { case 0x10: return(new DerSequenceParser(new Asn1StreamParser(inStream))); case 0x11: return(new DerSetParser(new Asn1StreamParser(inStream))); case 4: return(new BerOctetStringParser(new Asn1StreamParser(inStream))); case 8: return(new DerExternalParser(new Asn1StreamParser(inStream))); } throw new IOException("unknown tag " + num2 + " encountered"); } if (num2 == 4) { return(new DerOctetStringParser(inStream)); } try { convertible = Asn1InputStream.CreatePrimitiveDerObject(num2, inStream, this.tmpBuffers); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); } return(convertible); }
public Asn1Object ReadObject() { Asn1Object obj2; int tag = this.ReadByte(); if (tag <= 0) { if (tag == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } int num2 = ReadTagNumber(base.s, tag); bool flag = (tag & 0x20) != 0; int length = ReadLength(base.s, this.limit); if (length < 0) { if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(base.s, this.limit); Asn1StreamParser parser = new Asn1StreamParser(inStream, this.limit); if ((tag & 0x40) != 0) { return(new BerApplicationSpecificParser(num2, parser).ToAsn1Object()); } if ((tag & 0x80) != 0) { return(new BerTaggedObjectParser(true, num2, parser).ToAsn1Object()); } if (num2 == 0x10) { return(new BerSequenceParser(parser).ToAsn1Object()); } if (num2 == 0x11) { return(new BerSetParser(parser).ToAsn1Object()); } if (num2 == 4) { return(new BerOctetStringParser(parser).ToAsn1Object()); } if (num2 != 8) { throw new IOException("unknown BER object encountered"); } return(new DerExternalParser(parser).ToAsn1Object()); } try { obj2 = this.BuildObject(tag, num2, length); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); } return(obj2); }
public Asn1Object ReadObject() { int num = this.ReadByte(); if (num <= 0) { if (num == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } else { int num2 = Asn1InputStream.ReadTagNumber(this.s, num); bool flag = (num & 32) != 0; int num3 = Asn1InputStream.ReadLength(this.s, this.limit); if (num3 >= 0) { Asn1Object result; try { result = this.BuildObject(num, num2, num3); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); } return(result); } if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(this.s, this.limit); Asn1StreamParser parser = new Asn1StreamParser(inStream, this.limit); if ((num & 64) != 0) { return(new BerApplicationSpecificParser(num2, parser).ToAsn1Object()); } if ((num & 128) != 0) { return(new BerTaggedObjectParser(true, num2, parser).ToAsn1Object()); } int num4 = num2; if (num4 == 4) { return(new BerOctetStringParser(parser).ToAsn1Object()); } if (num4 == 8) { return(new DerExternalParser(parser).ToAsn1Object()); } switch (num4) { case 16: return(new BerSequenceParser(parser).ToAsn1Object()); case 17: return(new BerSetParser(parser).ToAsn1Object()); default: throw new IOException("unknown BER object encountered"); } } }
public IAsn1Convertible ReadObject() { int tag = _in.ReadByte(); if (tag == -1) { if (_eofFound) throw new EndOfStreamException("attempt to read past end of file."); _eofFound = true; return null; } // // turn of looking for "00" while we resolve the tag // if (_in is IndefiniteLengthInputStream) { ((IndefiniteLengthInputStream)_in).SetEofOn00(false); } // // calculate tag number // int baseTagNo = tag & ~Asn1Tags.Constructed; int tagNo = baseTagNo; if ((tag & Asn1Tags.Tagged) != 0) { tagNo = tag & 0x1f; // // with tagged object tag number is bottom 5 bits, or stored at the start of the content // if (tagNo == 0x1f) { tagNo = 0; int b = _in.ReadByte(); while ((b >= 0) && ((b & 0x80) != 0)) { tagNo |= (b & 0x7f); tagNo <<= 7; b = _in.ReadByte(); } if (b < 0) { _eofFound = true; throw new EndOfStreamException("EOF encountered inside tag value."); } tagNo |= (b & 0x7f); } } // // calculate length // int length = ReadLength(); if (length < 0) // indefinite length { IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in); if (baseTagNo == Asn1Tags.Null) { return BerNull.Instance; } switch (baseTagNo) { case Asn1Tags.OctetString: return new BerOctetStringParser(new Asn1ObjectParser(tag, tagNo, indIn)); case Asn1Tags.Sequence: return new BerSequenceParser(new Asn1ObjectParser(tag, tagNo, indIn)); case Asn1Tags.Set: return new BerSetParser(new Asn1ObjectParser(tag, tagNo, indIn)); default: return new BerTaggedObjectParser(tag, tagNo, indIn); } } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length); switch (baseTagNo) { case Asn1Tags.Integer: return new DerInteger(defIn.ToArray()); case Asn1Tags.Null: return DerNull.Instance; case Asn1Tags.ObjectIdentifier: return new DerObjectIdentifier(defIn.ToArray()); case Asn1Tags.OctetString: return new DerOctetString(defIn.ToArray()); case Asn1Tags.Sequence: return new DerSequence(loadVector(defIn.ToArray())).Parser; case Asn1Tags.Set: return new DerSet(loadVector(defIn.ToArray())).Parser; default: return new BerTaggedObjectParser(tag, tagNo, defIn); } } }
public Asn1Object ReadObject() { int tag = ReadByte(); if (tag <= 0) { if (tag == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } // // calculate tag number // int tagNo = ReadTagNumber(this, tag); bool isConstructed = (tag & Asn1Tags.Constructed) != 0; // // calculate length // int length = ReadLength(this, limit); if (length < 0) // indefinite length method { if (!isConstructed) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(this); if ((tag & Asn1Tags.Application) != 0) { Asn1StreamParser sp2 = new Asn1StreamParser(indIn, limit); return(new BerApplicationSpecificParser(tagNo, sp2).ToAsn1Object()); } if ((tag & Asn1Tags.Tagged) != 0) { // TODO Investigate passing an Asn1StreamParser into this constructor return(new BerTaggedObjectParser(tag, tagNo, indIn).ToAsn1Object()); } Asn1StreamParser sp = new Asn1StreamParser(indIn, limit); // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: return(new BerOctetStringParser(sp).ToAsn1Object()); case Asn1Tags.Sequence: return(new BerSequenceParser(sp).ToAsn1Object()); case Asn1Tags.Set: return(new BerSetParser(sp).ToAsn1Object()); case Asn1Tags.External: return(new DerExternalParser(sp).ToAsn1Object()); default: throw new IOException("unknown BER object encountered"); } } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(this, length); if ((tag & Asn1Tags.Application) != 0) { return(new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray())); } if ((tag & Asn1Tags.Tagged) != 0) { return(new BerTaggedObjectParser(tag, tagNo, defIn).ToAsn1Object()); } if (isConstructed) { // TODO There are other tags that may be constructed (e.g. BitString) switch (tagNo) { case Asn1Tags.OctetString: // // yes, people actually do this... // return(new BerOctetString(BuildDerEncodableVector(defIn))); case Asn1Tags.Sequence: return(CreateDerSequence(defIn)); case Asn1Tags.Set: return(CreateDerSet(defIn)); case Asn1Tags.External: return(new DerExternal(BuildDerEncodableVector(defIn))); default: return(new DerUnknownTag(true, tagNo, defIn.ToArray())); } } return(CreatePrimitiveDerObject(tagNo, defIn.ToArray())); } }
public virtual IAsn1Convertible ReadObject() { int num = this._in.ReadByte(); if (num == -1) { return(null); } this.Set00Check(false); int num2 = Asn1InputStream.ReadTagNumber(this._in, num); bool flag = (num & 32) != 0; int num3 = Asn1InputStream.ReadLength(this._in, this._limit); if (num3 < 0) { if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(this._in, this._limit); Asn1StreamParser asn1StreamParser = new Asn1StreamParser(inStream, this._limit); if ((num & 64) != 0) { return(new BerApplicationSpecificParser(num2, asn1StreamParser)); } if ((num & 128) != 0) { return(new BerTaggedObjectParser(true, num2, asn1StreamParser)); } return(asn1StreamParser.ReadIndef(num2)); } else { DefiniteLengthInputStream definiteLengthInputStream = new DefiniteLengthInputStream(this._in, num3); if ((num & 64) != 0) { return(new DerApplicationSpecific(flag, num2, definiteLengthInputStream.ToArray())); } if ((num & 128) != 0) { return(new BerTaggedObjectParser(flag, num2, new Asn1StreamParser(definiteLengthInputStream))); } if (flag) { int num4 = num2; if (num4 == 4) { return(new BerOctetStringParser(new Asn1StreamParser(definiteLengthInputStream))); } if (num4 == 8) { return(new DerExternalParser(new Asn1StreamParser(definiteLengthInputStream))); } switch (num4) { case 16: return(new DerSequenceParser(new Asn1StreamParser(definiteLengthInputStream))); case 17: return(new DerSetParser(new Asn1StreamParser(definiteLengthInputStream))); default: throw new IOException("unknown tag " + num2 + " encountered"); } } else { int num5 = num2; if (num5 == 4) { return(new DerOctetStringParser(definiteLengthInputStream)); } IAsn1Convertible result; try { result = Asn1InputStream.CreatePrimitiveDerObject(num2, definiteLengthInputStream, this.tmpBuffers); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); } return(result); } } }
public Asn1Object ReadObject() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown int num = ((Stream)this).ReadByte(); if (num <= 0) { if (num == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } int num2 = ReadTagNumber(s, num); bool flag = (num & 0x20) != 0; int num3 = ReadLength(s, limit); if (num3 < 0) { if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(s, limit); Asn1StreamParser parser = new Asn1StreamParser((Stream)(object)inStream, limit); if (((uint)num & 0x40u) != 0) { return(new BerApplicationSpecificParser(num2, parser).ToAsn1Object()); } if (((uint)num & 0x80u) != 0) { return(new BerTaggedObjectParser(constructed: true, num2, parser).ToAsn1Object()); } switch (num2) { case 4: return(new BerOctetStringParser(parser).ToAsn1Object()); case 16: return(new BerSequenceParser(parser).ToAsn1Object()); case 17: return(new BerSetParser(parser).ToAsn1Object()); case 8: return(new DerExternalParser(parser).ToAsn1Object()); default: throw new IOException("unknown BER object encountered"); } } try { return(BuildObject(num, num2, num3)); } catch (ArgumentException val) { ArgumentException exception = val; throw new Asn1Exception("corrupted stream detected", (global::System.Exception)(object) exception); } }
public Asn1Object ReadObject() { int num = ReadByte(); if (num <= 0) { if (num == 0) { throw new IOException("unexpected end-of-contents marker"); } return(null); } int num2 = ReadTagNumber(s, num); bool flag = (num & 0x20) != 0; int num3 = ReadLength(s, limit); if (num3 >= 0) { try { return(BuildObject(num, num2, num3)); IL_0130: Asn1Object result; return(result); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); IL_0144: Asn1Object result; return(result); } } if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(s, limit); Asn1StreamParser parser = new Asn1StreamParser(inStream, limit); if ((num & 0x40) != 0) { return(new BerApplicationSpecificParser(num2, parser).ToAsn1Object()); } if ((num & 0x80) == 0) { switch (num2) { case 4: return(new BerOctetStringParser(parser).ToAsn1Object()); case 16: return(new BerSequenceParser(parser).ToAsn1Object()); case 17: return(new BerSetParser(parser).ToAsn1Object()); case 8: return(new DerExternalParser(parser).ToAsn1Object()); default: throw new IOException("unknown BER object encountered"); } } return(new BerTaggedObjectParser(constructed: true, num2, parser).ToAsn1Object()); }
public virtual IAsn1Convertible ReadObject() { int num = _in.ReadByte(); if (num == -1) { return(null); } Set00Check(enabled: false); int num2 = Asn1InputStream.ReadTagNumber(_in, num); bool flag = (num & 0x20) != 0; int num3 = Asn1InputStream.ReadLength(_in, _limit); if (num3 < 0) { if (!flag) { throw new IOException("indefinite length primitive encoding encountered"); } IndefiniteLengthInputStream inStream = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser asn1StreamParser = new Asn1StreamParser(inStream, _limit); if ((num & 0x40) != 0) { return(new BerApplicationSpecificParser(num2, asn1StreamParser)); } if ((num & 0x80) != 0) { return(new BerTaggedObjectParser(constructed: true, num2, asn1StreamParser)); } return(asn1StreamParser.ReadIndef(num2)); } DefiniteLengthInputStream definiteLengthInputStream = new DefiniteLengthInputStream(_in, num3); if ((num & 0x40) != 0) { return(new DerApplicationSpecific(flag, num2, definiteLengthInputStream.ToArray())); } if ((num & 0x80) != 0) { return(new BerTaggedObjectParser(flag, num2, new Asn1StreamParser(definiteLengthInputStream))); } if (flag) { switch (num2) { case 4: return(new BerOctetStringParser(new Asn1StreamParser(definiteLengthInputStream))); case 16: return(new DerSequenceParser(new Asn1StreamParser(definiteLengthInputStream))); case 17: return(new DerSetParser(new Asn1StreamParser(definiteLengthInputStream))); case 8: return(new DerExternalParser(new Asn1StreamParser(definiteLengthInputStream))); default: throw new IOException("unknown tag " + num2 + " encountered"); } } int num4 = num2; if (num4 != 4) { try { return(Asn1InputStream.CreatePrimitiveDerObject(num2, definiteLengthInputStream, tmpBuffers)); IL_019e: IAsn1Convertible result; return(result); } catch (ArgumentException exception) { throw new Asn1Exception("corrupted stream detected", exception); IL_01b2: IAsn1Convertible result; return(result); } } return(new DerOctetStringParser(definiteLengthInputStream)); }