@@ -103,26 +103,24 @@ static int cifs_calc_signature(struct smb_rqst *rqst,
103103 if (!rqst -> rq_iov || !signature || !server )
104104 return - EINVAL ;
105105
106- rc = cifs_alloc_hash ("md5" , & server -> secmech .md5 ,
107- & server -> secmech .sdescmd5 );
106+ rc = cifs_alloc_hash ("md5" , & server -> secmech .md5 );
108107 if (rc )
109108 return -1 ;
110109
111- rc = crypto_shash_init (& server -> secmech .sdescmd5 -> shash );
110+ rc = crypto_shash_init (server -> secmech .md5 );
112111 if (rc ) {
113112 cifs_dbg (VFS , "%s: Could not init md5\n" , __func__ );
114113 return rc ;
115114 }
116115
117- rc = crypto_shash_update (& server -> secmech .sdescmd5 -> shash ,
116+ rc = crypto_shash_update (server -> secmech .md5 ,
118117 server -> session_key .response , server -> session_key .len );
119118 if (rc ) {
120119 cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
121120 return rc ;
122121 }
123122
124- return __cifs_calc_signature (rqst , server , signature ,
125- & server -> secmech .sdescmd5 -> shash );
123+ return __cifs_calc_signature (rqst , server , signature , server -> secmech .md5 );
126124}
127125
128126/* must be called with server->srv_mutex held */
@@ -412,22 +410,22 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
412410 wchar_t * domain ;
413411 wchar_t * server ;
414412
415- if (!ses -> server -> secmech .sdeschmacmd5 ) {
413+ if (!ses -> server -> secmech .hmacmd5 ) {
416414 cifs_dbg (VFS , "%s: can't generate ntlmv2 hash\n" , __func__ );
417415 return -1 ;
418416 }
419417
420418 /* calculate md4 hash of password */
421419 E_md4hash (ses -> password , nt_hash , nls_cp );
422420
423- rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 , nt_hash ,
421+ rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 -> tfm , nt_hash ,
424422 CIFS_NTHASH_SIZE );
425423 if (rc ) {
426424 cifs_dbg (VFS , "%s: Could not set NT Hash as a key\n" , __func__ );
427425 return rc ;
428426 }
429427
430- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
428+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
431429 if (rc ) {
432430 cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
433431 return rc ;
@@ -448,7 +446,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
448446 memset (user , '\0' , 2 );
449447 }
450448
451- rc = crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
449+ rc = crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
452450 (char * )user , 2 * len );
453451 kfree (user );
454452 if (rc ) {
@@ -468,7 +466,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
468466 len = cifs_strtoUTF16 ((__le16 * )domain , ses -> domainName , len ,
469467 nls_cp );
470468 rc =
471- crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
469+ crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
472470 (char * )domain , 2 * len );
473471 kfree (domain );
474472 if (rc ) {
@@ -488,7 +486,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
488486 len = cifs_strtoUTF16 ((__le16 * )server , ses -> ip_addr , len ,
489487 nls_cp );
490488 rc =
491- crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
489+ crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
492490 (char * )server , 2 * len );
493491 kfree (server );
494492 if (rc ) {
@@ -498,7 +496,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
498496 }
499497 }
500498
501- rc = crypto_shash_final (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
499+ rc = crypto_shash_final (ses -> server -> secmech .hmacmd5 ,
502500 ntlmv2_hash );
503501 if (rc )
504502 cifs_dbg (VFS , "%s: Could not generate md5 hash\n" , __func__ );
@@ -518,20 +516,20 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
518516 hash_len = ses -> auth_key .len - (CIFS_SESS_KEY_SIZE +
519517 offsetof(struct ntlmv2_resp , challenge .key [0 ]));
520518
521- if (!ses -> server -> secmech .sdeschmacmd5 ) {
519+ if (!ses -> server -> secmech .hmacmd5 ) {
522520 cifs_dbg (VFS , "%s: can't generate ntlmv2 hash\n" , __func__ );
523521 return -1 ;
524522 }
525523
526- rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 ,
524+ rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 -> tfm ,
527525 ntlmv2_hash , CIFS_HMAC_MD5_HASH_SIZE );
528526 if (rc ) {
529527 cifs_dbg (VFS , "%s: Could not set NTLMV2 Hash as a key\n" ,
530528 __func__ );
531529 return rc ;
532530 }
533531
534- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
532+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
535533 if (rc ) {
536534 cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
537535 return rc ;
@@ -543,15 +541,15 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
543541 else
544542 memcpy (ntlmv2 -> challenge .key ,
545543 ses -> server -> cryptkey , CIFS_SERVER_CHALLENGE_SIZE );
546- rc = crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
544+ rc = crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
547545 ntlmv2 -> challenge .key , hash_len );
548546 if (rc ) {
549547 cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
550548 return rc ;
551549 }
552550
553551 /* Note that the MD5 digest over writes anon.challenge_key.key */
554- rc = crypto_shash_final (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
552+ rc = crypto_shash_final (ses -> server -> secmech .hmacmd5 ,
555553 ntlmv2 -> ntlmv2_hash );
556554 if (rc )
557555 cifs_dbg (VFS , "%s: Could not generate md5 hash\n" , __func__ );
@@ -627,9 +625,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
627625
628626 cifs_server_lock (ses -> server );
629627
630- rc = cifs_alloc_hash ("hmac(md5)" ,
631- & ses -> server -> secmech .hmacmd5 ,
632- & ses -> server -> secmech .sdeschmacmd5 );
628+ rc = cifs_alloc_hash ("hmac(md5)" , & ses -> server -> secmech .hmacmd5 );
633629 if (rc ) {
634630 goto unlock ;
635631 }
@@ -649,29 +645,29 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
649645 }
650646
651647 /* now calculate the session key for NTLMv2 */
652- rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 ,
648+ rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 -> tfm ,
653649 ntlmv2_hash , CIFS_HMAC_MD5_HASH_SIZE );
654650 if (rc ) {
655651 cifs_dbg (VFS , "%s: Could not set NTLMV2 Hash as a key\n" ,
656652 __func__ );
657653 goto unlock ;
658654 }
659655
660- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
656+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
661657 if (rc ) {
662658 cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
663659 goto unlock ;
664660 }
665661
666- rc = crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
662+ rc = crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
667663 ntlmv2 -> ntlmv2_hash ,
668664 CIFS_HMAC_MD5_HASH_SIZE );
669665 if (rc ) {
670666 cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
671667 goto unlock ;
672668 }
673669
674- rc = crypto_shash_final (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
670+ rc = crypto_shash_final (ses -> server -> secmech .hmacmd5 ,
675671 ses -> auth_key .response );
676672 if (rc )
677673 cifs_dbg (VFS , "%s: Could not generate md5 hash\n" , __func__ );
@@ -718,30 +714,11 @@ calc_seckey(struct cifs_ses *ses)
718714void
719715cifs_crypto_secmech_release (struct TCP_Server_Info * server )
720716{
721- if (server -> secmech .cmacaes ) {
722- crypto_free_shash (server -> secmech .cmacaes );
723- server -> secmech .cmacaes = NULL ;
724- }
725-
726- if (server -> secmech .hmacsha256 ) {
727- crypto_free_shash (server -> secmech .hmacsha256 );
728- server -> secmech .hmacsha256 = NULL ;
729- }
730-
731- if (server -> secmech .md5 ) {
732- crypto_free_shash (server -> secmech .md5 );
733- server -> secmech .md5 = NULL ;
734- }
735-
736- if (server -> secmech .sha512 ) {
737- crypto_free_shash (server -> secmech .sha512 );
738- server -> secmech .sha512 = NULL ;
739- }
740-
741- if (server -> secmech .hmacmd5 ) {
742- crypto_free_shash (server -> secmech .hmacmd5 );
743- server -> secmech .hmacmd5 = NULL ;
744- }
717+ cifs_free_hash (& server -> secmech .aes_cmac );
718+ cifs_free_hash (& server -> secmech .hmacsha256 );
719+ cifs_free_hash (& server -> secmech .md5 );
720+ cifs_free_hash (& server -> secmech .sha512 );
721+ cifs_free_hash (& server -> secmech .hmacmd5 );
745722
746723 if (server -> secmech .enc ) {
747724 crypto_free_aead (server -> secmech .enc );
@@ -752,15 +729,4 @@ cifs_crypto_secmech_release(struct TCP_Server_Info *server)
752729 crypto_free_aead (server -> secmech .dec );
753730 server -> secmech .dec = NULL ;
754731 }
755-
756- kfree_sensitive (server -> secmech .sdesccmacaes );
757- server -> secmech .sdesccmacaes = NULL ;
758- kfree_sensitive (server -> secmech .sdeschmacsha256 );
759- server -> secmech .sdeschmacsha256 = NULL ;
760- kfree_sensitive (server -> secmech .sdeschmacmd5 );
761- server -> secmech .sdeschmacmd5 = NULL ;
762- kfree_sensitive (server -> secmech .sdescmd5 );
763- server -> secmech .sdescmd5 = NULL ;
764- kfree_sensitive (server -> secmech .sdescsha512 );
765- server -> secmech .sdescsha512 = NULL ;
766732}
0 commit comments