@@ -103,26 +103,24 @@ static int cifs_calc_signature(struct smb_rqst *rqst,
103
103
if (!rqst -> rq_iov || !signature || !server )
104
104
return - EINVAL ;
105
105
106
- rc = cifs_alloc_hash ("md5" , & server -> secmech .md5 ,
107
- & server -> secmech .sdescmd5 );
106
+ rc = cifs_alloc_hash ("md5" , & server -> secmech .md5 );
108
107
if (rc )
109
108
return -1 ;
110
109
111
- rc = crypto_shash_init (& server -> secmech .sdescmd5 -> shash );
110
+ rc = crypto_shash_init (server -> secmech .md5 );
112
111
if (rc ) {
113
112
cifs_dbg (VFS , "%s: Could not init md5\n" , __func__ );
114
113
return rc ;
115
114
}
116
115
117
- rc = crypto_shash_update (& server -> secmech .sdescmd5 -> shash ,
116
+ rc = crypto_shash_update (server -> secmech .md5 ,
118
117
server -> session_key .response , server -> session_key .len );
119
118
if (rc ) {
120
119
cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
121
120
return rc ;
122
121
}
123
122
124
- return __cifs_calc_signature (rqst , server , signature ,
125
- & server -> secmech .sdescmd5 -> shash );
123
+ return __cifs_calc_signature (rqst , server , signature , server -> secmech .md5 );
126
124
}
127
125
128
126
/* must be called with server->srv_mutex held */
@@ -412,22 +410,22 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
412
410
wchar_t * domain ;
413
411
wchar_t * server ;
414
412
415
- if (!ses -> server -> secmech .sdeschmacmd5 ) {
413
+ if (!ses -> server -> secmech .hmacmd5 ) {
416
414
cifs_dbg (VFS , "%s: can't generate ntlmv2 hash\n" , __func__ );
417
415
return -1 ;
418
416
}
419
417
420
418
/* calculate md4 hash of password */
421
419
E_md4hash (ses -> password , nt_hash , nls_cp );
422
420
423
- rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 , nt_hash ,
421
+ rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 -> tfm , nt_hash ,
424
422
CIFS_NTHASH_SIZE );
425
423
if (rc ) {
426
424
cifs_dbg (VFS , "%s: Could not set NT Hash as a key\n" , __func__ );
427
425
return rc ;
428
426
}
429
427
430
- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
428
+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
431
429
if (rc ) {
432
430
cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
433
431
return rc ;
@@ -448,7 +446,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
448
446
memset (user , '\0' , 2 );
449
447
}
450
448
451
- rc = crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
449
+ rc = crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
452
450
(char * )user , 2 * len );
453
451
kfree (user );
454
452
if (rc ) {
@@ -468,7 +466,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
468
466
len = cifs_strtoUTF16 ((__le16 * )domain , ses -> domainName , len ,
469
467
nls_cp );
470
468
rc =
471
- crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
469
+ crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
472
470
(char * )domain , 2 * len );
473
471
kfree (domain );
474
472
if (rc ) {
@@ -488,7 +486,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
488
486
len = cifs_strtoUTF16 ((__le16 * )server , ses -> ip_addr , len ,
489
487
nls_cp );
490
488
rc =
491
- crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
489
+ crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
492
490
(char * )server , 2 * len );
493
491
kfree (server );
494
492
if (rc ) {
@@ -498,7 +496,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
498
496
}
499
497
}
500
498
501
- rc = crypto_shash_final (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
499
+ rc = crypto_shash_final (ses -> server -> secmech .hmacmd5 ,
502
500
ntlmv2_hash );
503
501
if (rc )
504
502
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)
518
516
hash_len = ses -> auth_key .len - (CIFS_SESS_KEY_SIZE +
519
517
offsetof(struct ntlmv2_resp , challenge .key [0 ]));
520
518
521
- if (!ses -> server -> secmech .sdeschmacmd5 ) {
519
+ if (!ses -> server -> secmech .hmacmd5 ) {
522
520
cifs_dbg (VFS , "%s: can't generate ntlmv2 hash\n" , __func__ );
523
521
return -1 ;
524
522
}
525
523
526
- rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 ,
524
+ rc = crypto_shash_setkey (ses -> server -> secmech .hmacmd5 -> tfm ,
527
525
ntlmv2_hash , CIFS_HMAC_MD5_HASH_SIZE );
528
526
if (rc ) {
529
527
cifs_dbg (VFS , "%s: Could not set NTLMV2 Hash as a key\n" ,
530
528
__func__ );
531
529
return rc ;
532
530
}
533
531
534
- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
532
+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
535
533
if (rc ) {
536
534
cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
537
535
return rc ;
@@ -543,15 +541,15 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
543
541
else
544
542
memcpy (ntlmv2 -> challenge .key ,
545
543
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 ,
547
545
ntlmv2 -> challenge .key , hash_len );
548
546
if (rc ) {
549
547
cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
550
548
return rc ;
551
549
}
552
550
553
551
/* 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 ,
555
553
ntlmv2 -> ntlmv2_hash );
556
554
if (rc )
557
555
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)
627
625
628
626
cifs_server_lock (ses -> server );
629
627
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 );
633
629
if (rc ) {
634
630
goto unlock ;
635
631
}
@@ -649,29 +645,29 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
649
645
}
650
646
651
647
/* 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 ,
653
649
ntlmv2_hash , CIFS_HMAC_MD5_HASH_SIZE );
654
650
if (rc ) {
655
651
cifs_dbg (VFS , "%s: Could not set NTLMV2 Hash as a key\n" ,
656
652
__func__ );
657
653
goto unlock ;
658
654
}
659
655
660
- rc = crypto_shash_init (& ses -> server -> secmech .sdeschmacmd5 -> shash );
656
+ rc = crypto_shash_init (ses -> server -> secmech .hmacmd5 );
661
657
if (rc ) {
662
658
cifs_dbg (VFS , "%s: Could not init hmacmd5\n" , __func__ );
663
659
goto unlock ;
664
660
}
665
661
666
- rc = crypto_shash_update (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
662
+ rc = crypto_shash_update (ses -> server -> secmech .hmacmd5 ,
667
663
ntlmv2 -> ntlmv2_hash ,
668
664
CIFS_HMAC_MD5_HASH_SIZE );
669
665
if (rc ) {
670
666
cifs_dbg (VFS , "%s: Could not update with response\n" , __func__ );
671
667
goto unlock ;
672
668
}
673
669
674
- rc = crypto_shash_final (& ses -> server -> secmech .sdeschmacmd5 -> shash ,
670
+ rc = crypto_shash_final (ses -> server -> secmech .hmacmd5 ,
675
671
ses -> auth_key .response );
676
672
if (rc )
677
673
cifs_dbg (VFS , "%s: Could not generate md5 hash\n" , __func__ );
@@ -718,30 +714,11 @@ calc_seckey(struct cifs_ses *ses)
718
714
void
719
715
cifs_crypto_secmech_release (struct TCP_Server_Info * server )
720
716
{
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 );
745
722
746
723
if (server -> secmech .enc ) {
747
724
crypto_free_aead (server -> secmech .enc );
@@ -752,15 +729,4 @@ cifs_crypto_secmech_release(struct TCP_Server_Info *server)
752
729
crypto_free_aead (server -> secmech .dec );
753
730
server -> secmech .dec = NULL ;
754
731
}
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 ;
766
732
}
0 commit comments