Skip to content

Commit 5d10069

Browse files
alistair23keithbusch
authored andcommitted
nvme-auth: Include SC_C in RVAL controller hash
Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is included in the Response Value (RVAL) hash and SC_C should be included. Currently we are hardcoding 0 instead of using the correct SC_C value. Update the host and target code to use the SC_C when calculating the RVAL instead of using 0. Fixes: e88a759 ("nvme-tcp: request secure channel concatenation") Reviewed-by: Chris Leech <cleech@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 26bb12b commit 5d10069

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/nvme/host/auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,12 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
535535
put_unaligned_le16(chap->transaction, buf);
536536
nvme_auth_hmac_update(&hmac, buf, 2);
537537

538-
memset(buf, 0, 4);
538+
*buf = chap->sc_c;
539539
nvme_auth_hmac_update(&hmac, buf, 1);
540540
nvme_auth_hmac_update(&hmac, "Controller", 10);
541541
nvme_auth_hmac_update(&hmac, ctrl->opts->subsysnqn,
542542
strlen(ctrl->opts->subsysnqn));
543+
memset(buf, 0, 4);
543544
nvme_auth_hmac_update(&hmac, buf, 1);
544545
nvme_auth_hmac_update(&hmac, ctrl->opts->host->nqn,
545546
strlen(ctrl->opts->host->nqn));

drivers/nvme/target/auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,12 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
399399
put_unaligned_le16(req->sq->dhchap_tid, buf);
400400
nvme_auth_hmac_update(&hmac, buf, 2);
401401

402-
memset(buf, 0, 4);
402+
*buf = req->sq->sc_c;
403403
nvme_auth_hmac_update(&hmac, buf, 1);
404404
nvme_auth_hmac_update(&hmac, "Controller", 10);
405405
nvme_auth_hmac_update(&hmac, ctrl->subsys->subsysnqn,
406406
strlen(ctrl->subsys->subsysnqn));
407+
memset(buf, 0, 4);
407408
nvme_auth_hmac_update(&hmac, buf, 1);
408409
nvme_auth_hmac_update(&hmac, ctrl->hostnqn, strlen(ctrl->hostnqn));
409410
nvme_auth_hmac_final(&hmac, response);

0 commit comments

Comments
 (0)