HermaFx.Cryptography.ASN1.Decode C# (CSharp) 메소드

Decode() 보호된 메소드

protected Decode ( byte asn1, int &anPos, int anLength ) : void
asn1 byte
anPos int
anLength int
리턴 void
        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
            }
        }

Usage Example

예제 #1
0
파일: ASN1.cs 프로젝트: raulmola/HermaFx
        // Note: Recursive
        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
            }
        }