diff options
author | Steve French <sfrench@us.ibm.com> | 2006-06-05 12:26:05 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-06-05 12:26:05 -0400 |
commit | 6d027cfdb19c26df3151a519ed55acfe2c4cb7c3 (patch) | |
tree | c40004c2518013409bd0f701eca868fd14c74e7f /fs/cifs | |
parent | f64b23ae4aef9f69d71ea41529a188acd5ab4930 (diff) |
[CIFS] NTLMv2 support part 3
Response struct filled in exacty for 16 byte hash which we need to check
more to make sure it works.
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsencrypt.c | 17 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 1 | ||||
-rw-r--r-- | fs/cifs/sess.c | 6 |
4 files changed, 20 insertions, 6 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 24ab770f60dc..09f94617e534 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "cifs_unicode.h" | 27 | #include "cifs_unicode.h" |
28 | #include "cifsproto.h" | 28 | #include "cifsproto.h" |
29 | #include <linux/ctype.h> | 29 | #include <linux/ctype.h> |
30 | #include <linux/random.h> | ||
30 | 31 | ||
31 | /* Calculate and return the CIFS signature based on the mac key and the smb pdu */ | 32 | /* Calculate and return the CIFS signature based on the mac key and the smb pdu */ |
32 | /* the 16 byte signature must be allocated by the caller */ | 33 | /* the 16 byte signature must be allocated by the caller */ |
@@ -304,10 +305,22 @@ void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key) | |||
304 | } | 305 | } |
305 | #endif /* CIFS_WEAK_PW_HASH */ | 306 | #endif /* CIFS_WEAK_PW_HASH */ |
306 | 307 | ||
308 | void setup_ntlmv2_rsp(const struct cifsSesInfo * ses, char * resp_buf) | ||
309 | { | ||
310 | struct ntlmv2_resp * buf = (struct ntlmv2_resp *)resp_buf; | ||
311 | |||
312 | buf->blob_signature = cpu_to_le32(0x00000101); | ||
313 | buf->reserved = 0; | ||
314 | buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); | ||
315 | get_random_bytes(&buf->client_chal, sizeof(buf->client_chal)); | ||
316 | buf->reserved2 = 0; | ||
317 | buf->names[0].type = 0; | ||
318 | buf->names[0].length = 0; | ||
319 | /* calculate buf->ntlmv2_hash */ | ||
320 | } | ||
321 | |||
307 | void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) | 322 | void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) |
308 | { | 323 | { |
309 | /* BB FIXME - update struct ntlmv2_response and change calling convention | ||
310 | of this function */ | ||
311 | struct HMACMD5Context context; | 324 | struct HMACMD5Context context; |
312 | memcpy(v2_session_response + 8, ses->server->cryptKey,8); | 325 | memcpy(v2_session_response + 8, ses->server->cryptKey,8); |
313 | /* gen_blob(v2_session_response + 16); */ | 326 | /* gen_blob(v2_session_response + 16); */ |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index 503b7e32ede3..5250b93d3098 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -582,7 +582,7 @@ struct ntlmssp2_name { | |||
582 | 582 | ||
583 | struct ntlmv2_resp { | 583 | struct ntlmv2_resp { |
584 | char ntlmv2_hash[CIFS_ENCPWD_SIZE]; | 584 | char ntlmv2_hash[CIFS_ENCPWD_SIZE]; |
585 | __le32 blob_sign; | 585 | __le32 blob_signature; |
586 | __u32 reserved; | 586 | __u32 reserved; |
587 | __le64 time; | 587 | __le64 time; |
588 | __u64 client_chal; /* random */ | 588 | __u64 client_chal; /* random */ |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 59b037f14511..824afb937a6f 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -287,6 +287,7 @@ extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key, | |||
287 | extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); | 287 | extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); |
288 | extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *); | 288 | extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *); |
289 | extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * ); | 289 | extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * ); |
290 | extern void setup_ntlmv2_rsp(const struct cifsSesInfo *, char *); | ||
290 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 291 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
291 | extern void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key); | 292 | extern void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key); |
292 | #endif /* CIFS_WEAK_PW_HASH */ | 293 | #endif /* CIFS_WEAK_PW_HASH */ |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 9ce628df29b4..c6fd01f55e90 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -411,8 +411,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
411 | else | 411 | else |
412 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); | 412 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); |
413 | } else if (type == NTLMv2) { | 413 | } else if (type == NTLMv2) { |
414 | char * v2_sess_key = kmalloc(sizeof(struct ntlmv2_resp), | 414 | char * v2_sess_key = |
415 | GFP_KERNEL); | 415 | kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL); |
416 | 416 | ||
417 | /* BB FIXME change all users of v2_sess_key to | 417 | /* BB FIXME change all users of v2_sess_key to |
418 | struct ntlmv2_resp */ | 418 | struct ntlmv2_resp */ |
@@ -432,7 +432,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
432 | cpu_to_le16(sizeof(struct ntlmv2_resp)); | 432 | cpu_to_le16(sizeof(struct ntlmv2_resp)); |
433 | 433 | ||
434 | /* calculate session key */ | 434 | /* calculate session key */ |
435 | CalcNTLMv2_response(ses, v2_sess_key); | 435 | setup_ntlmv2_rsp(ses, v2_sess_key); |
436 | if(first_time) /* should this be moved into common code | 436 | if(first_time) /* should this be moved into common code |
437 | with similar ntlmv2 path? */ | 437 | with similar ntlmv2 path? */ |
438 | /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, | 438 | /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, |