2 * Copyright (c) 1997-2016 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
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.
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.
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
38 #ifndef __KRB5_LOCL_H__
39 #define __KRB5_LOCL_H__
50 #include <krb5-types.h>
52 #ifdef HAVE_SYS_TYPES_H
53 #include <sys/types.h>
55 #ifdef HAVE_SYS_MMAN_H
59 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
60 #include <sys/ioctl.h>
63 #undef _POSIX_PTHREAD_SEMANTICS
64 /* This gets us the 5-arg getpwnam_r on Solaris 9. */
65 #define _POSIX_PTHREAD_SEMANTICS
69 #ifdef HAVE_SYS_SELECT_H
70 #include <sys/select.h>
75 #ifdef HAVE_SYS_FILIO_H
76 #include <sys/filio.h>
78 #ifdef HAVE_SYS_FILE_H
85 #include "heimbase-atomics.h"
87 #define HEIMDAL_TEXTDOMAIN "heimdal_krb5"
91 #define N_(x,y) dgettext(HEIMDAL_TEXTDOMAIN, x)
94 #define bindtextdomain(package, localedir)
100 #define des_encrypt wingless_pigs_mostly_fail_to_fly
105 #ifdef HAVE_DOOR_CREATE
109 #include <parse_time.h>
115 * We use OpenSSL for EC, but to do this we need to disable cross-references
116 * between OpenSSL and hcrypto bn.h and such. Source files that use OpenSSL EC
117 * must define HEIM_NO_CRYPTO_HDRS before including this file.
119 #define HC_DEPRECATED_CRYPTO
120 #ifndef HEIM_NO_CRYPTO_HDRS
121 #include "crypto-headers.h"
125 #include <krb5_asn1.h>
126 typedef Krb5Int32 krb5int32
;
127 typedef Krb5UInt32 krb5uint32
;
128 #include <pkinit_asn1.h>
132 /* XXX glue for pkinit */
133 struct hx509_certs_data
;
134 struct krb5_pk_identity
;
137 struct AlgorithmIdentifier
;
138 typedef struct krb5_pk_init_ctx_data
*krb5_pk_init_ctx
;
139 struct krb5_dh_moduli
;
140 struct krb5_fast_state
;
141 struct krb5_gss_init_ctx_data
;
144 struct _krb5_krb_auth_data
;
146 struct krb5_gss_init_ctx_data
;
147 typedef struct krb5_gss_init_ctx_data
*krb5_gss_init_ctx
;
149 struct gss_ctx_id_t_desc_struct
;
150 struct gss_cred_id_t_desc_struct
;
151 struct gss_OID_desc_struct
;
156 #include <krb5_err.h>
157 #include <k5e1_err.h>
158 #include <asn1_err.h>
165 typedef krb5_error_code (KRB5_LIB_CALL
*krb5_gssic_step
)(
169 struct gss_ctx_id_t_desc_struct
**,
175 typedef krb5_error_code (KRB5_LIB_CALL
*krb5_gssic_finish
)(
179 struct gss_ctx_id_t_desc_struct
*,
185 typedef void (KRB5_LIB_CALL
*krb5_gssic_release_cred
)(
188 struct gss_cred_id_t_desc_struct
*);
190 typedef void (KRB5_LIB_CALL
*krb5_gssic_delete_sec_context
)(
193 struct gss_ctx_id_t_desc_struct
*);
195 #define KRB5_GSS_IC_FLAG_RELEASE_CRED 1
197 #include <krb5-private.h>
199 #include "heim_threads.h"
201 extern const char _krb5_wellknown_lkdc
[];
203 #define ALLOC(X, N) (X) = calloc((N), sizeof(*(X)))
204 #define ALLOC_SEQ(X, N) do { (X)->len = (N); ALLOC((X)->val, (N)); } while(0)
206 #define krb5_einval(context, argnum) _krb5_einval((context), __func__, (argnum))
212 /* should this be public? */
213 #define KEYTAB_DEFAULT "FILE:" SYSCONFDIR "/krb5.keytab"
214 #define KEYTAB_DEFAULT_MODIFY "FILE:" SYSCONFDIR "/krb5.keytab"
216 #ifndef CLIENT_KEYTAB_DEFAULT
217 #define CLIENT_KEYTAB_DEFAULT "FILE:" LOCALSTATEDIR "/user/%{euid}/client.keytab";
220 #define MODULI_FILE SYSCONFDIR "/krb5.moduli"
231 #define SOCK_CLOEXEC 0
235 #define KRB5_BUFSIZ 2048
238 KRB5_INIT_CREDS_TRISTATE_UNSET
= 0,
239 KRB5_INIT_CREDS_TRISTATE_TRUE
,
240 KRB5_INIT_CREDS_TRISTATE_FALSE
241 } krb5_get_init_creds_tristate
;
243 struct _krb5_get_init_creds_opt_private
{
246 const char *password
;
247 krb5_s2k_proc key_proc
;
249 krb5_get_init_creds_tristate req_pac
;
251 krb5_pk_init_ctx pk_init_ctx
;
252 krb5_get_init_creds_tristate addressless
;
254 #define KRB5_INIT_CREDS_DONE 1
255 #define KRB5_INIT_CREDS_CANONICALIZE 2
256 #define KRB5_INIT_CREDS_NO_C_CANON_CHECK 4
257 #define KRB5_INIT_CREDS_NO_C_NO_EKU_CHECK 8
258 #define KRB5_INIT_CREDS_PKINIT_KX_VALID 32
259 #define KRB5_INIT_CREDS_PKINIT_NO_KRBTGT_OTHERNAME_CHECK 64
261 krb5_gic_process_last_req func
;
266 typedef uint32_t krb5_enctype_set
;
269 * Do not remove or reorder the fields of this structure.
270 * Fields that are no longer used should be marked "deprecated".
271 * New fields should always be appended to the end of the
274 * Although this structure is internal it is shared with
275 * plugins and such changes will result in data corruption
276 * if plugins are not built with a matching version.
278 typedef struct krb5_context_data
{
279 heim_context hcontext
;
280 krb5_enctype
*etypes
;
281 krb5_enctype
*cfg_etypes
;
282 krb5_enctype
*etypes_des
;/* deprecated */
283 krb5_enctype
*as_etypes
;
284 krb5_enctype
*tgs_etypes
;
285 krb5_enctype
*permitted_enctypes
;
286 char **default_realms
;
290 unsigned max_retries
;
291 int32_t kdc_sec_offset
;
292 int32_t kdc_usec_offset
;
293 krb5_config_section
*cf
;
294 const krb5_cc_ops
**cc_ops
;
296 const char *http_proxy
;
297 const char *time_fmt
;
298 krb5_boolean log_utc
;
299 const char *default_keytab
;
300 const char *default_keytab_modify
;
301 krb5_boolean use_admin_kdc
;
302 krb5_addresses
*extra_addresses
;
303 krb5_boolean scan_interfaces
; /* `ifconfig -a' */
304 krb5_boolean srv_lookup
; /* do SRV lookups */
305 krb5_boolean srv_try_txt
; /* try TXT records also */
306 int32_t fcache_vno
; /* create cache files w/ this
308 int num_kt_types
; /* # of registered keytab types */
309 struct krb5_keytab_data
*kt_types
; /* registered keytab types */
310 const char *date_fmt
;
311 krb5_error_code error_code
;
312 krb5_addresses
*ignore_addresses
;
313 char *default_cc_name
;
314 char *default_cc_name_env
;
315 char *configured_default_cc_name
;
316 int default_cc_name_set
;
319 int tgs_negative_timeout
; /* timeout for TGS negative cache */
321 #define KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME 1
322 #define KRB5_CTX_F_CHECK_PAC 2
323 #define KRB5_CTX_F_HOMEDIR_ACCESS 4
324 #define KRB5_CTX_F_SOCKETS_INITIALIZED 8
325 #define KRB5_CTX_F_RD_REQ_IGNORE 16
326 #define KRB5_CTX_F_FCACHE_STRICT_CHECKING 32
327 #define KRB5_CTX_F_ENFORCE_OK_AS_DELEGATE 64
328 #define KRB5_CTX_F_REPORT_CANONICAL_CLIENT_NAME 128
329 struct send_to_kdc
*send_to_kdc
;
331 hx509_context hx509ctx
;
333 unsigned int num_kdc_requests
;
334 krb5_name_canon_rule name_canon_rules
;
335 size_t config_include_depth
;
336 krb5_boolean no_ticket_store
; /* Don't store service tickets */
339 #define KRB5_DEFAULT_CCNAME_FILE "FILE:%{TEMP}/krb5cc_%{uid}"
340 #define KRB5_DEFAULT_CCNAME_DIR "DIR:%{TEMP}/krb5cc_%{uid}_dir/"
341 #define KRB5_DEFAULT_CCNAME_API "API:"
342 #define KRB5_DEFAULT_CCNAME_KCM_KCM "KCM:%{uid}"
343 #define KRB5_DEFAULT_CCNAME_KCM_API "API:%{uid}"
345 #define EXTRACT_TICKET_ALLOW_CNAME_MISMATCH 1
346 #define EXTRACT_TICKET_ALLOW_SERVER_MISMATCH 2
347 #define EXTRACT_TICKET_MATCH_REALM 4
348 #define EXTRACT_TICKET_AS_REQ 8
349 #define EXTRACT_TICKET_TIMESYNC 16
350 #define EXTRACT_TICKET_MATCH_ANON 32
353 * Configurable options
356 #ifndef KRB5_DEFAULT_CCTYPE
358 #define KRB5_DEFAULT_CCTYPE (&krb5_acc_ops)
360 #define KRB5_DEFAULT_CCTYPE (&krb5_fcc_ops)
364 #ifndef KRB5_ADDRESSLESS_DEFAULT
365 #define KRB5_ADDRESSLESS_DEFAULT TRUE
368 #ifndef KRB5_FORWARDABLE_DEFAULT
369 #define KRB5_FORWARDABLE_DEFAULT TRUE
372 #ifndef KRB5_CONFIGURATION_CHANGE_NOTIFY_NAME
373 #define KRB5_CONFIGURATION_CHANGE_NOTIFY_NAME "org.h5l.Kerberos.configuration-changed"
376 #ifndef KRB5_FALLBACK_DEFAULT
377 #define KRB5_FALLBACK_DEFAULT TRUE
380 #ifndef KRB5_TKT_LIFETIME_DEFAULT
381 # define KRB5_TKT_LIFETIME_DEFAULT 15778800 /* seconds */
384 #ifndef KRB5_TKT_RENEW_LIFETIME_DEFAULT
385 # define KRB5_TKT_RENEW_LIFETIME_DEFAULT 15778800 /* seconds */
390 struct krb5_pk_identity
{
391 hx509_verify_ctx verify_ctx
;
395 hx509_certs certpool
;
396 hx509_revoke_ctx revokectx
;
398 #define PKINIT_BTMM 1
399 #define PKINIT_NO_KDC_ANCHOR 2
407 enum keyex_enum
{ USE_RSA
, USE_DH
, USE_ECDH
};
409 struct krb5_pk_init_ctx_data
{
410 struct krb5_pk_identity
*id
;
411 enum keyex_enum keyex
;
416 krb5_data
*clientDHNonce
;
417 struct krb5_dh_moduli
**m
;
418 hx509_peer_info peer
;
419 enum krb5_pk_type type
;
420 unsigned int require_binding
:1;
421 unsigned int require_eku
:1;
422 unsigned int require_krbtgt_otherName
:1;
423 unsigned int require_hostname_match
:1;
424 unsigned int trustedCertifiers
:1;
425 unsigned int anonymous
:1;
426 unsigned int kdc_verified
:1;
431 struct krb5_fast_state
{
432 enum PA_FX_FAST_REQUEST_enum type
;
434 #define KRB5_FAST_REPLY_KEY_USE_TO_ENCRYPT_THE_REPLY 0x0001
435 #define KRB5_FAST_REPLY_KEY_USE_IN_TRANSACTION 0x0002
436 #define KRB5_FAST_KDC_REPLY_KEY_REPLACED 0x0004
437 #define KRB5_FAST_REPLY_REPLY_VERIFIED 0x0008
438 #define KRB5_FAST_STRONG 0x0010
439 #define KRB5_FAST_EXPECTED 0x0020 /* in exchange with KDC, fast was discovered */
440 #define KRB5_FAST_REQUIRED 0x0040 /* fast required by action of caller */
441 #define KRB5_FAST_DISABLED 0x0080
443 #define KRB5_FAST_AP_ARMOR_SERVICE 0x0100
444 #define KRB5_FAST_OPTIMISTIC 0x0200 /* Optimistic try, like Anon + PKINIT or service fast bit */
445 #define KRB5_FAST_REQUIRE_ENC_PA 0x0400
447 #define KRB5_FAST_AS_REQ 0x1000
448 #define KRB5_FAST_ANON_PKINIT_ARMOR 0x2000
449 #define KRB5_FAST_KDC_VERIFIED 0x4000
451 krb5_keyblock
*reply_key
;
452 krb5_ccache armor_ccache
;
453 krb5_auth_context armor_ac
;
454 KrbFastArmor
*armor_data
;
455 krb5_principal armor_service
;
456 krb5_crypto armor_crypto
;
457 krb5_keyblock armor_key
;
458 krb5_keyblock
*strengthen_key
;
460 /* KRB5_FAST_ANON_PKINIT_ARMOR */
461 krb5_get_init_creds_opt
*anon_pkinit_opt
;
462 krb5_init_creds_context anon_pkinit_ctx
;
465 struct krb5_decrypt_tkt_with_subkey_state
{
466 krb5_keyblock
*subkey
;
467 struct krb5_fast_state
*fast_state
;
470 #define ISTILDE(x) (x == '~')
472 # define ISPATHSEP(x) (x == '/' || x =='\\')
474 # define ISPATHSEP(x) (x == '/')
477 /* Flag in KRB5_AUTHDATA_AP_OPTIONS */
478 #define KERB_AP_OPTIONS_CBT 0x00004000
480 /* Flag in PAC_ATTRIBUTES_INFO */
481 #define KRB5_PAC_WAS_REQUESTED 0x1
482 #define KRB5_PAC_WAS_GIVEN_IMPLICITLY 0x2
484 #endif /* __KRB5_LOCL_H__ */