diff options
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r-- | fs/cifs/cifsencrypt.c | 30 |
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 | ||
38 | extern void mdfour(unsigned char *out, unsigned char *in, int n); | 38 | extern void mdfour(unsigned char *out, unsigned char *in, int n); |
39 | extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); | 39 | extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); |
40 | extern void SMBencrypt(unsigned char *passwd, unsigned char *c8, | 40 | extern void SMBencrypt(unsigned char *passwd, const unsigned char *c8, |
41 | unsigned char *p24); | 41 | unsigned char *p24); |
42 | 42 | ||
43 | static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu, | 43 | static 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 |
283 | void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key) | 283 | void 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 | } |