Lines Matching +full:tcon +full:- +full:channel

22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
46 struct cifs_secmech *p = &server->secmech; in smb3_crypto_shash_allocate()
50 &p->hmacsha256, in smb3_crypto_shash_allocate()
51 &p->sdeschmacsha256); in smb3_crypto_shash_allocate()
55 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes); in smb3_crypto_shash_allocate()
61 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256); in smb3_crypto_shash_allocate()
68 struct cifs_secmech *p = &server->secmech; in smb311_crypto_shash_allocate()
72 &p->hmacsha256, in smb311_crypto_shash_allocate()
73 &p->sdeschmacsha256); in smb311_crypto_shash_allocate()
77 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes); in smb311_crypto_shash_allocate()
81 rc = cifs_alloc_hash("sha512", &p->sha512, &p->sdescsha512); in smb311_crypto_shash_allocate()
88 cifs_free_hash(&p->cmacaes, &p->sdesccmacaes); in smb311_crypto_shash_allocate()
89 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256); in smb311_crypto_shash_allocate()
106 list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) { in smb2_get_sign_key()
107 if (ses->Suid == ses_id) in smb2_get_sign_key()
113 rc = -ENOENT; in smb2_get_sign_key()
117 if (ses->binding) { in smb2_get_sign_key()
119 * If we are in the process of binding a new channel in smb2_get_sign_key()
123 memcpy(key, ses->smb3signingkey, SMB3_SIGN_KEY_SIZE); in smb2_get_sign_key()
128 * Otherwise, use the channel key. in smb2_get_sign_key()
131 for (i = 0; i < ses->chan_count; i++) { in smb2_get_sign_key()
132 chan = ses->chans + i; in smb2_get_sign_key()
133 if (chan->server == server) { in smb2_get_sign_key()
134 memcpy(key, chan->signkey, SMB3_SIGN_KEY_SIZE); in smb2_get_sign_key()
140 "%s: Could not find channel signing key for session 0x%llx\n", in smb2_get_sign_key()
142 rc = -ENOENT; in smb2_get_sign_key()
154 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { in smb2_find_smb_ses_unlocked()
155 if (ses->Suid != ses_id) in smb2_find_smb_ses_unlocked()
178 struct cifs_tcon *tcon; in smb2_find_smb_sess_tcon_unlocked() local
180 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { in smb2_find_smb_sess_tcon_unlocked()
181 if (tcon->tid != tid) in smb2_find_smb_sess_tcon_unlocked()
183 ++tcon->tc_count; in smb2_find_smb_sess_tcon_unlocked()
184 return tcon; in smb2_find_smb_sess_tcon_unlocked()
191 * Obtain tcon corresponding to the tid in the given
199 struct cifs_tcon *tcon; in smb2_find_smb_tcon() local
207 tcon = smb2_find_smb_sess_tcon_unlocked(ses, tid); in smb2_find_smb_tcon()
210 return tcon; in smb2_find_smb_tcon()
220 struct kvec *iov = rqst->rq_iov; in smb2_calc_signature()
228 ses = smb2_find_smb_ses(server, shdr->SessionId); in smb2_calc_signature()
235 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE); in smb2_calc_signature()
244 shash = &sdesc->shash; in smb2_calc_signature()
246 hash = server->secmech.hmacsha256; in smb2_calc_signature()
247 shash = &server->secmech.sdeschmacsha256->shash; in smb2_calc_signature()
250 rc = crypto_shash_setkey(hash, ses->auth_key.response, in smb2_calc_signature()
269 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to in smb2_calc_signature()
283 drqst.rq_nvec--; in smb2_calc_signature()
288 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE); in smb2_calc_signature()
306 struct TCP_Server_Info *server = ses->server; in generate_key()
317 rc = crypto_shash_setkey(server->secmech.hmacsha256, in generate_key()
318 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); in generate_key()
324 rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash); in generate_key()
330 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
337 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
344 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
351 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
358 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) || in generate_key()
359 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) { in generate_key()
360 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
363 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
371 rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash, in generate_key()
401 struct TCP_Server_Info *server = ses->server; in generate_smb3signingkey()
408 * When we generate the keys, check if it is for a new channel in generate_smb3signingkey()
410 * key and store it in the channel as to not overwrite the in generate_smb3signingkey()
414 if (ses->binding) { in generate_smb3signingkey()
415 rc = generate_key(ses, ptriplet->signing.label, in generate_smb3signingkey()
416 ptriplet->signing.context, in generate_smb3signingkey()
417 cifs_ses_binding_channel(ses)->signkey, in generate_smb3signingkey()
422 rc = generate_key(ses, ptriplet->signing.label, in generate_smb3signingkey()
423 ptriplet->signing.context, in generate_smb3signingkey()
424 ses->smb3signingkey, in generate_smb3signingkey()
429 memcpy(ses->chans[0].signkey, ses->smb3signingkey, in generate_smb3signingkey()
432 rc = generate_key(ses, ptriplet->encryption.label, in generate_smb3signingkey()
433 ptriplet->encryption.context, in generate_smb3signingkey()
434 ses->smb3encryptionkey, in generate_smb3signingkey()
436 rc = generate_key(ses, ptriplet->decryption.label, in generate_smb3signingkey()
437 ptriplet->decryption.context, in generate_smb3signingkey()
438 ses->smb3decryptionkey, in generate_smb3signingkey()
453 cifs_dbg(VFS, "Session Id %*ph\n", (int)sizeof(ses->Suid), in generate_smb3signingkey()
454 &ses->Suid); in generate_smb3signingkey()
455 cifs_dbg(VFS, "Cipher type %d\n", server->cipher_type); in generate_smb3signingkey()
457 SMB2_NTLMV2_SESSKEY_SIZE, ses->auth_key.response); in generate_smb3signingkey()
459 SMB3_SIGN_KEY_SIZE, ses->smb3signingkey); in generate_smb3signingkey()
460 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) || in generate_smb3signingkey()
461 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) { in generate_smb3signingkey()
463 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3encryptionkey); in generate_smb3signingkey()
465 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3decryptionkey); in generate_smb3signingkey()
468 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3encryptionkey); in generate_smb3signingkey()
470 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3decryptionkey); in generate_smb3signingkey()
484 d->label.iov_base = "SMB2AESCMAC"; in generate_smb30signingkey()
485 d->label.iov_len = 12; in generate_smb30signingkey()
486 d->context.iov_base = "SmbSign"; in generate_smb30signingkey()
487 d->context.iov_len = 8; in generate_smb30signingkey()
490 d->label.iov_base = "SMB2AESCCM"; in generate_smb30signingkey()
491 d->label.iov_len = 11; in generate_smb30signingkey()
492 d->context.iov_base = "ServerIn "; in generate_smb30signingkey()
493 d->context.iov_len = 10; in generate_smb30signingkey()
496 d->label.iov_base = "SMB2AESCCM"; in generate_smb30signingkey()
497 d->label.iov_len = 11; in generate_smb30signingkey()
498 d->context.iov_base = "ServerOut"; in generate_smb30signingkey()
499 d->context.iov_len = 10; in generate_smb30signingkey()
512 d->label.iov_base = "SMBSigningKey"; in generate_smb311signingkey()
513 d->label.iov_len = 14; in generate_smb311signingkey()
514 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
515 d->context.iov_len = 64; in generate_smb311signingkey()
518 d->label.iov_base = "SMBC2SCipherKey"; in generate_smb311signingkey()
519 d->label.iov_len = 16; in generate_smb311signingkey()
520 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
521 d->context.iov_len = 64; in generate_smb311signingkey()
524 d->label.iov_base = "SMBS2CCipherKey"; in generate_smb311signingkey()
525 d->label.iov_len = 16; in generate_smb311signingkey()
526 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
527 d->context.iov_len = 64; in generate_smb311signingkey()
539 struct kvec *iov = rqst->rq_iov; in smb3_calc_signature()
547 rc = smb2_get_sign_key(shdr->SessionId, server, key); in smb3_calc_signature()
556 shash = &sdesc->shash; in smb3_calc_signature()
558 hash = server->secmech.cmacaes; in smb3_calc_signature()
559 shash = &server->secmech.sdesccmacaes->shash; in smb3_calc_signature()
563 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE); in smb3_calc_signature()
586 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to in smb3_calc_signature()
599 drqst.rq_nvec--; in smb3_calc_signature()
604 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE); in smb3_calc_signature()
612 /* must be called with server->srv_mutex held */
622 shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_sign_rqst()
625 is_binding = shdr->Command == SMB2_SESSION_SETUP && in smb2_sign_rqst()
626 (ssr->Flags & SMB2_SESSION_REQ_FLAG_BINDING); in smb2_sign_rqst()
627 is_signed = shdr->Flags & SMB2_FLAGS_SIGNED; in smb2_sign_rqst()
631 if (server->tcpStatus == CifsNeedNegotiate) in smb2_sign_rqst()
633 if (!is_binding && !server->session_estab) { in smb2_sign_rqst()
634 strncpy(shdr->Signature, "BSRSPYL", 8); in smb2_sign_rqst()
638 rc = server->ops->calc_signature(rqst, server, false); in smb2_sign_rqst()
649 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_verify_signature()
651 if ((shdr->Command == SMB2_NEGOTIATE) || in smb2_verify_signature()
652 (shdr->Command == SMB2_SESSION_SETUP) || in smb2_verify_signature()
653 (shdr->Command == SMB2_OPLOCK_BREAK) || in smb2_verify_signature()
654 server->ignore_signature || in smb2_verify_signature()
655 (!server->session_estab)) in smb2_verify_signature()
664 if (memcmp(shdr->Signature, "BSRSPYL ", 8) == 0) in smb2_verify_signature()
666 shdr->Command); in smb2_verify_signature()
672 memcpy(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE); in smb2_verify_signature()
674 memset(shdr->Signature, 0, SMB2_SIGNATURE_SIZE); in smb2_verify_signature()
676 rc = server->ops->calc_signature(rqst, server, true); in smb2_verify_signature()
681 if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) { in smb2_verify_signature()
683 shdr->Command, shdr->MessageId); in smb2_verify_signature()
684 return -EACCES; in smb2_verify_signature()
697 unsigned int i, num = le16_to_cpu(shdr->CreditCharge); in smb2_seq_num_into_buf()
699 shdr->MessageId = get_next_mid64(server); in smb2_seq_num_into_buf()
710 unsigned int credits = le16_to_cpu(shdr->CreditCharge); in smb2_mid_entry_alloc()
719 kref_init(&temp->refcount); in smb2_mid_entry_alloc()
720 temp->mid = le64_to_cpu(shdr->MessageId); in smb2_mid_entry_alloc()
721 temp->credits = credits > 0 ? credits : 1; in smb2_mid_entry_alloc()
722 temp->pid = current->pid; in smb2_mid_entry_alloc()
723 temp->command = shdr->Command; /* Always LE */ in smb2_mid_entry_alloc()
724 temp->when_alloc = jiffies; in smb2_mid_entry_alloc()
725 temp->server = server; in smb2_mid_entry_alloc()
732 temp->creator = current; in smb2_mid_entry_alloc()
733 temp->callback = cifs_wake_up_task; in smb2_mid_entry_alloc()
734 temp->callback_data = current; in smb2_mid_entry_alloc()
737 temp->mid_state = MID_REQUEST_ALLOCATED; in smb2_mid_entry_alloc()
738 trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId, in smb2_mid_entry_alloc()
739 le16_to_cpu(shdr->Command), temp->mid); in smb2_mid_entry_alloc()
747 if (server->tcpStatus == CifsExiting) in smb2_get_mid_entry()
748 return -ENOENT; in smb2_get_mid_entry()
750 if (server->tcpStatus == CifsNeedReconnect) { in smb2_get_mid_entry()
751 cifs_dbg(FYI, "tcp session dead - return to caller to retry\n"); in smb2_get_mid_entry()
752 return -EAGAIN; in smb2_get_mid_entry()
755 if (server->tcpStatus == CifsNeedNegotiate && in smb2_get_mid_entry()
756 shdr->Command != SMB2_NEGOTIATE) in smb2_get_mid_entry()
757 return -EAGAIN; in smb2_get_mid_entry()
759 if (ses->status == CifsNew) { in smb2_get_mid_entry()
760 if ((shdr->Command != SMB2_SESSION_SETUP) && in smb2_get_mid_entry()
761 (shdr->Command != SMB2_NEGOTIATE)) in smb2_get_mid_entry()
762 return -EAGAIN; in smb2_get_mid_entry()
763 /* else ok - we are setting up session */ in smb2_get_mid_entry()
766 if (ses->status == CifsExiting) { in smb2_get_mid_entry()
767 if (shdr->Command != SMB2_LOGOFF) in smb2_get_mid_entry()
768 return -EAGAIN; in smb2_get_mid_entry()
769 /* else ok - we are shutting down the session */ in smb2_get_mid_entry()
774 return -ENOMEM; in smb2_get_mid_entry()
776 list_add_tail(&(*mid)->qhead, &server->pending_mid_q); in smb2_get_mid_entry()
786 unsigned int len = mid->resp_buf_size; in smb2_check_receive()
791 iov[0].iov_base = (char *)mid->resp_buf; in smb2_check_receive()
794 dump_smb(mid->resp_buf, min_t(u32, 80, len)); in smb2_check_receive()
796 if (len > 24 && server->sign && !mid->decrypted) { in smb2_check_receive()
805 return map_smb2_to_linux_error(mid->resp_buf, log_error); in smb2_check_receive()
814 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_setup_request()
840 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_setup_async_request()
843 if (server->tcpStatus == CifsNeedNegotiate && in smb2_setup_async_request()
844 shdr->Command != SMB2_NEGOTIATE) in smb2_setup_async_request()
845 return ERR_PTR(-EAGAIN); in smb2_setup_async_request()
852 return ERR_PTR(-ENOMEM); in smb2_setup_async_request()
870 if (!server->secmech.ccmaesencrypt) { in smb3_crypto_aead_allocate()
871 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) || in smb3_crypto_aead_allocate()
872 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in smb3_crypto_aead_allocate()
881 server->secmech.ccmaesencrypt = tfm; in smb3_crypto_aead_allocate()
884 if (!server->secmech.ccmaesdecrypt) { in smb3_crypto_aead_allocate()
885 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) || in smb3_crypto_aead_allocate()
886 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in smb3_crypto_aead_allocate()
891 crypto_free_aead(server->secmech.ccmaesencrypt); in smb3_crypto_aead_allocate()
892 server->secmech.ccmaesencrypt = NULL; in smb3_crypto_aead_allocate()
897 server->secmech.ccmaesdecrypt = tfm; in smb3_crypto_aead_allocate()