// methods

        protected override void Decode(byte[] message)
        {
            base.Decode(message);

            short targetNameSize   = BitConverterLE.ToInt16(message, 12);
            int   targetNameOffset = BitConverterLE.ToInt32(message, 16);

            Flags = (NtlmFlags)BitConverterLE.ToUInt32(message, 20);

            Buffer.BlockCopy(message, 24, _nonce, 0, 8);

            if (Version == NtlmVersion.Version1)
            {
                return;
            }

            Buffer.BlockCopy(message, 32, _context, 0, 8);
            short targetInfoSize   = BitConverterLE.ToInt16(message, 40);
            int   targetInfoOffset = BitConverterLE.ToInt32(message, 44);

            if (Version == NtlmVersion.Version3)
            {
                Buffer.BlockCopy(OSVersion, 0, message, 48, OSVersion.Length);
            }

            Encoding enc = (Flags & NtlmFlags.NegotiateUnicode) != 0 ? Encoding.Unicode : Encoding.UTF8;

            if (targetNameSize > 0)
            {
                TargetName = enc.GetString(message, targetNameOffset, targetNameSize);
            }

            _target.Decode(message, targetInfoOffset, targetInfoSize);
        }
        public void Decode(byte [] bytes, int length, int offset)
        {
            int end = offset + length;

            for (int pos = offset; pos < end;)
            {
                short  type = BitConverterLE.ToInt16(bytes, pos);                 // reader.ReadInt16 ();
                short  blen = BitConverterLE.ToInt16(bytes, pos + 2);             // reader.ReadInt16 ();
                string s    = Encoding.Unicode.GetString(bytes, pos + 4, blen);
                pos += blen + 4;
                switch (type)
                {
                case 0: break;                 // terminator

                case 1: ServerName = s; break;

                case 2: DomainName = s; break;

                case 3: DnsHostName = s; break;

                case 4: DnsDomainName = s; break;

                default:
                    throw new ArgumentException(String.Format("Invalid SSPI message type 2 subblock type: {0}", type));
                }
                if (type == 0)
                {
                    break;                     // terminator subblock
                }
            }
        }
Example #3
0
 public JSImplGuid(byte[] b)
 {
     JSImplGuid.CheckArray(b, 16);
     this._a = BitConverterLE.ToInt32(b, 0);
     this._b = BitConverterLE.ToInt16(b, 4);
     this._c = BitConverterLE.ToInt16(b, 6);
     this._d = b[8];
     this._e = b[9];
     this._f = b[10];
     this._g = b[11];
     this._h = b[12];
     this._i = b[13];
     this._j = b[14];
     this._k = b[15];
 }