/**
* build an object given its tag and the number of bytes to construct it from.
*/
private Asn1Object BuildObject(
int tag,
int tagNo,
int length)
{
bool isConstructed = (tag & Asn1Tags.Constructed) != 0;
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 Asn1StreamParser(defIn).ReadTaggedObject(isConstructed, tagNo));
}
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()));
}