2 * fs/cifs/smb2transport.c
4 * Copyright (C) International Business Machines Corp., 2002, 2011
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Jeremy Allison (jra@samba.org) 2006
8 * Pavel Shilovsky (pshilovsky@samba.org) 2012
10 * This library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published
12 * by the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 * the GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/list.h>
27 #include <linux/wait.h>
28 #include <linux/net.h>
29 #include <linux/delay.h>
30 #include <linux/uaccess.h>
31 #include <asm/processor.h>
32 #include <linux/mempool.h>
33 #include <linux/highmem.h>
34 #include <crypto/aead.h>
37 #include "cifsproto.h"
38 #include "smb2proto.h"
39 #include "cifs_debug.h"
40 #include "smb2status.h"
44 smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
46 struct cifs_secmech *p = &server->secmech;
49 rc = cifs_alloc_hash("hmac(sha256)",
55 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes);
61 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
66 smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
68 struct cifs_secmech *p = &server->secmech;
71 rc = cifs_alloc_hash("hmac(sha256)",
77 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes);
81 rc = cifs_alloc_hash("sha512", &p->sha512, &p->sdescsha512);
88 cifs_free_hash(&p->cmacaes, &p->sdesccmacaes);
89 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
95 int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key)
97 struct cifs_chan *chan;
98 struct cifs_ses *ses = NULL;
99 struct TCP_Server_Info *it = NULL;
103 spin_lock(&cifs_tcp_ses_lock);
105 list_for_each_entry(it, &cifs_tcp_ses_list, tcp_ses_list) {
106 list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) {
107 if (ses->Suid == ses_id)
111 cifs_server_dbg(VFS, "%s: Could not find session 0x%llx\n",
119 * If we are in the process of binding a new channel
120 * to an existing session, use the master connection
123 memcpy(key, ses->smb3signingkey, SMB3_SIGN_KEY_SIZE);
128 * Otherwise, use the channel key.
131 for (i = 0; i < ses->chan_count; i++) {
132 chan = ses->chans + i;
133 if (chan->server == server) {
134 memcpy(key, chan->signkey, SMB3_SIGN_KEY_SIZE);
140 "%s: Could not find channel signing key for session 0x%llx\n",
145 spin_unlock(&cifs_tcp_ses_lock);
149 static struct cifs_ses *
150 smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id)
152 struct cifs_ses *ses;
154 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
155 if (ses->Suid != ses_id)
164 smb2_find_smb_ses(struct TCP_Server_Info *server, __u64 ses_id)
166 struct cifs_ses *ses;
168 spin_lock(&cifs_tcp_ses_lock);
169 ses = smb2_find_smb_ses_unlocked(server, ses_id);
170 spin_unlock(&cifs_tcp_ses_lock);
175 static struct cifs_tcon *
176 smb2_find_smb_sess_tcon_unlocked(struct cifs_ses *ses, __u32 tid)
178 struct cifs_tcon *tcon;
180 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
181 if (tcon->tid != tid)
191 * Obtain tcon corresponding to the tid in the given
196 smb2_find_smb_tcon(struct TCP_Server_Info *server, __u64 ses_id, __u32 tid)
198 struct cifs_ses *ses;
199 struct cifs_tcon *tcon;
201 spin_lock(&cifs_tcp_ses_lock);
202 ses = smb2_find_smb_ses_unlocked(server, ses_id);
204 spin_unlock(&cifs_tcp_ses_lock);
207 tcon = smb2_find_smb_sess_tcon_unlocked(ses, tid);
208 spin_unlock(&cifs_tcp_ses_lock);
214 smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
215 bool allocate_crypto)
218 unsigned char smb2_signature[SMB2_HMACSHA256_SIZE];
219 unsigned char *sigptr = smb2_signature;
220 struct kvec *iov = rqst->rq_iov;
221 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
222 struct cifs_ses *ses;
223 struct shash_desc *shash;
224 struct crypto_shash *hash;
225 struct sdesc *sdesc = NULL;
226 struct smb_rqst drqst;
228 ses = smb2_find_smb_ses(server, shdr->SessionId);
230 cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
234 memset(smb2_signature, 0x0, SMB2_HMACSHA256_SIZE);
235 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE);
237 if (allocate_crypto) {
238 rc = cifs_alloc_hash("hmac(sha256)", &hash, &sdesc);
241 "%s: sha256 alloc failed\n", __func__);
244 shash = &sdesc->shash;
246 hash = server->secmech.hmacsha256;
247 shash = &server->secmech.sdeschmacsha256->shash;
250 rc = crypto_shash_setkey(hash, ses->auth_key.response,
251 SMB2_NTLMV2_SESSKEY_SIZE);
254 "%s: Could not update with response\n",
259 rc = crypto_shash_init(shash);
261 cifs_server_dbg(VFS, "%s: Could not init sha256", __func__);
266 * For SMB2+, __cifs_calc_signature() expects to sign only the actual
267 * data, that is, iov[0] should not contain a rfc1002 length.
269 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to
270 * __cifs_calc_signature().
273 if (drqst.rq_nvec >= 2 && iov[0].iov_len == 4) {
274 rc = crypto_shash_update(shash, iov[0].iov_base,
278 "%s: Could not update with payload\n",
286 rc = __cifs_calc_signature(&drqst, server, sigptr, shash);
288 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE);
292 cifs_free_hash(&hash, &sdesc);
296 static int generate_key(struct cifs_ses *ses, struct kvec label,
297 struct kvec context, __u8 *key, unsigned int key_size)
299 unsigned char zero = 0x0;
300 __u8 i[4] = {0, 0, 0, 1};
301 __u8 L128[4] = {0, 0, 0, 128};
302 __u8 L256[4] = {0, 0, 1, 0};
304 unsigned char prfhash[SMB2_HMACSHA256_SIZE];
305 unsigned char *hashptr = prfhash;
306 struct TCP_Server_Info *server = ses->server;
308 memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE);
309 memset(key, 0x0, key_size);
311 rc = smb3_crypto_shash_allocate(server);
313 cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
314 goto smb3signkey_ret;
317 rc = crypto_shash_setkey(server->secmech.hmacsha256,
318 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
320 cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__);
321 goto smb3signkey_ret;
324 rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash);
326 cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
327 goto smb3signkey_ret;
330 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
333 cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__);
334 goto smb3signkey_ret;
337 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
338 label.iov_base, label.iov_len);
340 cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__);
341 goto smb3signkey_ret;
344 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
347 cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__);
348 goto smb3signkey_ret;
351 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
352 context.iov_base, context.iov_len);
354 cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__);
355 goto smb3signkey_ret;
358 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) ||
359 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) {
360 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
363 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
367 cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__);
368 goto smb3signkey_ret;
371 rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
374 cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
375 goto smb3signkey_ret;
378 memcpy(key, hashptr, key_size);
389 struct derivation_triplet {
390 struct derivation signing;
391 struct derivation encryption;
392 struct derivation decryption;
396 generate_smb3signingkey(struct cifs_ses *ses,
397 const struct derivation_triplet *ptriplet)
400 #ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS
401 struct TCP_Server_Info *server = ses->server;
405 * All channels use the same encryption/decryption keys but
406 * they have their own signing key.
408 * When we generate the keys, check if it is for a new channel
409 * (binding) in which case we only need to generate a signing
410 * key and store it in the channel as to not overwrite the
411 * master connection signing key stored in the session
415 rc = generate_key(ses, ptriplet->signing.label,
416 ptriplet->signing.context,
417 cifs_ses_binding_channel(ses)->signkey,
422 rc = generate_key(ses, ptriplet->signing.label,
423 ptriplet->signing.context,
429 memcpy(ses->chans[0].signkey, ses->smb3signingkey,
432 rc = generate_key(ses, ptriplet->encryption.label,
433 ptriplet->encryption.context,
434 ses->smb3encryptionkey,
435 SMB3_ENC_DEC_KEY_SIZE);
436 rc = generate_key(ses, ptriplet->decryption.label,
437 ptriplet->decryption.context,
438 ses->smb3decryptionkey,
439 SMB3_ENC_DEC_KEY_SIZE);
447 #ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS
448 cifs_dbg(VFS, "%s: dumping generated AES session keys\n", __func__);
450 * The session id is opaque in terms of endianness, so we can't
451 * print it as a long long. we dump it as we got it on the wire
453 cifs_dbg(VFS, "Session Id %*ph\n", (int)sizeof(ses->Suid),
455 cifs_dbg(VFS, "Cipher type %d\n", server->cipher_type);
456 cifs_dbg(VFS, "Session Key %*ph\n",
457 SMB2_NTLMV2_SESSKEY_SIZE, ses->auth_key.response);
458 cifs_dbg(VFS, "Signing Key %*ph\n",
459 SMB3_SIGN_KEY_SIZE, ses->smb3signingkey);
460 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) ||
461 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) {
462 cifs_dbg(VFS, "ServerIn Key %*ph\n",
463 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3encryptionkey);
464 cifs_dbg(VFS, "ServerOut Key %*ph\n",
465 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3decryptionkey);
467 cifs_dbg(VFS, "ServerIn Key %*ph\n",
468 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3encryptionkey);
469 cifs_dbg(VFS, "ServerOut Key %*ph\n",
470 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3decryptionkey);
477 generate_smb30signingkey(struct cifs_ses *ses)
480 struct derivation_triplet triplet;
481 struct derivation *d;
483 d = &triplet.signing;
484 d->label.iov_base = "SMB2AESCMAC";
485 d->label.iov_len = 12;
486 d->context.iov_base = "SmbSign";
487 d->context.iov_len = 8;
489 d = &triplet.encryption;
490 d->label.iov_base = "SMB2AESCCM";
491 d->label.iov_len = 11;
492 d->context.iov_base = "ServerIn ";
493 d->context.iov_len = 10;
495 d = &triplet.decryption;
496 d->label.iov_base = "SMB2AESCCM";
497 d->label.iov_len = 11;
498 d->context.iov_base = "ServerOut";
499 d->context.iov_len = 10;
501 return generate_smb3signingkey(ses, &triplet);
505 generate_smb311signingkey(struct cifs_ses *ses)
508 struct derivation_triplet triplet;
509 struct derivation *d;
511 d = &triplet.signing;
512 d->label.iov_base = "SMBSigningKey";
513 d->label.iov_len = 14;
514 d->context.iov_base = ses->preauth_sha_hash;
515 d->context.iov_len = 64;
517 d = &triplet.encryption;
518 d->label.iov_base = "SMBC2SCipherKey";
519 d->label.iov_len = 16;
520 d->context.iov_base = ses->preauth_sha_hash;
521 d->context.iov_len = 64;
523 d = &triplet.decryption;
524 d->label.iov_base = "SMBS2CCipherKey";
525 d->label.iov_len = 16;
526 d->context.iov_base = ses->preauth_sha_hash;
527 d->context.iov_len = 64;
529 return generate_smb3signingkey(ses, &triplet);
533 smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
534 bool allocate_crypto)
537 unsigned char smb3_signature[SMB2_CMACAES_SIZE];
538 unsigned char *sigptr = smb3_signature;
539 struct kvec *iov = rqst->rq_iov;
540 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
541 struct shash_desc *shash;
542 struct crypto_shash *hash;
543 struct sdesc *sdesc = NULL;
544 struct smb_rqst drqst;
545 u8 key[SMB3_SIGN_KEY_SIZE];
547 rc = smb2_get_sign_key(shdr->SessionId, server, key);
551 if (allocate_crypto) {
552 rc = cifs_alloc_hash("cmac(aes)", &hash, &sdesc);
556 shash = &sdesc->shash;
558 hash = server->secmech.cmacaes;
559 shash = &server->secmech.sdesccmacaes->shash;
562 memset(smb3_signature, 0x0, SMB2_CMACAES_SIZE);
563 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE);
565 rc = crypto_shash_setkey(hash, key, SMB2_CMACAES_SIZE);
567 cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
572 * we already allocate sdesccmacaes when we init smb3 signing key,
573 * so unlike smb2 case we do not have to check here if secmech are
576 rc = crypto_shash_init(shash);
578 cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
583 * For SMB2+, __cifs_calc_signature() expects to sign only the actual
584 * data, that is, iov[0] should not contain a rfc1002 length.
586 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to
587 * __cifs_calc_signature().
590 if (drqst.rq_nvec >= 2 && iov[0].iov_len == 4) {
591 rc = crypto_shash_update(shash, iov[0].iov_base,
594 cifs_server_dbg(VFS, "%s: Could not update with payload\n",
602 rc = __cifs_calc_signature(&drqst, server, sigptr, shash);
604 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE);
608 cifs_free_hash(&hash, &sdesc);
612 /* must be called with server->srv_mutex held */
614 smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
617 struct smb2_sync_hdr *shdr;
618 struct smb2_sess_setup_req *ssr;
622 shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
623 ssr = (struct smb2_sess_setup_req *)shdr;
625 is_binding = shdr->Command == SMB2_SESSION_SETUP &&
626 (ssr->Flags & SMB2_SESSION_REQ_FLAG_BINDING);
627 is_signed = shdr->Flags & SMB2_FLAGS_SIGNED;
631 if (server->tcpStatus == CifsNeedNegotiate)
633 if (!is_binding && !server->session_estab) {
634 strncpy(shdr->Signature, "BSRSPYL", 8);
638 rc = server->ops->calc_signature(rqst, server, false);
644 smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
647 char server_response_sig[SMB2_SIGNATURE_SIZE];
648 struct smb2_sync_hdr *shdr =
649 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
651 if ((shdr->Command == SMB2_NEGOTIATE) ||
652 (shdr->Command == SMB2_SESSION_SETUP) ||
653 (shdr->Command == SMB2_OPLOCK_BREAK) ||
654 server->ignore_signature ||
655 (!server->session_estab))
659 * BB what if signatures are supposed to be on for session but
660 * server does not send one? BB
663 /* Do not need to verify session setups with signature "BSRSPYL " */
664 if (memcmp(shdr->Signature, "BSRSPYL ", 8) == 0)
665 cifs_dbg(FYI, "dummy signature received for smb command 0x%x\n",
669 * Save off the origiginal signature so we can modify the smb and check
670 * our calculated signature against what the server sent.
672 memcpy(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE);
674 memset(shdr->Signature, 0, SMB2_SIGNATURE_SIZE);
676 rc = server->ops->calc_signature(rqst, server, true);
681 if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) {
682 cifs_dbg(VFS, "sign fail cmd 0x%x message id 0x%llx\n",
683 shdr->Command, shdr->MessageId);
690 * Set message id for the request. Should be called after wait_for_free_request
691 * and when srv_mutex is held.
694 smb2_seq_num_into_buf(struct TCP_Server_Info *server,
695 struct smb2_sync_hdr *shdr)
697 unsigned int i, num = le16_to_cpu(shdr->CreditCharge);
699 shdr->MessageId = get_next_mid64(server);
700 /* skip message numbers according to CreditCharge field */
701 for (i = 1; i < num; i++)
702 get_next_mid(server);
705 static struct mid_q_entry *
706 smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
707 struct TCP_Server_Info *server)
709 struct mid_q_entry *temp;
710 unsigned int credits = le16_to_cpu(shdr->CreditCharge);
712 if (server == NULL) {
713 cifs_dbg(VFS, "Null TCP session in smb2_mid_entry_alloc\n");
717 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
718 memset(temp, 0, sizeof(struct mid_q_entry));
719 kref_init(&temp->refcount);
720 temp->mid = le64_to_cpu(shdr->MessageId);
721 temp->credits = credits > 0 ? credits : 1;
722 temp->pid = current->pid;
723 temp->command = shdr->Command; /* Always LE */
724 temp->when_alloc = jiffies;
725 temp->server = server;
728 * The default is for the mid to be synchronous, so the
729 * default callback just wakes up the current task.
731 get_task_struct(current);
732 temp->creator = current;
733 temp->callback = cifs_wake_up_task;
734 temp->callback_data = current;
736 atomic_inc(&midCount);
737 temp->mid_state = MID_REQUEST_ALLOCATED;
738 trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId,
739 le16_to_cpu(shdr->Command), temp->mid);
744 smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
745 struct smb2_sync_hdr *shdr, struct mid_q_entry **mid)
747 if (server->tcpStatus == CifsExiting)
750 if (server->tcpStatus == CifsNeedReconnect) {
751 cifs_dbg(FYI, "tcp session dead - return to caller to retry\n");
755 if (server->tcpStatus == CifsNeedNegotiate &&
756 shdr->Command != SMB2_NEGOTIATE)
759 if (ses->status == CifsNew) {
760 if ((shdr->Command != SMB2_SESSION_SETUP) &&
761 (shdr->Command != SMB2_NEGOTIATE))
763 /* else ok - we are setting up session */
766 if (ses->status == CifsExiting) {
767 if (shdr->Command != SMB2_LOGOFF)
769 /* else ok - we are shutting down the session */
772 *mid = smb2_mid_entry_alloc(shdr, server);
775 spin_lock(&GlobalMid_Lock);
776 list_add_tail(&(*mid)->qhead, &server->pending_mid_q);
777 spin_unlock(&GlobalMid_Lock);
783 smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
786 unsigned int len = mid->resp_buf_size;
788 struct smb_rqst rqst = { .rq_iov = iov,
791 iov[0].iov_base = (char *)mid->resp_buf;
792 iov[0].iov_len = len;
794 dump_smb(mid->resp_buf, min_t(u32, 80, len));
795 /* convert the length into a more usable form */
796 if (len > 24 && server->sign && !mid->decrypted) {
799 rc = smb2_verify_signature(&rqst, server);
801 cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
805 return map_smb2_to_linux_error(mid->resp_buf, log_error);
809 smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
810 struct smb_rqst *rqst)
813 struct smb2_sync_hdr *shdr =
814 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
815 struct mid_q_entry *mid;
817 smb2_seq_num_into_buf(server, shdr);
819 rc = smb2_get_mid_entry(ses, server, shdr, &mid);
821 revert_current_mid_from_hdr(server, shdr);
825 rc = smb2_sign_rqst(rqst, server);
827 revert_current_mid_from_hdr(server, shdr);
828 cifs_delete_mid(mid);
836 smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
839 struct smb2_sync_hdr *shdr =
840 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
841 struct mid_q_entry *mid;
843 if (server->tcpStatus == CifsNeedNegotiate &&
844 shdr->Command != SMB2_NEGOTIATE)
845 return ERR_PTR(-EAGAIN);
847 smb2_seq_num_into_buf(server, shdr);
849 mid = smb2_mid_entry_alloc(shdr, server);
851 revert_current_mid_from_hdr(server, shdr);
852 return ERR_PTR(-ENOMEM);
855 rc = smb2_sign_rqst(rqst, server);
857 revert_current_mid_from_hdr(server, shdr);
858 DeleteMidQEntry(mid);
866 smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
868 struct crypto_aead *tfm;
870 if (!server->secmech.ccmaesencrypt) {
871 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) ||
872 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM))
873 tfm = crypto_alloc_aead("gcm(aes)", 0, 0);
875 tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
877 cifs_server_dbg(VFS, "%s: Failed alloc encrypt aead\n",
881 server->secmech.ccmaesencrypt = tfm;
884 if (!server->secmech.ccmaesdecrypt) {
885 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) ||
886 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM))
887 tfm = crypto_alloc_aead("gcm(aes)", 0, 0);
889 tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
891 crypto_free_aead(server->secmech.ccmaesencrypt);
892 server->secmech.ccmaesencrypt = NULL;
893 cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
897 server->secmech.ccmaesdecrypt = tfm;