public static byte[] GetLmPasswordHash(SecureString password) { var passwordBuf = GetLmPasswordBuffer(password); var input = Encoding.ASCII.GetBytes("KGS!@#$%KGS!@#$%"); return(DesHash.ComputeHash(passwordBuf, input)); }
public static byte[] GetLmChallengeResponse(byte[] challenge, SecureString password) { var lmPasswordHash = GetLmPasswordHash(password); var key = new byte[21]; Buffer.BlockCopy(lmPasswordHash, 0, key, 0, 16); Buffer.BlockCopy(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, key, 16, 5); var input = new byte[24]; for (var i = 0; i < 3; i++) { Buffer.BlockCopy(challenge, 0, input, i * 8, 8); } return(DesHash.ComputeHash(key, input)); }
public static byte[] GetNtResponse(byte[] authenticatorChallenge, byte[] peerChallenge, byte[] userBuf, SecureString password) { var challengeHash = GetChallengeHash(authenticatorChallenge, peerChallenge, userBuf); var input = new byte[24]; for (var i = 0; i < 3; i++) { Buffer.BlockCopy(challengeHash, 0, input, i * 8, 8); } var passwordHash = GetNtPasswordHash(password); var key = new byte[21]; Buffer.BlockCopy(passwordHash, 0, key, 0, 16); Buffer.BlockCopy(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, key, 16, 5); return(DesHash.ComputeHash(key, input)); }