1 // SPDX-License-Identifier: LGPL-2.1
3 * fs/cifs/smb2transport.c
5 * Copyright (C) International Business Machines Corp., 2002, 2011
7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * Jeremy Allison (jra@samba.org) 2006
9 * Pavel Shilovsky (pshilovsky@samba.org) 2012
14 #include <linux/list.h>
15 #include <linux/wait.h>
16 #include <linux/net.h>
17 #include <linux/delay.h>
18 #include <linux/uaccess.h>
19 #include <asm/processor.h>
20 #include <linux/mempool.h>
21 #include <linux/highmem.h>
22 #include <crypto/aead.h>
25 #include "cifsproto.h"
26 #include "smb2proto.h"
27 #include "cifs_debug.h"
28 #include "smb2status.h"
32 smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
34 struct cifs_secmech *p = &server->secmech;
37 rc = cifs_alloc_hash("hmac(sha256)",
43 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes);
49 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
54 smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
56 struct cifs_secmech *p = &server->secmech;
59 rc = cifs_alloc_hash("hmac(sha256)",
65 rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes);
69 rc = cifs_alloc_hash("sha512", &p->sha512, &p->sdescsha512);
76 cifs_free_hash(&p->cmacaes, &p->sdesccmacaes);
77 cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
83 int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key)
85 struct cifs_chan *chan;
86 struct cifs_ses *ses = NULL;
87 struct TCP_Server_Info *it = NULL;
91 spin_lock(&cifs_tcp_ses_lock);
93 list_for_each_entry(it, &cifs_tcp_ses_list, tcp_ses_list) {
94 list_for_each_entry(ses, &it->smb_ses_list, smb_ses_list) {
95 if (ses->Suid == ses_id)
99 cifs_server_dbg(VFS, "%s: Could not find session 0x%llx\n",
107 * If we are in the process of binding a new channel
108 * to an existing session, use the master connection
111 memcpy(key, ses->smb3signingkey, SMB3_SIGN_KEY_SIZE);
116 * Otherwise, use the channel key.
119 for (i = 0; i < ses->chan_count; i++) {
120 chan = ses->chans + i;
121 if (chan->server == server) {
122 memcpy(key, chan->signkey, SMB3_SIGN_KEY_SIZE);
128 "%s: Could not find channel signing key for session 0x%llx\n",
133 spin_unlock(&cifs_tcp_ses_lock);
137 static struct cifs_ses *
138 smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id)
140 struct cifs_ses *ses;
142 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
143 if (ses->Suid != ses_id)
153 smb2_find_smb_ses(struct TCP_Server_Info *server, __u64 ses_id)
155 struct cifs_ses *ses;
157 spin_lock(&cifs_tcp_ses_lock);
158 ses = smb2_find_smb_ses_unlocked(server, ses_id);
159 spin_unlock(&cifs_tcp_ses_lock);
164 static struct cifs_tcon *
165 smb2_find_smb_sess_tcon_unlocked(struct cifs_ses *ses, __u32 tid)
167 struct cifs_tcon *tcon;
169 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
170 if (tcon->tid != tid)
180 * Obtain tcon corresponding to the tid in the given
185 smb2_find_smb_tcon(struct TCP_Server_Info *server, __u64 ses_id, __u32 tid)
187 struct cifs_ses *ses;
188 struct cifs_tcon *tcon;
190 spin_lock(&cifs_tcp_ses_lock);
191 ses = smb2_find_smb_ses_unlocked(server, ses_id);
193 spin_unlock(&cifs_tcp_ses_lock);
196 tcon = smb2_find_smb_sess_tcon_unlocked(ses, tid);
198 cifs_put_smb_ses(ses);
199 spin_unlock(&cifs_tcp_ses_lock);
202 spin_unlock(&cifs_tcp_ses_lock);
203 /* tcon already has a ref to ses, so we don't need ses anymore */
204 cifs_put_smb_ses(ses);
210 smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
211 bool allocate_crypto)
214 unsigned char smb2_signature[SMB2_HMACSHA256_SIZE];
215 unsigned char *sigptr = smb2_signature;
216 struct kvec *iov = rqst->rq_iov;
217 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
218 struct cifs_ses *ses;
219 struct shash_desc *shash;
220 struct crypto_shash *hash;
221 struct sdesc *sdesc = NULL;
222 struct smb_rqst drqst;
224 ses = smb2_find_smb_ses(server, shdr->SessionId);
226 cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
230 memset(smb2_signature, 0x0, SMB2_HMACSHA256_SIZE);
231 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE);
233 if (allocate_crypto) {
234 rc = cifs_alloc_hash("hmac(sha256)", &hash, &sdesc);
237 "%s: sha256 alloc failed\n", __func__);
240 shash = &sdesc->shash;
242 hash = server->secmech.hmacsha256;
243 shash = &server->secmech.sdeschmacsha256->shash;
246 rc = crypto_shash_setkey(hash, ses->auth_key.response,
247 SMB2_NTLMV2_SESSKEY_SIZE);
250 "%s: Could not update with response\n",
255 rc = crypto_shash_init(shash);
257 cifs_server_dbg(VFS, "%s: Could not init sha256", __func__);
262 * For SMB2+, __cifs_calc_signature() expects to sign only the actual
263 * data, that is, iov[0] should not contain a rfc1002 length.
265 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to
266 * __cifs_calc_signature().
269 if (drqst.rq_nvec >= 2 && iov[0].iov_len == 4) {
270 rc = crypto_shash_update(shash, iov[0].iov_base,
274 "%s: Could not update with payload\n",
282 rc = __cifs_calc_signature(&drqst, server, sigptr, shash);
284 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE);
288 cifs_free_hash(&hash, &sdesc);
290 cifs_put_smb_ses(ses);
294 static int generate_key(struct cifs_ses *ses, struct kvec label,
295 struct kvec context, __u8 *key, unsigned int key_size)
297 unsigned char zero = 0x0;
298 __u8 i[4] = {0, 0, 0, 1};
299 __u8 L128[4] = {0, 0, 0, 128};
300 __u8 L256[4] = {0, 0, 1, 0};
302 unsigned char prfhash[SMB2_HMACSHA256_SIZE];
303 unsigned char *hashptr = prfhash;
304 struct TCP_Server_Info *server = ses->server;
306 memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE);
307 memset(key, 0x0, key_size);
309 rc = smb3_crypto_shash_allocate(server);
311 cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
312 goto smb3signkey_ret;
315 rc = crypto_shash_setkey(server->secmech.hmacsha256,
316 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
318 cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__);
319 goto smb3signkey_ret;
322 rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash);
324 cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
325 goto smb3signkey_ret;
328 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
331 cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__);
332 goto smb3signkey_ret;
335 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
336 label.iov_base, label.iov_len);
338 cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__);
339 goto smb3signkey_ret;
342 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
345 cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__);
346 goto smb3signkey_ret;
349 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
350 context.iov_base, context.iov_len);
352 cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__);
353 goto smb3signkey_ret;
356 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) ||
357 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) {
358 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
361 rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
365 cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__);
366 goto smb3signkey_ret;
369 rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
372 cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
373 goto smb3signkey_ret;
376 memcpy(key, hashptr, key_size);
387 struct derivation_triplet {
388 struct derivation signing;
389 struct derivation encryption;
390 struct derivation decryption;
394 generate_smb3signingkey(struct cifs_ses *ses,
395 const struct derivation_triplet *ptriplet)
398 #ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS
399 struct TCP_Server_Info *server = ses->server;
403 * All channels use the same encryption/decryption keys but
404 * they have their own signing key.
406 * When we generate the keys, check if it is for a new channel
407 * (binding) in which case we only need to generate a signing
408 * key and store it in the channel as to not overwrite the
409 * master connection signing key stored in the session
413 rc = generate_key(ses, ptriplet->signing.label,
414 ptriplet->signing.context,
415 cifs_ses_binding_channel(ses)->signkey,
420 rc = generate_key(ses, ptriplet->signing.label,
421 ptriplet->signing.context,
427 memcpy(ses->chans[0].signkey, ses->smb3signingkey,
430 rc = generate_key(ses, ptriplet->encryption.label,
431 ptriplet->encryption.context,
432 ses->smb3encryptionkey,
433 SMB3_ENC_DEC_KEY_SIZE);
434 rc = generate_key(ses, ptriplet->decryption.label,
435 ptriplet->decryption.context,
436 ses->smb3decryptionkey,
437 SMB3_ENC_DEC_KEY_SIZE);
445 #ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS
446 cifs_dbg(VFS, "%s: dumping generated AES session keys\n", __func__);
448 * The session id is opaque in terms of endianness, so we can't
449 * print it as a long long. we dump it as we got it on the wire
451 cifs_dbg(VFS, "Session Id %*ph\n", (int)sizeof(ses->Suid),
453 cifs_dbg(VFS, "Cipher type %d\n", server->cipher_type);
454 cifs_dbg(VFS, "Session Key %*ph\n",
455 SMB2_NTLMV2_SESSKEY_SIZE, ses->auth_key.response);
456 cifs_dbg(VFS, "Signing Key %*ph\n",
457 SMB3_SIGN_KEY_SIZE, ses->smb3signingkey);
458 if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) ||
459 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)) {
460 cifs_dbg(VFS, "ServerIn Key %*ph\n",
461 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3encryptionkey);
462 cifs_dbg(VFS, "ServerOut Key %*ph\n",
463 SMB3_GCM256_CRYPTKEY_SIZE, ses->smb3decryptionkey);
465 cifs_dbg(VFS, "ServerIn Key %*ph\n",
466 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3encryptionkey);
467 cifs_dbg(VFS, "ServerOut Key %*ph\n",
468 SMB3_GCM128_CRYPTKEY_SIZE, ses->smb3decryptionkey);
475 generate_smb30signingkey(struct cifs_ses *ses)
478 struct derivation_triplet triplet;
479 struct derivation *d;
481 d = &triplet.signing;
482 d->label.iov_base = "SMB2AESCMAC";
483 d->label.iov_len = 12;
484 d->context.iov_base = "SmbSign";
485 d->context.iov_len = 8;
487 d = &triplet.encryption;
488 d->label.iov_base = "SMB2AESCCM";
489 d->label.iov_len = 11;
490 d->context.iov_base = "ServerIn ";
491 d->context.iov_len = 10;
493 d = &triplet.decryption;
494 d->label.iov_base = "SMB2AESCCM";
495 d->label.iov_len = 11;
496 d->context.iov_base = "ServerOut";
497 d->context.iov_len = 10;
499 return generate_smb3signingkey(ses, &triplet);
503 generate_smb311signingkey(struct cifs_ses *ses)
506 struct derivation_triplet triplet;
507 struct derivation *d;
509 d = &triplet.signing;
510 d->label.iov_base = "SMBSigningKey";
511 d->label.iov_len = 14;
512 d->context.iov_base = ses->preauth_sha_hash;
513 d->context.iov_len = 64;
515 d = &triplet.encryption;
516 d->label.iov_base = "SMBC2SCipherKey";
517 d->label.iov_len = 16;
518 d->context.iov_base = ses->preauth_sha_hash;
519 d->context.iov_len = 64;
521 d = &triplet.decryption;
522 d->label.iov_base = "SMBS2CCipherKey";
523 d->label.iov_len = 16;
524 d->context.iov_base = ses->preauth_sha_hash;
525 d->context.iov_len = 64;
527 return generate_smb3signingkey(ses, &triplet);
531 smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
532 bool allocate_crypto)
535 unsigned char smb3_signature[SMB2_CMACAES_SIZE];
536 unsigned char *sigptr = smb3_signature;
537 struct kvec *iov = rqst->rq_iov;
538 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
539 struct shash_desc *shash;
540 struct crypto_shash *hash;
541 struct sdesc *sdesc = NULL;
542 struct smb_rqst drqst;
543 u8 key[SMB3_SIGN_KEY_SIZE];
545 rc = smb2_get_sign_key(shdr->SessionId, server, key);
549 if (allocate_crypto) {
550 rc = cifs_alloc_hash("cmac(aes)", &hash, &sdesc);
554 shash = &sdesc->shash;
556 hash = server->secmech.cmacaes;
557 shash = &server->secmech.sdesccmacaes->shash;
560 memset(smb3_signature, 0x0, SMB2_CMACAES_SIZE);
561 memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE);
563 rc = crypto_shash_setkey(hash, key, SMB2_CMACAES_SIZE);
565 cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
570 * we already allocate sdesccmacaes when we init smb3 signing key,
571 * so unlike smb2 case we do not have to check here if secmech are
574 rc = crypto_shash_init(shash);
576 cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
581 * For SMB2+, __cifs_calc_signature() expects to sign only the actual
582 * data, that is, iov[0] should not contain a rfc1002 length.
584 * Sign the rfc1002 length prior to passing the data (iov[1-N]) down to
585 * __cifs_calc_signature().
588 if (drqst.rq_nvec >= 2 && iov[0].iov_len == 4) {
589 rc = crypto_shash_update(shash, iov[0].iov_base,
592 cifs_server_dbg(VFS, "%s: Could not update with payload\n",
600 rc = __cifs_calc_signature(&drqst, server, sigptr, shash);
602 memcpy(shdr->Signature, sigptr, SMB2_SIGNATURE_SIZE);
606 cifs_free_hash(&hash, &sdesc);
610 /* must be called with server->srv_mutex held */
612 smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
615 struct smb2_sync_hdr *shdr;
616 struct smb2_sess_setup_req *ssr;
620 shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
621 ssr = (struct smb2_sess_setup_req *)shdr;
623 is_binding = shdr->Command == SMB2_SESSION_SETUP &&
624 (ssr->Flags & SMB2_SESSION_REQ_FLAG_BINDING);
625 is_signed = shdr->Flags & SMB2_FLAGS_SIGNED;
629 if (server->tcpStatus == CifsNeedNegotiate)
631 if (!is_binding && !server->session_estab) {
632 strncpy(shdr->Signature, "BSRSPYL", 8);
636 rc = server->ops->calc_signature(rqst, server, false);
642 smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
645 char server_response_sig[SMB2_SIGNATURE_SIZE];
646 struct smb2_sync_hdr *shdr =
647 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
649 if ((shdr->Command == SMB2_NEGOTIATE) ||
650 (shdr->Command == SMB2_SESSION_SETUP) ||
651 (shdr->Command == SMB2_OPLOCK_BREAK) ||
652 server->ignore_signature ||
653 (!server->session_estab))
657 * BB what if signatures are supposed to be on for session but
658 * server does not send one? BB
661 /* Do not need to verify session setups with signature "BSRSPYL " */
662 if (memcmp(shdr->Signature, "BSRSPYL ", 8) == 0)
663 cifs_dbg(FYI, "dummy signature received for smb command 0x%x\n",
667 * Save off the origiginal signature so we can modify the smb and check
668 * our calculated signature against what the server sent.
670 memcpy(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE);
672 memset(shdr->Signature, 0, SMB2_SIGNATURE_SIZE);
674 rc = server->ops->calc_signature(rqst, server, true);
679 if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) {
680 cifs_dbg(VFS, "sign fail cmd 0x%x message id 0x%llx\n",
681 shdr->Command, shdr->MessageId);
688 * Set message id for the request. Should be called after wait_for_free_request
689 * and when srv_mutex is held.
692 smb2_seq_num_into_buf(struct TCP_Server_Info *server,
693 struct smb2_sync_hdr *shdr)
695 unsigned int i, num = le16_to_cpu(shdr->CreditCharge);
697 shdr->MessageId = get_next_mid64(server);
698 /* skip message numbers according to CreditCharge field */
699 for (i = 1; i < num; i++)
700 get_next_mid(server);
703 static struct mid_q_entry *
704 smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
705 struct TCP_Server_Info *server)
707 struct mid_q_entry *temp;
708 unsigned int credits = le16_to_cpu(shdr->CreditCharge);
710 if (server == NULL) {
711 cifs_dbg(VFS, "Null TCP session in smb2_mid_entry_alloc\n");
715 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
716 memset(temp, 0, sizeof(struct mid_q_entry));
717 kref_init(&temp->refcount);
718 temp->mid = le64_to_cpu(shdr->MessageId);
719 temp->credits = credits > 0 ? credits : 1;
720 temp->pid = current->pid;
721 temp->command = shdr->Command; /* Always LE */
722 temp->when_alloc = jiffies;
723 temp->server = server;
726 * The default is for the mid to be synchronous, so the
727 * default callback just wakes up the current task.
729 get_task_struct(current);
730 temp->creator = current;
731 temp->callback = cifs_wake_up_task;
732 temp->callback_data = current;
734 atomic_inc(&midCount);
735 temp->mid_state = MID_REQUEST_ALLOCATED;
736 trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId,
737 le16_to_cpu(shdr->Command), temp->mid);
742 smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
743 struct smb2_sync_hdr *shdr, struct mid_q_entry **mid)
745 if (server->tcpStatus == CifsExiting)
748 if (server->tcpStatus == CifsNeedReconnect) {
749 cifs_dbg(FYI, "tcp session dead - return to caller to retry\n");
753 if (server->tcpStatus == CifsNeedNegotiate &&
754 shdr->Command != SMB2_NEGOTIATE)
757 if (ses->status == CifsNew) {
758 if ((shdr->Command != SMB2_SESSION_SETUP) &&
759 (shdr->Command != SMB2_NEGOTIATE))
761 /* else ok - we are setting up session */
764 if (ses->status == CifsExiting) {
765 if (shdr->Command != SMB2_LOGOFF)
767 /* else ok - we are shutting down the session */
770 *mid = smb2_mid_entry_alloc(shdr, server);
773 spin_lock(&GlobalMid_Lock);
774 list_add_tail(&(*mid)->qhead, &server->pending_mid_q);
775 spin_unlock(&GlobalMid_Lock);
781 smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
784 unsigned int len = mid->resp_buf_size;
786 struct smb_rqst rqst = { .rq_iov = iov,
789 iov[0].iov_base = (char *)mid->resp_buf;
790 iov[0].iov_len = len;
792 dump_smb(mid->resp_buf, min_t(u32, 80, len));
793 /* convert the length into a more usable form */
794 if (len > 24 && server->sign && !mid->decrypted) {
797 rc = smb2_verify_signature(&rqst, server);
799 cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
803 return map_smb2_to_linux_error(mid->resp_buf, log_error);
807 smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
808 struct smb_rqst *rqst)
811 struct smb2_sync_hdr *shdr =
812 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
813 struct mid_q_entry *mid;
815 smb2_seq_num_into_buf(server, shdr);
817 rc = smb2_get_mid_entry(ses, server, shdr, &mid);
819 revert_current_mid_from_hdr(server, shdr);
823 rc = smb2_sign_rqst(rqst, server);
825 revert_current_mid_from_hdr(server, shdr);
826 cifs_delete_mid(mid);
834 smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
837 struct smb2_sync_hdr *shdr =
838 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
839 struct mid_q_entry *mid;
841 if (server->tcpStatus == CifsNeedNegotiate &&
842 shdr->Command != SMB2_NEGOTIATE)
843 return ERR_PTR(-EAGAIN);
845 smb2_seq_num_into_buf(server, shdr);
847 mid = smb2_mid_entry_alloc(shdr, server);
849 revert_current_mid_from_hdr(server, shdr);
850 return ERR_PTR(-ENOMEM);
853 rc = smb2_sign_rqst(rqst, server);
855 revert_current_mid_from_hdr(server, shdr);
856 DeleteMidQEntry(mid);
864 smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
866 struct crypto_aead *tfm;
868 if (!server->secmech.ccmaesencrypt) {
869 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) ||
870 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM))
871 tfm = crypto_alloc_aead("gcm(aes)", 0, 0);
873 tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
875 cifs_server_dbg(VFS, "%s: Failed alloc encrypt aead\n",
879 server->secmech.ccmaesencrypt = tfm;
882 if (!server->secmech.ccmaesdecrypt) {
883 if ((server->cipher_type == SMB2_ENCRYPTION_AES128_GCM) ||
884 (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM))
885 tfm = crypto_alloc_aead("gcm(aes)", 0, 0);
887 tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
889 crypto_free_aead(server->secmech.ccmaesencrypt);
890 server->secmech.ccmaesencrypt = NULL;
891 cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
895 server->secmech.ccmaesdecrypt = tfm;