aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-12-31 18:49:18 -0900
committerDavid M. Syzdek <david@syzdek.net>2022-12-31 18:49:18 -0900
commit74883f567f1b6cb5d7f38ed573ae55982ab494cb (patch)
tree80f35c7834001f3e90a4d1bd4da2bbcac60359c2 /src
parentdd9023ad46275595d8cd0d7b5e619989203ecc36 (diff)
downloadotputils-74883f567f1b6cb5d7f38ed573ae55982ab494cb.tar.gz
otputils-74883f567f1b6cb5d7f38ed573ae55982ab494cb.tar.bz2
otputils-74883f567f1b6cb5d7f38ed573ae55982ab494cb.tar.xz
otputils-74883f567f1b6cb5d7f38ed573ae55982ab494cb.zip
otputil: removing widget verify
Diffstat (limited to 'src')
-rw-r--r--src/otputil.c10
-rw-r--r--src/otputil.h4
-rw-r--r--src/widget-verify.c102
3 files changed, 0 insertions, 116 deletions
diff --git a/src/otputil.c b/src/otputil.c
index 315e9a7..3685716 100644
--- a/src/otputil.c
+++ b/src/otputil.c
@@ -183,16 +183,6 @@ static otputil_widget_t otputil_widget_map[] =
183 .func_exec = &otputil_widget_totp, 183 .func_exec = &otputil_widget_totp,
184 .func_usage = NULL, 184 .func_usage = NULL,
185 }, 185 },
186 { .name = "verify",
187 .desc = "verify TOTP code",
188 .usage = " [ code ]",
189 .short_opt = NULL,
190 .arg_min = 0,
191 .arg_max = 1,
192 .aliases = NULL,
193 .func_exec = &otputil_widget_verify,
194 .func_usage = NULL,
195 },
196 { .name = "version", 186 { .name = "version",
197 .desc = "display version", 187 .desc = "display version",
198 .usage = NULL, 188 .usage = NULL,
diff --git a/src/otputil.h b/src/otputil.h
index 3aa1535..5f80223 100644
--- a/src/otputil.h
+++ b/src/otputil.h
@@ -147,8 +147,4 @@ otputil_widget_totp(
147 otputil_config_t * cnf ); 147 otputil_config_t * cnf );
148 148
149 149
150extern int
151otputil_widget_verify(
152 otputil_config_t * cnf );
153
154#endif /* end of header file */ 150#endif /* end of header file */
diff --git a/src/widget-verify.c b/src/widget-verify.c
deleted file mode 100644
index 53504b4..0000000
--- a/src/widget-verify.c
+++ /dev/null
@@ -1,102 +0,0 @@
1/*
2 * OTP Utilities
3 * Copyright (C) 2022 David M. Syzdek <david@syzdek.net>.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of David M. Syzdek nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M SYZDEK BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30/*
31 * @file src/widget-verify.c
32 */
33#define _SRC_WIDGET_VERIFY_C 1
34
35///////////////
36// //
37// Headers //
38// //
39///////////////
40#pragma mark - Headers
41
42#ifdef HAVE_CONFIG_H
43#include <config.h>
44#endif
45
46#include <errno.h>
47#include <assert.h>
48#include <stdarg.h>
49#include <string.h>
50#include <strings.h>
51#include <stdlib.h>
52#include <getopt.h>
53#include <stdio.h>
54
55#include "otputil.h"
56
57
58/////////////////
59// //
60// Functions //
61// //
62/////////////////
63#pragma mark - Functions
64
65
66//---------------//
67// main function //
68//---------------//
69#pragma mark main function
70
71int
72otputil_widget_verify(
73 otputil_config_t * cnf )
74{
75 int rc;
76 int otp_code;
77 int user_code;
78 char * user_str;
79
80 assert(cnf != NULL);
81
82 // initial processing of cli arguments
83 if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0)
84 return((rc == -1) ? 0 : 1);
85 if ((user_str = ((cnf->argc > optind)) ? cnf->argv[optind] : NULL) == NULL)
86 user_str = otputil_getpass("Enter OTP code: ", NULL, 0);
87 user_code = (int)strtoll(user_str, NULL, 10);
88
89 if ((otp_code = otputil_code(NULL)) == -1)
90 {
91 fprintf(stderr, "%s: internal error\n", cnf->prog_name);
92 return(1);
93 };
94
95 if (!(cnf->quiet))
96 printf("%s\n", (otp_code == user_code) ? "valid code" : "invalid code" );
97
98 return( (otp_code == user_code) ? 0 : 1 );
99}
100
101
102/* end of source file */