Ejemplo n.º 1
0
        public void SerializeType3Message()
        {
            Type2Message m2 = Type2Message.Deserialize(type2MessageVersion3);
            // Compute the challenge response
            Type3Message msg = new Type3Message("Testuser", "Testpassword",
                                                m2.Challenge, "MyWorkstation");

            byte[] serialized = msg.Serialize();

            Assert.IsTrue(type3Message.SequenceEqual(serialized));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Computes the actual challenge response to an NTLM challenge
        /// which is sent as part of an NTLM type 2 message.
        /// </summary>
        /// <param name="challenge">The challenge sent by the server.</param>
        /// <returns>The response to the NTLM challenge.</returns>
        /// <exception cref="SaslException">Thrown if the challenge
        /// response could not be computed.</exception>
        protected new byte[] ComputeChallengeResponse(byte[] challenge)
        {
            try {
                Type2Message msg = Type2Message.Deserialize(challenge);
                // This creates an NTLMv2 challenge response.
                var type3Message = new Type3Message(Credential, msg.Challenge,
                                                    Credential.UserName, _additionalFlags, true, msg.TargetName,
                                                    msg.RawTargetInformation);
                SessionKey = type3Message.SessionKey;

                return(type3Message.Serialize());
            } catch (Exception e) {
                throw new SaslException("The challenge response could not be " +
                                        "computed.", e);
            }
        }