19unsigned char *LM_Password_Hash(
const unsigned char *password,
unsigned char *cipher)
21 unsigned char tmp_pass[14] = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0"};
27 strncpy((
char *)tmp_pass, (
const char *)password, 14);
30 for (i = 0; i < 14; i++) {
31 tmp_pass[i] = toupper(tmp_pass[i]);
35 memcpy(K1, &tmp_pass[0], 7);
36 memcpy(K2, &tmp_pass[7], 7);
39 DES(K1, (
const unsigned char *)
"KGS!@#$%", &cipher[0]);
40 DES(K2, (
const unsigned char *)
"KGS!@#$%", &cipher[8]);
48unsigned char *NTLM_Password_Hash(
const unsigned char *password,
unsigned char *cipher)
52 memset(passwd_buf, 0,
sizeof(passwd_buf));
55 for (i = 0, j = 0; (
unsigned int)i < strlen((
const char *)password); i++, j += 2)
56 passwd_buf[j] = password[i];
59 MD4(passwd_buf, j, cipher);
61 return (
unsigned char *)cipher;
67unsigned char *LM_Response(
const unsigned char *LMpasswordhash,
unsigned char *chal,
unsigned char *cipher)
69 unsigned char P21[21];
74 memcpy(&P21[0], LMpasswordhash, 16);
75 memset(&P21[16], 0, 5);
78 for (i = 0; i < 3; i++) {
81 memcpy(K, &P21[i * 7], 7);
84 DES(K, chal, &cipher[i * 8]);
87 return (
unsigned char *)cipher;