2 Unix SMB/CIFS implementation.
3 Password cacheing. obfuscation is planned
4 Copyright (C) Luke Kenneth Casson Leighton 1996-1998
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /****************************************************************************
24 Initialises a password structure.
25 ****************************************************************************/
27 static void pwd_init(struct pwd_info *pwd)
29 memset((char *)pwd->password , '\0', sizeof(pwd->password ));
30 memset((char *)pwd->smb_lm_pwd, '\0', sizeof(pwd->smb_lm_pwd));
31 memset((char *)pwd->smb_nt_pwd, '\0', sizeof(pwd->smb_nt_pwd));
32 memset((char *)pwd->smb_lm_owf, '\0', sizeof(pwd->smb_lm_owf));
33 memset((char *)pwd->smb_nt_owf, '\0', sizeof(pwd->smb_nt_owf));
35 pwd->null_pwd = True; /* safest option... */
36 pwd->cleartext = False;
40 /****************************************************************************
41 Makes lm and nt hashed passwords.
42 ****************************************************************************/
44 static void pwd_make_lm_nt_16(struct pwd_info *pwd, const char *clr)
48 nt_lm_owf_gen(clr, pwd->smb_nt_pwd, pwd->smb_lm_pwd);
49 pwd->null_pwd = False;
53 /****************************************************************************
54 Stores a cleartext password.
55 ****************************************************************************/
57 void pwd_set_cleartext(struct pwd_info *pwd, const char *clr)
59 pwd_make_lm_nt_16(pwd, clr);
60 fstrcpy(pwd->password, clr);
61 pwd->cleartext = True;
64 /****************************************************************************
65 Gets a cleartext password.
66 ****************************************************************************/
68 void pwd_get_cleartext(struct pwd_info *pwd, fstring clr)
71 fstrcpy(clr, pwd->password);
77 /****************************************************************************
78 Gets lm and nt hashed passwords.
79 ****************************************************************************/
81 void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
84 memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
86 memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
89 /****************************************************************************
90 Makes lm and nt OWF crypts.
91 ****************************************************************************/
93 void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
97 DEBUG(100,("client cryptkey: "));
98 dump_data(100, (char *)cryptkey, 8);
101 SMBOWFencrypt(pwd->smb_nt_pwd, cryptkey, pwd->smb_nt_owf);
103 #ifdef DEBUG_PASSWORD
104 DEBUG(100,("nt_owf_passwd: "));
105 dump_data(100, (char *)pwd->smb_nt_owf, sizeof(pwd->smb_nt_owf));
106 DEBUG(100,("nt_sess_pwd: "));
107 dump_data(100, (char *)pwd->smb_nt_pwd, sizeof(pwd->smb_nt_pwd));
110 SMBOWFencrypt(pwd->smb_lm_pwd, cryptkey, pwd->smb_lm_owf);
112 #ifdef DEBUG_PASSWORD
113 DEBUG(100,("lm_owf_passwd: "));
114 dump_data(100, (char *)pwd->smb_lm_owf, sizeof(pwd->smb_lm_owf));
115 DEBUG(100,("lm_sess_pwd: "));
116 dump_data(100, (char *)pwd->smb_lm_pwd, sizeof(pwd->smb_lm_pwd));
122 /****************************************************************************
123 Gets lm and nt crypts.
124 ****************************************************************************/
126 void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
129 memcpy(lm_owf, pwd->smb_lm_owf, 24);
131 memcpy(nt_owf, pwd->smb_nt_owf, 24);