Lines Matching refs:ses
273 build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) in build_avpair_blob() argument
281 if (!ses->domainName) { in build_avpair_blob()
282 ses->domainName = kstrdup(defdmname, GFP_KERNEL); in build_avpair_blob()
283 if (!ses->domainName) in build_avpair_blob()
287 dlen = strlen(ses->domainName); in build_avpair_blob()
295 kfree_sensitive(ses->auth_key.response); in build_avpair_blob()
296 ses->auth_key.len = size + 2 * dlen; in build_avpair_blob()
297 ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL); in build_avpair_blob()
298 if (!ses->auth_key.response) { in build_avpair_blob()
299 ses->auth_key.len = 0; in build_avpair_blob()
303 blobptr = ses->auth_key.response; in build_avpair_blob()
313 cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp); in build_avpair_blob()
322 #define av_for_each_entry(ses, av) \ argument
323 for (av = NULL; (av = find_next_av(ses, av));)
325 static struct ntlmssp2_name *find_next_av(struct cifs_ses *ses, in find_next_av() argument
331 end = (u8 *)ses->auth_key.response + ses->auth_key.len; in find_next_av()
333 if (unlikely(!ses->auth_key.response || !ses->auth_key.len)) in find_next_av()
335 av = (void *)ses->auth_key.response; in find_next_av()
355 static int find_av_name(struct cifs_ses *ses, u16 type, char **name, u16 maxlen) in find_av_name() argument
357 const struct nls_table *nlsc = ses->local_nls; in find_av_name()
364 av_for_each_entry(ses, av) { in find_av_name()
393 static __le64 find_timestamp(struct cifs_ses *ses) in find_timestamp() argument
398 av_for_each_entry(ses, av) { in find_timestamp()
407 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, in calc_ntlmv2_hash() argument
418 E_md4hash(ses->password, nt_hash, nls_cp); in calc_ntlmv2_hash()
433 len = ses->user_name ? strlen(ses->user_name) : 0; in calc_ntlmv2_hash()
439 len = cifs_strtoUTF16(user, ses->user_name, len, nls_cp); in calc_ntlmv2_hash()
453 if (ses->domainName) { in calc_ntlmv2_hash()
454 len = strlen(ses->domainName); in calc_ntlmv2_hash()
460 len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len, in calc_ntlmv2_hash()
470 len = strlen(ses->ip_addr); in calc_ntlmv2_hash()
476 len = cifs_strtoUTF16((__le16 *)server, ses->ip_addr, len, nls_cp); in calc_ntlmv2_hash()
493 CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash, struct shash_desc *hmacmd5) in CalcNTLMv2_response() argument
497 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in CalcNTLMv2_response()
501 hash_len = ses->auth_key.len - (CIFS_SESS_KEY_SIZE + in CalcNTLMv2_response()
516 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) in CalcNTLMv2_response()
517 memcpy(ntlmv2->challenge.key, ses->ntlmssp->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
519 memcpy(ntlmv2->challenge.key, ses->server->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
539 static int set_auth_key_response(struct cifs_ses *ses) in set_auth_key_response() argument
543 struct TCP_Server_Info *server = ses->server; in set_auth_key_response()
560 av_for_each_entry(ses, av) in set_auth_key_response()
570 memcpy(rsp + baselen, ses->auth_key.response, tilen); in set_auth_key_response()
574 cifs_strtoUTF16((__le16 *)av->data, spn, spnlen, ses->local_nls); in set_auth_key_response()
580 ses->auth_key.len = len; in set_auth_key_response()
582 ses->auth_key.response = rsp; in set_auth_key_response()
587 setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) in setup_ntlmv2_rsp() argument
602 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) { in setup_ntlmv2_rsp()
603 if (!ses->domainName) { in setup_ntlmv2_rsp()
604 if (ses->domainAuto) { in setup_ntlmv2_rsp()
611 rc = find_av_name(ses, NTLMSSP_AV_NB_DOMAIN_NAME, in setup_ntlmv2_rsp()
612 &ses->domainName, in setup_ntlmv2_rsp()
617 ses->domainName = kstrdup("", GFP_KERNEL); in setup_ntlmv2_rsp()
618 if (!ses->domainName) { in setup_ntlmv2_rsp()
624 rc = find_av_name(ses, NTLMSSP_AV_DNS_DOMAIN_NAME, in setup_ntlmv2_rsp()
625 &ses->dns_dom, CIFS_MAX_DOMAINNAME_LEN); in setup_ntlmv2_rsp()
629 rc = build_avpair_blob(ses, nls_cp); in setup_ntlmv2_rsp()
640 rsp_timestamp = find_timestamp(ses); in setup_ntlmv2_rsp()
643 cifs_server_lock(ses->server); in setup_ntlmv2_rsp()
645 tiblob = ses->auth_key.response; in setup_ntlmv2_rsp()
646 rc = set_auth_key_response(ses); in setup_ntlmv2_rsp()
648 ses->auth_key.len = 0; in setup_ntlmv2_rsp()
653 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in setup_ntlmv2_rsp()
667 rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp, hmacmd5); in setup_ntlmv2_rsp()
674 rc = CalcNTLMv2_response(ses, ntlmv2_hash, hmacmd5); in setup_ntlmv2_rsp()
699 rc = crypto_shash_final(hmacmd5, ses->auth_key.response); in setup_ntlmv2_rsp()
703 cifs_server_unlock(ses->server); in setup_ntlmv2_rsp()
712 calc_seckey(struct cifs_ses *ses) in calc_seckey() argument
728 cifs_arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE); in calc_seckey()
729 cifs_arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key, in calc_seckey()
733 memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE); in calc_seckey()
735 ses->auth_key.len = CIFS_SESS_KEY_SIZE; in calc_seckey()