/// <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. byte[] data = new Type3Message(Username, Password, msg.Challenge, Username, true, msg.TargetName, msg.RawTargetInformation).Serialize(); return data; } catch (Exception e) { throw new SaslException("The challenge response could not be " + "computed.", e); } }
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)); }
/// <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 byte[] ComputeChallengeResponse(byte[] challenge) { try { Type2Message msg = Type2Message.Deserialize(challenge); byte[] data = new Type3Message(Username, Password, msg.Challenge, "Workstation").Serialize(); return data; } catch (Exception e) { throw new SaslException("The challenge response could not be " + "computed.", e); } }