Skip to content

Commit

Permalink
add key index option to ykchalresp.
Browse files Browse the repository at this point in the history
  • Loading branch information
klali committed Feb 5, 2016
1 parent 0410fc8 commit f496a71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ykchalresp.1.adoc
Expand Up @@ -9,7 +9,7 @@ ykchalresp - Perform challenge-response operation with YubiKey

== SYNOPSIS

*ykchalresp* [__-1__ | __-2__] [__-H__ | __-Y__] [__-N__] [__-x__] [__-v__] [__-6__ | __-8__] [__-t__] [__-iFILE__] [__-V__] [__-h__]
*ykchalresp* [__-nkey__] [__-1__ | __-2__] [__-H__ | __-Y__] [__-N__] [__-x__] [__-v__] [__-6__ | __-8__] [__-t__] [__-iFILE__] [__-V__] [__-h__]

== DESCRIPTION

Expand All @@ -20,6 +20,8 @@ will result in different responses.

== OPTIONS

*-nkey*:: send the challenge to the nth key found.

*-1*:: send the challenge to slot 1. This is the default

*−2*:: send the challenge to slot 2.
Expand Down
10 changes: 7 additions & 3 deletions ykchalresp.c
Expand Up @@ -47,6 +47,7 @@ const char *usage =
"\n"
"Options :\n"
"\n"
"\t-nkey Send challenge to nth key found.\n"
"\t-1 Send challenge to slot 1. This is the default.\n"
"\t-2 Send challenge to slot 2.\n"
"\t-H Send a 64 byte HMAC challenge. This is the default.\n"
Expand All @@ -64,7 +65,7 @@ const char *usage =
"\n"
"\n"
;
const char *optstring = "1268xvhHtYNVi:";
const char *optstring = "1268xvhHtYNVi:n:";

static void report_yk_error(void)
{
Expand All @@ -85,7 +86,7 @@ static int parse_args(int argc, char **argv,
int *slot, bool *verbose,
unsigned char **challenge, unsigned int *challenge_len,
bool *hmac, bool *may_block, bool *totp, int *digits,
int *exit_code)
int *exit_code, int *key_index)
{
int c;
bool hex_encoded = false;
Expand Down Expand Up @@ -132,6 +133,9 @@ static int parse_args(int argc, char **argv,
input = stdin;
}
break;
case 'n':
*key_index = atoi(optarg);
break;
case 'V':
fputs(YKPERS_VERSION_STRING "\n", stderr);
*exit_code = 0;
Expand Down Expand Up @@ -321,7 +325,7 @@ int main(int argc, char **argv)
&slot, &verbose,
&challenge, &challenge_len,
&hmac, &may_block, &totp, &digits,
&exit_code))
&exit_code, &key_index))
exit(exit_code);

if (!yk_init()) {
Expand Down

0 comments on commit f496a71

Please sign in to comment.