public override byte[] GetBytes()
        {
            byte [] name_bytes = null, target = null;
            short   name_len = 0, target_len = 0;

            if (TargetName != null)
            {
                Encoding enc = (Flags & NtlmFlags.NegotiateUnicode) != 0 ? Encoding.Unicode : Encoding.UTF8;
                name_bytes = enc.GetBytes(TargetName);
                name_len   = (short)name_bytes.Length;
            }
            if (Version != NtlmVersion.Version1)
            {
                target     = _target.ToBytes();
                target_len = (short)target.Length;
            }

            uint name_offset = (uint)(Version == NtlmVersion.Version3 ? 56 : 40);

            int size = (int)name_offset +
                       (name_len > 0 ? name_len + 8 : 0) +
                       (target_len > 0 ? target_len + 8 : 0);

            byte[] data = PrepareMessage(size);

            // target name
            data [12] = (byte)name_len;
            data [13] = (byte)(name_len >> 8);
            data [14] = data [12];
            data [15] = data [13];
            data [16] = (byte)name_offset;
            data [17] = (byte)(name_offset >> 8);
            data [18] = (byte)(name_offset >> 16);
            data [19] = (byte)(name_offset >> 24);

            // flags
            data [20] = (byte)Flags;
            data [21] = (byte)((uint)Flags >> 8);
            data [22] = (byte)((uint)Flags >> 16);
            data [23] = (byte)((uint)Flags >> 24);

            Buffer.BlockCopy(_nonce, 0, data, 24, _nonce.Length);

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

            // context
            Buffer.BlockCopy(_context, 0, data, 32, 8);

            // target information
            data [40] = (byte)target_len;
            data [41] = (byte)(target_len >> 8);
            data [42] = data [40];
            data [43] = data [41];
            uint info_offset = (uint)(name_offset + name_bytes.Length);

            data [44] = (byte)info_offset;
            data [45] = (byte)(info_offset >> 8);
            data [46] = (byte)(info_offset >> 16);
            data [47] = (byte)(info_offset >> 24);

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

            Buffer.BlockCopy(name_bytes, 0, data, (int)name_offset, name_len);
            Buffer.BlockCopy(target, 0, data, (int)info_offset, target.Length);

            return(data);
        }