Lines Matching refs:ses
265 int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp) in setup_ntlm_response() argument
271 if (!ses) in setup_ntlm_response()
274 ses->auth_key.response = kmalloc(temp_len, GFP_KERNEL); in setup_ntlm_response()
275 if (!ses->auth_key.response) in setup_ntlm_response()
278 ses->auth_key.len = temp_len; in setup_ntlm_response()
280 rc = SMBNTencrypt(ses->password, ses->server->cryptkey, in setup_ntlm_response()
281 ses->auth_key.response + CIFS_SESS_KEY_SIZE, nls_cp); in setup_ntlm_response()
288 rc = E_md4hash(ses->password, temp_key, nls_cp); in setup_ntlm_response()
295 rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE); in setup_ntlm_response()
346 build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) in build_avpair_blob() argument
354 if (!ses->domainName) { in build_avpair_blob()
355 ses->domainName = kstrdup(defdmname, GFP_KERNEL); in build_avpair_blob()
356 if (!ses->domainName) in build_avpair_blob()
360 dlen = strlen(ses->domainName); in build_avpair_blob()
368 ses->auth_key.len = size + 2 * dlen; in build_avpair_blob()
369 ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL); in build_avpair_blob()
370 if (!ses->auth_key.response) { in build_avpair_blob()
371 ses->auth_key.len = 0; in build_avpair_blob()
375 blobptr = ses->auth_key.response; in build_avpair_blob()
385 cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp); in build_avpair_blob()
401 find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp) in find_domain_name() argument
410 if (!ses->auth_key.len || !ses->auth_key.response) in find_domain_name()
413 blobptr = ses->auth_key.response; in find_domain_name()
414 blobend = blobptr + ses->auth_key.len; in find_domain_name()
429 if (!ses->domainName) { in find_domain_name()
430 ses->domainName = in find_domain_name()
432 if (!ses->domainName) in find_domain_name()
434 cifs_from_utf16(ses->domainName, in find_domain_name()
453 find_timestamp(struct cifs_ses *ses) in find_timestamp() argument
463 if (!ses->auth_key.len || !ses->auth_key.response) in find_timestamp()
466 blobptr = ses->auth_key.response; in find_timestamp()
467 blobend = blobptr + ses->auth_key.len; in find_timestamp()
490 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, in calc_ntlmv2_hash() argument
500 if (!ses->server->secmech.sdeschmacmd5) { in calc_ntlmv2_hash()
506 E_md4hash(ses->password, nt_hash, nls_cp); in calc_ntlmv2_hash()
508 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, nt_hash, in calc_ntlmv2_hash()
515 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in calc_ntlmv2_hash()
522 len = ses->user_name ? strlen(ses->user_name) : 0; in calc_ntlmv2_hash()
530 len = cifs_strtoUTF16(user, ses->user_name, len, nls_cp); in calc_ntlmv2_hash()
536 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
545 if (ses->domainName) { in calc_ntlmv2_hash()
546 len = strlen(ses->domainName); in calc_ntlmv2_hash()
553 len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len, in calc_ntlmv2_hash()
556 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
566 len = strlen(ses->serverName); in calc_ntlmv2_hash()
573 len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len, in calc_ntlmv2_hash()
576 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
586 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
595 CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash) in CalcNTLMv2_response() argument
599 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in CalcNTLMv2_response()
603 hash_len = ses->auth_key.len - (CIFS_SESS_KEY_SIZE + in CalcNTLMv2_response()
606 if (!ses->server->secmech.sdeschmacmd5) { in CalcNTLMv2_response()
611 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, in CalcNTLMv2_response()
619 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in CalcNTLMv2_response()
625 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) in CalcNTLMv2_response()
627 ses->ntlmssp->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
630 ses->server->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
631 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in CalcNTLMv2_response()
639 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in CalcNTLMv2_response()
648 setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) in setup_ntlmv2_rsp() argument
658 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) { in setup_ntlmv2_rsp()
659 if (!ses->domainName) { in setup_ntlmv2_rsp()
660 if (ses->domainAuto) { in setup_ntlmv2_rsp()
661 rc = find_domain_name(ses, nls_cp); in setup_ntlmv2_rsp()
668 ses->domainName = kstrdup("", GFP_KERNEL); in setup_ntlmv2_rsp()
672 rc = build_avpair_blob(ses, nls_cp); in setup_ntlmv2_rsp()
683 rsp_timestamp = find_timestamp(ses); in setup_ntlmv2_rsp()
686 tilen = ses->auth_key.len; in setup_ntlmv2_rsp()
687 tiblob = ses->auth_key.response; in setup_ntlmv2_rsp()
689 ses->auth_key.response = kmalloc(baselen + tilen, GFP_KERNEL); in setup_ntlmv2_rsp()
690 if (!ses->auth_key.response) { in setup_ntlmv2_rsp()
692 ses->auth_key.len = 0; in setup_ntlmv2_rsp()
695 ses->auth_key.len += baselen; in setup_ntlmv2_rsp()
698 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in setup_ntlmv2_rsp()
706 memcpy(ses->auth_key.response + baselen, tiblob, tilen); in setup_ntlmv2_rsp()
708 mutex_lock(&ses->server->srv_mutex); in setup_ntlmv2_rsp()
711 &ses->server->secmech.hmacmd5, in setup_ntlmv2_rsp()
712 &ses->server->secmech.sdeschmacmd5); in setup_ntlmv2_rsp()
718 rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp); in setup_ntlmv2_rsp()
725 rc = CalcNTLMv2_response(ses, ntlmv2_hash); in setup_ntlmv2_rsp()
732 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, in setup_ntlmv2_rsp()
740 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in setup_ntlmv2_rsp()
746 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in setup_ntlmv2_rsp()
754 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in setup_ntlmv2_rsp()
755 ses->auth_key.response); in setup_ntlmv2_rsp()
760 mutex_unlock(&ses->server->srv_mutex); in setup_ntlmv2_rsp()
768 calc_seckey(struct cifs_ses *ses) in calc_seckey() argument
789 rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response, in calc_seckey()
805 sg_init_one(&sgout, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); in calc_seckey()
818 memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE); in calc_seckey()
820 ses->auth_key.len = CIFS_SESS_KEY_SIZE; in calc_seckey()