protected void DecodeTLV(byte[] asn1, ref int pos, out byte tag, out int length, out byte[] content)
{
tag = asn1[pos++];
length = asn1[pos++];
// special case where L contains the Length of the Length + 0x80
if ((length & 0x80) == 0x80)
{
int nLengthLen = length & 0x7F;
length = 0;
for (int i = 0; i < nLengthLen; i++)
length = length * 256 + asn1[pos++];
}
content = new byte[length];
Buffer.BlockCopy(asn1, pos, content, 0, length);
}