aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsencrypt.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2008-12-05 20:41:21 -0500
committerSteve French <sfrench@us.ibm.com>2008-12-25 21:29:11 -0500
commit4e53a3fb98d3d5c2941d2e7199dab317a9d4ead3 (patch)
treec3485a826f33e4b6f18b603a475a1bfef7bb7986 /fs/cifs/cifsencrypt.c
parent55162dec9371a6f6ac63ff546c182cc6144a649e (diff)
cifs: have calc_lanman_hash take more granular args
cifs: have calc_lanman_hash take more granular args We need to use this routine to encrypt passwords associated with the tcon too. Don't assume that the password will be attached to the smb_session. Also, make some of the values in the lower encryption functions const since they aren't changed. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r--fs/cifs/cifsencrypt.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index bd5f13d38450..d4839cf0cb2c 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -37,7 +37,7 @@
37 37
38extern void mdfour(unsigned char *out, unsigned char *in, int n); 38extern void mdfour(unsigned char *out, unsigned char *in, int n);
39extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); 39extern void E_md4hash(const unsigned char *passwd, unsigned char *p16);
40extern void SMBencrypt(unsigned char *passwd, unsigned char *c8, 40extern void SMBencrypt(unsigned char *passwd, const unsigned char *c8,
41 unsigned char *p24); 41 unsigned char *p24);
42 42
43static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu, 43static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,
@@ -280,25 +280,22 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *ses,
280} 280}
281 281
282#ifdef CONFIG_CIFS_WEAK_PW_HASH 282#ifdef CONFIG_CIFS_WEAK_PW_HASH
283void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key) 283void calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
284 char *lnm_session_key)
284{ 285{
285 int i; 286 int i;
286 char password_with_pad[CIFS_ENCPWD_SIZE]; 287 char password_with_pad[CIFS_ENCPWD_SIZE];
287 288
288 if (ses->server == NULL)
289 return;
290
291 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE); 289 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
292 if (ses->password) 290 if (password)
293 strncpy(password_with_pad, ses->password, CIFS_ENCPWD_SIZE); 291 strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE);
294 292
295 if ((ses->server->secMode & SECMODE_PW_ENCRYPT) == 0) 293 if (!encrypt && extended_security & CIFSSEC_MAY_PLNTXT) {
296 if (extended_security & CIFSSEC_MAY_PLNTXT) { 294 memset(lnm_session_key, 0, CIFS_SESS_KEY_SIZE);
297 memset(lnm_session_key, 0, CIFS_SESS_KEY_SIZE); 295 memcpy(lnm_session_key, password_with_pad,
298 memcpy(lnm_session_key, password_with_pad, 296 CIFS_ENCPWD_SIZE);
299 CIFS_ENCPWD_SIZE); 297 return;
300 return; 298 }
301 }
302 299
303 /* calculate old style session key */ 300 /* calculate old style session key */
304 /* calling toupper is less broken than repeatedly 301 /* calling toupper is less broken than repeatedly
@@ -314,7 +311,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key)
314 for (i = 0; i < CIFS_ENCPWD_SIZE; i++) 311 for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
315 password_with_pad[i] = toupper(password_with_pad[i]); 312 password_with_pad[i] = toupper(password_with_pad[i]);
316 313
317 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); 314 SMBencrypt(password_with_pad, cryptkey, lnm_session_key);
315
318 /* clear password before we return/free memory */ 316 /* clear password before we return/free memory */
319 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE); 317 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
320} 318}