Esempio n. 1
0
        /// <summary>
        /// compute response
        /// </summary>
        /// <param name="flags">the flags for challenge</param>
        /// <param name="serverChallenge">the server challenge</param>
        /// <param name="targetInfo">the target info contains avpairs</param>
        /// <param name="responseKeyNT">the response nt key</param>
        /// <param name="responseKeyLM">the response lm key</param>
        /// <param name="lmChallengeResponse">the challenge response lm</param>
        /// <param name="ntChallengeResponse">the challenge response nt</param>
        private void ComputeResponse(
            NegotiateTypes flags,
            ulong serverChallenge,
            ICollection <AV_PAIR> targetInfo,
            byte[] responseKeyNT,
            byte[] responseKeyLM,
            out byte[] lmChallengeResponse,
            out byte[] ntChallengeResponse
            )
        {
            // clientChallenge, a random 8 bytes.
            ulong clientChallenge = NlmpUtility.BytesToSecurityUInt64(NlmpUtility.Nonce(8));

            // time
            ulong time = 0;

            if (!NlmpUtility.IsNtlmV1(this.client.Config.Version))
            {
                time = NlmpUtility.GetTime(targetInfo);
            }

            byte[] sessionBaseKey = null;

            // compute response
            NlmpUtility.ComputeResponse(
                this.client.Config.Version, flags, responseKeyNT, responseKeyLM, serverChallenge, clientChallenge,
                time, NlmpUtility.AvPairCollectionGetBytes(targetInfo), out ntChallengeResponse,
                out lmChallengeResponse, out sessionBaseKey);

            // save key to context
            this.client.Context.SessionBaseKey = sessionBaseKey;
        }