nvmet-auth: Diffie-Hellman key exchange support

Implement Diffie-Hellman key exchange using FFDHE groups for NVMe
In-Band Authentication.
This patch adds a new host configfs attribute 'dhchap_dhgroup' to
select the FFDHE group to use.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Hannes Reinecke
2022-06-27 11:52:06 +02:00
committed by Jens Axboe
parent db1312dd95
commit 7a277c37d3
5 changed files with 232 additions and 8 deletions

View File

@@ -1766,10 +1766,41 @@ static ssize_t nvmet_host_dhchap_hash_store(struct config_item *item,
CONFIGFS_ATTR(nvmet_host_, dhchap_hash);
static ssize_t nvmet_host_dhchap_dhgroup_show(struct config_item *item,
char *page)
{
struct nvmet_host *host = to_host(item);
const char *dhgroup = nvme_auth_dhgroup_name(host->dhchap_dhgroup_id);
return sprintf(page, "%s\n", dhgroup ? dhgroup : "none");
}
static ssize_t nvmet_host_dhchap_dhgroup_store(struct config_item *item,
const char *page, size_t count)
{
struct nvmet_host *host = to_host(item);
int dhgroup_id;
dhgroup_id = nvme_auth_dhgroup_id(page);
if (dhgroup_id == NVME_AUTH_DHGROUP_INVALID)
return -EINVAL;
if (dhgroup_id != NVME_AUTH_DHGROUP_NULL) {
const char *kpp = nvme_auth_dhgroup_kpp(dhgroup_id);
if (!crypto_has_kpp(kpp, 0, 0))
return -EINVAL;
}
host->dhchap_dhgroup_id = dhgroup_id;
return count;
}
CONFIGFS_ATTR(nvmet_host_, dhchap_dhgroup);
static struct configfs_attribute *nvmet_host_attrs[] = {
&nvmet_host_attr_dhchap_key,
&nvmet_host_attr_dhchap_ctrl_key,
&nvmet_host_attr_dhchap_hash,
&nvmet_host_attr_dhchap_dhgroup,
NULL,
};
#endif /* CONFIG_NVME_TARGET_AUTH */