HermaFx.Cryptography.ASN1.DecodeTLV C# (CSharp) Method

DecodeTLV() protected method

protected DecodeTLV ( byte asn1, int &pos, byte &tag, int &length, byte &content ) : void
asn1 byte
pos int
tag byte
length int
content byte
return void
        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);
        }