protected void Decode(byte[] asn1, ref int anPos, int anLength)
{
byte nTag;
int nLength;
byte[] aValue;
// minimum is 2 bytes (tag + length of 0)
while (anPos < anLength - 1)
{
DecodeTLV(asn1, ref anPos, out nTag, out nLength, out aValue);
// sometimes we get trailing 0
if (nTag == 0)
continue;
ASN1 elm = Add(new ASN1(nTag, aValue));
if ((nTag & 0x20) == 0x20)
{
int nConstructedPos = anPos;
elm.Decode(asn1, ref nConstructedPos, nConstructedPos + nLength);
}
anPos += nLength; // value length
}
}