aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-04-06 22:28:24 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-04-06 22:28:24 -0800
commit448106b84d7c403dc3cba93b084dfcc9c683ecc8 (patch)
tree787cddd194c7f6ca44c824b8375e80dc1637a1be
parentbdff93464cb854e29d9e02660be65b26ceb8d4bf (diff)
downloadtinytac-github/master.tar.gz
tinytac-github/master.tar.bz2
tinytac-github/master.tar.xz
tinytac-github/master.zip
libtinytac: adding initial RFC datagithub/master
-rw-r--r--Makefile.am4
-rw-r--r--include/tinytac.h61
-rw-r--r--lib/libtinytac/lproto.c105
-rw-r--r--lib/libtinytac/lproto.h184
4 files changed, 353 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 3ba83ed..bea3ca7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -149,7 +149,9 @@ lib_libtinytac_a_SOURCES = include/tinytac.h \
149 lib/libtinytac/ldebug.c \ 149 lib/libtinytac/ldebug.c \
150 lib/libtinytac/ldebug.h \ 150 lib/libtinytac/ldebug.h \
151 lib/libtinytac/lmemory.c \ 151 lib/libtinytac/lmemory.c \
152 lib/libtinytac/lmemory.h 152 lib/libtinytac/lmemory.h \
153 lib/libtinytac/lproto.c \
154 lib/libtinytac/lproto.h
153 155
154 156
155# macros for lib/libtinytac.la 157# macros for lib/libtinytac.la
diff --git a/include/tinytac.h b/include/tinytac.h
index 12e4d70..5bf14df 100644
--- a/include/tinytac.h
+++ b/include/tinytac.h
@@ -136,6 +136,67 @@
136#define TTAC_DFLT_DEBUG_SYSLOG TTAC_NO 136#define TTAC_DFLT_DEBUG_SYSLOG TTAC_NO
137 137
138 138
139// RFC8907 Section 4.1 The TACACS+ Packet Header
140#define TTAC_MAJOR_VER 0x0c // RFC name: TTAC_PLUS_MAJOR_VER
141#define TTAC_MINOR_VER_DEFAULT 0x00 // RFC name: TTAC_PLUS_MINOR_VER_DEFAULT
142#define TTAC_MINOR_VER_ONE 0x01 // RFC name: TTAC_PLUS_MINOR_VER_ONE
143#define TTAC_TYPE_AUTHEN 0x01 // RFC name: TTAC_PLUS_AUTHEN
144#define TTAC_TYPE_AUTHOR 0x02 // RFC name: TTAC_PLUS_AUTHOR
145#define TTAC_TYPE_ACCT 0x03 // RFC name: TTAC_PLUS_ACCT
146#define TTAC_FLAG_UNENCRYPTED 0x01 // RFC name: TAC_PLUS_UNENCRYPTED_FLAG
147#define TTAC_FLAG_SINGLE_CONNECT 0x04 // RFC name: TAC_PLUS_SINGLE_CONNECT_FLAG
148
149
150// RFC8907 Section 5.1 The Authentication START Packet Body
151#define TTAC_AUTHEN_LOGIN 0x01 // RFC name: TAC_PLUS_AUTHEN_LOGIN
152#define TTAC_AUTHEN_CHPASS 0x02 // RFC name: TAC_PLUS_AUTHEN_CHPASS
153#define TTAC_AUTHEN_SENDAUTH 0x04 // RFC name: TAC_PLUS_AUTHEN_SENDAUTH
154#define TTAC_AUTHEN_TYPE_ASCII 0x01 // RFC name: TAC_PLUS_AUTHEN_TYPE_ASCII
155#define TTAC_AUTHEN_TYPE_PAP 0x02 // RFC name: TAC_PLUS_AUTHEN_TYPE_PAP
156#define TTAC_AUTHEN_TYPE_CHAP 0x03 // RFC name: TAC_PLUS_AUTHEN_TYPE_CHAP
157#define TTAC_AUTHEN_TYPE_MSCHAP 0x05 // RFC name: TAC_PLUS_AUTHEN_TYPE_MSCHAP
158#define TTAC_AUTHEN_TYPE_MSCHAPV2 0x06 // RFC name: TAC_PLUS_AUTHEN_TYPE_MSCHAPV2
159#define TTAC_AUTHEN_SVC_NONE 0x00 // RFC name: TAC_PLUS_AUTHEN_SVC_NONE
160#define TTAC_AUTHEN_SVC_LOGIN 0x01 // RFC name: TAC_PLUS_AUTHEN_SVC_LOGIN
161#define TTAC_AUTHEN_SVC_ENABLE 0x02 // RFC name: TAC_PLUS_AUTHEN_SVC_ENABLE
162#define TTAC_AUTHEN_SVC_PPP 0x03 // RFC name: TAC_PLUS_AUTHEN_SVC_PPP
163#define TTAC_AUTHEN_SVC_PT 0x05 // RFC name: TAC_PLUS_AUTHEN_SVC_PT
164#define TTAC_AUTHEN_SVC_RCMD 0x06 // RFC name: TAC_PLUS_AUTHEN_SVC_RCMD
165#define TTAC_AUTHEN_SVC_X25 0x07 // RFC name: TAC_PLUS_AUTHEN_SVC_X25
166#define TTAC_AUTHEN_SVC_NASI 0x08 // RFC name: TAC_PLUS_AUTHEN_SVC_NASI
167#define TTAC_AUTHEN_SVC_FWPROXY 0x09 // RFC name: TAC_PLUS_AUTHEN_SVC_FWPROXY
168
169
170// RFC8907 Section 5.2 The Authentication REPLY Packet Body
171#define TTAC_AUTHEN_STATUS_PASS 0x01 // RFC name: TAC_PLUS_AUTHEN_STATUS_PASS
172#define TTAC_AUTHEN_STATUS_FAIL 0x02 // RFC name: TAC_PLUS_AUTHEN_STATUS_FAIL
173#define TTAC_AUTHEN_STATUS_GETDATA 0x03 // RFC name: TAC_PLUS_AUTHEN_STATUS_GETDATA
174#define TTAC_AUTHEN_STATUS_GETUSER 0x04 // RFC name: TAC_PLUS_AUTHEN_STATUS_GETUSER
175#define TTAC_AUTHEN_STATUS_GETPASS 0x05 // RFC name: TAC_PLUS_AUTHEN_STATUS_GETPASS
176#define TTAC_AUTHEN_STATUS_RESTART 0x06 // RFC name: TAC_PLUS_AUTHEN_STATUS_RESTART
177#define TTAC_AUTHEN_STATUS_ERROR 0x07 // RFC name: TAC_PLUS_AUTHEN_STATUS_ERROR
178#define TTAC_AUTHEN_STATUS_FOLLOW 0x21 // RFC name: TAC_PLUS_AUTHEN_STATUS_FOLLOW
179#define TTAC_REPLY_FLAG_NOECHO 0x01 // RFC name: TAC_PLUS_REPLY_FLAG_NOECHO
180
181
182// RFC8907 Section 5.3 The Authentication CONTINUE Packet Body
183#define TTAC_CONTINUE_FLAG_ABORT 0x01 // RFC name: TAC_PLUS_CONTINUE_FLAG_ABORT
184
185
186// RFC8907 Section 6.1 The Authorization REQUEST Packet Body
187#define TTAC_AUTHEN_METH_NOT_SET 0x00 // RFC name: TAC_PLUS_AUTHEN_METH_NOT_SET
188#define TTAC_AUTHEN_METH_NONE 0x01 // RFC name: TAC_PLUS_AUTHEN_METH_NONE
189#define TTAC_AUTHEN_METH_KRB5 0x02 // RFC name: TAC_PLUS_AUTHEN_METH_KRB5
190#define TTAC_AUTHEN_METH_LINE 0x03 // RFC name: TAC_PLUS_AUTHEN_METH_LINE
191#define TTAC_AUTHEN_METH_ENABLE 0x04 // RFC name: TAC_PLUS_AUTHEN_METH_ENABLE
192#define TTAC_AUTHEN_METH_LOCAL 0x05 // RFC name: TAC_PLUS_AUTHEN_METH_LOCAL
193#define TTAC_AUTHEN_METH_TACACSPLUS 0x06 // RFC name: TAC_PLUS_AUTHEN_METH_TACACSPLUS
194#define TTAC_AUTHEN_METH_GUEST 0x08 // RFC name: TAC_PLUS_AUTHEN_METH_GUEST
195#define TTAC_AUTHEN_METH_RADIUS 0x10 // RFC name: TAC_PLUS_AUTHEN_METH_RADIUS
196#define TTAC_AUTHEN_METH_KRB4 0x11 // RFC name: TAC_PLUS_AUTHEN_METH_KRB4
197#define TTAC_AUTHEN_METH_RCMD 0x20 // RFC name: TAC_PLUS_AUTHEN_METH_RCMD
198
199
139////////////////// 200//////////////////
140// // 201// //
141// Data Types // 202// Data Types //
diff --git a/lib/libtinytac/lproto.c b/lib/libtinytac/lproto.c
new file mode 100644
index 0000000..864ecdb
--- /dev/null
+++ b/lib/libtinytac/lproto.c
@@ -0,0 +1,105 @@
1/*
2 * Tiny TACACS+ Client Library
3 * Copyright (C) 2022 David M. Syzdek <david@syzdek.net>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of David M. Syzdek nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31#define _LIB_LIBTINYTAC_LPROTO_C 1
32#include "lproto.h"
33
34
35///////////////
36// //
37// Headers //
38// //
39///////////////
40#pragma mark - Headers
41
42#include <stdlib.h>
43#include <string.h>
44#include <strings.h>
45#include <unistd.h>
46#include <fcntl.h>
47#include <sys/types.h>
48#include <sys/uio.h>
49#include <time.h>
50#include <sys/socket.h>
51#include <arpa/inet.h>
52#include <netinet/in.h>
53#include <netdb.h>
54#include <assert.h>
55
56
57///////////////////
58// //
59// Definitions //
60// //
61///////////////////
62#pragma mark - Definitions
63
64
65//////////////////
66// //
67// Prototypes //
68// //
69//////////////////
70#pragma mark - Prototypes
71
72//--------------------//
73// TinyTac prototypes //
74//--------------------//
75#pragma mark TinyTac prototypes
76
77
78//-------------------//
79// object prototypes //
80//-------------------//
81#pragma mark object prototypes
82
83
84/////////////////
85// //
86// Variables //
87// //
88/////////////////
89#pragma mark - Variables
90
91
92/////////////////
93// //
94// Functions //
95// //
96/////////////////
97#pragma mark - Functions
98
99//-------------------//
100// TinyTac functions //
101//-------------------//
102#pragma mark TinyTac functions
103
104
105/* end of source */
diff --git a/lib/libtinytac/lproto.h b/lib/libtinytac/lproto.h
new file mode 100644
index 0000000..d24029e
--- /dev/null
+++ b/lib/libtinytac/lproto.h
@@ -0,0 +1,184 @@
1/*
2 * Tiny TACACS+ Client Library
3 * Copyright (C) 2022 David M. Syzdek <david@syzdek.net>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of David M. Syzdek nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31#ifndef _LIB_LIBTINYTAC_LPROTO_H
32#define _LIB_LIBTINYTAC_LPROTO_H 1
33
34
35///////////////
36// //
37// Headers //
38// //
39///////////////
40#pragma mark - Headers
41
42#include "libtinytac.h"
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47#include <strings.h>
48
49
50///////////////////
51// //
52// Definitions //
53// //
54///////////////////
55#pragma mark - Definitions
56
57#define TTAC_MINOR_TO_VERSION( minor, ver ) ((ver & 0xff00) | ((minor & 0x00ff) << 0))
58#define TTAC_MAJOR_TO_VERSION( major, ver ) ((ver & 0x00ff) | ((major & 0x00ff) << 4))
59#define TTAC_VERSION_TO_MINOR( ver ) ((ver & 0x00ff) >> 0)
60#define TTAC_VERSION_TO_MAJOR( ver ) ((ver & 0xff00) >> 4)
61
62
63//////////////////
64// //
65// Data Types //
66// //
67//////////////////
68#pragma mark - Data Types
69
70// RFC 8907 Section 4.1. The TACACS+ Packet Header
71typedef struct tinytac_header
72{
73 uint8_t pckt_version; // 4 bits major and 4 bits minor
74 uint8_t pckt_type;
75 uint8_t pckt_seq_no;
76 uint8_t pckt_flags;
77 uint32_t pckt_session_id;
78 uint32_t pckt_length;
79 uint8_t pckt_body[];
80} tinyrad_header_t;
81
82
83// RFC 8907 Section 5.1. The Authentication START Packet Body
84typedef struct tinytac_packet_authen_start
85{
86 uint8_t bdy_action;
87 uint8_t bdy_priv_lvl;
88 uint8_t bdy_authen_type;
89 uint8_t bdy_authen_service;
90 uint8_t bdy_user_len;
91 uint8_t bdy_port_len;
92 uint8_t bdy_rem_addr_len;
93 uint8_t bdy_data_len;
94 uint8_t bdy_bytes[];
95} tinyrad_authen_start_t;
96
97
98// RFC 8907 Section 5.2. The Authentication REPLY Packet Body
99typedef struct tinytac_packet_authen_reply
100{
101 uint8_t bdy_status;
102 uint8_t bdy_flags;
103 uint16_t bdy_server_msg_len;
104 uint16_t bdy_data_len;
105 uint8_t bdy_bytes[];
106} tinyrad_authen_reply_t;
107
108
109// RFC 8907 Section 5.3. The Authentication CONTINUE Packet Body
110typedef struct tinytac_packet_authen_continue
111{
112 uint16_t bdy_user_msg_len;
113 uint16_t bdy_data_len;
114 uint8_t bdy_flags;
115 uint8_t bdy_bytes[];
116} tinyrad_authen_contiue_t;
117
118
119// RFC 8907 Section 6.1. The Authorization REQUEST Packet Body
120typedef struct tinytac_packet_author_request
121{
122 uint8_t bdy_authen_method;
123 uint8_t bdy_priv_lvl;
124 uint8_t bdy_authen_type;
125 uint8_t bdy_authen_service;
126 uint8_t bdy_user_len;
127 uint8_t bdy_port_len;
128 uint8_t bdy_rem_addr_len;
129 uint8_t bdy_arg_cnt;
130 uint8_t bdy_bytes[];
131} tinyrad_author_request_t;
132
133
134// RFC 8907 Section 6.2. The Authorization REPLY Packet Body
135typedef struct tinytac_packet_author_reply
136{
137 uint8_t bdy_status;
138 uint8_t bdy_arg_cnt;
139 uint16_t bdy_server_msg_len;
140 uint16_t bdy_data_len;
141 uint8_t bdy_bytes[];
142} tinyrad_author_reply_t;
143
144
145// RFC 8907 Section 7.1. The Account REQUEST Packet Body
146typedef struct tinytac_packet_acct_reqeust
147{
148 uint8_t bdy_flags;
149 uint8_t bdy_authen_method;
150 uint8_t bdy_priv_lvl;
151 uint8_t bdy_authen_type;
152 uint8_t bdy_authen_service;
153 uint8_t bdy_user_len;
154 uint8_t bdy_port_len;
155 uint8_t bdy_rem_addr_len;
156 uint8_t bdy_arg_cnt;
157 uint8_t bdy_bytes[];
158} tinyrad_acct_request_t;
159
160
161// RFC 8907 Section 7.2. The Accounting REPLY Packet Body
162typedef struct tinytac_packet_acct_reply
163{
164 uint16_t bdy_server_msg_len;
165 uint16_t bdy_data_len;
166 uint8_t bdy_status;
167 uint8_t bdy_bytes[];
168} tinyrad_acct_reply_t;
169
170
171//////////////////
172// //
173// Prototypes //
174// //
175//////////////////
176#pragma mark - Prototypes
177
178//-------------------//
179// object prototypes //
180//-------------------//
181#pragma mark object prototypes
182
183
184#endif /* end of header */