aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2023-01-10 12:51:39 -0900
committerDavid M. Syzdek <david@syzdek.net>2023-01-10 12:51:39 -0900
commit0bbcb4cfee37e373cf988b5e0d10363db7c8c1e0 (patch)
tree65c2e2262f4112af349789e3ebc79e296758515c /lib
parent39b51d2bd1ec567dc02fc6a333ade59043d86fe7 (diff)
downloadotputils-0bbcb4cfee37e373cf988b5e0d10363db7c8c1e0.tar.gz
otputils-0bbcb4cfee37e373cf988b5e0d10363db7c8c1e0.tar.bz2
otputils-0bbcb4cfee37e373cf988b5e0d10363db7c8c1e0.tar.xz
otputils-0bbcb4cfee37e373cf988b5e0d10363db7c8c1e0.zip
libotputil: adding otputil_skey_dict_word()
Diffstat (limited to 'lib')
-rw-r--r--lib/libotputil/libotputil.sym2
-rw-r--r--lib/libotputil/lrfc1760-skey.c67
-rw-r--r--lib/libotputil/lrfc1760-skey.h47
3 files changed, 116 insertions, 0 deletions
diff --git a/lib/libotputil/libotputil.sym b/lib/libotputil/libotputil.sym
index dac3069..17c94e9 100644
--- a/lib/libotputil/libotputil.sym
+++ b/lib/libotputil/libotputil.sym
@@ -84,6 +84,8 @@ otputil_otp_decode
84otputil_otp_decode_len 84otputil_otp_decode_len
85otputil_otp_encode 85otputil_otp_encode
86otputil_otp_encode_len 86otputil_otp_encode_len
87# S/KEY functions (RFC 1760)
88otputil_skey_dict_word
87# TOTP functions (RFC 6238) 89# TOTP functions (RFC 6238)
88otputil_totp_code 90otputil_totp_code
89otputil_totp_str 91otputil_totp_str
diff --git a/lib/libotputil/lrfc1760-skey.c b/lib/libotputil/lrfc1760-skey.c
new file mode 100644
index 0000000..bb79414
--- /dev/null
+++ b/lib/libotputil/lrfc1760-skey.c
@@ -0,0 +1,67 @@
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 lib/libotputil/lrfc1760-skey.c
32 */
33#define _LIB_LIBOTPUTIL_LRFC1760_SKEY_C 1
34#include "lrfc1760-skey.h"
35
36///////////////
37// //
38// Headers //
39// //
40///////////////
41#pragma mark - Headers
42
43#include <errno.h>
44#include <string.h>
45#include <strings.h>
46
47#include "lrfc1760-skey-dict.h"
48
49
50/////////////////
51// //
52// Functions //
53// //
54/////////////////
55#pragma mark - Functions
56
57const char *
58otputil_skey_dict_word(
59 int value )
60{
61 if ((value < 0) || (value > 2047))
62 return(NULL);
63 return(otputil_skey_rfc1760_dict[value]);
64}
65
66
67/* end of source file */
diff --git a/lib/libotputil/lrfc1760-skey.h b/lib/libotputil/lrfc1760-skey.h
new file mode 100644
index 0000000..f5e01a6
--- /dev/null
+++ b/lib/libotputil/lrfc1760-skey.h
@@ -0,0 +1,47 @@
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 lib/libotputil/lrfc1760-skey.h
32 */
33#ifndef _LIB_LIBOTPUTIL_LRFC1760_SKEY_H
34#define _LIB_LIBOTPUTIL_LRFC1760_SKEY_H 1
35
36
37///////////////
38// //
39// Headers //
40// //
41///////////////
42#pragma mark - Headers
43
44#include "libotputil.h"
45
46
47#endif /* end of header file */