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()
305 struct TCP_Server_Info *server = ses->server; in generate_key()
316 rc = crypto_shash_setkey(server->secmech.hmacsha256, in generate_key()
317 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE); in generate_key()
323 rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash); in generate_key()
329 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
336 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
343 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
350 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
357 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash, in generate_key()
364 rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash, in generate_key()
398 * When we generate the keys, check if it is for a new channel in generate_smb3signingkey()
400 * key and store it in the channel as to not overwrite the in generate_smb3signingkey()
404 if (ses->binding) { in generate_smb3signingkey()
405 rc = generate_key(ses, ptriplet->signing.label, in generate_smb3signingkey()
406 ptriplet->signing.context, in generate_smb3signingkey()
407 cifs_ses_binding_channel(ses)->signkey, in generate_smb3signingkey()
412 rc = generate_key(ses, ptriplet->signing.label, in generate_smb3signingkey()
413 ptriplet->signing.context, in generate_smb3signingkey()
414 ses->smb3signingkey, in generate_smb3signingkey()
419 memcpy(ses->chans[0].signkey, ses->smb3signingkey, in generate_smb3signingkey()
422 rc = generate_key(ses, ptriplet->encryption.label, in generate_smb3signingkey()
423 ptriplet->encryption.context, in generate_smb3signingkey()
424 ses->smb3encryptionkey, in generate_smb3signingkey()
426 rc = generate_key(ses, ptriplet->decryption.label, in generate_smb3signingkey()
427 ptriplet->decryption.context, in generate_smb3signingkey()
428 ses->smb3decryptionkey, in generate_smb3signingkey()
443 cifs_dbg(VFS, "Session Id %*ph\n", (int)sizeof(ses->Suid), in generate_smb3signingkey()
444 &ses->Suid); in generate_smb3signingkey()
446 SMB2_NTLMV2_SESSKEY_SIZE, ses->auth_key.response); in generate_smb3signingkey()
448 SMB3_SIGN_KEY_SIZE, ses->smb3signingkey); in generate_smb3signingkey()
450 SMB3_SIGN_KEY_SIZE, ses->smb3encryptionkey); in generate_smb3signingkey()
452 SMB3_SIGN_KEY_SIZE, ses->smb3decryptionkey); in generate_smb3signingkey()
465 d->label.iov_base = "SMB2AESCMAC"; in generate_smb30signingkey()
466 d->label.iov_len = 12; in generate_smb30signingkey()
467 d->context.iov_base = "SmbSign"; in generate_smb30signingkey()
468 d->context.iov_len = 8; in generate_smb30signingkey()
471 d->label.iov_base = "SMB2AESCCM"; in generate_smb30signingkey()
472 d->label.iov_len = 11; in generate_smb30signingkey()
473 d->context.iov_base = "ServerIn "; in generate_smb30signingkey()
474 d->context.iov_len = 10; in generate_smb30signingkey()
477 d->label.iov_base = "SMB2AESCCM"; in generate_smb30signingkey()
478 d->label.iov_len = 11; in generate_smb30signingkey()
479 d->context.iov_base = "ServerOut"; in generate_smb30signingkey()
480 d->context.iov_len = 10; in generate_smb30signingkey()
493 d->label.iov_base = "SMBSigningKey"; in generate_smb311signingkey()
494 d->label.iov_len = 14; in generate_smb311signingkey()
495 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
496 d->context.iov_len = 64; in generate_smb311signingkey()
499 d->label.iov_base = "SMBC2SCipherKey"; in generate_smb311signingkey()
500 d->label.iov_len = 16; in generate_smb311signingkey()
501 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
502 d->context.iov_len = 64; in generate_smb311signingkey()
505 d->label.iov_base = "SMBS2CCipherKey"; in generate_smb311signingkey()
506 d->label.iov_len = 16; in generate_smb311signingkey()
507 d->context.iov_base = ses->preauth_sha_hash; in generate_smb311signingkey()
508 d->context.iov_len = 64; in generate_smb311signingkey()
520 struct kvec *iov = rqst->rq_iov; in smb3_calc_signature()
528 rc = smb2_get_sign_key(shdr->SessionId, server, key); in smb3_calc_signature()
537 shash = &sdesc->shash; in smb3_calc_signature()
539 hash = server->secmech.cmacaes; in smb3_calc_signature()
540 shash = &server->secmech.sdesccmacaes->shash; in smb3_calc_signature()
544 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE); in smb3_calc_signature()
567 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to in smb3_calc_signature()
580 drqst.rq_nvec--; in smb3_calc_signature()
585 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE); in smb3_calc_signature()
593 /* must be called with server->srv_mutex held */
603 shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_sign_rqst()
606 is_binding = shdr->Command == SMB2_SESSION_SETUP && in smb2_sign_rqst()
607 (ssr->Flags & SMB2_SESSION_REQ_FLAG_BINDING); in smb2_sign_rqst()
608 is_signed = shdr->Flags & SMB2_FLAGS_SIGNED; in smb2_sign_rqst()
612 if (server->tcpStatus == CifsNeedNegotiate) in smb2_sign_rqst()
614 if (!is_binding && !server->session_estab) { in smb2_sign_rqst()
615 strncpy(shdr->Signature, "BSRSPYL", 8); in smb2_sign_rqst()
619 rc = server->ops->calc_signature(rqst, server, false); in smb2_sign_rqst()
630 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_verify_signature()
632 if ((shdr->Command == SMB2_NEGOTIATE) || in smb2_verify_signature()
633 (shdr->Command == SMB2_SESSION_SETUP) || in smb2_verify_signature()
634 (shdr->Command == SMB2_OPLOCK_BREAK) || in smb2_verify_signature()
635 server->ignore_signature || in smb2_verify_signature()
636 (!server->session_estab)) in smb2_verify_signature()
645 if (memcmp(shdr->Signature, "BSRSPYL ", 8) == 0) in smb2_verify_signature()
647 shdr->Command); in smb2_verify_signature()
653 memcpy(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE); in smb2_verify_signature()
655 memset(shdr->Signature, 0, SMB2_SIGNATURE_SIZE); in smb2_verify_signature()
657 rc = server->ops->calc_signature(rqst, server, true); in smb2_verify_signature()
662 if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) { in smb2_verify_signature()
664 shdr->Command, shdr->MessageId); in smb2_verify_signature()
665 return -EACCES; in smb2_verify_signature()
678 unsigned int i, num = le16_to_cpu(shdr->CreditCharge); in smb2_seq_num_into_buf()
680 shdr->MessageId = get_next_mid64(server); in smb2_seq_num_into_buf()
691 unsigned int credits = le16_to_cpu(shdr->CreditCharge); in smb2_mid_entry_alloc()
700 kref_init(&temp->refcount); in smb2_mid_entry_alloc()
701 temp->mid = le64_to_cpu(shdr->MessageId); in smb2_mid_entry_alloc()
702 temp->credits = credits > 0 ? credits : 1; in smb2_mid_entry_alloc()
703 temp->pid = current->pid; in smb2_mid_entry_alloc()
704 temp->command = shdr->Command; /* Always LE */ in smb2_mid_entry_alloc()
705 temp->when_alloc = jiffies; in smb2_mid_entry_alloc()
706 temp->server = server; in smb2_mid_entry_alloc()
713 temp->creator = current; in smb2_mid_entry_alloc()
714 temp->callback = cifs_wake_up_task; in smb2_mid_entry_alloc()
715 temp->callback_data = current; in smb2_mid_entry_alloc()
718 temp->mid_state = MID_REQUEST_ALLOCATED; in smb2_mid_entry_alloc()
719 trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId, in smb2_mid_entry_alloc()
720 le16_to_cpu(shdr->Command), temp->mid); in smb2_mid_entry_alloc()
728 if (server->tcpStatus == CifsExiting) in smb2_get_mid_entry()
729 return -ENOENT; in smb2_get_mid_entry()
731 if (server->tcpStatus == CifsNeedReconnect) { in smb2_get_mid_entry()
732 cifs_dbg(FYI, "tcp session dead - return to caller to retry\n"); in smb2_get_mid_entry()
733 return -EAGAIN; in smb2_get_mid_entry()
736 if (server->tcpStatus == CifsNeedNegotiate && in smb2_get_mid_entry()
737 shdr->Command != SMB2_NEGOTIATE) in smb2_get_mid_entry()
738 return -EAGAIN; in smb2_get_mid_entry()
740 if (ses->status == CifsNew) { in smb2_get_mid_entry()
741 if ((shdr->Command != SMB2_SESSION_SETUP) && in smb2_get_mid_entry()
742 (shdr->Command != SMB2_NEGOTIATE)) in smb2_get_mid_entry()
743 return -EAGAIN; in smb2_get_mid_entry()
744 /* else ok - we are setting up session */ in smb2_get_mid_entry()
747 if (ses->status == CifsExiting) { in smb2_get_mid_entry()
748 if (shdr->Command != SMB2_LOGOFF) in smb2_get_mid_entry()
749 return -EAGAIN; in smb2_get_mid_entry()
750 /* else ok - we are shutting down the session */ in smb2_get_mid_entry()
755 return -ENOMEM; in smb2_get_mid_entry()
757 list_add_tail(&(*mid)->qhead, &server->pending_mid_q); in smb2_get_mid_entry()
767 unsigned int len = mid->resp_buf_size; in smb2_check_receive()
772 iov[0].iov_base = (char *)mid->resp_buf; in smb2_check_receive()
775 dump_smb(mid->resp_buf, min_t(u32, 80, len)); in smb2_check_receive()
777 if (len > 24 && server->sign && !mid->decrypted) { in smb2_check_receive()
786 return map_smb2_to_linux_error(mid->resp_buf, log_error); in smb2_check_receive()
795 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_setup_request()
821 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; in smb2_setup_async_request()
824 if (server->tcpStatus == CifsNeedNegotiate && in smb2_setup_async_request()
825 shdr->Command != SMB2_NEGOTIATE) in smb2_setup_async_request()
826 return ERR_PTR(-EAGAIN); in smb2_setup_async_request()
833 return ERR_PTR(-ENOMEM); in smb2_setup_async_request()
851 if (!server->secmech.ccmaesencrypt) { in smb3_crypto_aead_allocate()
852 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) || in smb3_crypto_aead_allocate()
853 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in smb3_crypto_aead_allocate()
862 server->secmech.ccmaesencrypt = tfm; in smb3_crypto_aead_allocate()
865 if (!server->secmech.ccmaesdecrypt) { in smb3_crypto_aead_allocate()
866 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) || in smb3_crypto_aead_allocate()
867 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) in smb3_crypto_aead_allocate()
872 crypto_free_aead(server->secmech.ccmaesencrypt); in smb3_crypto_aead_allocate()
873 server->secmech.ccmaesencrypt = NULL; in smb3_crypto_aead_allocate()
878 server->secmech.ccmaesdecrypt = tfm; in smb3_crypto_aead_allocate()