Example #1
0
File: ASN1.cs Project: sv99/DVSDK
        // Public Constructors
        public Asn1Length( Stream dataStream )
            : base()
        {
            Byte b = ReadByte(dataStream);

              if ((b & 0x80) == 0x00)
              {
            lengthType = Asn1LengthType.SHORT;
            // Short Form
            length = (UInt32) (b & 0x7F);
              }
              else
              {
            length = 0;
            // Long Form
            UInt32 numLengthOctets = (UInt32) (b & 0x7F);
            if (numLengthOctets == 0x00)
            {
              lengthType = Asn1LengthType.LONG_INDEFINITE;
            }
            else
            {
              lengthType = Asn1LengthType.LONG_DEFINITE;
              while (numLengthOctets > 0)
              {
            b = ReadByte(dataStream);
            length <<= 8;
            length |= b;
            numLengthOctets--;
              }
            }
              }
        }