mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-14 05:15:03 +02:00
NTLMCryptography: Minor styling change
This commit is contained in:
parent
7628bb6ba8
commit
c090de02ec
1 changed files with 16 additions and 16 deletions
|
@ -60,22 +60,6 @@ namespace SMBLibrary.Authentication.NTLM
|
||||||
return _NTProof;
|
return _NTProof;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks>
|
|
||||||
/// Caller must verify that the authenticate message has MIC before calling this method
|
|
||||||
/// </remarks>
|
|
||||||
public static bool ValidateAuthenticateMessageMIC(byte[] exportedSessionKey, byte[] negotiateMessageBytes, byte[] challengeMessageBytes, byte[] authenticateMessageBytes)
|
|
||||||
{
|
|
||||||
// https://msdn.microsoft.com/en-us/library/cc236695.aspx
|
|
||||||
int micFieldOffset = AuthenticateMessage.GetMicFieldOffset(authenticateMessageBytes);
|
|
||||||
byte[] expectedMic = ByteReader.ReadBytes(authenticateMessageBytes, micFieldOffset, AuthenticateMessage.MicFieldLenght);
|
|
||||||
|
|
||||||
ByteWriter.WriteBytes(authenticateMessageBytes, micFieldOffset, new byte[AuthenticateMessage.MicFieldLenght]);
|
|
||||||
byte[] temp = ByteUtils.Concatenate(ByteUtils.Concatenate(negotiateMessageBytes, challengeMessageBytes), authenticateMessageBytes);
|
|
||||||
byte[] mic = new HMACMD5(exportedSessionKey).ComputeHash(temp);
|
|
||||||
|
|
||||||
return ByteUtils.AreByteArraysEqual(mic, expectedMic);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] DesEncrypt(byte[] key, byte[] plainText)
|
public static byte[] DesEncrypt(byte[] key, byte[] plainText)
|
||||||
{
|
{
|
||||||
return DesEncrypt(key, plainText, 0, plainText.Length);
|
return DesEncrypt(key, plainText, 0, plainText.Length);
|
||||||
|
@ -273,5 +257,21 @@ namespace SMBLibrary.Authentication.NTLM
|
||||||
return keyExchangeKey;
|
return keyExchangeKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// Caller must verify that the authenticate message has MIC before calling this method
|
||||||
|
/// </remarks>
|
||||||
|
public static bool ValidateAuthenticateMessageMIC(byte[] exportedSessionKey, byte[] negotiateMessageBytes, byte[] challengeMessageBytes, byte[] authenticateMessageBytes)
|
||||||
|
{
|
||||||
|
// https://msdn.microsoft.com/en-us/library/cc236695.aspx
|
||||||
|
int micFieldOffset = AuthenticateMessage.GetMicFieldOffset(authenticateMessageBytes);
|
||||||
|
byte[] expectedMic = ByteReader.ReadBytes(authenticateMessageBytes, micFieldOffset, AuthenticateMessage.MicFieldLenght);
|
||||||
|
|
||||||
|
ByteWriter.WriteBytes(authenticateMessageBytes, micFieldOffset, new byte[AuthenticateMessage.MicFieldLenght]);
|
||||||
|
byte[] temp = ByteUtils.Concatenate(ByteUtils.Concatenate(negotiateMessageBytes, challengeMessageBytes), authenticateMessageBytes);
|
||||||
|
byte[] mic = new HMACMD5(exportedSessionKey).ComputeHash(temp);
|
||||||
|
|
||||||
|
return ByteUtils.AreByteArraysEqual(mic, expectedMic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue