diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/otputil.c | 10 | ||||
| -rw-r--r-- | src/widget-totp.c | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/otputil.c b/src/otputil.c index 7f2ca4d..134f2e2 100644 --- a/src/otputil.c +++ b/src/otputil.c | |||
| @@ -233,6 +233,16 @@ static otputil_widget_t otputil_widget_map[] = | |||
| 233 | .func_exec = &otputil_widget_totp, | 233 | .func_exec = &otputil_widget_totp, |
| 234 | .func_usage = NULL, | 234 | .func_usage = NULL, |
| 235 | }, | 235 | }, |
| 236 | { .name = "totp-sha1", | ||
| 237 | .desc = NULL, | ||
| 238 | .usage = " [ code ]", | ||
| 239 | .short_opt = (TOTP_SHORT_OPT "d:k:O:oT:t:x:"), | ||
| 240 | .arg_min = 0, | ||
| 241 | .arg_max = 1, | ||
| 242 | .aliases = (const char *[]){ "totp-sha256", "totp-sha512", NULL }, | ||
| 243 | .func_exec = &otputil_widget_totp, | ||
| 244 | .func_usage = NULL, | ||
| 245 | }, | ||
| 236 | 246 | ||
| 237 | // version widget | 247 | // version widget |
| 238 | { .name = "version", | 248 | { .name = "version", |
diff --git a/src/widget-totp.c b/src/widget-totp.c index fe08220..69c67cb 100644 --- a/src/widget-totp.c +++ b/src/widget-totp.c | |||
| @@ -100,6 +100,7 @@ otputil_widget_totp( | |||
| 100 | otputil_config_t * cnf ) | 100 | otputil_config_t * cnf ) |
| 101 | { | 101 | { |
| 102 | int rc; | 102 | int rc; |
| 103 | int hash; | ||
| 103 | uint64_t meth; | 104 | uint64_t meth; |
| 104 | 105 | ||
| 105 | assert(cnf != NULL); | 106 | assert(cnf != NULL); |
| @@ -112,6 +113,17 @@ otputil_widget_totp( | |||
| 112 | return(1); | 113 | return(1); |
| 113 | }; | 114 | }; |
| 114 | 115 | ||
| 116 | // set default hash | ||
| 117 | if (!(strncasecmp(cnf->argv[0], "totp-", 5))) | ||
| 118 | { | ||
| 119 | if ((hash = otputil_str2md(&cnf->argv[0][5])) == -1) | ||
| 120 | { | ||
| 121 | fprintf(stderr, "%s: unsupported hash algorithm\n", cnf->prog_name); | ||
| 122 | return(1); | ||
| 123 | }; | ||
| 124 | otputil_set_param(NULL, OTPUTIL_OPT_TOTP_HMAC, &hash); | ||
| 125 | }; | ||
| 126 | |||
| 115 | // initial processing of cli arguments | 127 | // initial processing of cli arguments |
| 116 | if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) | 128 | if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) |
| 117 | return((rc == -1) ? 0 : 1); | 129 | return((rc == -1) ? 0 : 1); |
