Commit 5d10069e authored by Alistair Francis's avatar Alistair Francis Committed by Keith Busch
Browse files

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: e88a7595 ("nvme-tcp: request secure channel concatenation")
Reviewed-by: default avatarChris Leech <cleech@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarAlistair Francis <alistair.francis@wdc.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 26bb12b9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -535,11 +535,12 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl,
	put_unaligned_le16(chap->transaction, buf);
	nvme_auth_hmac_update(&hmac, buf, 2);

	memset(buf, 0, 4);
	*buf = chap->sc_c;
	nvme_auth_hmac_update(&hmac, buf, 1);
	nvme_auth_hmac_update(&hmac, "Controller", 10);
	nvme_auth_hmac_update(&hmac, ctrl->opts->subsysnqn,
			      strlen(ctrl->opts->subsysnqn));
	memset(buf, 0, 4);
	nvme_auth_hmac_update(&hmac, buf, 1);
	nvme_auth_hmac_update(&hmac, ctrl->opts->host->nqn,
			      strlen(ctrl->opts->host->nqn));
+2 −1
Original line number Diff line number Diff line
@@ -399,11 +399,12 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
	put_unaligned_le16(req->sq->dhchap_tid, buf);
	nvme_auth_hmac_update(&hmac, buf, 2);

	memset(buf, 0, 4);
	*buf = req->sq->sc_c;
	nvme_auth_hmac_update(&hmac, buf, 1);
	nvme_auth_hmac_update(&hmac, "Controller", 10);
	nvme_auth_hmac_update(&hmac, ctrl->subsys->subsysnqn,
			      strlen(ctrl->subsys->subsysnqn));
	memset(buf, 0, 4);
	nvme_auth_hmac_update(&hmac, buf, 1);
	nvme_auth_hmac_update(&hmac, ctrl->hostnqn, strlen(ctrl->hostnqn));
	nvme_auth_hmac_final(&hmac, response);