diff options
| -rw-r--r-- | src/otputil.c | 10 | ||||
| -rw-r--r-- | src/widget-hotp.c | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/otputil.c b/src/otputil.c index 134f2e2..628fdf6 100644 --- a/src/otputil.c +++ b/src/otputil.c | |||
| @@ -177,6 +177,16 @@ static otputil_widget_t otputil_widget_map[] = | |||
| 177 | .func_exec = &otputil_widget_hotp, | 177 | .func_exec = &otputil_widget_hotp, |
| 178 | .func_usage = NULL, | 178 | .func_usage = NULL, |
| 179 | }, | 179 | }, |
| 180 | { .name = "hotp-sha1", | ||
| 181 | .desc = NULL, | ||
| 182 | .usage = " [ code ]", | ||
| 183 | .short_opt = (TOTP_SHORT_OPT "c:d:k:O:o"), | ||
| 184 | .arg_min = 0, | ||
| 185 | .arg_max = 1, | ||
| 186 | .aliases = (const char *[]){ "hotp-sha256", "hotp-sha512", NULL }, | ||
| 187 | .func_exec = &otputil_widget_hotp, | ||
| 188 | .func_usage = NULL, | ||
| 189 | }, | ||
| 180 | 190 | ||
| 181 | // OTP widget and aliases | 191 | // OTP widget and aliases |
| 182 | { .name = "otp", | 192 | { .name = "otp", |
diff --git a/src/widget-hotp.c b/src/widget-hotp.c index 535d543..f6e308a 100644 --- a/src/widget-hotp.c +++ b/src/widget-hotp.c | |||
| @@ -99,6 +99,7 @@ otputil_widget_hotp( | |||
| 99 | otputil_config_t * cnf ) | 99 | otputil_config_t * cnf ) |
| 100 | { | 100 | { |
| 101 | int rc; | 101 | int rc; |
| 102 | int hash; | ||
| 102 | uint64_t meth; | 103 | uint64_t meth; |
| 103 | 104 | ||
| 104 | assert(cnf != NULL); | 105 | assert(cnf != NULL); |
| @@ -111,6 +112,17 @@ otputil_widget_hotp( | |||
| 111 | return(1); | 112 | return(1); |
| 112 | }; | 113 | }; |
| 113 | 114 | ||
| 115 | // set default hash | ||
| 116 | if (!(strncasecmp(cnf->argv[0], "hotp-", 5))) | ||
| 117 | { | ||
| 118 | if ((hash = otputil_str2md(&cnf->argv[0][5])) == -1) | ||
| 119 | { | ||
| 120 | fprintf(stderr, "%s: unsupported hash algorithm\n", cnf->prog_name); | ||
| 121 | return(1); | ||
| 122 | }; | ||
| 123 | otputil_set_param(NULL, OTPUTIL_OPT_HOTP_HMAC, &hash); | ||
| 124 | }; | ||
| 125 | |||
| 114 | // initial processing of cli arguments | 126 | // initial processing of cli arguments |
| 115 | if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) | 127 | if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) |
| 116 | return((rc == -1) ? 0 : 1); | 128 | return((rc == -1) ? 0 : 1); |
