Exemplo n.º 1
0
        /// <summary>
        /// initialize the exportedSessionKey and internal keys
        /// </summary>
        /// <param name="flags">the flags of challenge</param>
        /// <param name="challenge">the challenge packet</param>
        /// <param name="responseKeyLM">the response key lm</param>
        /// <param name="lmChallengeResponse">the challenge response lm</param>
        /// <param name="encryptedRandomSessionKey">the encrypted random session key</param>
        /// <param name="exportedSessionKey">the exported session key</param>
        private void InitializeKeys(
            NegotiateTypes flags,
            NlmpChallengePacket challenge,
            byte[] responseKeyLM,
            byte[] lmChallengeResponse,
            out byte[] encryptedRandomSessionKey,
            out byte[] exportedSessionKey
            )
        {
            // keyExchangeKey
            byte[] keyExchangeKey = null;

            // get random session key
            NlmpUtility.GetEncryptedRandomSessionKey(
                this.client.Config.Version, flags, this.client.Context.SessionBaseKey, lmChallengeResponse,
                responseKeyLM, challenge.Payload.ServerChallenge, out encryptedRandomSessionKey, out keyExchangeKey,
                out exportedSessionKey);

            this.client.Context.ClientSigningKey = NlmpUtility.SignKey(flags, exportedSessionKey, "Client");
            this.client.Context.ServerSigningKey = NlmpUtility.SignKey(flags, exportedSessionKey, "Server");
            this.client.Context.ClientSealingKey = NlmpUtility.SealKey(flags, exportedSessionKey, "Client");
            this.client.Context.ServerSealingKey = NlmpUtility.SealKey(flags, exportedSessionKey, "Server");

            NlmpUtility.RC4Init(this.client.Context.ClientHandle, this.client.Context.ClientSealingKey);
            NlmpUtility.RC4Init(this.client.Context.ServerHandle, this.client.Context.ServerSealingKey);
        }
Exemplo n.º 2
0
        /// <summary>
        /// after successfully authenticate, initialize the keys and handles
        /// </summary>
        /// <param name="exportedSessionKey">the exported key to initialize the keys and handles</param>
        private void InitializeKeys(byte[] exportedSessionKey)
        {
            // initialize keys
            this.nlmpServer.Context.ClientSigningKey =
                NlmpUtility.SignKey(this.nlmpServer.Context.NegFlg, exportedSessionKey, "Client");
            this.nlmpServer.Context.ServerSigningKey =
                NlmpUtility.SignKey(this.nlmpServer.Context.NegFlg, exportedSessionKey, "Server");
            this.nlmpServer.Context.ClientSealingKey =
                NlmpUtility.SealKey(this.nlmpServer.Context.NegFlg, exportedSessionKey, "Client");
            this.nlmpServer.Context.ServerSealingKey =
                NlmpUtility.SealKey(this.nlmpServer.Context.NegFlg, exportedSessionKey, "Server");

            // initialize handles
            NlmpUtility.RC4Init(this.nlmpServer.Context.ClientHandle, this.nlmpServer.Context.ClientSealingKey);
            NlmpUtility.RC4Init(this.nlmpServer.Context.ServerHandle, this.nlmpServer.Context.ServerSealingKey);
        }