Skip to content

Commit bb2df18

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvmet-auth: allow to clear DH-HMAC-CHAP keys
As we can set DH-HMAC-CHAP keys, we should also be able to unset them. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 02a3688 commit bb2df18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/nvme/target/auth.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
2525
unsigned char key_hash;
2626
char *dhchap_secret;
2727

28+
if (!strlen(secret)) {
29+
if (set_ctrl) {
30+
kfree(host->dhchap_ctrl_secret);
31+
host->dhchap_ctrl_secret = NULL;
32+
host->dhchap_ctrl_key_hash = 0;
33+
} else {
34+
kfree(host->dhchap_secret);
35+
host->dhchap_secret = NULL;
36+
host->dhchap_key_hash = 0;
37+
}
38+
return 0;
39+
}
2840
if (sscanf(secret, "DHHC-1:%hhd:%*s", &key_hash) != 1)
2941
return -EINVAL;
3042
if (key_hash > 3) {

0 commit comments

Comments
 (0)