aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2006-06-05 01:27:37 -0400
committerSteve French <sfrench@us.ibm.com>2006-06-05 01:27:37 -0400
commitf64b23ae4aef9f69d71ea41529a188acd5ab4930 (patch)
tree7c8c0b06a98523c4fee98e12e621591a3ab69042
parent9312f6754d4b2d3ce27c21b16fb92923ce92a411 (diff)
[CIFS] NTLMv2 support part 2
Still need to fill in response structure and check that hash works Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifsencrypt.c2
-rw-r--r--fs/cifs/cifspdu.h27
-rw-r--r--fs/cifs/sess.c13
3 files changed, 35 insertions, 7 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 3ae964bbfdc3..24ab770f60dc 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -306,6 +306,8 @@ void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key)
306 306
307void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) 307void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response)
308{ 308{
309 /* BB FIXME - update struct ntlmv2_response and change calling convention
310 of this function */
309 struct HMACMD5Context context; 311 struct HMACMD5Context context;
310 memcpy(v2_session_response + 8, ses->server->cryptKey,8); 312 memcpy(v2_session_response + 8, ses->server->cryptKey,8);
311 /* gen_blob(v2_session_response + 16); */ 313 /* gen_blob(v2_session_response + 16); */
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index e714803a52dc..503b7e32ede3 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -117,7 +117,6 @@
117 * Size of the session key (crypto key encrypted with the password 117 * Size of the session key (crypto key encrypted with the password
118 */ 118 */
119#define CIFS_SESS_KEY_SIZE (24) 119#define CIFS_SESS_KEY_SIZE (24)
120#define V2_SESS_KEY_SIZE (86)
121 120
122/* 121/*
123 * Maximum user name length 122 * Maximum user name length
@@ -539,7 +538,7 @@ typedef union smb_com_session_setup_andx {
539/* unsigned char * NativeOS; */ 538/* unsigned char * NativeOS; */
540/* unsigned char * NativeLanMan; */ 539/* unsigned char * NativeLanMan; */
541/* unsigned char * PrimaryDomain; */ 540/* unsigned char * PrimaryDomain; */
542 } __attribute__((packed)) resp; /* NTLM response format (with or without extended security */ 541 } __attribute__((packed)) resp; /* NTLM response with or without extended sec*/
543 542
544 struct { /* request format */ 543 struct { /* request format */
545 struct smb_hdr hdr; /* wct = 10 */ 544 struct smb_hdr hdr; /* wct = 10 */
@@ -573,6 +572,26 @@ typedef union smb_com_session_setup_andx {
573 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */ 572 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
574} __attribute__((packed)) SESSION_SETUP_ANDX; 573} __attribute__((packed)) SESSION_SETUP_ANDX;
575 574
575/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
576
577struct ntlmssp2_name {
578 __le16 type;
579 __le16 length;
580/* char name[length]; */
581} __attribute__((packed));
582
583struct ntlmv2_resp {
584 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
585 __le32 blob_sign;
586 __u32 reserved;
587 __le64 time;
588 __u64 client_chal; /* random */
589 __u32 reserved2;
590 struct ntlmssp2_name names[1];
591 /* array of name entries could follow ending in minimum 4 byte struct */
592} __attribute__((packed));
593
594
576#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" 595#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
577 596
578/* Capabilities bits (for NTLM SessSetup request) */ 597/* Capabilities bits (for NTLM SessSetup request) */
@@ -603,7 +622,9 @@ typedef struct smb_com_tconx_req {
603} __attribute__((packed)) TCONX_REQ; 622} __attribute__((packed)) TCONX_REQ;
604 623
605typedef struct smb_com_tconx_rsp { 624typedef struct smb_com_tconx_rsp {
606 struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */ 625 struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7
626 in some cases on responses. Four unspecified
627 words followed OptionalSupport */
607 __u8 AndXCommand; 628 __u8 AndXCommand;
608 __u8 AndXReserved; 629 __u8 AndXReserved;
609 __le16 AndXOffset; 630 __le16 AndXOffset;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 1fe9461c6dca..9ce628df29b4 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -411,7 +411,11 @@ 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(V2_SESS_KEY_SIZE, GFP_KERNEL); 414 char * v2_sess_key = kmalloc(sizeof(struct ntlmv2_resp),
415 GFP_KERNEL);
416
417 /* BB FIXME change all users of v2_sess_key to
418 struct ntlmv2_resp */
415 419
416 if(v2_sess_key == NULL) { 420 if(v2_sess_key == NULL) {
417 cifs_small_buf_release(smb_buf); 421 cifs_small_buf_release(smb_buf);
@@ -425,7 +429,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
425 /* cpu_to_le16(LM2_SESS_KEY_SIZE); */ 429 /* cpu_to_le16(LM2_SESS_KEY_SIZE); */
426 430
427 pSMB->req_no_secext.CaseSensitivePasswordLength = 431 pSMB->req_no_secext.CaseSensitivePasswordLength =
428 cpu_to_le16(V2_SESS_KEY_SIZE); 432 cpu_to_le16(sizeof(struct ntlmv2_resp));
429 433
430 /* calculate session key */ 434 /* calculate session key */
431 CalcNTLMv2_response(ses, v2_sess_key); 435 CalcNTLMv2_response(ses, v2_sess_key);
@@ -438,8 +442,9 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
438 442
439 /* memcpy(bcc_ptr, (char *)ntlm_session_key,LM2_SESS_KEY_SIZE); 443 /* memcpy(bcc_ptr, (char *)ntlm_session_key,LM2_SESS_KEY_SIZE);
440 bcc_ptr += LM2_SESS_KEY_SIZE; */ 444 bcc_ptr += LM2_SESS_KEY_SIZE; */
441 memcpy(bcc_ptr, (char *)v2_sess_key, V2_SESS_KEY_SIZE); 445 memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp));
442 bcc_ptr += V2_SESS_KEY_SIZE; 446 bcc_ptr += sizeof(struct ntlmv2_resp);
447 kfree(v2_sess_key);
443 if(ses->capabilities & CAP_UNICODE) 448 if(ses->capabilities & CAP_UNICODE)
444 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); 449 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
445 else 450 else