Commit 69872294 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

nvme: make spdk_nvme_dhchap_get_digest_length() public



We'll want to use this function on the target side too.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I4f138c5e21f350719de78343014e62e39c277b1d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22663


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 67ab645c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -4084,6 +4084,15 @@ const char *spdk_nvme_dhchap_get_digest_name(int id);
 */
int spdk_nvme_dhchap_get_digest_id(const char *name);

/**
 * Return the length of a digest.
 *
 * \param id Digest identifier (see `enum spdk_nvmf_dhchap_hash`).
 *
 * \return Length of a digest or 0 if the id is unknown.
 */
uint8_t spdk_nvme_dhchap_get_digest_length(int id);

/**
 * Return the name of a Diffie-Hellman group.
 *
+7 −7
Original line number Diff line number Diff line
@@ -120,15 +120,15 @@ spdk_nvme_dhchap_get_dhgroup_name(int id)
	return NULL;
}

#ifdef SPDK_CONFIG_HAVE_EVP_MAC
static uint8_t
nvme_auth_get_digest_len(int id)
uint8_t
spdk_nvme_dhchap_get_digest_length(int id)
{
	const struct nvme_auth_digest *digest = nvme_auth_get_digest(id);

	return digest != NULL ? digest->len : 0;
}

#ifdef SPDK_CONFIG_HAVE_EVP_MAC
static bool
nvme_auth_digest_allowed(struct spdk_nvme_qpair *qpair, uint8_t digest)
{
@@ -412,7 +412,7 @@ nvme_auth_calc_response(struct spdk_key *key, enum spdk_nvmf_dhchap_hash hash,
	size_t hlen, calen = sizeof(caval);
	int rc, keylen;

	hlen = nvme_auth_get_digest_len(hash);
	hlen = spdk_nvme_dhchap_get_digest_length(hash);
	rc = nvme_auth_augment_challenge(cval, hlen, dhkey, dhlen, caval, &calen, hash);
	if (rc != 0) {
		return rc;
@@ -808,7 +808,7 @@ nvme_auth_check_challenge(struct spdk_nvme_qpair *qpair)
		goto error;
	}

	hl = nvme_auth_get_digest_len(challenge->hash_id);
	hl = spdk_nvme_dhchap_get_digest_length(challenge->hash_id);
	if (hl == 0) {
		AUTH_ERRLOG(qpair, "unsupported hash function: 0x%x\n", challenge->hash_id);
		goto error;
@@ -882,7 +882,7 @@ nvme_auth_send_reply(struct spdk_nvme_qpair *qpair)
	int rc;

	auth->hash = challenge->hash_id;
	hl = nvme_auth_get_digest_len(challenge->hash_id);
	hl = spdk_nvme_dhchap_get_digest_length(challenge->hash_id);
	if (challenge->dhg_id != SPDK_NVMF_DHCHAP_DHGROUP_NULL) {
		dhseclen = sizeof(dhsec);
		publen = sizeof(pubkey);
@@ -994,7 +994,7 @@ nvme_auth_check_success1(struct spdk_nvme_qpair *qpair)
			goto error;
		}

		hl = nvme_auth_get_digest_len(auth->hash);
		hl = spdk_nvme_dhchap_get_digest_length(auth->hash);
		if (msg->hl != hl) {
			AUTH_ERRLOG(qpair, "received invalid hl=%u, expected=%u\n", msg->hl, hl);
			status = SPDK_NVMF_AUTH_INCORRECT_PAYLOAD;
+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@

	spdk_nvme_dhchap_get_digest_name;
	spdk_nvme_dhchap_get_digest_id;
	spdk_nvme_dhchap_get_digest_length;
	spdk_nvme_dhchap_get_dhgroup_name;
	spdk_nvme_dhchap_get_dhgroup_id;