Lines Matching refs:ses
266 int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp) in setup_ntlm_response() argument
272 if (!ses) in setup_ntlm_response()
275 ses->auth_key.response = kmalloc(temp_len, GFP_KERNEL); in setup_ntlm_response()
276 if (!ses->auth_key.response) in setup_ntlm_response()
279 ses->auth_key.len = temp_len; in setup_ntlm_response()
281 rc = SMBNTencrypt(ses->password, ses->server->cryptkey, in setup_ntlm_response()
282 ses->auth_key.response + CIFS_SESS_KEY_SIZE, nls_cp); in setup_ntlm_response()
289 rc = E_md4hash(ses->password, temp_key, nls_cp); in setup_ntlm_response()
296 rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE); in setup_ntlm_response()
352 build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp) in build_avpair_blob() argument
360 if (!ses->domainName) { in build_avpair_blob()
361 ses->domainName = kstrdup(defdmname, GFP_KERNEL); in build_avpair_blob()
362 if (!ses->domainName) in build_avpair_blob()
366 dlen = strlen(ses->domainName); in build_avpair_blob()
374 ses->auth_key.len = size + 2 * dlen; in build_avpair_blob()
375 ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL); in build_avpair_blob()
376 if (!ses->auth_key.response) { in build_avpair_blob()
377 ses->auth_key.len = 0; in build_avpair_blob()
381 blobptr = ses->auth_key.response; in build_avpair_blob()
391 cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp); in build_avpair_blob()
407 find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp) in find_domain_name() argument
416 if (!ses->auth_key.len || !ses->auth_key.response) in find_domain_name()
419 blobptr = ses->auth_key.response; in find_domain_name()
420 blobend = blobptr + ses->auth_key.len; in find_domain_name()
435 if (!ses->domainName) { in find_domain_name()
436 ses->domainName = in find_domain_name()
438 if (!ses->domainName) in find_domain_name()
440 cifs_from_utf16(ses->domainName, in find_domain_name()
459 find_timestamp(struct cifs_ses *ses) in find_timestamp() argument
469 if (!ses->auth_key.len || !ses->auth_key.response) in find_timestamp()
472 blobptr = ses->auth_key.response; in find_timestamp()
473 blobend = blobptr + ses->auth_key.len; in find_timestamp()
496 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, in calc_ntlmv2_hash() argument
506 if (!ses->server->secmech.sdeschmacmd5) { in calc_ntlmv2_hash()
512 E_md4hash(ses->password, nt_hash, nls_cp); in calc_ntlmv2_hash()
514 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, nt_hash, in calc_ntlmv2_hash()
521 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in calc_ntlmv2_hash()
528 len = ses->user_name ? strlen(ses->user_name) : 0; in calc_ntlmv2_hash()
536 len = cifs_strtoUTF16(user, ses->user_name, len, nls_cp); in calc_ntlmv2_hash()
542 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
551 if (ses->domainName) { in calc_ntlmv2_hash()
552 len = strlen(ses->domainName); in calc_ntlmv2_hash()
559 len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len, in calc_ntlmv2_hash()
562 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
572 len = strlen(ses->serverName); in calc_ntlmv2_hash()
579 len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len, in calc_ntlmv2_hash()
582 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
592 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in calc_ntlmv2_hash()
601 CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash) in CalcNTLMv2_response() argument
605 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in CalcNTLMv2_response()
609 hash_len = ses->auth_key.len - (CIFS_SESS_KEY_SIZE + in CalcNTLMv2_response()
612 if (!ses->server->secmech.sdeschmacmd5) { in CalcNTLMv2_response()
617 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, in CalcNTLMv2_response()
625 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in CalcNTLMv2_response()
631 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) in CalcNTLMv2_response()
633 ses->ntlmssp->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
636 ses->server->cryptkey, CIFS_SERVER_CHALLENGE_SIZE); in CalcNTLMv2_response()
637 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in CalcNTLMv2_response()
645 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in CalcNTLMv2_response()
654 setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) in setup_ntlmv2_rsp() argument
664 if (ses->server->negflavor == CIFS_NEGFLAVOR_EXTENDED) { in setup_ntlmv2_rsp()
665 if (!ses->domainName) { in setup_ntlmv2_rsp()
666 if (ses->domainAuto) { in setup_ntlmv2_rsp()
667 rc = find_domain_name(ses, nls_cp); in setup_ntlmv2_rsp()
674 ses->domainName = kstrdup("", GFP_KERNEL); in setup_ntlmv2_rsp()
678 rc = build_avpair_blob(ses, nls_cp); in setup_ntlmv2_rsp()
689 rsp_timestamp = find_timestamp(ses); in setup_ntlmv2_rsp()
692 tilen = ses->auth_key.len; in setup_ntlmv2_rsp()
693 tiblob = ses->auth_key.response; in setup_ntlmv2_rsp()
695 ses->auth_key.response = kmalloc(baselen + tilen, GFP_KERNEL); in setup_ntlmv2_rsp()
696 if (!ses->auth_key.response) { in setup_ntlmv2_rsp()
698 ses->auth_key.len = 0; in setup_ntlmv2_rsp()
701 ses->auth_key.len += baselen; in setup_ntlmv2_rsp()
704 (ses->auth_key.response + CIFS_SESS_KEY_SIZE); in setup_ntlmv2_rsp()
712 memcpy(ses->auth_key.response + baselen, tiblob, tilen); in setup_ntlmv2_rsp()
714 mutex_lock(&ses->server->srv_mutex); in setup_ntlmv2_rsp()
717 &ses->server->secmech.hmacmd5, in setup_ntlmv2_rsp()
718 &ses->server->secmech.sdeschmacmd5); in setup_ntlmv2_rsp()
724 rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp); in setup_ntlmv2_rsp()
731 rc = CalcNTLMv2_response(ses, ntlmv2_hash); in setup_ntlmv2_rsp()
738 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, in setup_ntlmv2_rsp()
746 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash); in setup_ntlmv2_rsp()
752 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, in setup_ntlmv2_rsp()
760 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, in setup_ntlmv2_rsp()
761 ses->auth_key.response); in setup_ntlmv2_rsp()
766 mutex_unlock(&ses->server->srv_mutex); in setup_ntlmv2_rsp()
774 calc_seckey(struct cifs_ses *ses) in calc_seckey() argument
790 arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE); in calc_seckey()
791 arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key, in calc_seckey()
795 memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE); in calc_seckey()
797 ses->auth_key.len = CIFS_SESS_KEY_SIZE; in calc_seckey()