Skip to content

Commit

Permalink
Added destroy authkey command
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Nov 4, 2021
1 parent f42da92 commit dd16407
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,29 @@ int yh_com_put_authentication_ex(yubihsm_context *ctx, Argument *argv,
return 0;
}

// NOTE: Delete a persistent authentication key
// argc = 1
// arg 0: s:key_name
int yh_com_destroy_authentication_ex(yubihsm_context *ctx, Argument *argv,
cmd_format in_fmt, cmd_format fmt) {

UNUSED(ctx);
UNUSED(argv);
UNUSED(in_fmt);
UNUSED(fmt);

yh_rc yrc = yh_util_destroy_auth_key(argv[0].s);

if (yrc != YHR_SUCCESS) {
fprintf(stderr, "Failed to delete persistent authkey: %s\n",
yh_strerror(yrc));
return -1;
}

fprintf(stderr, "Deleted Persistent Authentication key 0x%04x\n", argv[1].w);
return 0;
}

#ifdef USE_ASYMMETRIC_AUTH
// NOTE: Store an asymmetric authentication key
// argc = 7
Expand Down
2 changes: 2 additions & 0 deletions src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ int yh_com_put_authentication(yubihsm_context *ctx, Argument *argv,
cmd_format in_fmt, cmd_format fmt);
int yh_com_put_authentication_ex(yubihsm_context *ctx, Argument *argv,
cmd_format in_fmt, cmd_format fmt);
int yh_com_destroy_authentication_ex(yubihsm_context *ctx, Argument *argv,
cmd_format in_fmt, cmd_format fmt);
#ifdef USE_ASYMMETRIC_AUTH
int yh_com_put_authentication_asym(yubihsm_context *ctx, Argument *argv,
cmd_format in_fmt, cmd_format fmt);
Expand Down
8 changes: 8 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,14 @@ static void create_command_list(CommandList *c) {
NULL, NULL});
#endif

*c = register_command(*c, (Command){"destroy", yh_com_noop, NULL, fmt_nofmt,
fmt_nofmt, "destroy persistent objects",
NULL, NULL});
register_subcommand(*c, (Command){"authkey", yh_com_destroy_authentication_ex,
"s:key_name", fmt_nofmt, fmt_nofmt,
"Delete a persisten authentication key",
NULL, NULL});

*c = msort_list(*c);

for (Command *t = *c; t != NULL; t = t->next) {
Expand Down

0 comments on commit dd16407

Please sign in to comment.