Fix API.
[shishi.git] / lib / internal.h
blob7b7d3f64a7c18fa3b2d4f2e0f538c5f15f79e456
1 /* internal.h internal header file for shishi
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _INTERNAL_H
23 #define _INTERNAL_H
25 #if HAVE_CONFIG_H
26 #include "config.h"
27 #endif
29 #ifdef STDC_HEADERS
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stdarg.h>
33 #include <ctype.h>
34 #endif
36 #ifdef HAVE_SYS_TYPES_H
37 #include <sys/types.h>
38 #endif
40 #ifdef HAVE_SYS_SELECT_H
41 #include <sys/select.h>
42 #endif
44 #ifdef HAVE_SYS_SOCKET_H
45 #include <sys/socket.h>
46 #endif
48 #ifdef HAVE_SYS_IOCTL_H
49 #include <sys/ioctl.h>
50 #endif
52 #ifdef HAVE_SYS_STAT_H
53 #include <sys/stat.h>
54 #endif
56 #if HAVE_UNISTD_H
57 #include <unistd.h>
58 #endif
60 #ifdef HAVE_NETDB_H
61 #include <netdb.h>
62 #endif
64 #if defined HAVE_DECL_H_ERRNO && !HAVE_DECL_H_ERRNO
65 //extern int h_errno;
66 #endif
68 #ifdef HAVE_PWD_H
69 #include <pwd.h>
70 #endif
72 #ifdef HAVE_FCNTL_H
73 #include <fcntl.h>
74 #endif
76 #ifdef HAVE_ERRNO_H
77 #include <errno.h>
78 #endif
80 #if TIME_WITH_SYS_TIME
81 # include <sys/time.h>
82 # include <time.h>
83 #else
84 # if HAVE_SYS_TIME_H
85 # include <sys/time.h>
86 # else
87 # include <time.h>
88 # endif
89 #endif
91 #if HAVE_STRING_H
92 # if !STDC_HEADERS && HAVE_MEMORY_H
93 # include <memory.h>
94 # endif
95 # include <string.h>
96 #endif
97 #if HAVE_STRINGS_H
98 # include <strings.h>
99 #endif
101 #ifdef HAVE_SIGNAL_H
102 #include <signal.h>
103 #endif
105 #ifdef HAVE_NETINET_IN_H
106 #include <netinet/in.h>
107 #endif
108 #ifdef HAVE_NETINET_IN6_H
109 #include <netinet/in6.h>
110 #endif
111 #ifdef HAVE_ARPA_INET_H
112 #include <arpa/inet.h>
113 #endif
115 #ifdef HAVE_ARPA_NAMESER_H
116 #include <arpa/nameser.h>
117 #endif
118 #ifdef HAVE_RESOLV_H
119 #include <resolv.h>
120 #endif
122 #include "gettext.h"
124 #include "setenv.h"
125 #include "vasprintf.h"
126 #include "xalloc.h"
127 #include "xstrndup.h"
128 #include "getdate.h"
129 #include "base64.h"
130 #include "xmemdup.h"
132 #include "shishi.h"
134 #define _(String) dgettext (PACKAGE, String)
135 #define gettext_noop(String) String
136 #define N_(String) gettext_noop (String)
138 #define GENERALIZEDTIME_TIME_LEN 15
139 #define MAX_KEY_LEN 32
140 #define MAX_RANDOM_LEN 32
141 #define MAX_HASH_LEN 32
142 #define MAX_CKSUM_LEN 32
144 #define SHISHI_VERBOSE_CRYPTO (1<<1)
145 #define SHISHI_VERBOSE_ASN1 (1<<2)
146 #define SHISHI_VERBOSE_NOICE (1<<3)
148 #define KRBTGT "krbtgt"
149 #define PRINCIPAL_DELIMITER "/"
151 #define VERBOSEASN1(h) (h->verbose & SHISHI_VERBOSE_ASN1)
152 #define VERBOSECRYPTO(h) (h->verbose & SHISHI_VERBOSE_CRYPTO)
153 #define VERBOSENOICE(h) (h->verbose & SHISHI_VERBOSE_NOICE)
154 #define VERBOSES (SHISHI_VERBOSE_ASN1 | \
155 SHISHI_VERBOSE_CRYPTO | \
156 SHISHI_VERBOSE_NOICE)
157 #define VERBOSE(h) (h->verbose & ~VERBOSES)
159 #ifndef HOST_NAME_MAX
160 #define HOST_NAME_MAX BUFSIZ
161 #endif
163 enum {
164 UDP,
165 TCP,
169 struct Shishi_kdcinfo
171 char *name;
172 struct sockaddr sockaddress;
173 int protocol;
176 struct Shishi_realminfo
178 char *name;
179 struct Shishi_kdcinfo *kdcaddresses;
180 size_t nkdcaddresses;
181 char **serverwildcards;
182 size_t nserverwildcards;
185 struct Shishi
187 Shishi_asn1 asn1;
188 int verbose;
189 char *default_realm;
190 char *default_principal;
191 size_t kdctimeout;
192 size_t kdcretries;
193 int ticketlife;
194 int renewlife;
195 int32_t *clientkdcetypes;
196 size_t nclientkdcetypes;
197 struct Shishi_realminfo *realminfos;
198 size_t nrealminfos;
199 char *kdc;
200 char error[1024];
201 char gztime_buf[40];
202 char *userdirectory;
203 char *usercfgfile;
204 char *tktsdefaultfile;
205 char *hostkeysdefaultfile;
206 char *stringprocess;
207 Shishi_tkts *tkts;
210 #define BASE_DIR "/.shishi"
211 #define TICKET_FILE BASE_DIR "/tickets"
212 #define USERCFG_FILE BASE_DIR "/shishi.conf"
214 #define TICKETLIFE (60*60*8) /* Work day */
215 #define RENEWLIFE (60*60*24*7) /* Week */
218 _shishi_print_armored_data (Shishi * handle,
219 FILE * fh,
220 Shishi_asn1 asn1, char *asn1type, char *headers);
222 _shishi_save_data (Shishi * handle, FILE * fh, Shishi_asn1 asn1,
223 char *asn1type);
226 _shishi_authenticator_input (Shishi * handle,
227 FILE * fh, Shishi_asn1 * authenticator,
228 int type);
230 _shishi_apreq_input (Shishi * handle, FILE * fh, Shishi_asn1 * apreq,
231 int type);
232 int _shishi_aprep_input (Shishi * handle, FILE * fh, Shishi_asn1 * aprep,
233 int type);
234 int _shishi_kdcreq_input (Shishi * handle, FILE * fh, Shishi_asn1 * asreq,
235 int type);
236 int _shishi_kdcrep_input (Shishi * handle, FILE * fh, Shishi_asn1 * asrep,
237 int type);
238 int _shishi_krberror_input (Shishi * handle, FILE * fh,
239 Shishi_asn1 * krberror, int type);
240 int _shishi_encapreppart_input (Shishi * handle, FILE * fh,
241 Shishi_asn1 * encapreppart, int type);
242 int _shishi_safe_input (Shishi * handle, FILE * fh,
243 Shishi_asn1 * safe, int type);
245 Shishi_asn1 _shishi_asn1_read (void);
246 int _shishi_cipher_init (void);
249 shishi_asn1_integer2_field (Shishi * handle,
250 Shishi_asn1 node, unsigned long *i,
251 const char *field);
253 extern time_t xtime (time_t * t);
254 extern int xgettimeofday (struct timeval *tv, struct timezone *tz);
256 extern struct Shishi_realminfo *shishi_realminfo (Shishi * handle,
257 const char *realm);
258 extern struct Shishi_realminfo *shishi_realminfo_new (Shishi * handle,
259 char *realm);
261 #if defined(WITH_DMALLOC) && WITH_DMALLOC
262 #include <dmalloc.h>
263 #endif
265 /* older systems might not have these */
266 #ifndef T_SRV
267 # define T_SRV (33)
268 #endif
270 typedef struct dnshost_st
272 struct dnshost_st *next;
274 unsigned int type;
275 unsigned int class;
276 unsigned int ttl;
278 void *rr;
279 } *dnshost_t;
281 typedef struct dns_srv_st
283 unsigned int priority;
284 unsigned int weight;
285 unsigned int port;
286 unsigned int rweight;
288 char name[256];
289 } *dns_srv_t;
291 dnshost_t _shishi_resolv (const char *zone, unsigned int type);
292 void _shishi_resolv_free (dnshost_t dns);
294 #endif /* _INTERNAL_H */