[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>
This commit is contained in:
Steve French 2006-06-05 16:26:05 +00:00
parent f64b23ae4a
commit 6d027cfdb1
4 changed files with 20 additions and 6 deletions

View File

@ -27,6 +27,7 @@
#include "cifs_unicode.h" #include "cifs_unicode.h"
#include "cifsproto.h" #include "cifsproto.h"
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/random.h>
/* Calculate and return the CIFS signature based on the mac key and the smb pdu */ /* Calculate and return the CIFS signature based on the mac key and the smb pdu */
/* the 16 byte signature must be allocated by the caller */ /* 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)
} }
#endif /* CIFS_WEAK_PW_HASH */ #endif /* CIFS_WEAK_PW_HASH */
void setup_ntlmv2_rsp(const struct cifsSesInfo * ses, char * resp_buf)
{
struct ntlmv2_resp * buf = (struct ntlmv2_resp *)resp_buf;
buf->blob_signature = cpu_to_le32(0x00000101);
buf->reserved = 0;
buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
get_random_bytes(&buf->client_chal, sizeof(buf->client_chal));
buf->reserved2 = 0;
buf->names[0].type = 0;
buf->names[0].length = 0;
/* calculate buf->ntlmv2_hash */
}
void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response) void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_response)
{ {
/* BB FIXME - update struct ntlmv2_response and change calling convention
of this function */
struct HMACMD5Context context; struct HMACMD5Context context;
memcpy(v2_session_response + 8, ses->server->cryptKey,8); memcpy(v2_session_response + 8, ses->server->cryptKey,8);
/* gen_blob(v2_session_response + 16); */ /* gen_blob(v2_session_response + 16); */

View File

@ -582,7 +582,7 @@ struct ntlmssp2_name {
struct ntlmv2_resp { struct ntlmv2_resp {
char ntlmv2_hash[CIFS_ENCPWD_SIZE]; char ntlmv2_hash[CIFS_ENCPWD_SIZE];
__le32 blob_sign; __le32 blob_signature;
__u32 reserved; __u32 reserved;
__le64 time; __le64 time;
__u64 client_chal; /* random */ __u64 client_chal; /* random */

View File

@ -287,6 +287,7 @@ extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key,
extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);
extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *); extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *);
extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * ); extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * );
extern void setup_ntlmv2_rsp(const struct cifsSesInfo *, char *);
#ifdef CONFIG_CIFS_WEAK_PW_HASH #ifdef CONFIG_CIFS_WEAK_PW_HASH
extern void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key); extern void calc_lanman_hash(struct cifsSesInfo * ses, char * lnm_session_key);
#endif /* CIFS_WEAK_PW_HASH */ #endif /* CIFS_WEAK_PW_HASH */

View File

@ -411,8 +411,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
else else
ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
} else if (type == NTLMv2) { } else if (type == NTLMv2) {
char * v2_sess_key = kmalloc(sizeof(struct ntlmv2_resp), char * v2_sess_key =
GFP_KERNEL); kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL);
/* BB FIXME change all users of v2_sess_key to /* BB FIXME change all users of v2_sess_key to
struct ntlmv2_resp */ struct ntlmv2_resp */
@ -432,7 +432,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
cpu_to_le16(sizeof(struct ntlmv2_resp)); cpu_to_le16(sizeof(struct ntlmv2_resp));
/* calculate session key */ /* calculate session key */
CalcNTLMv2_response(ses, v2_sess_key); setup_ntlmv2_rsp(ses, v2_sess_key);
if(first_time) /* should this be moved into common code if(first_time) /* should this be moved into common code
with similar ntlmv2 path? */ with similar ntlmv2 path? */
/* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,