Debian Codegraph @

lib/krb5/krb5_locl.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * Copyright (c) 1997-2016 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 /* $Id$ */
37
38 #ifndef __KRB5_LOCL_H__
39 #define __KRB5_LOCL_H__
40
41 #include <config.h>
42 #include <roken.h>
43
44 #include <ctype.h>
45
46 #ifdef HAVE_POLL_H
47 #include <sys/poll.h>
48 #endif
49
50 #include <krb5-types.h>
51
52 #ifdef HAVE_SYS_TYPES_H
53 #include <sys/types.h>
54 #endif
55 #ifdef HAVE_SYS_MMAN_H
56 #include <sys/mman.h>
57 #endif
58
59 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
60 #include <sys/ioctl.h>
61 #endif
62 #ifdef HAVE_PWD_H
63 #undef _POSIX_PTHREAD_SEMANTICS
64 /* This gets us the 5-arg getpwnam_r on Solaris 9. */
65 #define _POSIX_PTHREAD_SEMANTICS
66 #include <pwd.h>
67 #endif
68
69 #ifdef HAVE_SYS_SELECT_H
70 #include <sys/select.h>
71 #endif
72 #ifdef _AIX
73 struct mbuf;
74 #endif
75 #ifdef HAVE_SYS_FILIO_H
76 #include <sys/filio.h>
77 #endif
78 #ifdef HAVE_SYS_FILE_H
79 #include <sys/file.h>
80 #endif
81
82 #include <com_err.h>
83
84 #include <heimbase.h>
85
86 #define HEIMDAL_TEXTDOMAIN "heimdal_krb5"
87
88 #ifdef LIBINTL
89 #include <libintl.h>
90 #define N_(x,y) dgettext(HEIMDAL_TEXTDOMAIN, x)
91 #else
92 #define N_(x,y) (x)
93 #define bindtextdomain(package, localedir)
94 #endif
95
96
97 #ifdef HAVE_CRYPT_H
98 #undef des_encrypt
99 #define des_encrypt wingless_pigs_mostly_fail_to_fly
100 #include <crypt.h>
101 #undef des_encrypt
102 #endif
103
104 #ifdef HAVE_DOOR_CREATE
105 #include <door.h>
106 #endif
107
108 #include <parse_time.h>
109 #include <base64.h>
110
111 #include <wind.h>
112
113 /*
114 * We use OpenSSL for EC, but to do this we need to disable cross-references
115 * between OpenSSL and hcrypto bn.h and such. Source files that use OpenSSL EC
116 * must define HEIM_NO_CRYPTO_HDRS before including this file.
117 */
118 #define HC_DEPRECATED_CRYPTO
119 #ifndef HEIM_NO_CRYPTO_HDRS
120 #include "crypto-headers.h"
121 #endif
122
123
124 #include <krb5_asn1.h>
125 #include <pkinit_asn1.h>
126
127 struct send_to_kdc;
128
129 /* XXX glue for pkinit */
130 struct hx509_certs_data;
131 struct krb5_pk_identity;
132 struct krb5_pk_cert;
133 struct ContentInfo;
134 struct AlgorithmIdentifier;
135 typedef struct krb5_pk_init_ctx_data *krb5_pk_init_ctx;
136 struct krb5_dh_moduli;
137
138 /* v4 glue */
139 struct _krb5_krb_auth_data;
140
141 #include <der.h>
142
143 #include <krb5.h>
144 #include <krb5_err.h>
145 #include <asn1_err.h>
146 #ifdef PKINIT
147 #include <hx509.h>
148 #endif
149
150 #include "crypto.h"
151
152 #include <krb5-private.h>
153
154 #include "heim_threads.h"
155
156 #define ALLOC(X, N) (X) = calloc((N), sizeof(*(X)))
157 #define ALLOC_SEQ(X, N) do { (X)->len = (N); ALLOC((X)->val, (N)); } while(0)
158
159 #ifndef __func__
160 #define __func__ "unknown-function"
161 #endif
162
163 #define krb5_einval(context, argnum) _krb5_einval((context), __func__, (argnum))
164
165 #ifndef PATH_SEP
166 #define PATH_SEP ":"
167 #endif
168
169 /* should this be public? */
170 #define KEYTAB_DEFAULT "FILE:" SYSCONFDIR "/krb5.keytab"
171 #define KEYTAB_DEFAULT_MODIFY "FILE:" SYSCONFDIR "/krb5.keytab"
172
173
174 #define MODULI_FILE SYSCONFDIR "/krb5.moduli"
175
176 #ifndef O_BINARY
177 #define O_BINARY 0
178 #endif
179
180 #ifndef O_CLOEXEC
181 #define O_CLOEXEC 0
182 #endif
183
184 #ifndef SOCK_CLOEXEC
185 #define SOCK_CLOEXEC 0
186 #endif
187
188
189 #define KRB5_BUFSIZ 2048
190
191 typedef enum {
192 KRB5_INIT_CREDS_TRISTATE_UNSET = 0,
193 KRB5_INIT_CREDS_TRISTATE_TRUE,
194 KRB5_INIT_CREDS_TRISTATE_FALSE
195 } krb5_get_init_creds_tristate;
196
197 struct _krb5_get_init_creds_opt_private {
198 int refcount;
199 /* ENC_TIMESTAMP */
200 const char *password;
201 krb5_s2k_proc key_proc;
202 /* PA_PAC_REQUEST */
203 krb5_get_init_creds_tristate req_pac;
204 /* PKINIT */
205 krb5_pk_init_ctx pk_init_ctx;
206 krb5_get_init_creds_tristate addressless;
207 int flags;
208 #define KRB5_INIT_CREDS_CANONICALIZE 1
209 #define KRB5_INIT_CREDS_NO_C_CANON_CHECK 2
210 #define KRB5_INIT_CREDS_NO_C_NO_EKU_CHECK 4
211 #define KRB5_INIT_CREDS_PKINIT_KX_VALID 32
212 #define KRB5_INIT_CREDS_PKINIT_NO_KRBTGT_OTHERNAME_CHECK 64
213 struct {
214 krb5_gic_process_last_req func;
215 void *ctx;
216 } lr;
217 };
218
219 typedef uint32_t krb5_enctype_set;
220
221 typedef struct krb5_context_data {
222 krb5_enctype *etypes;
223 krb5_enctype *cfg_etypes;
224 krb5_enctype *etypes_des;/* deprecated */
225 krb5_enctype *as_etypes;
226 krb5_enctype *tgs_etypes;
227 krb5_enctype *permitted_enctypes;
228 char **default_realms;
229 time_t max_skew;
230 time_t kdc_timeout;
231 time_t host_timeout;
232 unsigned max_retries;
233 int32_t kdc_sec_offset;
234 int32_t kdc_usec_offset;
235 krb5_config_section *cf;
236 struct et_list *et_list;
237 struct krb5_log_facility *warn_dest;
238 struct krb5_log_facility *debug_dest;
239 const krb5_cc_ops **cc_ops;
240 int num_cc_ops;
241 const char *http_proxy;
242 const char *time_fmt;
243 krb5_boolean log_utc;
244 const char *default_keytab;
245 const char *default_keytab_modify;
246 krb5_boolean use_admin_kdc;
247 krb5_addresses *extra_addresses;
248 krb5_boolean scan_interfaces; /* `ifconfig -a' */
249 krb5_boolean srv_lookup; /* do SRV lookups */
250 krb5_boolean srv_try_txt; /* try TXT records also */
251 int32_t fcache_vno; /* create cache files w/ this
252 version */
253 int num_kt_types; /* # of registered keytab types */
254 struct krb5_keytab_data *kt_types; /* registered keytab types */
255 const char *date_fmt;
256 char *error_string;
257 krb5_error_code error_code;
258 krb5_addresses *ignore_addresses;
259 char *default_cc_name;
260 char *default_cc_name_env;
261 int default_cc_name_set;
262 HEIMDAL_MUTEX mutex; /* protects error_string */
263 int large_msg_size;
264 int max_msg_size;
265 int tgs_negative_timeout; /* timeout for TGS negative cache */
266 int flags;
267 #define KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME 1
268 #define KRB5_CTX_F_CHECK_PAC 2
269 #define KRB5_CTX_F_HOMEDIR_ACCESS 4
270 #define KRB5_CTX_F_SOCKETS_INITIALIZED 8
271 #define KRB5_CTX_F_RD_REQ_IGNORE 16
272 #define KRB5_CTX_F_FCACHE_STRICT_CHECKING 32
273 struct send_to_kdc *send_to_kdc;
274 #ifdef PKINIT
275 hx509_context hx509ctx;
276 #endif
277 unsigned int num_kdc_requests;
278 krb5_name_canon_rule name_canon_rules;
279 } krb5_context_data;
280
281 #ifndef KRB5_USE_PATH_TOKENS
282 #define KRB5_DEFAULT_CCNAME_FILE "FILE:/tmp/krb5cc_%{uid}"
283 #define KRB5_DEFAULT_CCNAME_DIR "DIR:/tmp/krb5cc_%{uid}_dir/"
284 #else
285 #define KRB5_DEFAULT_CCNAME_FILE "FILE:%{TEMP}/krb5cc_%{uid}"
286 #define KRB5_DEFAULT_CCNAME_DIR "DIR:%{TEMP}/krb5cc_%{uid}_dir/"
287 #endif
288 #define KRB5_DEFAULT_CCNAME_API "API:"
289 #define KRB5_DEFAULT_CCNAME_KCM_KCM "KCM:%{uid}"
290 #define KRB5_DEFAULT_CCNAME_KCM_API "API:%{uid}"
291
292 #define EXTRACT_TICKET_ALLOW_CNAME_MISMATCH 1
293 #define EXTRACT_TICKET_ALLOW_SERVER_MISMATCH 2
294 #define EXTRACT_TICKET_MATCH_REALM 4
295 #define EXTRACT_TICKET_AS_REQ 8
296 #define EXTRACT_TICKET_TIMESYNC 16
297 #define EXTRACT_TICKET_MATCH_ANON 32
298
299 /*
300 * Configurable options
301 */
302
303 #ifndef KRB5_DEFAULT_CCTYPE
304 #ifdef __APPLE__
305 #define KRB5_DEFAULT_CCTYPE (&krb5_acc_ops)
306 #else
307 #define KRB5_DEFAULT_CCTYPE (&krb5_fcc_ops)
308 #endif
309 #endif
310
311 #ifndef KRB5_ADDRESSLESS_DEFAULT
312 #define KRB5_ADDRESSLESS_DEFAULT TRUE
313 #endif
314
315 #ifndef KRB5_FORWARDABLE_DEFAULT
316 #define KRB5_FORWARDABLE_DEFAULT TRUE
317 #endif
318
319 #ifndef KRB5_CONFIGURATION_CHANGE_NOTIFY_NAME
320 #define KRB5_CONFIGURATION_CHANGE_NOTIFY_NAME "org.h5l.Kerberos.configuration-changed"
321 #endif
322
323 #ifndef KRB5_FALLBACK_DEFAULT
324 #define KRB5_FALLBACK_DEFAULT TRUE
325 #endif
326
327 #ifndef KRB5_TKT_LIFETIME_DEFAULT
328 # define KRB5_TKT_LIFETIME_DEFAULT 15778800 /* seconds */
329 #endif
330
331 #ifndef KRB5_TKT_RENEW_LIFETIME_DEFAULT
332 # define KRB5_TKT_RENEW_LIFETIME_DEFAULT 15778800 /* seconds */
333 #endif
334
335 #ifdef PKINIT
336
337 struct krb5_pk_identity {
338 hx509_verify_ctx verify_ctx;
339 hx509_certs certs;
340 hx509_cert cert;
341 hx509_certs anchors;
342 hx509_certs certpool;
343 hx509_revoke_ctx revokectx;
344 int flags;
345 #define PKINIT_BTMM 1
346 };
347
348 enum krb5_pk_type {
349 PKINIT_WIN2K = 1,
350 PKINIT_27 = 2
351 };
352
353 enum keyex_enum { USE_RSA, USE_DH, USE_ECDH };
354
355 struct krb5_pk_init_ctx_data {
356 struct krb5_pk_identity *id;
357 enum keyex_enum keyex;
358 union {
359 DH *dh;
360 void *eckey;
361 } u;
362 krb5_data *clientDHNonce;
363 struct krb5_dh_moduli **m;
364 hx509_peer_info peer;
365 enum krb5_pk_type type;
366 unsigned int require_binding:1;
367 unsigned int require_eku:1;
368 unsigned int require_krbtgt_otherName:1;
369 unsigned int require_hostname_match:1;
370 unsigned int trustedCertifiers:1;
371 unsigned int anonymous:1;
372 };
373
374 #endif /* PKINIT */
375
376 #define ISTILDE(x) (x == '~')
377 #ifdef _WIN32
378 # define ISPATHSEP(x) (x == '/' || x =='\\')
379 #else
380 # define ISPATHSEP(x) (x == '/')
381 #endif
382
383 #endif /* __KRB5_LOCL_H__ */