@@ -23,6 +23,7 @@ struct nvme_dhchap_queue_context {
2323 struct nvme_ctrl * ctrl ;
2424 struct crypto_shash * shash_tfm ;
2525 struct crypto_kpp * dh_tfm ;
26+ struct nvme_dhchap_key * transformed_key ;
2627 void * buf ;
2728 int qid ;
2829 int error ;
@@ -36,7 +37,6 @@ struct nvme_dhchap_queue_context {
3637 u8 c1 [64 ];
3738 u8 c2 [64 ];
3839 u8 response [64 ];
39- u8 * host_response ;
4040 u8 * ctrl_key ;
4141 u8 * host_key ;
4242 u8 * sess_key ;
@@ -428,12 +428,12 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl,
428428 dev_dbg (ctrl -> device , "%s: qid %d host response seq %u transaction %d\n" ,
429429 __func__ , chap -> qid , chap -> s1 , chap -> transaction );
430430
431- if (!chap -> host_response ) {
432- chap -> host_response = nvme_auth_transform_key (ctrl -> host_key ,
431+ if (!chap -> transformed_key ) {
432+ chap -> transformed_key = nvme_auth_transform_key (ctrl -> host_key ,
433433 ctrl -> opts -> host -> nqn );
434- if (IS_ERR (chap -> host_response )) {
435- ret = PTR_ERR (chap -> host_response );
436- chap -> host_response = NULL ;
434+ if (IS_ERR (chap -> transformed_key )) {
435+ ret = PTR_ERR (chap -> transformed_key );
436+ chap -> transformed_key = NULL ;
437437 return ret ;
438438 }
439439 } else {
@@ -442,7 +442,7 @@ static int nvme_auth_dhchap_setup_host_response(struct nvme_ctrl *ctrl,
442442 }
443443
444444 ret = crypto_shash_setkey (chap -> shash_tfm ,
445- chap -> host_response , ctrl -> host_key -> len );
445+ chap -> transformed_key -> key , chap -> transformed_key -> len );
446446 if (ret ) {
447447 dev_warn (ctrl -> device , "qid %d: failed to set key, error %d\n" ,
448448 chap -> qid , ret );
@@ -508,19 +508,19 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
508508 struct nvme_dhchap_queue_context * chap )
509509{
510510 SHASH_DESC_ON_STACK (shash , chap -> shash_tfm );
511- u8 * ctrl_response ;
511+ struct nvme_dhchap_key * transformed_key ;
512512 u8 buf [4 ], * challenge = chap -> c2 ;
513513 int ret ;
514514
515- ctrl_response = nvme_auth_transform_key (ctrl -> ctrl_key ,
515+ transformed_key = nvme_auth_transform_key (ctrl -> ctrl_key ,
516516 ctrl -> opts -> subsysnqn );
517- if (IS_ERR (ctrl_response )) {
518- ret = PTR_ERR (ctrl_response );
517+ if (IS_ERR (transformed_key )) {
518+ ret = PTR_ERR (transformed_key );
519519 return ret ;
520520 }
521521
522522 ret = crypto_shash_setkey (chap -> shash_tfm ,
523- ctrl_response , ctrl -> ctrl_key -> len );
523+ transformed_key -> key , transformed_key -> len );
524524 if (ret ) {
525525 dev_warn (ctrl -> device , "qid %d: failed to set key, error %d\n" ,
526526 chap -> qid , ret );
@@ -586,7 +586,7 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
586586out :
587587 if (challenge != chap -> c2 )
588588 kfree (challenge );
589- kfree ( ctrl_response );
589+ nvme_auth_free_key ( transformed_key );
590590 return ret ;
591591}
592592
@@ -648,8 +648,8 @@ static int nvme_auth_dhchap_exponential(struct nvme_ctrl *ctrl,
648648
649649static void nvme_auth_reset_dhchap (struct nvme_dhchap_queue_context * chap )
650650{
651- kfree_sensitive (chap -> host_response );
652- chap -> host_response = NULL ;
651+ nvme_auth_free_key (chap -> transformed_key );
652+ chap -> transformed_key = NULL ;
653653 kfree_sensitive (chap -> host_key );
654654 chap -> host_key = NULL ;
655655 chap -> host_key_len = 0 ;
0 commit comments