Skip to content

Commit

Permalink
Add pin-info command
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Nov 21, 2024
1 parent e9050e0 commit c4d414c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ void print_help(char *app_name) {
printf("Available commands: \n"
"\t%s id\n"
"\t%s info\n"
"\t%s pin-info\n"
"\t%s version\n"
"\t%s check <HOTP CODE>\n"
"\t%s regenerate <ADMIN PIN>\n"
"\t%s set <BASE32 HOTP SECRET> <ADMIN PIN> [COUNTER]\n",
app_name, app_name, app_name, app_name, app_name, app_name);
app_name, app_name, app_name, app_name, app_name, app_name, app_name);
}


Expand Down Expand Up @@ -119,6 +120,21 @@ int parse_cmd_and_run(int argc, char *const *argv) {
res = RET_NO_ERROR;
}
} break;
case 'p': { // pin-info
struct ResponseStatus status;
res = device_get_status(&dev, &status);
check_ret((res != RET_NO_ERROR) && (res != RET_NO_PIN_ATTEMPTS), res);
if (res != RET_NO_PIN_ATTEMPTS) {
printf("Admin PIN counter: %d\nUser PIN Counter: %d\n",
status.retry_admin, status.retry_user);
} else {
printf("Admin PIN counter: Not set\nUser PIN Counter: Not set\n");
}
if (res == RET_NO_PIN_ATTEMPTS) {
// Ignore if PIN is not set here
res = RET_NO_ERROR;
}
} break;
case 'c':
if (argc != 3) break;
res = check_code_on_device(&dev, argv[2]);
Expand Down

0 comments on commit c4d414c

Please sign in to comment.