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
{
throw new IOException("indefinite length primitive encoding encountered");
}
else
{
try
{
return BuildObject(tag, tagNo, length);
}
catch(ArgumentException e)
{
throw new Asn1Exception("corrupted stream detected", e);
}
}
}