2 * fs/cifs/cifsencrypt.c
4 * Copyright (C) International Business Machines Corp., 2005,2006
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/slab.h>
26 #include "cifs_debug.h"
27 #include "cifs_unicode.h"
28 #include "cifsproto.h"
30 #include <linux/ctype.h>
31 #include <linux/random.h>
34 * Calculate and return the CIFS signature based on the mac key and SMB PDU.
35 * The 16 byte signature must be allocated by the caller. Note we only use the
36 * 1st eight bytes and that the smb header signature field on input contains
37 * the sequence number before this function is called. Also, this function
38 * should be called with the server->srv_mutex held.
40 static int cifs_calc_signature(struct smb_rqst *rqst,
41 struct TCP_Server_Info *server, char *signature)
45 struct kvec *iov = rqst->rq_iov;
46 int n_vec = rqst->rq_nvec;
48 if (iov == NULL || signature == NULL || server == NULL)
51 if (!server->secmech.sdescmd5) {
52 cERROR(1, "%s: Can't generate signature", __func__);
56 rc = crypto_shash_init(&server->secmech.sdescmd5->shash);
58 cERROR(1, "%s: Could not init md5", __func__);
62 rc = crypto_shash_update(&server->secmech.sdescmd5->shash,
63 server->session_key.response, server->session_key.len);
65 cERROR(1, "%s: Could not update with response", __func__);
69 for (i = 0; i < n_vec; i++) {
70 if (iov[i].iov_len == 0)
72 if (iov[i].iov_base == NULL) {
73 cERROR(1, "null iovec entry");
76 /* The first entry includes a length field (which does not get
77 signed that occupies the first 4 bytes before the header */
79 if (iov[0].iov_len <= 8) /* cmd field at offset 9 */
80 break; /* nothing to sign or corrupt header */
82 crypto_shash_update(&server->secmech.sdescmd5->shash,
83 iov[i].iov_base + 4, iov[i].iov_len - 4);
86 crypto_shash_update(&server->secmech.sdescmd5->shash,
87 iov[i].iov_base, iov[i].iov_len);
90 cERROR(1, "%s: Could not update with payload",
96 rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature);
98 cERROR(1, "%s: Could not generate md5 hash", __func__);
103 /* must be called with server->srv_mutex held */
104 int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
105 __u32 *pexpected_response_sequence_number)
108 char smb_signature[20];
109 struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
111 if ((cifs_pdu == NULL) || (server == NULL))
114 if (!(cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) ||
115 server->tcpStatus == CifsNeedNegotiate)
118 if (!server->session_estab) {
119 memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
123 cifs_pdu->Signature.Sequence.SequenceNumber =
124 cpu_to_le32(server->sequence_number);
125 cifs_pdu->Signature.Sequence.Reserved = 0;
127 *pexpected_response_sequence_number = server->sequence_number++;
128 server->sequence_number++;
130 rc = cifs_calc_signature(rqst, server, smb_signature);
132 memset(cifs_pdu->Signature.SecuritySignature, 0, 8);
134 memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8);
139 int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
140 __u32 *pexpected_response_sequence)
142 struct smb_rqst rqst = { .rq_iov = iov,
145 return cifs_sign_rqst(&rqst, server, pexpected_response_sequence);
148 /* must be called with server->srv_mutex held */
149 int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
150 __u32 *pexpected_response_sequence_number)
154 iov.iov_base = cifs_pdu;
155 iov.iov_len = be32_to_cpu(cifs_pdu->smb_buf_length) + 4;
157 return cifs_sign_smbv(&iov, 1, server,
158 pexpected_response_sequence_number);
161 int cifs_verify_signature(struct smb_rqst *rqst,
162 struct TCP_Server_Info *server,
163 __u32 expected_sequence_number)
166 char server_response_sig[8];
167 char what_we_think_sig_should_be[20];
168 struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
170 if (cifs_pdu == NULL || server == NULL)
173 if (!server->session_estab)
176 if (cifs_pdu->Command == SMB_COM_LOCKING_ANDX) {
177 struct smb_com_lock_req *pSMB =
178 (struct smb_com_lock_req *)cifs_pdu;
179 if (pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)
183 /* BB what if signatures are supposed to be on for session but
184 server does not send one? BB */
186 /* Do not need to verify session setups with signature "BSRSPYL " */
187 if (memcmp(cifs_pdu->Signature.SecuritySignature, "BSRSPYL ", 8) == 0)
188 cFYI(1, "dummy signature received for smb command 0x%x",
191 /* save off the origiginal signature so we can modify the smb and check
192 its signature against what the server sent */
193 memcpy(server_response_sig, cifs_pdu->Signature.SecuritySignature, 8);
195 cifs_pdu->Signature.Sequence.SequenceNumber =
196 cpu_to_le32(expected_sequence_number);
197 cifs_pdu->Signature.Sequence.Reserved = 0;
199 mutex_lock(&server->srv_mutex);
200 rc = cifs_calc_signature(rqst, server, what_we_think_sig_should_be);
201 mutex_unlock(&server->srv_mutex);
206 /* cifs_dump_mem("what we think it should be: ",
207 what_we_think_sig_should_be, 16); */
209 if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
216 /* first calculate 24 bytes ntlm response and then 16 byte session key */
217 int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp)
220 unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE;
221 char temp_key[CIFS_SESS_KEY_SIZE];
226 ses->auth_key.response = kmalloc(temp_len, GFP_KERNEL);
227 if (!ses->auth_key.response) {
228 cERROR(1, "NTLM can't allocate (%u bytes) memory", temp_len);
231 ses->auth_key.len = temp_len;
233 rc = SMBNTencrypt(ses->password, ses->server->cryptkey,
234 ses->auth_key.response + CIFS_SESS_KEY_SIZE, nls_cp);
236 cFYI(1, "%s Can't generate NTLM response, error: %d",
241 rc = E_md4hash(ses->password, temp_key, nls_cp);
243 cFYI(1, "%s Can't generate NT hash, error: %d", __func__, rc);
247 rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE);
249 cFYI(1, "%s Can't generate NTLM session key, error: %d",
255 #ifdef CONFIG_CIFS_WEAK_PW_HASH
256 int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
257 char *lnm_session_key)
261 char password_with_pad[CIFS_ENCPWD_SIZE];
263 memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
265 strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE);
267 if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) {
268 memset(lnm_session_key, 0, CIFS_SESS_KEY_SIZE);
269 memcpy(lnm_session_key, password_with_pad,
274 /* calculate old style session key */
275 /* calling toupper is less broken than repeatedly
276 calling nls_toupper would be since that will never
277 work for UTF8, but neither handles multibyte code pages
278 but the only alternative would be converting to UCS-16 (Unicode)
279 (using a routine something like UniStrupr) then
280 uppercasing and then converting back from Unicode - which
281 would only worth doing it if we knew it were utf8. Basically
282 utf8 and other multibyte codepages each need their own strupper
283 function since a byte at a time will ont work. */
285 for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
286 password_with_pad[i] = toupper(password_with_pad[i]);
288 rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key);
292 #endif /* CIFS_WEAK_PW_HASH */
294 /* Build a proper attribute value/target info pairs blob.
295 * Fill in netbios and dns domain name and workstation name
296 * and client time (total five av pairs and + one end of fields indicator.
297 * Allocate domain name which gets freed when session struct is deallocated.
300 build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp)
303 unsigned int size = 2 * sizeof(struct ntlmssp2_name);
304 char *defdmname = "WORKGROUP";
305 unsigned char *blobptr;
306 struct ntlmssp2_name *attrptr;
308 if (!ses->domainName) {
309 ses->domainName = kstrdup(defdmname, GFP_KERNEL);
310 if (!ses->domainName)
314 dlen = strlen(ses->domainName);
317 * The length of this blob is two times the size of a
318 * structure (av pair) which holds name/size
319 * ( for NTLMSSP_AV_NB_DOMAIN_NAME followed by NTLMSSP_AV_EOL ) +
320 * unicode length of a netbios domain name
322 ses->auth_key.len = size + 2 * dlen;
323 ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL);
324 if (!ses->auth_key.response) {
325 ses->auth_key.len = 0;
326 cERROR(1, "Challenge target info allocation failure");
330 blobptr = ses->auth_key.response;
331 attrptr = (struct ntlmssp2_name *) blobptr;
334 * As defined in MS-NTLM 3.3.2, just this av pair field
335 * is sufficient as part of the temp
337 attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME);
338 attrptr->length = cpu_to_le16(2 * dlen);
339 blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name);
340 cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp);
345 /* Server has provided av pairs/target info in the type 2 challenge
346 * packet and we have plucked it and stored within smb session.
347 * We parse that blob here to find netbios domain name to be used
348 * as part of ntlmv2 authentication (in Target String), if not already
349 * specified on the command line.
350 * If this function returns without any error but without fetching
351 * domain name, authentication may fail against some server but
352 * may not fail against other (those who are not very particular
353 * about target string i.e. for some, just user name might suffice.
356 find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
358 unsigned int attrsize;
360 unsigned int onesize = sizeof(struct ntlmssp2_name);
361 unsigned char *blobptr;
362 unsigned char *blobend;
363 struct ntlmssp2_name *attrptr;
365 if (!ses->auth_key.len || !ses->auth_key.response)
368 blobptr = ses->auth_key.response;
369 blobend = blobptr + ses->auth_key.len;
371 while (blobptr + onesize < blobend) {
372 attrptr = (struct ntlmssp2_name *) blobptr;
373 type = le16_to_cpu(attrptr->type);
374 if (type == NTLMSSP_AV_EOL)
376 blobptr += 2; /* advance attr type */
377 attrsize = le16_to_cpu(attrptr->length);
378 blobptr += 2; /* advance attr size */
379 if (blobptr + attrsize > blobend)
381 if (type == NTLMSSP_AV_NB_DOMAIN_NAME) {
384 if (!ses->domainName) {
386 kmalloc(attrsize + 1, GFP_KERNEL);
387 if (!ses->domainName)
389 cifs_from_utf16(ses->domainName,
390 (__le16 *)blobptr, attrsize, attrsize,
395 blobptr += attrsize; /* advance attr value */
401 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
402 const struct nls_table *nls_cp)
406 char nt_hash[CIFS_NTHASH_SIZE];
411 if (!ses->server->secmech.sdeschmacmd5) {
412 cERROR(1, "calc_ntlmv2_hash: can't generate ntlmv2 hash");
416 /* calculate md4 hash of password */
417 E_md4hash(ses->password, nt_hash, nls_cp);
419 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5, nt_hash,
422 cERROR(1, "%s: Could not set NT Hash as a key", __func__);
426 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
428 cERROR(1, "calc_ntlmv2_hash: could not init hmacmd5");
432 /* convert ses->user_name to unicode and uppercase */
433 len = ses->user_name ? strlen(ses->user_name) : 0;
434 user = kmalloc(2 + (len * 2), GFP_KERNEL);
436 cERROR(1, "calc_ntlmv2_hash: user mem alloc failure");
442 len = cifs_strtoUTF16((__le16 *)user, ses->user_name, len, nls_cp);
445 memset(user, '\0', 2);
448 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
449 (char *)user, 2 * len);
452 cERROR(1, "%s: Could not update with user", __func__);
456 /* convert ses->domainName to unicode and uppercase */
457 if (ses->domainName) {
458 len = strlen(ses->domainName);
460 domain = kmalloc(2 + (len * 2), GFP_KERNEL);
461 if (domain == NULL) {
462 cERROR(1, "calc_ntlmv2_hash: domain mem alloc failure");
466 len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len,
469 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
470 (char *)domain, 2 * len);
473 cERROR(1, "%s: Could not update with domain",
477 } else if (ses->serverName) {
478 len = strlen(ses->serverName);
480 server = kmalloc(2 + (len * 2), GFP_KERNEL);
481 if (server == NULL) {
482 cERROR(1, "calc_ntlmv2_hash: server mem alloc failure");
486 len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len,
489 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
490 (char *)server, 2 * len);
493 cERROR(1, "%s: Could not update with server",
499 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash,
502 cERROR(1, "%s: Could not generate md5 hash", __func__);
508 CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
511 unsigned int offset = CIFS_SESS_KEY_SIZE + 8;
513 if (!ses->server->secmech.sdeschmacmd5) {
514 cERROR(1, "calc_ntlmv2_hash: can't generate ntlmv2 hash");
518 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5,
519 ntlmv2_hash, CIFS_HMAC_MD5_HASH_SIZE);
521 cERROR(1, "%s: Could not set NTLMV2 Hash as a key", __func__);
525 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
527 cERROR(1, "CalcNTLMv2_response: could not init hmacmd5");
531 if (ses->server->secType == RawNTLMSSP)
532 memcpy(ses->auth_key.response + offset,
533 ses->ntlmssp->cryptkey, CIFS_SERVER_CHALLENGE_SIZE);
535 memcpy(ses->auth_key.response + offset,
536 ses->server->cryptkey, CIFS_SERVER_CHALLENGE_SIZE);
537 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
538 ses->auth_key.response + offset, ses->auth_key.len - offset);
540 cERROR(1, "%s: Could not update with response", __func__);
544 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash,
545 ses->auth_key.response + CIFS_SESS_KEY_SIZE);
547 cERROR(1, "%s: Could not generate md5 hash", __func__);
554 setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
559 struct ntlmv2_resp *buf;
560 char ntlmv2_hash[16];
561 unsigned char *tiblob = NULL; /* target info blob */
563 if (ses->server->secType == RawNTLMSSP) {
564 if (!ses->domainName) {
565 rc = find_domain_name(ses, nls_cp);
567 cERROR(1, "error %d finding domain name", rc);
568 goto setup_ntlmv2_rsp_ret;
572 rc = build_avpair_blob(ses, nls_cp);
574 cERROR(1, "error %d building av pair blob", rc);
575 goto setup_ntlmv2_rsp_ret;
579 baselen = CIFS_SESS_KEY_SIZE + sizeof(struct ntlmv2_resp);
580 tilen = ses->auth_key.len;
581 tiblob = ses->auth_key.response;
583 ses->auth_key.response = kmalloc(baselen + tilen, GFP_KERNEL);
584 if (!ses->auth_key.response) {
586 ses->auth_key.len = 0;
587 cERROR(1, "%s: Can't allocate auth blob", __func__);
588 goto setup_ntlmv2_rsp_ret;
590 ses->auth_key.len += baselen;
592 buf = (struct ntlmv2_resp *)
593 (ses->auth_key.response + CIFS_SESS_KEY_SIZE);
594 buf->blob_signature = cpu_to_le32(0x00000101);
596 buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
597 get_random_bytes(&buf->client_chal, sizeof(buf->client_chal));
600 memcpy(ses->auth_key.response + baselen, tiblob, tilen);
602 /* calculate ntlmv2_hash */
603 rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp);
605 cERROR(1, "could not get v2 hash rc %d", rc);
606 goto setup_ntlmv2_rsp_ret;
609 /* calculate first part of the client response (CR1) */
610 rc = CalcNTLMv2_response(ses, ntlmv2_hash);
612 cERROR(1, "Could not calculate CR1 rc: %d", rc);
613 goto setup_ntlmv2_rsp_ret;
616 /* now calculate the session key for NTLMv2 */
617 rc = crypto_shash_setkey(ses->server->secmech.hmacmd5,
618 ntlmv2_hash, CIFS_HMAC_MD5_HASH_SIZE);
620 cERROR(1, "%s: Could not set NTLMV2 Hash as a key", __func__);
621 goto setup_ntlmv2_rsp_ret;
624 rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
626 cERROR(1, "%s: Could not init hmacmd5", __func__);
627 goto setup_ntlmv2_rsp_ret;
630 rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
631 ses->auth_key.response + CIFS_SESS_KEY_SIZE,
632 CIFS_HMAC_MD5_HASH_SIZE);
634 cERROR(1, "%s: Could not update with response", __func__);
635 goto setup_ntlmv2_rsp_ret;
638 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash,
639 ses->auth_key.response);
641 cERROR(1, "%s: Could not generate md5 hash", __func__);
643 setup_ntlmv2_rsp_ret:
650 calc_seckey(struct cifs_ses *ses)
653 struct crypto_blkcipher *tfm_arc4;
654 struct scatterlist sgin, sgout;
655 struct blkcipher_desc desc;
656 unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */
658 get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
660 tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
661 if (IS_ERR(tfm_arc4)) {
662 rc = PTR_ERR(tfm_arc4);
663 cERROR(1, "could not allocate crypto API arc4");
669 rc = crypto_blkcipher_setkey(tfm_arc4, ses->auth_key.response,
672 cERROR(1, "%s: Could not set response as a key", __func__);
676 sg_init_one(&sgin, sec_key, CIFS_SESS_KEY_SIZE);
677 sg_init_one(&sgout, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE);
679 rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, CIFS_CPHTXT_SIZE);
681 cERROR(1, "could not encrypt session key rc: %d", rc);
682 crypto_free_blkcipher(tfm_arc4);
686 /* make secondary_key/nonce as session key */
687 memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE);
688 /* and make len as that of session key only */
689 ses->auth_key.len = CIFS_SESS_KEY_SIZE;
691 crypto_free_blkcipher(tfm_arc4);
697 cifs_crypto_shash_release(struct TCP_Server_Info *server)
699 if (server->secmech.hmacsha256)
700 crypto_free_shash(server->secmech.hmacsha256);
702 if (server->secmech.md5)
703 crypto_free_shash(server->secmech.md5);
705 if (server->secmech.hmacmd5)
706 crypto_free_shash(server->secmech.hmacmd5);
708 kfree(server->secmech.sdeschmacsha256);
710 kfree(server->secmech.sdeschmacmd5);
712 kfree(server->secmech.sdescmd5);
716 cifs_crypto_shash_allocate(struct TCP_Server_Info *server)
721 server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0);
722 if (IS_ERR(server->secmech.hmacmd5)) {
723 cERROR(1, "could not allocate crypto hmacmd5");
724 return PTR_ERR(server->secmech.hmacmd5);
727 server->secmech.md5 = crypto_alloc_shash("md5", 0, 0);
728 if (IS_ERR(server->secmech.md5)) {
729 cERROR(1, "could not allocate crypto md5");
730 rc = PTR_ERR(server->secmech.md5);
731 goto crypto_allocate_md5_fail;
734 server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0);
735 if (IS_ERR(server->secmech.hmacsha256)) {
736 cERROR(1, "could not allocate crypto hmacsha256\n");
737 rc = PTR_ERR(server->secmech.hmacsha256);
738 goto crypto_allocate_hmacsha256_fail;
741 size = sizeof(struct shash_desc) +
742 crypto_shash_descsize(server->secmech.hmacmd5);
743 server->secmech.sdeschmacmd5 = kmalloc(size, GFP_KERNEL);
744 if (!server->secmech.sdeschmacmd5) {
745 cERROR(1, "cifs_crypto_shash_allocate: can't alloc hmacmd5");
747 goto crypto_allocate_hmacmd5_sdesc_fail;
749 server->secmech.sdeschmacmd5->shash.tfm = server->secmech.hmacmd5;
750 server->secmech.sdeschmacmd5->shash.flags = 0x0;
752 size = sizeof(struct shash_desc) +
753 crypto_shash_descsize(server->secmech.md5);
754 server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL);
755 if (!server->secmech.sdescmd5) {
756 cERROR(1, "cifs_crypto_shash_allocate: can't alloc md5");
758 goto crypto_allocate_md5_sdesc_fail;
760 server->secmech.sdescmd5->shash.tfm = server->secmech.md5;
761 server->secmech.sdescmd5->shash.flags = 0x0;
763 size = sizeof(struct shash_desc) +
764 crypto_shash_descsize(server->secmech.hmacsha256);
765 server->secmech.sdeschmacsha256 = kmalloc(size, GFP_KERNEL);
766 if (!server->secmech.sdeschmacsha256) {
767 cERROR(1, "%s: Can't alloc hmacsha256\n", __func__);
769 goto crypto_allocate_hmacsha256_sdesc_fail;
771 server->secmech.sdeschmacsha256->shash.tfm = server->secmech.hmacsha256;
772 server->secmech.sdeschmacsha256->shash.flags = 0x0;
776 crypto_allocate_hmacsha256_sdesc_fail:
777 kfree(server->secmech.sdescmd5);
779 crypto_allocate_md5_sdesc_fail:
780 kfree(server->secmech.sdeschmacmd5);
782 crypto_allocate_hmacmd5_sdesc_fail:
783 crypto_free_shash(server->secmech.hmacsha256);
785 crypto_allocate_hmacsha256_fail:
786 crypto_free_shash(server->secmech.md5);
788 crypto_allocate_md5_fail:
789 crypto_free_shash(server->secmech.hmacmd5);