1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 * Copyright (C) 1989,1990,1991,1992,1993,1994,1995,2000,2001,
4 * 2003,2006,2007,2008,2009 by the Massachusetts Institute of Technology,
5 * Cambridge, MA, USA. All Rights Reserved.
7 * This software is being provided to you, the LICENSEE, by the
8 * Massachusetts Institute of Technology (M.I.T.) under the following
9 * license. By obtaining, using and/or copying this software, you agree
10 * that you have read, understood, and will comply with these terms and
13 * Export of this software from the United States of America may
14 * require a specific license from the United States Government.
15 * It is the responsibility of any person or organization contemplating
16 * export to obtain such a license before exporting.
18 * WITHIN THAT CONSTRAINT, permission to use, copy, modify and distribute
19 * this software and its documentation for any purpose and without fee or
20 * royalty is hereby granted, provided that you agree to comply with the
21 * following copyright notice and statements, including the disclaimer, and
22 * that the same appear on ALL copies of the software and documentation,
23 * including modifications that you make for internal use or for
26 * THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS
27 * OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not
28 * limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF
29 * MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
30 * THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
31 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
33 * The name of the Massachusetts Institute of Technology or M.I.T. may NOT
34 * be used in advertising or publicity pertaining to distribution of the
35 * software. Title to copyright in this software and any associated
36 * documentation shall at all times remain with M.I.T., and USER agrees to
39 * Furthermore if you modify this software you must label
40 * your software as modified software and not distribute it in such a
41 * fashion that it might be confused with the original M.I.T. software.
44 * Copyright (C) 1998 by the FundsXpress, INC.
46 * All rights reserved.
48 * Export of this software from the United States of America may require
49 * a specific license from the United States Government. It is the
50 * responsibility of any person or organization contemplating export to
51 * obtain such a license before exporting.
53 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
54 * distribute this software and its documentation for any purpose and
55 * without fee is hereby granted, provided that the above copyright
56 * notice appear in all copies and that both that copyright notice and
57 * this permission notice appear in supporting documentation, and that
58 * the name of FundsXpress. not be used in advertising or publicity pertaining
59 * to distribution of the software without specific, written prior
60 * permission. FundsXpress makes no representations about the suitability of
61 * this software for any purpose. It is provided "as is" without express
62 * or implied warranty.
64 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
65 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
66 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
70 * This prototype for k5-int.h (Krb5 internals include file)
71 * includes the user-visible definitions from krb5.h and then
72 * includes other definitions that are not user-visible but are
73 * required for compiling Kerberos internal routines.
75 * John Gilmore, Cygnus Support, Sat Jan 21 22:45:52 PST 1995
82 #error krb5.h included before k5-int.h
83 #endif /* KRB5_GENERAL__ */
87 #if defined(__MACH__) && defined(__APPLE__)
88 # include <TargetConditionals.h>
89 # if TARGET_RT_MAC_CFM
90 # error "Use KfM 4.0 SDK headers for CFM compilation."
101 * Machine-type definitions: PC Clone 386 running Microloss Windows
104 #if defined(_MSDOS) || defined(_WIN32)
107 /* Kerberos Windows initialization file */
108 #define KERBEROS_INI "kerberos.ini"
109 #define INI_FILES "Files"
110 #define INI_KRB_CCACHE "krb5cc" /* Location of the ccache */
111 #define INI_KRB5_CONF "krb5.ini" /* Location of krb5.conf file */
113 #define DISABLE_TRACING
116 #include "autoconf.h"
118 #ifndef KRB5_SYSTYPES__
119 #define KRB5_SYSTYPES__
121 #ifdef HAVE_SYS_TYPES_H /* From autoconf.h */
122 #include <sys/types.h>
123 #else /* HAVE_SYS_TYPES_H */
124 typedef unsigned long u_long;
125 typedef unsigned int u_int;
126 typedef unsigned short u_short;
127 typedef unsigned char u_char;
128 #endif /* HAVE_SYS_TYPES_H */
129 #endif /* KRB5_SYSTYPES__ */
132 #include "k5-platform.h"
133 /* not used in krb5.h (yet) */
134 typedef UINT64_TYPE krb5_ui_8;
135 typedef INT64_TYPE krb5_int64;
138 #define DEFAULT_PWD_STRING1 "Enter password"
139 #define DEFAULT_PWD_STRING2 "Re-enter password for verification"
141 #define KRB5_KDB_MAX_LIFE (60*60*24) /* one day */
142 #define KRB5_KDB_MAX_RLIFE (60*60*24*7) /* one week */
143 #define KRB5_KDB_EXPIRATION 2145830400 /* Thu Jan 1 00:00:00 2038 UTC */
146 * Windows requires a different api interface to each function. Here
147 * just define it as NULL.
149 #ifndef KRB5_CALLCONV
150 #define KRB5_CALLCONV
151 #define KRB5_CALLCONV_C
157 /* #define KRB5_OLD_CRYPTO is done in krb5.h */
159 #endif /* KRB5_CONFIG__ */
166 * After loading the configuration definitions, load the Kerberos definitions.
170 #include <krb5/plugin.h>
173 #include "port-sockets.h"
174 #include "socket-utils.h"
176 /* Get mutex support; currently used only for the replay cache. */
177 #include "k5-thread.h"
179 /* Get error info support. */
182 /* Get string buffer support. */
185 /* Define tracing macros. */
186 #include "k5-trace.h"
188 /* cofiguration variables */
189 #define KRB5_CONF_ACL_FILE "acl_file"
190 #define KRB5_CONF_ADMIN_SERVER "admin_server"
191 #define KRB5_CONF_ALLOW_WEAK_CRYPTO "allow_weak_crypto"
192 #define KRB5_CONF_AP_REQ_CHECKSUM_TYPE "ap_req_checksum_type"
193 #define KRB5_CONF_AUTH_TO_LOCAL "auth_to_local"
194 #define KRB5_CONF_AUTH_TO_LOCAL_NAMES "auth_to_local_names"
195 #define KRB5_CONF_CANONICALIZE "canonicalize"
196 #define KRB5_CONF_CCACHE_TYPE "ccache_type"
197 #define KRB5_CONF_CLOCKSKEW "clockskew"
198 #define KRB5_CONF_DATABASE_NAME "database_name"
199 #define KRB5_CONF_DB_MODULE_DIR "db_module_dir"
200 #define KRB5_CONF_DEFAULT "default"
201 #define KRB5_CONF_DEFAULT_REALM "default_realm"
202 #define KRB5_CONF_DEFAULT_DOMAIN "default_domain"
203 #define KRB5_CONF_DEFAULT_TKT_ENCTYPES "default_tkt_enctypes"
204 #define KRB5_CONF_DEFAULT_TGS_ENCTYPES "default_tgs_enctypes"
205 #define KRB5_CONF_DEFAULT_KEYTAB_NAME "default_keytab_name"
206 #define KRB5_CONF_DEFAULT_PRINCIPAL_EXPIRATION "default_principal_expiration"
207 #define KRB5_CONF_DEFAULT_PRINCIPAL_FLAGS "default_principal_flags"
208 #define KRB5_CONF_DICT_FILE "dict_file"
209 #define KRB5_CONF_DISABLE "disable"
210 #define KRB5_CONF_DISABLE_LAST_SUCCESS "disable_last_success"
211 #define KRB5_CONF_DISABLE_LOCKOUT "disable_lockout"
212 #define KRB5_CONF_DNS_LOOKUP_KDC "dns_lookup_kdc"
213 #define KRB5_CONF_DNS_LOOKUP_REALM "dns_lookup_realm"
214 #define KRB5_CONF_DNS_FALLBACK "dns_fallback"
215 #define KRB5_CONF_DOMAIN_REALM "domain_realm"
216 #define KRB5_CONF_ENABLE_ONLY "enable_only"
217 #define KRB5_CONF_EXTRA_ADDRESSES "extra_addresses"
218 #define KRB5_CONF_FORWARDABLE "forwardable"
219 #define KRB5_CONF_HOST_BASED_SERVICES "host_based_services"
220 #define KRB5_CONF_IGNORE_ACCEPTOR_HOSTNAME "ignore_acceptor_hostname"
221 #define KRB5_CONF_IPROP_ENABLE "iprop_enable"
222 #define KRB5_CONF_IPROP_MASTER_ULOGSIZE "iprop_master_ulogsize"
223 #define KRB5_CONF_IPROP_PORT "iprop_port"
224 #define KRB5_CONF_IPROP_SLAVE_POLL "iprop_slave_poll"
225 #define KRB5_CONF_IPROP_LOGFILE "iprop_logfile"
226 #define KRB5_CONF_K5LOGIN_AUTHORITATIVE "k5login_authoritative"
227 #define KRB5_CONF_K5LOGIN_DIRECTORY "k5login_directory"
228 #define KRB5_CONF_KADMIND_PORT "kadmind_port"
229 #define KRB5_CONF_KRB524_SERVER "krb524_server"
230 #define KRB5_CONF_KDC "kdc"
231 #define KRB5_CONF_KDCDEFAULTS "kdcdefaults"
232 #define KRB5_CONF_KDC_PORTS "kdc_ports"
233 #define KRB5_CONF_KDC_TCP_PORTS "kdc_tcp_ports"
234 #define KRB5_CONF_MAX_DGRAM_REPLY_SIZE "kdc_max_dgram_reply_size"
235 #define KRB5_CONF_KDC_DEFAULT_OPTIONS "kdc_default_options"
236 #define KRB5_CONF_KDC_TIMESYNC "kdc_timesync"
237 #define KRB5_CONF_KDC_REQ_CHECKSUM_TYPE "kdc_req_checksum_type"
238 #define KRB5_CONF_KEY_STASH_FILE "key_stash_file"
239 #define KRB5_CONF_KPASSWD_PORT "kpasswd_port"
240 #define KRB5_CONF_KPASSWD_SERVER "kpasswd_server"
241 #define KRB5_CONF_LDAP_CONNS_PER_SERVER "ldap_conns_per_server"
242 #define KRB5_CONF_LDAP_KADMIN_DN "ldap_kadmind_dn"
243 #define KRB5_CONF_LDAP_KDC_DN "ldap_kdc_dn"
244 #define KRB5_CONF_LDAP_KERBEROS_CONTAINER_DN "ldap_kerberos_container_dn"
245 #define KRB5_CONF_LDAP_KPASSWDD_DN "ldap_kpasswdd_dn"
246 #define KRB5_CONF_LDAP_SERVERS "ldap_servers"
247 #define KRB5_CONF_LDAP_SERVICE_PASSWORD_FILE "ldap_service_password_file"
248 #define KRB5_CONF_LIBDEFAULTS "libdefaults"
249 #define KRB5_CONF_LOGGING "logging"
250 #define KRB5_CONF_MASTER_KEY_NAME "master_key_name"
251 #define KRB5_CONF_MASTER_KEY_TYPE "master_key_type"
252 #define KRB5_CONF_MASTER_KDC "master_kdc"
253 #define KRB5_CONF_MAX_LIFE "max_life"
254 #define KRB5_CONF_MAX_RENEWABLE_LIFE "max_renewable_life"
255 #define KRB5_CONF_MODULE "module"
256 #define KRB5_CONF_NOADDRESSES "noaddresses"
257 #define KRB5_CONF_NO_HOST_REFERRAL "no_host_referral"
258 #define KRB5_CONF_PERMITTED_ENCTYPES "permitted_enctypes"
259 #define KRB5_CONF_PLUGINS "plugins"
260 #define KRB5_CONF_PLUGIN_BASE_DIR "plugin_base_dir"
261 #define KRB5_CONF_PREFERRED_PREAUTH_TYPES "preferred_preauth_types"
262 #define KRB5_CONF_PROXIABLE "proxiable"
263 #define KRB5_CONF_RDNS "rdns"
264 #define KRB5_CONF_REALMS "realms"
265 #define KRB5_CONF_REALM_TRY_DOMAINS "realm_try_domains"
266 #define KRB5_CONF_REJECT_BAD_TRANSIT "reject_bad_transit"
267 #define KRB5_CONF_RENEW_LIFETIME "renew_lifetime"
268 #define KRB5_CONF_RESTRICT_ANONYMOUS_TO_TGT "restrict_anonymous_to_tgt"
269 #define KRB5_CONF_SAFE_CHECKSUM_TYPE "safe_checksum_type"
270 #define KRB5_CONF_SUPPORTED_ENCTYPES "supported_enctypes"
271 #define KRB5_CONF_TICKET_LIFETIME "ticket_lifetime"
272 #define KRB5_CONF_UDP_PREFERENCE_LIMIT "udp_preference_limit"
273 #define KRB5_CONF_VERIFY_AP_REQ_NOFAIL "verify_ap_req_nofail"
274 #define KRB5_CONF_V4_INSTANCE_CONVERT "v4_instance_convert"
275 #define KRB5_CONF_V4_REALM "v4_realm"
276 #define KRB5_CONF_ASTERISK "*"
278 /* Cache configuration variables */
279 #define KRB5_CONF_FAST_AVAIL "fast_avail"
280 #define KRB5_CONF_PROXY_IMPERSONATOR "proxy_impersonator"
282 /* Error codes used in KRB_ERROR protocol messages.
283 Return values of library routines are based on a different error table
284 (which allows non-ambiguous error codes between subsystems) */
287 #define KDC_ERR_NONE 0 /* No error */
288 #define KDC_ERR_NAME_EXP 1 /* Client's entry in DB expired */
289 #define KDC_ERR_SERVICE_EXP 2 /* Server's entry in DB expired */
290 #define KDC_ERR_BAD_PVNO 3 /* Requested pvno not supported */
291 #define KDC_ERR_C_OLD_MAST_KVNO 4 /* C's key encrypted in old master */
292 #define KDC_ERR_S_OLD_MAST_KVNO 5 /* S's key encrypted in old master */
293 #define KDC_ERR_C_PRINCIPAL_UNKNOWN 6 /* Client not found in Kerberos DB */
294 #define KDC_ERR_S_PRINCIPAL_UNKNOWN 7 /* Server not found in Kerberos DB */
295 #define KDC_ERR_PRINCIPAL_NOT_UNIQUE 8 /* Multiple entries in Kerberos DB */
296 #define KDC_ERR_NULL_KEY 9 /* The C or S has a null key */
297 #define KDC_ERR_CANNOT_POSTDATE 10 /* Tkt ineligible for postdating */
298 #define KDC_ERR_NEVER_VALID 11 /* Requested starttime > endtime */
299 #define KDC_ERR_POLICY 12 /* KDC policy rejects request */
300 #define KDC_ERR_BADOPTION 13 /* KDC can't do requested opt. */
301 #define KDC_ERR_ENCTYPE_NOSUPP 14 /* No support for encryption type */
302 #define KDC_ERR_SUMTYPE_NOSUPP 15 /* No support for checksum type */
303 #define KDC_ERR_PADATA_TYPE_NOSUPP 16 /* No support for padata type */
304 #define KDC_ERR_TRTYPE_NOSUPP 17 /* No support for transited type */
305 #define KDC_ERR_CLIENT_REVOKED 18 /* C's creds have been revoked */
306 #define KDC_ERR_SERVICE_REVOKED 19 /* S's creds have been revoked */
307 #define KDC_ERR_TGT_REVOKED 20 /* TGT has been revoked */
308 #define KDC_ERR_CLIENT_NOTYET 21 /* C not yet valid */
309 #define KDC_ERR_SERVICE_NOTYET 22 /* S not yet valid */
310 #define KDC_ERR_KEY_EXP 23 /* Password has expired */
311 #define KDC_ERR_PREAUTH_FAILED 24 /* Preauthentication failed */
312 #define KDC_ERR_PREAUTH_REQUIRED 25 /* Additional preauthentication */
314 #define KDC_ERR_SERVER_NOMATCH 26 /* Requested server and */
315 /* ticket don't match*/
316 #define KDC_ERR_MUST_USE_USER2USER 27 /* Server principal valid for */
318 #define KDC_ERR_PATH_NOT_ACCEPTED 28 /* KDC policy rejected transited */
320 #define KDC_ERR_SVC_UNAVAILABLE 29 /* A service is not
322 * required to process the
324 /* Application errors */
325 #define KRB_AP_ERR_BAD_INTEGRITY 31 /* Decrypt integrity check failed */
326 #define KRB_AP_ERR_TKT_EXPIRED 32 /* Ticket expired */
327 #define KRB_AP_ERR_TKT_NYV 33 /* Ticket not yet valid */
328 #define KRB_AP_ERR_REPEAT 34 /* Request is a replay */
329 #define KRB_AP_ERR_NOT_US 35 /* The ticket isn't for us */
330 #define KRB_AP_ERR_BADMATCH 36 /* Ticket/authenticator don't match */
331 #define KRB_AP_ERR_SKEW 37 /* Clock skew too great */
332 #define KRB_AP_ERR_BADADDR 38 /* Incorrect net address */
333 #define KRB_AP_ERR_BADVERSION 39 /* Protocol version mismatch */
334 #define KRB_AP_ERR_MSG_TYPE 40 /* Invalid message type */
335 #define KRB_AP_ERR_MODIFIED 41 /* Message stream modified */
336 #define KRB_AP_ERR_BADORDER 42 /* Message out of order */
337 #define KRB_AP_ERR_BADKEYVER 44 /* Key version is not available */
338 #define KRB_AP_ERR_NOKEY 45 /* Service key not available */
339 #define KRB_AP_ERR_MUT_FAIL 46 /* Mutual authentication failed */
340 #define KRB_AP_ERR_BADDIRECTION 47 /* Incorrect message direction */
341 #define KRB_AP_ERR_METHOD 48 /* Alternative authentication */
342 /* method required */
343 #define KRB_AP_ERR_BADSEQ 49 /* Incorrect sequence numnber */
345 #define KRB_AP_ERR_INAPP_CKSUM 50 /* Inappropriate type of */
346 /* checksum in message */
347 #define KRB_AP_PATH_NOT_ACCEPTED 51 /* Policy rejects transited path */
348 #define KRB_ERR_RESPONSE_TOO_BIG 52 /* Response too big for UDP, */
352 #define KRB_ERR_GENERIC 60 /* Generic error (description */
354 #define KRB_ERR_FIELD_TOOLONG 61 /* Field is too long for impl. */
356 /* PKINIT server-reported errors */
357 #define KDC_ERR_CLIENT_NOT_TRUSTED 62 /* client cert not trusted */
358 #define KDC_ERR_KDC_NOT_TRUSTED 63
359 #define KDC_ERR_INVALID_SIG 64 /* client signature verify failed */
360 #define KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED 65 /* invalid Diffie-Hellman parameters */
361 #define KDC_ERR_CERTIFICATE_MISMATCH 66
362 #define KRB_AP_ERR_NO_TGT 67
363 #define KDC_ERR_WRONG_REALM 68
364 #define KRB_AP_ERR_USER_TO_USER_REQUIRED 69
365 #define KDC_ERR_CANT_VERIFY_CERTIFICATE 70 /* client cert not verifiable to */
366 /* trusted root cert */
367 #define KDC_ERR_INVALID_CERTIFICATE 71 /* client cert had invalid signature */
368 #define KDC_ERR_REVOKED_CERTIFICATE 72 /* client cert was revoked */
369 #define KDC_ERR_REVOCATION_STATUS_UNKNOWN 73 /* client cert revoked, reason unknown */
370 #define KDC_ERR_REVOCATION_STATUS_UNAVAILABLE 74
371 #define KDC_ERR_CLIENT_NAME_MISMATCH 75 /* mismatch between client cert and */
373 #define KDC_ERR_INCONSISTENT_KEY_PURPOSE 77 /* bad extended key use */
374 #define KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED 78 /* bad digest algorithm in client cert */
375 #define KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED 79 /* missing paChecksum in PA-PK-AS-REQ */
376 #define KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED 80 /* bad digest algorithm in SignedData */
377 #define KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED 81
378 #define KRB_AP_ERR_IAKERB_KDC_NOT_FOUND 85 /* The IAKERB proxy could
380 #define KRB_AP_ERR_IAKERB_KDC_NO_RESPONSE 86 /* The KDC did not respond
381 to the IAKERB proxy */
384 * A null-terminated array of this structure is returned by the KDC as
385 * the data part of the ETYPE_INFO preauth type. It informs the
386 * client which encryption types are supported.
387 * The same data structure is used by both etype-info and etype-info2
388 * but s2kparams must be null when encoding etype-info.
390 typedef struct _krb5_etype_info_entry {
396 } krb5_etype_info_entry;
399 * This is essentially -1 without sign extension which can screw up
400 * comparisons on 64 bit machines. If the length is this value, then
401 * the salt data is not present. This is to distinguish between not
402 * being set and being of 0 length.
404 #define KRB5_ETYPE_NO_SALT VALID_UINT_BITS
406 typedef krb5_etype_info_entry ** krb5_etype_info;
409 typedef struct _krb5_etype_list {
411 krb5_enctype *etypes;
414 /* sam_type values -- informational only */
415 #define PA_SAM_TYPE_ENIGMA 1 /* Enigma Logic */
416 #define PA_SAM_TYPE_DIGI_PATH 2 /* Digital Pathways */
417 #define PA_SAM_TYPE_SKEY_K0 3 /* S/key where KDC has key 0 */
418 #define PA_SAM_TYPE_SKEY 4 /* Traditional S/Key */
419 #define PA_SAM_TYPE_SECURID 5 /* Security Dynamics */
420 #define PA_SAM_TYPE_CRYPTOCARD 6 /* CRYPTOCard */
421 #if 1 /* XXX need to figure out who has which numbers assigned */
422 #define PA_SAM_TYPE_ACTIVCARD_DEC 6 /* ActivCard decimal mode */
423 #define PA_SAM_TYPE_ACTIVCARD_HEX 7 /* ActivCard hex mode */
424 #define PA_SAM_TYPE_DIGI_PATH_HEX 8 /* Digital Pathways hex mode */
426 #define PA_SAM_TYPE_EXP_BASE 128 /* experimental */
427 #define PA_SAM_TYPE_GRAIL (PA_SAM_TYPE_EXP_BASE+0) /* testing */
428 #define PA_SAM_TYPE_SECURID_PREDICT (PA_SAM_TYPE_EXP_BASE+1) /* special */
430 typedef struct _krb5_sam_challenge_2 {
431 krb5_data sam_challenge_2_body;
432 krb5_checksum **sam_cksum; /* Array of checksums */
433 } krb5_sam_challenge_2;
435 typedef struct _krb5_sam_challenge_2_body {
437 krb5_int32 sam_type; /* information */
438 krb5_flags sam_flags; /* KRB5_SAM_* values */
439 krb5_data sam_type_name;
440 krb5_data sam_track_id;
441 krb5_data sam_challenge_label;
442 krb5_data sam_challenge;
443 krb5_data sam_response_prompt;
444 krb5_data sam_pk_for_sad;
445 krb5_int32 sam_nonce;
446 krb5_enctype sam_etype;
447 } krb5_sam_challenge_2_body;
449 typedef struct _krb5_sam_response_2 {
451 krb5_int32 sam_type; /* informational */
452 krb5_flags sam_flags; /* KRB5_SAM_* values */
453 krb5_data sam_track_id; /* copied */
454 krb5_enc_data sam_enc_nonce_or_sad; /* krb5_enc_sam_response_enc */
455 krb5_int32 sam_nonce;
456 } krb5_sam_response_2;
458 typedef struct _krb5_enc_sam_response_enc_2 {
460 krb5_int32 sam_nonce;
462 } krb5_enc_sam_response_enc_2;
465 * Keep the pkinit definitions in a separate file so that the plugin
466 * only has to include k5-int-pkinit.h rather than k5-int.h
469 #include "k5-int-pkinit.h"
475 extern char *strdup (const char *);
482 #ifdef HAVE_SYS_TIME_H
483 #include <sys/time.h>
484 #ifdef TIME_WITH_SYS_TIME
491 #ifdef HAVE_SYS_STAT_H
492 #include <sys/stat.h> /* struct stat, stat() */
495 #ifdef HAVE_SYS_PARAM_H
496 #include <sys/param.h> /* MAXPATHLEN */
499 #ifdef HAVE_SYS_FILE_H
500 #include <sys/file.h> /* prototypes for file-related
501 syscalls; flags for open &
511 #include "k5-gmt_mktime.h"
513 struct sendto_callback_info;
516 krb5_error_code krb5_lock_file(krb5_context, int, int);
517 krb5_error_code krb5_unlock_file(krb5_context, int);
518 krb5_error_code krb5_sendto_kdc(krb5_context, const krb5_data *,
519 const krb5_data *, krb5_data *, int *, int);
521 krb5_error_code krb5_get_krbhst(krb5_context, const krb5_data *, char *** );
522 krb5_error_code krb5_free_krbhst(krb5_context, char * const * );
523 krb5_error_code krb5_create_secure_file(krb5_context, const char * pathname);
524 krb5_error_code krb5_sync_disk_file(krb5_context, FILE *fp);
526 krb5_error_code krb5int_init_context_kdc(krb5_context *);
528 krb5_error_code krb5_os_init_context(krb5_context context, profile_t profile,
531 void krb5_os_free_context(krb5_context);
533 /* This function is needed by KfM's KerberosPreferences API
534 * because it needs to be able to specify "secure" */
536 os_get_default_config_files(profile_filespec_t **pfiles, krb5_boolean secure);
539 krb5_os_hostaddr(krb5_context, const char *, krb5_address ***);
542 krb5int_get_domain_realm_mapping(krb5_context , const char *, char ***);
547 struct derived_key *next;
550 /* Internal structure of an opaque key identifier */
552 krb5_keyblock keyblock;
554 struct derived_key *derived;
556 * Cache of data private to the cipher implementation, which we
557 * don't want to have to recompute for every operation. This may
558 * include key schedules, iteration counts, etc.
560 * The cipher implementation is responsible for setting this up
561 * whenever needed, and the enc_provider key_cleanup method must
562 * then be provided to dispose of it.
568 krb5int_arcfour_gsscrypt(const krb5_keyblock *keyblock, krb5_keyusage usage,
569 const krb5_data *kd_data, krb5_crypto_iov *data,
573 * Attempt to zero memory in a way that compilers won't optimize out.
575 * This mechanism should work even for heap storage about to be freed,
576 * or automatic storage right before we return from a function.
578 * Then, even if we leak uninitialized memory someplace, or UNIX
579 * "core" files get created with world-read access, some of the most
580 * sensitive data in the process memory will already be safely wiped.
582 * We're not going so far -- yet -- as to try to protect key data that
583 * may have been written into swap space....
586 # define zap(ptr, len) SecureZeroMemory(ptr, len)
587 #elif defined(__GNUC__)
588 static inline void zap(void *ptr, size_t len)
592 * Some versions of gcc have gotten clever enough to eliminate a
593 * memset call right before the block in question is released.
594 * This (empty) asm requires it to assume that we're doing
595 * something interesting with the stored (zero) value, so the
596 * memset can't be eliminated.
598 * An optimizer that looks at assembly or object code may not be
599 * fooled, and may still cause the memset to go away. Address
600 * that problem if and when we encounter it.
602 * This also may not be enough if free() does something
603 * interesting like purge memory locations from a write-back cache
604 * that hasn't written back the zero bytes yet. A memory barrier
605 * instruction would help in that case.
607 asm volatile ("" : : "g" (ptr), "g" (len));
610 /* Use a function from libkrb5support to defeat inlining. */
611 # define zap(ptr, len) krb5int_zap(ptr, len)
614 /* Convenience function: zap and free ptr if it is non-NULL. */
616 zapfree(void *ptr, size_t len)
625 * Combine two keys (normally used by the hardware preauth mechanism)
628 krb5int_c_combine_keys(krb5_context context, krb5_keyblock *key1,
629 krb5_keyblock *key2, krb5_keyblock *outkey);
631 void krb5int_c_free_keyblock(krb5_context, krb5_keyblock *key);
632 void krb5int_c_free_keyblock_contents(krb5_context, krb5_keyblock *);
633 krb5_error_code krb5int_c_init_keyblock(krb5_context, krb5_enctype enctype,
634 size_t length, krb5_keyblock **out);
635 krb5_error_code krb5int_c_copy_keyblock(krb5_context context,
636 const krb5_keyblock *from,
638 krb5_error_code krb5int_c_copy_keyblock_contents(krb5_context context,
639 const krb5_keyblock *from,
642 #ifdef KRB5_OLD_CRYPTO
643 /* old provider api */
645 krb5_error_code krb5_crypto_os_localaddr(krb5_address ***);
647 krb5_error_code krb5_crypto_us_timeofday(krb5_int32 *, krb5_int32 *);
649 #endif /* KRB5_OLD_CRYPTO */
651 /* this helper fct is in libkrb5, but it makes sense declared here. */
654 krb5_encrypt_keyhelper(krb5_context context, krb5_key key,
655 krb5_keyusage keyusage, const krb5_data *plain,
656 krb5_enc_data *cipher);
662 typedef struct _krb5_os_context {
664 krb5_int32 time_offset;
665 krb5_int32 usec_offset;
667 char * default_ccname;
670 /* Get the current time of day plus a specified offset. */
671 krb5_error_code k5_time_with_offset(krb5_timestamp offset,
672 krb5_int32 offset_usec,
673 krb5_timestamp *time_out,
674 krb5_int32 *usec_out);
677 * Flags for the os_flags field
679 * KRB5_OS_TOFFSET_VALID means that the time offset fields are valid.
680 * The intention is that this facility to correct the system clocks so
681 * that they reflect the "real" time, for systems where for some
682 * reason we can't set the system clock. Instead we calculate the
683 * offset between the system time and real time, and store the offset
684 * in the os context so that we can correct the system clock as necessary.
686 * KRB5_OS_TOFFSET_TIME means that the time offset fields should be
687 * returned as the time by the krb5 time routines. This should only
688 * be used for testing purposes (obviously!)
690 #define KRB5_OS_TOFFSET_VALID 1
691 #define KRB5_OS_TOFFSET_TIME 2
693 /* lock mode flags */
694 #define KRB5_LOCKMODE_SHARED 0x0001
695 #define KRB5_LOCKMODE_EXCLUSIVE 0x0002
696 #define KRB5_LOCKMODE_DONTBLOCK 0x0004
697 #define KRB5_LOCKMODE_UNLOCK 0x0008
700 * Define our view of the size of a DES key.
702 #define KRB5_MIT_DES_KEYSIZE 8
703 #define KRB5_MIT_DES3_KEYSIZE 24
704 #define KRB5_MIT_DES3_KEY_BYTES 21
707 * Check if des_int.h has been included before us. If so, then check to see
708 * that our view of the DES key size is the same as des_int.h's.
710 #ifdef MIT_DES_KEYSIZE
711 #if MIT_DES_KEYSIZE != KRB5_MIT_DES_KEYSIZE
712 error(MIT_DES_KEYSIZE does not equal KRB5_MIT_DES_KEYSIZE)
713 #endif /* MIT_DES_KEYSIZE != KRB5_MIT_DES_KEYSIZE */
714 #endif /* MIT_DES_KEYSIZE */
719 * (Originally written by Glen Machin at Sandia Labs.)
722 * Sandia National Laboratories also makes no representations about the
723 * suitability of the modifications, or additions to this software for
724 * any purpose. It is provided "as is" without express or implied warranty.
726 #ifndef KRB5_PREAUTH__
727 #define KRB5_PREAUTH__
729 #include <krb5/preauth_plugin.h>
731 typedef krb5_error_code
732 (*krb5_gic_get_as_key_fct)(krb5_context, krb5_principal, krb5_enctype,
733 krb5_prompter_fct, void *prompter_data,
734 krb5_data *salt, krb5_data *s2kparams,
735 krb5_keyblock *as_key, void *gak_data);
737 #define CLIENT_ROCK_MAGIC 0x4352434b
739 * This structure is passed into the clpreauth methods and passed back to
740 * clpreauth callbacks so that they can locate the requested information. It
741 * is opaque to the plugin code and can be expanded in the future as new types
742 * of requests are defined which may require other things to be passed through.
743 * All pointer fields are aliases and should not be freed.
745 struct krb5int_fast_request_state;
746 struct krb5_clpreauth_rock_st {
749 struct krb5int_fast_request_state *fast_state;
752 * These fields allow gak_fct to be called via the rock. The
753 * gak_fct and gak_data fields have an extra level of indirection
754 * since they can change in the init_creds context.
756 krb5_keyblock *as_key;
757 krb5_gic_get_as_key_fct *gak_fct;
759 krb5_boolean *default_salt;
761 krb5_data *s2kparams;
762 krb5_principal client;
763 krb5_prompter_fct prompter;
766 /* Discovered offset of server time during preauth */
767 krb5_timestamp pa_offset;
768 krb5_int32 pa_offset_usec;
769 enum { NO_OFFSET = 0, UNAUTH_OFFSET, AUTH_OFFSET } pa_offset_state;
772 typedef struct _krb5_pa_enc_ts {
773 krb5_timestamp patimestamp;
777 typedef struct _krb5_pa_for_user {
780 krb5_data auth_package;
783 typedef struct _krb5_s4u_userid {
786 krb5_data subject_cert;
790 #define KRB5_S4U_OPTS_CHECK_LOGON_HOURS 0x40000000 /* check logon hour restrictions */
791 #define KRB5_S4U_OPTS_USE_REPLY_KEY_USAGE 0x20000000 /* sign with usage 27 instead of 26 */
793 typedef struct _krb5_pa_s4u_x509_user {
794 krb5_s4u_userid user_id;
796 } krb5_pa_s4u_x509_user;
799 KRB5_FAST_ARMOR_AP_REQUEST = 0x1
802 typedef struct _krb5_fast_armor {
803 krb5_int32 armor_type;
804 krb5_data armor_value;
806 typedef struct _krb5_fast_armored_req {
808 krb5_fast_armor *armor;
809 krb5_checksum req_checksum;
810 krb5_enc_data enc_part;
811 } krb5_fast_armored_req;
813 typedef struct _krb5_fast_req {
815 krb5_flags fast_options;
816 /* padata from req_body is used*/
817 krb5_kdc_req *req_body;
820 /* Bits 0-15 are critical in fast options.*/
821 #define UNSUPPORTED_CRITICAL_FAST_OPTIONS 0x00ff
822 #define KRB5_FAST_OPTION_HIDE_CLIENT_NAMES 0x01
824 typedef struct _krb5_fast_finished {
825 krb5_timestamp timestamp;
827 krb5_principal client;
828 krb5_checksum ticket_checksum;
829 } krb5_fast_finished;
831 typedef struct _krb5_fast_response {
833 krb5_pa_data **padata;
834 krb5_keyblock *strengthen_key;
835 krb5_fast_finished *finished;
837 } krb5_fast_response;
839 typedef struct _krb5_ad_kdcissued {
840 krb5_checksum ad_checksum;
841 krb5_principal i_principal;
842 krb5_authdata **elements;
845 typedef struct _krb5_ad_signedpath_data {
846 krb5_principal client;
847 krb5_timestamp authtime;
848 krb5_principal *delegated;
849 krb5_pa_data **method_data;
850 krb5_authdata **authorization_data;
851 } krb5_ad_signedpath_data;
853 typedef struct _krb5_ad_signedpath {
854 krb5_enctype enctype;
855 krb5_checksum checksum;
856 krb5_principal *delegated;
857 krb5_pa_data **method_data;
858 } krb5_ad_signedpath;
860 typedef struct _krb5_iakerb_header {
861 krb5_data target_realm;
863 } krb5_iakerb_header;
865 typedef struct _krb5_iakerb_finished {
866 krb5_checksum checksum;
867 } krb5_iakerb_finished;
869 typedef krb5_error_code
870 (*krb5_preauth_obtain_proc)(krb5_context, krb5_pa_data *,
871 krb5_etype_info, krb5_keyblock *,
872 krb5_error_code (*)(krb5_context,
877 krb5_const_pointer, krb5_creds *,
878 krb5_kdc_req *, krb5_pa_data **);
880 typedef krb5_error_code
881 (*krb5_preauth_process_proc)(krb5_context, krb5_pa_data *, krb5_kdc_req *,
883 krb5_error_code (*)(krb5_context,
889 krb5_error_code (*)(krb5_context,
890 const krb5_keyblock *,
893 krb5_keyblock **, krb5_creds *, krb5_int32 *,
896 typedef struct _krb5_preauth_ops {
900 krb5_preauth_obtain_proc obtain;
901 krb5_preauth_process_proc process;
905 krb5int_find_pa_data(krb5_context, krb5_pa_data *const *, krb5_preauthtype);
906 /* Does not return a copy; original padata sequence responsible for freeing*/
908 void krb5_free_etype_info(krb5_context, krb5_etype_info);
911 * Preauthentication property flags
913 #define KRB5_PREAUTH_FLAGS_ENCRYPT 0x00000001
914 #define KRB5_PREAUTH_FLAGS_HARDWARE 0x00000002
916 #endif /* KRB5_PREAUTH__ */
922 * Extending the krb5_get_init_creds_opt structure. The original
923 * krb5_get_init_creds_opt structure is defined publicly. The
924 * new extended version is private. The original interface
925 * assumed a pre-allocated structure which was passed to
926 * krb5_get_init_creds_init(). The new interface assumes that
927 * the caller will call krb5_get_init_creds_alloc() and
928 * krb5_get_init_creds_free().
930 * Callers MUST NOT call krb5_get_init_creds_init() after allocating an
931 * opts structure using krb5_get_init_creds_alloc(). To do so will
932 * introduce memory leaks. Unfortunately, there is no way to enforce
935 * Two private flags are added for backward compatibility.
936 * KRB5_GET_INIT_CREDS_OPT_EXTENDED says that the structure was allocated
937 * with the new krb5_get_init_creds_opt_alloc() function.
938 * KRB5_GET_INIT_CREDS_OPT_SHADOWED is set to indicate that the extended
939 * structure is a shadow copy of an original krb5_get_init_creds_opt
941 * If KRB5_GET_INIT_CREDS_OPT_SHADOWED is set after a call to
942 * krb5int_gic_opt_to_opte(), the resulting extended structure should be
943 * freed (using krb5_get_init_creds_free). Otherwise, the original
944 * structure was already extended and there is no need to free it.
947 #define KRB5_GET_INIT_CREDS_OPT_EXTENDED 0x80000000
948 #define KRB5_GET_INIT_CREDS_OPT_SHADOWED 0x40000000
950 #define krb5_gic_opt_is_extended(s) \
951 ((s) && ((s)->flags & KRB5_GET_INIT_CREDS_OPT_EXTENDED) ? 1 : 0)
952 #define krb5_gic_opt_is_shadowed(s) \
953 ((s) && ((s)->flags & KRB5_GET_INIT_CREDS_OPT_SHADOWED) ? 1 : 0)
956 typedef struct _krb5_gic_opt_private {
957 int num_preauth_data;
958 krb5_gic_opt_pa_data *preauth_data;
959 char * fast_ccache_name;
960 krb5_ccache out_ccache;
961 krb5_flags fast_flags;
962 krb5_expire_callback_func expire_cb;
964 } krb5_gic_opt_private;
967 * On the Mac, ensure that the layout of krb5_gic_opt_ext matches that
968 * of krb5_get_init_creds_opt.
971 # pragma pack(push,2)
974 typedef struct _krb5_gic_opt_ext {
976 krb5_deltat tkt_life;
977 krb5_deltat renew_life;
980 krb5_enctype *etype_list;
981 int etype_list_length;
982 krb5_address **address_list;
983 krb5_preauthtype *preauth_list;
984 int preauth_list_length;
987 * Do not change anything above this point in this structure.
988 * It is identical to the public krb5_get_init_creds_opt structure.
989 * New members must be added below.
991 krb5_gic_opt_private *opt_private;
999 krb5int_gic_opt_to_opte(krb5_context context, krb5_get_init_creds_opt *opt,
1000 krb5_gic_opt_ext **opte, unsigned int force,
1004 krb5int_copy_data_contents(krb5_context, const krb5_data *, krb5_data *);
1007 krb5int_copy_data_contents_add0(krb5_context, const krb5_data *, krb5_data *);
1010 krb5int_copy_creds_contents(krb5_context, const krb5_creds *, krb5_creds *);
1012 krb5_error_code KRB5_CALLCONV
1013 krb5int_get_init_creds(krb5_context context, krb5_creds *creds,
1014 krb5_principal client, krb5_prompter_fct prompter,
1015 void *prompter_data, krb5_deltat start_time,
1016 const char *in_tkt_service,
1017 krb5_get_init_creds_opt *options,
1018 krb5_gic_get_as_key_fct gak, void *gak_data,
1019 int *master, krb5_kdc_rep **as_reply);
1022 krb5int_populate_gic_opt (krb5_context, krb5_get_init_creds_opt **,
1023 krb5_flags options, krb5_address *const *addrs,
1024 krb5_enctype *ktypes,
1025 krb5_preauthtype *pre_auth_types, krb5_creds *creds);
1028 krb5_error_code KRB5_CALLCONV
1029 krb5_do_preauth(krb5_context context, krb5_kdc_req *request,
1030 krb5_data *encoded_request_body,
1031 krb5_data *encoded_previous_request, krb5_pa_data **in_padata,
1032 krb5_pa_data ***out_padata, krb5_prompter_fct prompter,
1033 void *prompter_data, krb5_clpreauth_rock preauth_rock,
1034 krb5_gic_opt_ext *opte, krb5_boolean *got_real_out);
1036 krb5_error_code KRB5_CALLCONV
1037 krb5_do_preauth_tryagain(krb5_context context, krb5_kdc_req *request,
1038 krb5_data *encoded_request_body,
1039 krb5_data *encoded_previous_request,
1040 krb5_pa_data **in_padata, krb5_pa_data ***out_padata,
1041 krb5_error *err_reply, krb5_pa_data **err_padata,
1042 krb5_prompter_fct prompter, void *prompter_data,
1043 krb5_clpreauth_rock preauth_rock,
1044 krb5_gic_opt_ext *opte);
1046 void KRB5_CALLCONV krb5_init_preauth_context(krb5_context);
1047 void KRB5_CALLCONV krb5_free_preauth_context(krb5_context);
1048 void KRB5_CALLCONV krb5_clear_preauth_context_use_counts(krb5_context);
1049 void KRB5_CALLCONV krb5_preauth_prepare_request(krb5_context,
1052 void KRB5_CALLCONV krb5_preauth_request_context_init(krb5_context);
1053 void KRB5_CALLCONV krb5_preauth_request_context_fini(krb5_context);
1056 krb5_free_sam_challenge_2(krb5_context, krb5_sam_challenge_2 *);
1059 krb5_free_sam_challenge_2_body(krb5_context, krb5_sam_challenge_2_body *);
1062 krb5_free_sam_response_2(krb5_context, krb5_sam_response_2 *);
1065 krb5_free_enc_sam_response_enc_2(krb5_context, krb5_enc_sam_response_enc_2 *);
1068 krb5_free_sam_challenge_2_contents(krb5_context, krb5_sam_challenge_2 *);
1071 krb5_free_sam_challenge_2_body_contents(krb5_context,
1072 krb5_sam_challenge_2_body *);
1075 krb5_free_sam_response_2_contents(krb5_context, krb5_sam_response_2 *);
1078 krb5_free_enc_sam_response_enc_2_contents(krb5_context,
1079 krb5_enc_sam_response_enc_2 * );
1082 krb5_free_pa_enc_ts(krb5_context, krb5_pa_enc_ts *);
1085 krb5_free_pa_for_user(krb5_context, krb5_pa_for_user *);
1088 krb5_free_s4u_userid_contents(krb5_context, krb5_s4u_userid *);
1091 krb5_free_pa_s4u_x509_user(krb5_context, krb5_pa_s4u_x509_user *);
1094 krb5_free_pa_pac_req(krb5_context, krb5_pa_pac_req * );
1097 krb5_free_etype_list(krb5_context, krb5_etype_list * );
1099 void KRB5_CALLCONV krb5_free_fast_armor(krb5_context, krb5_fast_armor *);
1100 void KRB5_CALLCONV krb5_free_fast_armored_req(krb5_context,
1101 krb5_fast_armored_req *);
1102 void KRB5_CALLCONV krb5_free_fast_req(krb5_context, krb5_fast_req *);
1103 void KRB5_CALLCONV krb5_free_fast_finished(krb5_context, krb5_fast_finished *);
1104 void KRB5_CALLCONV krb5_free_fast_response(krb5_context, krb5_fast_response *);
1105 void KRB5_CALLCONV krb5_free_ad_kdcissued(krb5_context, krb5_ad_kdcissued *);
1106 void KRB5_CALLCONV krb5_free_ad_signedpath(krb5_context, krb5_ad_signedpath *);
1107 void KRB5_CALLCONV krb5_free_iakerb_header(krb5_context, krb5_iakerb_header *);
1108 void KRB5_CALLCONV krb5_free_iakerb_finished(krb5_context,
1109 krb5_iakerb_finished *);
1111 /* #include "krb5/wordsize.h" -- comes in through base-defs.h. */
1112 #include "com_err.h"
1113 #include "k5-plugin.h"
1115 #include <krb5/authdata_plugin.h>
1117 struct _krb5_authdata_context {
1120 struct _krb5_authdata_context_module {
1121 krb5_authdatatype ad_type;
1122 void *plugin_context;
1123 authdata_client_plugin_fini_proc client_fini;
1125 krb5plugin_authdata_client_ftable_v0 *ftable;
1126 authdata_client_request_init_proc client_req_init;
1127 authdata_client_request_fini_proc client_req_fini;
1129 void *request_context;
1130 void **request_context_pp;
1132 struct plugin_dir_handle plugins;
1135 typedef struct _krb5_authdata_context *krb5_authdata_context;
1138 krb5int_free_data_list(krb5_context context, krb5_data *data);
1140 krb5_error_code KRB5_CALLCONV
1141 krb5_authdata_context_init(krb5_context kcontext,
1142 krb5_authdata_context *pcontext);
1145 krb5_authdata_context_free(krb5_context kcontext,
1146 krb5_authdata_context context);
1148 krb5_error_code KRB5_CALLCONV
1149 krb5_authdata_export_authdata(krb5_context kcontext,
1150 krb5_authdata_context context, krb5_flags usage,
1151 krb5_authdata ***pauthdata);
1153 krb5_error_code KRB5_CALLCONV
1154 krb5_authdata_get_attribute_types(krb5_context kcontext,
1155 krb5_authdata_context context,
1158 krb5_error_code KRB5_CALLCONV
1159 krb5_authdata_get_attribute(krb5_context kcontext,
1160 krb5_authdata_context context,
1161 const krb5_data *attribute,
1162 krb5_boolean *authenticated,
1163 krb5_boolean *complete, krb5_data *value,
1164 krb5_data *display_value, int *more);
1166 krb5_error_code KRB5_CALLCONV
1167 krb5_authdata_set_attribute(krb5_context kcontext,
1168 krb5_authdata_context context,
1169 krb5_boolean complete, const krb5_data *attribute,
1170 const krb5_data *value);
1172 krb5_error_code KRB5_CALLCONV
1173 krb5_authdata_delete_attribute(krb5_context kcontext,
1174 krb5_authdata_context context,
1175 const krb5_data *attribute);
1177 krb5_error_code KRB5_CALLCONV
1178 krb5_authdata_import_attributes(krb5_context kcontext,
1179 krb5_authdata_context context,
1180 krb5_flags usage, const krb5_data *attributes);
1182 krb5_error_code KRB5_CALLCONV
1183 krb5_authdata_export_attributes(krb5_context kcontext,
1184 krb5_authdata_context context,
1185 krb5_flags usage, krb5_data **pattributes);
1187 krb5_error_code KRB5_CALLCONV
1188 krb5_authdata_export_internal(krb5_context kcontext,
1189 krb5_authdata_context context,
1190 krb5_boolean restrict_authenticated,
1191 const char *module, void **ptr);
1193 krb5_error_code KRB5_CALLCONV
1194 krb5_authdata_context_copy(krb5_context kcontext, krb5_authdata_context src,
1195 krb5_authdata_context *dst);
1197 krb5_error_code KRB5_CALLCONV
1198 krb5_authdata_free_internal(krb5_context kcontext,
1199 krb5_authdata_context context, const char *module,
1202 /*** Plugin framework ***/
1205 * This framework can be used to create pluggable interfaces. Not all existing
1206 * pluggable interface use this framework, but new ones should. A new
1207 * pluggable interface entails:
1209 * - An interface ID definition in the list of #defines below.
1211 * - A name in the interface_names array in lib/krb5/krb/plugins.c.
1213 * - An installed public header file in include/krb5. The public header should
1214 * include <krb5/plugin.h> and should declare a vtable structure for each
1215 * supported major version of the interface.
1217 * - A consumer API implementation, located within the code unit which makes
1218 * use of the pluggable interface. The consumer API should consist of:
1220 * . An interface-specific handle type which contains a vtable structure for
1221 * the module (or a union of several such structures, if there are multiple
1222 * supported major versions) and, optionally, resource data bound to the
1225 * . An interface-specific loader function which creates a handle or list of
1226 * handles. A list of handles would be created if the interface is a
1227 * one-to-many interface where the consumer wants to consult all available
1228 * modules; a single handle would be created for an interface where the
1229 * consumer wants to consult a specific module. The loader function should
1230 * use k5_plugin_load or k5_plugin_load_all to produce one or a list of
1231 * vtable initializer functions, and should use those functions to fill in
1232 * the vtable structure for the module (if necessary, trying each supported
1233 * major version starting from the most recent). The loader function can
1234 * also bind resource data into the handle based on caller arguments, if
1237 * . For each plugin method, a wrapper function which accepts a krb5_context,
1238 * a plugin handle, and the method arguments. Wrapper functions should
1239 * invoke the method function contained in the handle's vtable.
1241 * - Possibly, built-in implementations of the interface, also located within
1242 * the code unit which makes use of the interface. Built-in implementations
1243 * must be registered with k5_plugin_register before the first call to
1244 * k5_plugin_load or k5_plugin_load_all.
1246 * A pluggable interface should have one or more currently supported major
1247 * versions, starting at 1. Each major version should have a current minor
1248 * version, also starting at 1. If new methods are added to a vtable, the
1249 * minor version should be incremented and the vtable stucture should document
1250 * where each minor vtable version ends. If method signatures for a vtable are
1251 * changed, the major version should be incremented.
1253 * Plugin module implementations (either built-in or dynamically loaded) should
1254 * define a function named <interfacename>_<modulename>_initvt, matching the
1255 * signature of krb5_plugin_initvt_fn as declared in include/krb5/plugin.h.
1256 * The initvt function should check the given maj_ver argument against its own
1257 * supported major versions, cast the vtable pointer to the appropriate
1258 * interface-specific vtable type, and fill in the vtable methods, stopping as
1259 * appropriate for the given min_ver. Memory for the vtable structure is
1260 * allocated by the caller, not by the module.
1262 * Dynamic plugin modules are registered with the framework through the
1263 * [plugins] section of the profile, as described in the admin documentation
1264 * and krb5.conf man page.
1268 * A linked list entry mapping a module name to a module initvt function. The
1269 * entry may also include a dynamic object handle so that it can be released
1270 * when the context is destroyed.
1272 struct plugin_mapping {
1274 krb5_plugin_initvt_fn module;
1275 struct plugin_file_handle *dyn_handle;
1276 struct plugin_mapping *next;
1279 /* Holds krb5_context information about each pluggable interface. */
1280 struct plugin_interface {
1281 struct plugin_mapping *modules;
1282 krb5_boolean configured;
1285 /* A list of plugin interface IDs. Make sure to increment
1286 * PLUGIN_NUM_INTERFACES when a new interface is added, and add an entry to the
1287 * interface_names table in lib/krb5/krb/plugin.c. */
1288 #define PLUGIN_INTERFACE_PWQUAL 0
1289 #define PLUGIN_INTERFACE_KADM5_HOOK 1
1290 #define PLUGIN_INTERFACE_CLPREAUTH 2
1291 #define PLUGIN_INTERFACE_KDCPREAUTH 3
1292 #define PLUGIN_INTERFACE_CCSELECT 4
1293 #define PLUGIN_NUM_INTERFACES 5
1295 /* Retrieve the plugin module of type interface_id and name modname,
1296 * storing the result into module. */
1298 k5_plugin_load(krb5_context context, int interface_id, const char *modname,
1299 krb5_plugin_initvt_fn *module);
1301 /* Retrieve all plugin modules of type interface_id, storing the result
1302 * into modules. Free the result with k5_plugin_free_handles. */
1304 k5_plugin_load_all(krb5_context context, int interface_id,
1305 krb5_plugin_initvt_fn **modules);
1307 /* Release a module list allocated by k5_plugin_load_all. */
1309 k5_plugin_free_modules(krb5_context context, krb5_plugin_initvt_fn *modules);
1311 /* Register a plugin module of type interface_id and name modname. */
1313 k5_plugin_register(krb5_context context, int interface_id, const char *modname,
1314 krb5_plugin_initvt_fn module);
1317 * Register a plugin module which is part of the krb5 tree but is built as a
1318 * dynamic plugin. Look for the module in modsubdir relative to the
1319 * context->base_plugin_dir.
1322 k5_plugin_register_dyn(krb5_context context, int interface_id,
1323 const char *modname, const char *modsubdir);
1325 /* Destroy the module state within context; used by krb5_free_context. */
1327 k5_plugin_free_context(krb5_context context);
1329 struct _kdb5_dal_handle; /* private, in kdb5.h */
1330 typedef struct _kdb5_dal_handle kdb5_dal_handle;
1331 struct _kdb_log_context;
1332 typedef struct krb5_preauth_context_st krb5_preauth_context;
1333 struct ccselect_module_handle;
1334 struct _krb5_context {
1336 krb5_enctype *in_tkt_etypes;
1337 krb5_enctype *tgs_etypes;
1338 struct _krb5_os_context os_context;
1339 char *default_realm;
1341 kdb5_dal_handle *dal_handle;
1344 /* allowable clock skew */
1345 krb5_deltat clockskew;
1346 krb5_cksumtype kdc_req_sumtype;
1347 krb5_cksumtype default_ap_req_sumtype;
1348 krb5_cksumtype default_safe_sumtype;
1349 krb5_flags kdc_default_options;
1350 krb5_flags library_options;
1351 krb5_boolean profile_secure;
1352 int fcc_default_format;
1353 krb5_prompt_type *prompt_types;
1354 /* Message size above which we'll try TCP first in send-to-kdc
1355 type code. Aside from the 2**16 size limit, we put no
1356 absolute limit on the UDP packet size. */
1359 /* Use the config-file ktypes instead of app-specified? */
1360 krb5_boolean use_conf_ktypes;
1362 #ifdef KRB5_DNS_LOOKUP
1363 krb5_boolean profile_in_memory;
1364 #endif /* KRB5_DNS_LOOKUP */
1366 /* locate_kdc module stuff */
1367 struct plugin_dir_handle libkrb5_plugins;
1368 struct krb5plugin_service_locate_ftable *vtbl;
1369 void (**locate_fptrs)(void);
1371 /* preauth module stuff */
1372 krb5_preauth_context *preauth_context;
1374 /* cache module stuff */
1375 struct ccselect_module_handle **ccselect_handles;
1377 /* error detail info */
1380 /* For Sun iprop code; does this really have to be here? */
1381 struct _kdb_log_context *kdblog_context;
1383 krb5_boolean allow_weak_crypto;
1384 krb5_boolean ignore_acceptor_hostname;
1386 krb5_trace_callback trace_callback;
1387 void *trace_callback_data;
1389 struct plugin_interface plugins[PLUGIN_NUM_INTERFACES];
1390 char *plugin_base_dir;
1393 /* could be used in a table to find an etype and initialize a block */
1396 #define KRB5_LIBOPT_SYNC_KDCTIME 0x0001
1398 /* internal message representations */
1400 typedef struct _krb5_safe {
1402 krb5_data user_data; /* user data */
1403 krb5_timestamp timestamp; /* client time, optional */
1404 krb5_int32 usec; /* microsecond portion of time,
1406 krb5_ui_4 seq_number; /* sequence #, optional */
1407 krb5_address *s_address; /* sender address */
1408 krb5_address *r_address; /* recipient address, optional */
1409 krb5_checksum *checksum; /* data integrity checksum */
1412 typedef struct _krb5_priv {
1414 krb5_enc_data enc_part; /* encrypted part */
1417 typedef struct _krb5_priv_enc_part {
1419 krb5_data user_data; /* user data */
1420 krb5_timestamp timestamp; /* client time, optional */
1421 krb5_int32 usec; /* microsecond portion of time, opt. */
1422 krb5_ui_4 seq_number; /* sequence #, optional */
1423 krb5_address *s_address; /* sender address */
1424 krb5_address *r_address; /* recipient address, optional */
1425 } krb5_priv_enc_part;
1427 void KRB5_CALLCONV krb5_free_safe(krb5_context, krb5_safe *);
1428 void KRB5_CALLCONV krb5_free_priv(krb5_context, krb5_priv *);
1429 void KRB5_CALLCONV krb5_free_priv_enc_part(krb5_context, krb5_priv_enc_part *);
1437 /* ASN.1 encoding knowledge; KEEP IN SYNC WITH ASN.1 defs! */
1438 /* here we use some knowledge of ASN.1 encodings */
1440 Ticket is APPLICATION 1.
1441 Authenticator is APPLICATION 2.
1442 AS_REQ is APPLICATION 10.
1443 AS_REP is APPLICATION 11.
1444 TGS_REQ is APPLICATION 12.
1445 TGS_REP is APPLICATION 13.
1446 AP_REQ is APPLICATION 14.
1447 AP_REP is APPLICATION 15.
1448 KRB_SAFE is APPLICATION 20.
1449 KRB_PRIV is APPLICATION 21.
1450 KRB_CRED is APPLICATION 22.
1451 EncASRepPart is APPLICATION 25.
1452 EncTGSRepPart is APPLICATION 26.
1453 EncAPRepPart is APPLICATION 27.
1454 EncKrbPrivPart is APPLICATION 28.
1455 EncKrbCredPart is APPLICATION 29.
1456 KRB_ERROR is APPLICATION 30.
1458 /* allow either constructed or primitive encoding, so check for bit 6
1460 #define krb5int_is_app_tag(dat,tag) \
1461 ((dat != NULL) && (dat)->length && \
1462 ((((dat)->data[0] & ~0x20) == ((tag) | 0x40))))
1463 #define krb5_is_krb_ticket(dat) krb5int_is_app_tag(dat, 1)
1464 #define krb5_is_krb_authenticator(dat) krb5int_is_app_tag(dat, 2)
1465 #define krb5_is_as_req(dat) krb5int_is_app_tag(dat, 10)
1466 #define krb5_is_as_rep(dat) krb5int_is_app_tag(dat, 11)
1467 #define krb5_is_tgs_req(dat) krb5int_is_app_tag(dat, 12)
1468 #define krb5_is_tgs_rep(dat) krb5int_is_app_tag(dat, 13)
1469 #define krb5_is_ap_req(dat) krb5int_is_app_tag(dat, 14)
1470 #define krb5_is_ap_rep(dat) krb5int_is_app_tag(dat, 15)
1471 #define krb5_is_krb_safe(dat) krb5int_is_app_tag(dat, 20)
1472 #define krb5_is_krb_priv(dat) krb5int_is_app_tag(dat, 21)
1473 #define krb5_is_krb_cred(dat) krb5int_is_app_tag(dat, 22)
1474 #define krb5_is_krb_enc_as_rep_part(dat) krb5int_is_app_tag(dat, 25)
1475 #define krb5_is_krb_enc_tgs_rep_part(dat) krb5int_is_app_tag(dat, 26)
1476 #define krb5_is_krb_enc_ap_rep_part(dat) krb5int_is_app_tag(dat, 27)
1477 #define krb5_is_krb_enc_krb_priv_part(dat) krb5int_is_app_tag(dat, 28)
1478 #define krb5_is_krb_enc_krb_cred_part(dat) krb5int_is_app_tag(dat, 29)
1479 #define krb5_is_krb_error(dat) krb5int_is_app_tag(dat, 30)
1481 /*************************************************************************
1482 * Prototypes for krb5_encode.c
1483 *************************************************************************/
1486 krb5_error_code encode_krb5_structure(const krb5_structure *rep,
1489 effects Returns the ASN.1 encoding of *rep in **code.
1490 Returns ASN1_MISSING_FIELD if a required field is emtpy in *rep.
1491 Returns ENOMEM if memory runs out.
1495 encode_krb5_authenticator(const krb5_authenticator *rep, krb5_data **code);
1498 encode_krb5_ticket(const krb5_ticket *rep, krb5_data **code);
1501 encode_krb5_enc_tkt_part(const krb5_enc_tkt_part *rep, krb5_data **code);
1504 encode_krb5_enc_kdc_rep_part(const krb5_enc_kdc_rep_part *rep,
1507 /* yes, the translation is identical to that used for KDC__REP */
1509 encode_krb5_as_rep(const krb5_kdc_rep *rep, krb5_data **code);
1511 /* yes, the translation is identical to that used for KDC__REP */
1513 encode_krb5_tgs_rep(const krb5_kdc_rep *rep, krb5_data **code);
1516 encode_krb5_ap_req(const krb5_ap_req *rep, krb5_data **code);
1519 encode_krb5_ap_rep(const krb5_ap_rep *rep, krb5_data **code);
1522 encode_krb5_ap_rep_enc_part(const krb5_ap_rep_enc_part *rep, krb5_data **code);
1525 encode_krb5_as_req(const krb5_kdc_req *rep, krb5_data **code);
1528 encode_krb5_tgs_req(const krb5_kdc_req *rep, krb5_data **code);
1531 encode_krb5_kdc_req_body(const krb5_kdc_req *rep, krb5_data **code);
1534 encode_krb5_safe(const krb5_safe *rep, krb5_data **code);
1536 struct krb5_safe_with_body {
1541 encode_krb5_safe_with_body(const struct krb5_safe_with_body *rep,
1545 encode_krb5_priv(const krb5_priv *rep, krb5_data **code);
1548 encode_krb5_enc_priv_part(const krb5_priv_enc_part *rep, krb5_data **code);
1551 encode_krb5_cred(const krb5_cred *rep, krb5_data **code);
1553 encode_krb5_checksum(const krb5_checksum *, krb5_data **);
1556 encode_krb5_enc_cred_part(const krb5_cred_enc_part *rep, krb5_data **code);
1559 encode_krb5_error(const krb5_error *rep, krb5_data **code);
1562 encode_krb5_authdata(krb5_authdata *const *rep, krb5_data **code);
1565 encode_krb5_padata_sequence(krb5_pa_data *const *rep, krb5_data **code);
1568 encode_krb5_typed_data(krb5_pa_data *const *rep, krb5_data **code);
1571 encode_krb5_etype_info(krb5_etype_info_entry *const *, krb5_data **code);
1574 encode_krb5_etype_info2(krb5_etype_info_entry *const *, krb5_data **code);
1577 encode_krb5_pa_enc_ts(const krb5_pa_enc_ts *, krb5_data **);
1580 encode_krb5_sam_challenge_2(const krb5_sam_challenge_2 * , krb5_data **);
1583 encode_krb5_sam_challenge_2_body(const krb5_sam_challenge_2_body *,
1587 encode_krb5_enc_sam_response_enc_2(const krb5_enc_sam_response_enc_2 *,
1591 encode_krb5_sam_response_2(const krb5_sam_response_2 * , krb5_data **);
1593 struct krb5_setpw_req {
1594 krb5_principal target;
1598 encode_krb5_setpw_req(const struct krb5_setpw_req *rep, krb5_data **code);
1601 encode_krb5_pa_for_user(const krb5_pa_for_user *, krb5_data **);
1604 encode_krb5_s4u_userid(const krb5_s4u_userid *, krb5_data **);
1607 encode_krb5_pa_s4u_x509_user(const krb5_pa_s4u_x509_user *, krb5_data **);
1610 encode_krb5_pa_pac_req(const krb5_pa_pac_req *, krb5_data **);
1613 encode_krb5_etype_list(const krb5_etype_list * , krb5_data **);
1616 encode_krb5_pa_fx_fast_request(const krb5_fast_armored_req *, krb5_data **);
1619 encode_krb5_fast_req(const krb5_fast_req *, krb5_data **);
1622 encode_krb5_pa_fx_fast_reply(const krb5_enc_data *, krb5_data **);
1625 encode_krb5_iakerb_header(const krb5_iakerb_header *, krb5_data **);
1628 encode_krb5_iakerb_finished(const krb5_iakerb_finished *, krb5_data **);
1631 encode_krb5_fast_response(const krb5_fast_response *, krb5_data **);
1634 encode_krb5_ad_kdcissued(const krb5_ad_kdcissued *, krb5_data **);
1637 encode_krb5_ad_signedpath(const krb5_ad_signedpath *, krb5_data **);
1640 encode_krb5_ad_signedpath_data(const krb5_ad_signedpath_data *, krb5_data **);
1642 /*************************************************************************
1643 * End of prototypes for krb5_encode.c
1644 *************************************************************************/
1647 decode_krb5_sam_challenge_2(const krb5_data *, krb5_sam_challenge_2 **);
1650 decode_krb5_sam_challenge_2_body(const krb5_data *,
1651 krb5_sam_challenge_2_body **);
1654 decode_krb5_enc_sam_response_enc_2(const krb5_data *,
1655 krb5_enc_sam_response_enc_2 **);
1658 decode_krb5_sam_response_2(const krb5_data *, krb5_sam_response_2 **);
1661 /*************************************************************************
1662 * Prototypes for krb5_decode.c
1663 *************************************************************************/
1665 krb5_error_code decode_krb5_structure(const krb5_data *code,
1666 krb5_structure **rep);
1668 requires Expects **rep to not have been allocated;
1669 a new *rep is allocated regardless of the old value.
1670 effects Decodes *code into **rep.
1671 Returns ENOMEM if memory is exhausted.
1672 Returns asn1 and krb5 errors.
1676 decode_krb5_authenticator(const krb5_data *code, krb5_authenticator **rep);
1679 decode_krb5_ticket(const krb5_data *code, krb5_ticket **rep);
1682 decode_krb5_encryption_key(const krb5_data *output, krb5_keyblock **rep);
1685 decode_krb5_enc_tkt_part(const krb5_data *output, krb5_enc_tkt_part **rep);
1688 decode_krb5_enc_kdc_rep_part(const krb5_data *output,
1689 krb5_enc_kdc_rep_part **rep);
1692 decode_krb5_as_rep(const krb5_data *output, krb5_kdc_rep **rep);
1695 decode_krb5_tgs_rep(const krb5_data *output, krb5_kdc_rep **rep);
1698 decode_krb5_ap_req(const krb5_data *output, krb5_ap_req **rep);
1701 decode_krb5_ap_rep(const krb5_data *output, krb5_ap_rep **rep);
1704 decode_krb5_ap_rep_enc_part(const krb5_data *output,
1705 krb5_ap_rep_enc_part **rep);
1708 decode_krb5_as_req(const krb5_data *output, krb5_kdc_req **rep);
1711 decode_krb5_tgs_req(const krb5_data *output, krb5_kdc_req **rep);
1714 decode_krb5_kdc_req_body(const krb5_data *output, krb5_kdc_req **rep);
1717 decode_krb5_safe(const krb5_data *output, krb5_safe **rep);
1720 decode_krb5_safe_with_body(const krb5_data *output, krb5_safe **rep,
1724 decode_krb5_priv(const krb5_data *output, krb5_priv **rep);
1727 decode_krb5_enc_priv_part(const krb5_data *output, krb5_priv_enc_part **rep);
1729 decode_krb5_checksum(const krb5_data *, krb5_checksum **);
1732 decode_krb5_cred(const krb5_data *output, krb5_cred **rep);
1735 decode_krb5_enc_cred_part(const krb5_data *output, krb5_cred_enc_part **rep);
1738 decode_krb5_error(const krb5_data *output, krb5_error **rep);
1741 decode_krb5_authdata(const krb5_data *output, krb5_authdata ***rep);
1744 decode_krb5_padata_sequence(const krb5_data *output, krb5_pa_data ***rep);
1747 decode_krb5_typed_data(const krb5_data *, krb5_pa_data ***);
1750 decode_krb5_etype_info(const krb5_data *output, krb5_etype_info_entry ***rep);
1753 decode_krb5_etype_info2(const krb5_data *output, krb5_etype_info_entry ***rep);
1756 decode_krb5_enc_data(const krb5_data *output, krb5_enc_data **rep);
1759 decode_krb5_pa_enc_ts(const krb5_data *output, krb5_pa_enc_ts **rep);
1762 decode_krb5_setpw_req(const krb5_data *, krb5_data **, krb5_principal *);
1765 decode_krb5_pa_for_user(const krb5_data *, krb5_pa_for_user **);
1768 decode_krb5_pa_s4u_x509_user(const krb5_data *, krb5_pa_s4u_x509_user **);
1771 decode_krb5_pa_pac_req(const krb5_data *, krb5_pa_pac_req **);
1774 decode_krb5_etype_list(const krb5_data *, krb5_etype_list **);
1777 decode_krb5_pa_fx_fast_request(const krb5_data *, krb5_fast_armored_req **);
1780 decode_krb5_fast_req(const krb5_data *, krb5_fast_req **);
1783 decode_krb5_pa_fx_fast_reply(const krb5_data *, krb5_enc_data **);
1786 decode_krb5_fast_response(const krb5_data *, krb5_fast_response **);
1789 decode_krb5_ad_kdcissued(const krb5_data *, krb5_ad_kdcissued **);
1792 decode_krb5_ad_signedpath(const krb5_data *, krb5_ad_signedpath **);
1795 decode_krb5_iakerb_header(const krb5_data *, krb5_iakerb_header **);
1798 decode_krb5_iakerb_finished(const krb5_data *, krb5_iakerb_finished **);
1800 struct _krb5_key_data; /* kdb.h */
1802 struct ldap_seqof_key_data {
1803 krb5_int32 mkvno; /* Master key version number */
1804 krb5_int16 kvno; /* kvno of key_data elements (all the same) */
1805 struct _krb5_key_data *key_data;
1806 krb5_int16 n_key_data;
1808 typedef struct ldap_seqof_key_data ldap_seqof_key_data;
1811 krb5int_ldap_encode_sequence_of_keys(const ldap_seqof_key_data *val,
1815 krb5int_ldap_decode_sequence_of_keys(const krb5_data *in,
1816 ldap_seqof_key_data **rep);
1818 /*************************************************************************
1819 * End of prototypes for krb5_decode.c
1820 *************************************************************************/
1822 #endif /* KRB5_ASN1__ */
1829 * Internal krb5 library routines
1832 krb5_encrypt_tkt_part(krb5_context, const krb5_keyblock *, krb5_ticket *);
1835 krb5_encode_kdc_rep(krb5_context, krb5_msgtype, const krb5_enc_kdc_rep_part *,
1836 int using_subkey, const krb5_keyblock *, krb5_kdc_rep *,
1840 * [De]Serialization Handle and operations.
1842 struct __krb5_serializer {
1844 krb5_error_code (*sizer) (krb5_context,
1847 krb5_error_code (*externalizer) (krb5_context,
1851 krb5_error_code (*internalizer) (krb5_context,
1856 typedef const struct __krb5_serializer * krb5_ser_handle;
1857 typedef struct __krb5_serializer krb5_ser_entry;
1859 krb5_ser_handle krb5_find_serializer(krb5_context, krb5_magic);
1860 krb5_error_code krb5_register_serializer(krb5_context, const krb5_ser_entry *);
1862 /* Determine the external size of a particular opaque structure */
1863 krb5_error_code KRB5_CALLCONV
1864 krb5_size_opaque(krb5_context, krb5_magic, krb5_pointer, size_t *);
1866 /* Serialize the structure into a buffer */
1867 krb5_error_code KRB5_CALLCONV
1868 krb5_externalize_opaque(krb5_context, krb5_magic, krb5_pointer, krb5_octet **,
1871 /* Deserialize the structure from a buffer */
1872 krb5_error_code KRB5_CALLCONV
1873 krb5_internalize_opaque(krb5_context, krb5_magic, krb5_pointer *,
1874 krb5_octet **, size_t *);
1876 /* Serialize data into a buffer */
1878 krb5_externalize_data(krb5_context, krb5_pointer, krb5_octet **, size_t *);
1880 * Initialization routines.
1883 /* Initialize serialization for krb5_[os_]context */
1884 krb5_error_code KRB5_CALLCONV krb5_ser_context_init(krb5_context);
1886 /* Initialize serialization for krb5_auth_context */
1887 krb5_error_code KRB5_CALLCONV krb5_ser_auth_context_init(krb5_context);
1889 /* Initialize serialization for krb5_keytab */
1890 krb5_error_code KRB5_CALLCONV krb5_ser_keytab_init(krb5_context);
1892 /* Initialize serialization for krb5_ccache */
1893 krb5_error_code KRB5_CALLCONV krb5_ser_ccache_init(krb5_context);
1895 /* Initialize serialization for krb5_rcache */
1896 krb5_error_code KRB5_CALLCONV krb5_ser_rcache_init(krb5_context);
1898 /* [De]serialize 4-byte integer */
1899 krb5_error_code KRB5_CALLCONV
1900 krb5_ser_pack_int32(krb5_int32, krb5_octet **, size_t *);
1902 krb5_error_code KRB5_CALLCONV
1903 krb5_ser_unpack_int32(krb5_int32 *, krb5_octet **, size_t *);
1905 /* [De]serialize 8-byte integer */
1906 krb5_error_code KRB5_CALLCONV
1907 krb5_ser_pack_int64(krb5_int64, krb5_octet **, size_t *);
1909 krb5_error_code KRB5_CALLCONV
1910 krb5_ser_unpack_int64(krb5_int64 *, krb5_octet **, size_t *);
1912 /* [De]serialize byte string */
1913 krb5_error_code KRB5_CALLCONV
1914 krb5_ser_pack_bytes(krb5_octet *, size_t, krb5_octet **, size_t *);
1916 krb5_error_code KRB5_CALLCONV
1917 krb5_ser_unpack_bytes(krb5_octet *, size_t, krb5_octet **, size_t *);
1919 krb5_error_code KRB5_CALLCONV
1920 krb5int_cc_default(krb5_context, krb5_ccache *);
1922 krb5_error_code KRB5_CALLCONV
1923 krb5_cc_retrieve_cred_default(krb5_context, krb5_ccache, krb5_flags,
1924 krb5_creds *, krb5_creds *);
1926 krb5_boolean KRB5_CALLCONV
1927 krb5_creds_compare(krb5_context in_context, krb5_creds *in_creds,
1928 krb5_creds *in_compare_creds);
1931 krb5int_set_prompt_types(krb5_context, krb5_prompt_type *);
1934 krb5int_generate_and_save_subkey(krb5_context, krb5_auth_context,
1935 krb5_keyblock * /* Old keyblock, not new! */,
1938 struct srv_dns_entry {
1939 struct srv_dns_entry *next;
1942 unsigned short port;
1946 #define MAX_DNS_NAMELEN (15*(MAXHOSTNAMELEN + 1)+1)
1948 #ifdef KRB5_DNS_LOOKUP
1950 krb5int_make_srv_query_realm(const krb5_data *realm,
1951 const char *service,
1952 const char *protocol,
1953 struct srv_dns_entry **answers);
1954 void krb5int_free_srv_dns_data(struct srv_dns_entry *);
1957 /* value to use when requesting a keytab entry and KVNO doesn't matter */
1958 #define IGNORE_VNO 0
1959 /* value to use when requesting a keytab entry and enctype doesn't matter */
1960 #define IGNORE_ENCTYPE 0
1963 * Convenience function for structure magic number
1965 #define KRB5_VERIFY_MAGIC(structure,magic_number) \
1966 if ((structure)->magic != (magic_number)) return (magic_number);
1968 /* to keep lint happy */
1969 #define krb5_xfree(val) free((char *)(val))
1971 /* To keep happy libraries which are (for now) accessing internal stuff */
1973 /* Make sure to increment by one when changing the struct */
1974 #define KRB5INT_ACCESS_STRUCT_VERSION 21
1976 typedef struct _krb5int_access {
1977 krb5_error_code (*auth_con_get_subkey_enctype)(krb5_context,
1981 krb5_error_code (*clean_hostname)(krb5_context, const char *, char *,
1984 krb5_error_code (*mandatory_cksumtype)(krb5_context, krb5_enctype,
1986 krb5_error_code (KRB5_CALLCONV *ser_pack_int64)(krb5_int64, krb5_octet **,
1988 krb5_error_code (KRB5_CALLCONV *ser_unpack_int64)(krb5_int64 *,
1989 krb5_octet **, size_t *);
1991 /* Used for KDB LDAP back end. */
1993 (*asn1_ldap_encode_sequence_of_keys)(const ldap_seqof_key_data *val,
1997 (*asn1_ldap_decode_sequence_of_keys)(krb5_data *in,
1998 ldap_seqof_key_data **);
2001 * pkinit asn.1 encode/decode functions
2004 (*encode_krb5_auth_pack)(const krb5_auth_pack *rep, krb5_data **code);
2007 (*encode_krb5_auth_pack_draft9)(const krb5_auth_pack_draft9 *rep,
2011 (*encode_krb5_kdc_dh_key_info)(const krb5_kdc_dh_key_info *rep,
2015 (*encode_krb5_pa_pk_as_rep)(const krb5_pa_pk_as_rep *rep,
2019 (*encode_krb5_pa_pk_as_rep_draft9)(const krb5_pa_pk_as_rep_draft9 *rep,
2023 (*encode_krb5_pa_pk_as_req)(const krb5_pa_pk_as_req *rep,
2027 (*encode_krb5_pa_pk_as_req_draft9)(const krb5_pa_pk_as_req_draft9 *rep,
2031 (*encode_krb5_reply_key_pack)(const krb5_reply_key_pack *,
2035 (*encode_krb5_reply_key_pack_draft9)(const krb5_reply_key_pack_draft9 *,
2039 (*encode_krb5_td_dh_parameters)(const krb5_algorithm_identifier **,
2043 (*encode_krb5_td_trusted_certifiers)(const
2044 krb5_external_principal_identifier **,
2048 (*decode_krb5_auth_pack)(const krb5_data *, krb5_auth_pack **);
2051 (*decode_krb5_auth_pack_draft9)(const krb5_data *,
2052 krb5_auth_pack_draft9 **);
2055 (*decode_krb5_pa_pk_as_req)(const krb5_data *, krb5_pa_pk_as_req **);
2058 (*decode_krb5_pa_pk_as_req_draft9)(const krb5_data *,
2059 krb5_pa_pk_as_req_draft9 **);
2062 (*decode_krb5_pa_pk_as_rep)(const krb5_data *, krb5_pa_pk_as_rep **);
2065 (*decode_krb5_kdc_dh_key_info)(const krb5_data *, krb5_kdc_dh_key_info **);
2068 (*decode_krb5_principal_name)(const krb5_data *, krb5_principal_data **);
2071 (*decode_krb5_reply_key_pack)(const krb5_data *, krb5_reply_key_pack **);
2074 (*decode_krb5_reply_key_pack_draft9)(const krb5_data *,
2075 krb5_reply_key_pack_draft9 **);
2078 (*decode_krb5_td_dh_parameters)(const krb5_data *,
2079 krb5_algorithm_identifier ***);
2082 (*decode_krb5_td_trusted_certifiers)(const krb5_data *,
2083 krb5_external_principal_identifier
2087 (*encode_krb5_kdc_req_body)(const krb5_kdc_req *rep, krb5_data **code);
2090 (KRB5_CALLCONV *free_kdc_req)(krb5_context, krb5_kdc_req * );
2092 (*set_prompt_types)(krb5_context, krb5_prompt_type *);
2095 #define KRB5INT_ACCESS_VERSION \
2096 (((krb5_int32)((sizeof(krb5int_access) & 0xFFFF) | \
2097 (KRB5INT_ACCESS_STRUCT_VERSION << 16))) & 0xFFFFFFFF)
2099 krb5_error_code KRB5_CALLCONV
2100 krb5int_accessor(krb5int_access*, krb5_int32);
2102 /* Ick -- some krb524 and krb4 support placed in the krb5 library,
2103 because AFS (and potentially other applications?) use the krb4
2104 object as an opaque token, which (in some implementations) is not
2105 in fact a krb4 ticket, so we don't want to drag in the krb4 support
2106 just to enable this. */
2108 #define KRB524_SERVICE "krb524"
2109 #define KRB524_PORT 4444
2111 /* temporary -- this should be under lib/krb5/ccache somewhere */
2113 struct _krb5_ccache {
2115 const struct _krb5_cc_ops *ops;
2120 * Per-type ccache cursor.
2122 struct krb5_cc_ptcursor_s {
2123 const struct _krb5_cc_ops *ops;
2126 typedef struct krb5_cc_ptcursor_s *krb5_cc_ptcursor;
2128 struct _krb5_cc_ops {
2131 const char * (KRB5_CALLCONV *get_name)(krb5_context, krb5_ccache);
2132 krb5_error_code (KRB5_CALLCONV *resolve)(krb5_context, krb5_ccache *,
2134 krb5_error_code (KRB5_CALLCONV *gen_new)(krb5_context, krb5_ccache *);
2135 krb5_error_code (KRB5_CALLCONV *init)(krb5_context, krb5_ccache,
2137 krb5_error_code (KRB5_CALLCONV *destroy)(krb5_context, krb5_ccache);
2138 krb5_error_code (KRB5_CALLCONV *close)(krb5_context, krb5_ccache);
2139 krb5_error_code (KRB5_CALLCONV *store)(krb5_context, krb5_ccache,
2141 krb5_error_code (KRB5_CALLCONV *retrieve)(krb5_context, krb5_ccache,
2142 krb5_flags, krb5_creds *,
2144 krb5_error_code (KRB5_CALLCONV *get_princ)(krb5_context, krb5_ccache,
2146 krb5_error_code (KRB5_CALLCONV *get_first)(krb5_context, krb5_ccache,
2148 krb5_error_code (KRB5_CALLCONV *get_next)(krb5_context, krb5_ccache,
2149 krb5_cc_cursor *, krb5_creds *);
2150 krb5_error_code (KRB5_CALLCONV *end_get)(krb5_context, krb5_ccache,
2152 krb5_error_code (KRB5_CALLCONV *remove_cred)(krb5_context, krb5_ccache,
2153 krb5_flags, krb5_creds *);
2154 krb5_error_code (KRB5_CALLCONV *set_flags)(krb5_context, krb5_ccache,
2156 krb5_error_code (KRB5_CALLCONV *get_flags)(krb5_context, krb5_ccache,
2158 krb5_error_code (KRB5_CALLCONV *ptcursor_new)(krb5_context,
2159 krb5_cc_ptcursor *);
2160 krb5_error_code (KRB5_CALLCONV *ptcursor_next)(krb5_context,
2163 krb5_error_code (KRB5_CALLCONV *ptcursor_free)(krb5_context,
2164 krb5_cc_ptcursor *);
2165 krb5_error_code (KRB5_CALLCONV *move)(krb5_context, krb5_ccache,
2167 krb5_error_code (KRB5_CALLCONV *lastchange)(krb5_context,
2168 krb5_ccache, krb5_timestamp *);
2169 krb5_error_code (KRB5_CALLCONV *wasdefault)(krb5_context, krb5_ccache,
2171 krb5_error_code (KRB5_CALLCONV *lock)(krb5_context, krb5_ccache);
2172 krb5_error_code (KRB5_CALLCONV *unlock)(krb5_context, krb5_ccache);
2173 krb5_error_code (KRB5_CALLCONV *switch_to)(krb5_context, krb5_ccache);
2176 extern const krb5_cc_ops *krb5_cc_dfl_ops;
2179 krb5int_cc_os_default_name(krb5_context context, char **name);
2181 typedef struct _krb5_donot_replay {
2184 char *server; /* null-terminated */
2185 char *client; /* null-terminated */
2186 char *msghash; /* null-terminated */
2188 krb5_timestamp ctime;
2189 } krb5_donot_replay;
2191 krb5_error_code krb5_rc_default(krb5_context, krb5_rcache *);
2192 krb5_error_code krb5_rc_resolve_type(krb5_context, krb5_rcache *,char *);
2193 krb5_error_code krb5_rc_resolve_full(krb5_context, krb5_rcache *,char *);
2194 char *krb5_rc_get_type(krb5_context, krb5_rcache);
2195 char *krb5_rc_default_type(krb5_context);
2196 char *krb5_rc_default_name(krb5_context);
2197 krb5_error_code krb5_auth_to_rep(krb5_context, krb5_tkt_authent *,
2198 krb5_donot_replay *);
2199 krb5_error_code krb5_rc_hash_message(krb5_context context,
2200 const krb5_data *message, char **out);
2202 krb5_error_code KRB5_CALLCONV
2203 krb5_rc_initialize(krb5_context, krb5_rcache, krb5_deltat);
2205 krb5_error_code KRB5_CALLCONV
2206 krb5_rc_recover_or_initialize(krb5_context, krb5_rcache,krb5_deltat);
2208 krb5_error_code KRB5_CALLCONV
2209 krb5_rc_recover(krb5_context, krb5_rcache);
2211 krb5_error_code KRB5_CALLCONV
2212 krb5_rc_destroy(krb5_context, krb5_rcache);
2214 krb5_error_code KRB5_CALLCONV
2215 krb5_rc_close(krb5_context, krb5_rcache);
2217 krb5_error_code KRB5_CALLCONV
2218 krb5_rc_store(krb5_context, krb5_rcache, krb5_donot_replay *);
2220 krb5_error_code KRB5_CALLCONV
2221 krb5_rc_expunge(krb5_context, krb5_rcache);
2223 krb5_error_code KRB5_CALLCONV
2224 krb5_rc_get_lifespan(krb5_context, krb5_rcache,krb5_deltat *);
2227 krb5_rc_get_name(krb5_context, krb5_rcache);
2229 krb5_error_code KRB5_CALLCONV
2230 krb5_rc_resolve(krb5_context, krb5_rcache, char *);
2233 * This structure was exposed and used in macros in krb5 1.2, so do not
2236 typedef struct _krb5_kt_ops {
2240 /* routines always present */
2241 krb5_error_code (KRB5_CALLCONV *resolve)(krb5_context, const char *,
2243 krb5_error_code (KRB5_CALLCONV *get_name)(krb5_context, krb5_keytab,
2244 char *, unsigned int);
2245 krb5_error_code (KRB5_CALLCONV *close)(krb5_context, krb5_keytab);
2246 krb5_error_code (KRB5_CALLCONV *get)(krb5_context, krb5_keytab,
2247 krb5_const_principal, krb5_kvno,
2248 krb5_enctype, krb5_keytab_entry *);
2249 krb5_error_code (KRB5_CALLCONV *start_seq_get)(krb5_context, krb5_keytab,
2251 krb5_error_code (KRB5_CALLCONV *get_next)(krb5_context, krb5_keytab,
2252 krb5_keytab_entry *,
2254 krb5_error_code (KRB5_CALLCONV *end_get)(krb5_context, krb5_keytab,
2256 /* routines to be included on extended version (write routines) */
2257 krb5_error_code (KRB5_CALLCONV *add)(krb5_context, krb5_keytab,
2258 krb5_keytab_entry *);
2259 krb5_error_code (KRB5_CALLCONV *remove)(krb5_context, krb5_keytab,
2260 krb5_keytab_entry *);
2262 /* Handle for serializer */
2263 const krb5_ser_entry *serializer;
2266 extern const krb5_kt_ops krb5_kt_dfl_ops;
2268 extern krb5_error_code krb5int_translate_gai_error(int);
2270 /* Not sure it's ready for exposure just yet. */
2271 extern krb5_error_code
2272 krb5int_c_mandatory_cksumtype(krb5_context, krb5_enctype, krb5_cksumtype *);
2275 * Referral definitions and subfunctions.
2277 #define KRB5_REFERRAL_MAXHOPS 10
2279 /* Common hostname-parsing code. */
2281 krb5int_clean_hostname(krb5_context, const char *, char *, size_t);
2285 * There are no IANA assignments for these enctypes or cksumtypes yet. They
2286 * must be defined to local-use negative numbers at build time for Camellia
2287 * support to function at the moment. If one is defined, they should all be
2288 * defined. When IANA assignments exist, these definitions should move to the
2289 * appropriate places in krb5.hin and all CAMELLIA conditional code should be
2290 * made unconditional.
2292 * The present code is experimental and may not be compatible with the
2293 * standardized version.
2295 #define ENCTYPE_CAMELLIA128_CTS_CMAC -XXX /* Camellia CTS mode, 128-bit key */
2296 #define ENCTYPE_CAMELLIA256_CTS_CMAC -YYY /* Camellia CTS mode, 256-bit key */
2297 #define CKSUMTYPE_CMAC_CAMELLIA128 -XXX /* CMAC, 128-bit Camellia key */
2298 #define CKSUMTYPE_CMAC_CAMELLIA256 -YYY /* CMAC, 256-bit Camellia key */
2301 #ifdef ENCTYPE_CAMELLIA128_CTS_CMAC
2305 struct _krb5_kt { /* should move into k5-int.h */
2307 const struct _krb5_kt_ops *ops;
2311 krb5_error_code krb5_set_default_in_tkt_ktypes(krb5_context,
2312 const krb5_enctype *);
2314 krb5_error_code krb5_get_default_in_tkt_ktypes(krb5_context, krb5_enctype **);
2316 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context,
2317 const krb5_enctype *);
2319 krb5_error_code KRB5_CALLCONV
2320 krb5_get_tgs_ktypes(krb5_context, krb5_const_principal, krb5_enctype **);
2322 void KRB5_CALLCONV krb5_free_ktypes(krb5_context, krb5_enctype *);
2324 krb5_boolean krb5_is_permitted_enctype(krb5_context, krb5_enctype);
2328 krb5_enctype *etype;
2329 krb5_boolean *etype_ok;
2330 krb5_int32 etype_count;
2331 } krb5_etypes_permitted;
2333 krb5_boolean krb5_is_permitted_enctype_ext(krb5_context,
2334 krb5_etypes_permitted *);
2336 krb5_boolean KRB5_CALLCONV krb5int_c_weak_enctype(krb5_enctype);
2338 krb5_error_code krb5_kdc_rep_decrypt_proc(krb5_context, const krb5_keyblock *,
2339 krb5_const_pointer, krb5_kdc_rep *);
2340 krb5_error_code KRB5_CALLCONV krb5_decrypt_tkt_part(krb5_context,
2341 const krb5_keyblock *,
2344 krb5_error_code krb5_get_cred_via_tkt(krb5_context, krb5_creds *, krb5_flags,
2345 krb5_address *const *, krb5_creds *,
2348 krb5_error_code KRB5_CALLCONV krb5_copy_addr(krb5_context,
2349 const krb5_address *,
2352 void krb5_init_ets(krb5_context);
2353 void krb5_free_ets(krb5_context);
2354 krb5_error_code krb5_generate_subkey(krb5_context, const krb5_keyblock *,
2356 krb5_error_code krb5_generate_subkey_extended(krb5_context,
2357 const krb5_keyblock *,
2358 krb5_enctype, krb5_keyblock **);
2359 krb5_error_code krb5_generate_seq_number(krb5_context, const krb5_keyblock *,
2362 krb5_error_code KRB5_CALLCONV krb5_kt_register(krb5_context,
2363 const struct _krb5_kt_ops *);
2365 krb5_error_code k5_kt_get_principal(krb5_context context, krb5_keytab keytab,
2366 krb5_principal *princ_out);
2368 krb5_error_code krb5_principal2salt_norealm(krb5_context, krb5_const_principal,
2371 unsigned int KRB5_CALLCONV krb5_get_notification_message(void);
2374 krb5_error_code krb5_check_transited_list(krb5_context, const krb5_data *trans,
2375 const krb5_data *realm1,
2376 const krb5_data *realm2);
2379 void krb5_free_realm_tree(krb5_context, krb5_principal *);
2381 void KRB5_CALLCONV krb5_free_authenticator_contents(krb5_context,
2382 krb5_authenticator *);
2384 void KRB5_CALLCONV krb5_free_address(krb5_context, krb5_address *);
2386 void KRB5_CALLCONV krb5_free_enc_tkt_part(krb5_context, krb5_enc_tkt_part *);
2388 void KRB5_CALLCONV krb5_free_tickets(krb5_context, krb5_ticket **);
2389 void KRB5_CALLCONV krb5_free_kdc_req(krb5_context, krb5_kdc_req *);
2390 void KRB5_CALLCONV krb5_free_kdc_rep(krb5_context, krb5_kdc_rep *);
2391 void KRB5_CALLCONV krb5_free_last_req(krb5_context, krb5_last_req_entry **);
2392 void KRB5_CALLCONV krb5_free_enc_kdc_rep_part(krb5_context,
2393 krb5_enc_kdc_rep_part *);
2394 void KRB5_CALLCONV krb5_free_ap_req(krb5_context, krb5_ap_req *);
2395 void KRB5_CALLCONV krb5_free_ap_rep(krb5_context, krb5_ap_rep *);
2396 void KRB5_CALLCONV krb5_free_cred(krb5_context, krb5_cred *);
2397 void KRB5_CALLCONV krb5_free_cred_enc_part(krb5_context, krb5_cred_enc_part *);
2398 void KRB5_CALLCONV krb5_free_pa_data(krb5_context, krb5_pa_data **);
2399 void KRB5_CALLCONV krb5_free_tkt_authent(krb5_context, krb5_tkt_authent *);
2400 void KRB5_CALLCONV krb5_free_enc_data(krb5_context, krb5_enc_data *);
2401 krb5_error_code krb5_set_config_files(krb5_context, const char **);
2403 krb5_error_code KRB5_CALLCONV krb5_get_default_config_files(char ***filenames);
2405 void KRB5_CALLCONV krb5_free_config_files(char **filenames);
2407 krb5_error_code krb5_rd_req_decoded(krb5_context, krb5_auth_context *,
2408 const krb5_ap_req *, krb5_const_principal,
2409 krb5_keytab, krb5_flags *, krb5_ticket **);
2411 krb5_error_code krb5_rd_req_decoded_anyflag(krb5_context, krb5_auth_context *,
2412 const krb5_ap_req *,
2413 krb5_const_principal, krb5_keytab,
2414 krb5_flags *, krb5_ticket **);
2416 krb5_error_code KRB5_CALLCONV
2417 krb5_cc_register(krb5_context, const krb5_cc_ops *, krb5_boolean );
2419 krb5_error_code krb5_walk_realm_tree(krb5_context, const krb5_data *,
2420 const krb5_data *, krb5_principal **,
2424 k5_client_realm_path(krb5_context context, const krb5_data *client,
2425 const krb5_data *server, krb5_data **rpath_out);
2428 krb5_auth_con_set_safe_cksumtype(krb5_context, krb5_auth_context,
2431 krb5_error_code krb5_auth_con_setivector(krb5_context, krb5_auth_context,
2434 krb5_error_code krb5_auth_con_getivector(krb5_context, krb5_auth_context,
2437 krb5_error_code krb5_auth_con_setpermetypes(krb5_context, krb5_auth_context,
2438 const krb5_enctype *);
2440 krb5_error_code krb5_auth_con_getpermetypes(krb5_context, krb5_auth_context,
2443 krb5_error_code krb5_auth_con_get_subkey_enctype(krb5_context context,
2448 krb5_auth_con_get_authdata_context(krb5_context context,
2449 krb5_auth_context auth_context,
2450 krb5_authdata_context *ad_context);
2453 krb5_auth_con_set_authdata_context(krb5_context context,
2454 krb5_auth_context auth_context,
2455 krb5_authdata_context ad_context);
2457 krb5_error_code KRB5_CALLCONV
2458 krb5int_server_decrypt_ticket_keyblock(krb5_context context,
2459 const krb5_keyblock *key,
2460 krb5_ticket *ticket);
2462 krb5_error_code krb5_read_message(krb5_context, krb5_pointer, krb5_data *);
2463 krb5_error_code krb5_write_message(krb5_context, krb5_pointer, krb5_data *);
2464 krb5_error_code krb5int_write_messages(krb5_context, krb5_pointer, krb5_data *,
2466 int krb5_net_read(krb5_context, int , char *, int);
2467 int krb5_net_write(krb5_context, int , const char *, int);
2469 krb5_error_code KRB5_CALLCONV krb5_get_realm_domain(krb5_context,
2470 const char *, char ** );
2472 krb5_error_code krb5_gen_portaddr(krb5_context, const krb5_address *,
2473 krb5_const_pointer, krb5_address **);
2475 krb5_error_code krb5_gen_replay_name(krb5_context, const krb5_address *,
2476 const char *, char **);
2477 krb5_error_code krb5_make_fulladdr(krb5_context, krb5_address *,
2478 krb5_address *, krb5_address *);
2480 krb5_error_code krb5_set_debugging_time(krb5_context, krb5_timestamp,
2482 krb5_error_code krb5_use_natural_time(krb5_context);
2483 krb5_error_code krb5_set_time_offsets(krb5_context, krb5_timestamp,
2486 /* Internal principal function used by KIM to avoid code duplication */
2487 krb5_error_code KRB5_CALLCONV
2488 krb5int_build_principal_alloc_va(krb5_context context,
2489 krb5_principal *princ,
2495 /* Some data comparison and conversion functions. */
2497 data_eq(krb5_data d1, krb5_data d2)
2499 return (d1.length == d2.length && !memcmp(d1.data, d2.data, d1.length));
2503 data_eq_string (krb5_data d, const char *s)
2505 return (d.length == strlen(s) && !memcmp(d.data, s, d.length));
2508 static inline krb5_data
2509 make_data(void *data, unsigned int len)
2513 d.magic = KV5M_DATA;
2514 d.data = (char *) data;
2519 static inline krb5_data
2522 return make_data(NULL, 0);
2525 static inline krb5_data
2526 string2data(char *str)
2528 return make_data(str, strlen(str));
2531 static inline krb5_error_code
2532 alloc_data(krb5_data *data, unsigned int len)
2534 /* Allocate at least one byte since zero-byte allocs may return NULL. */
2535 char *ptr = (char *) calloc((len > 0) ? len : 1, 1);
2539 data->magic = KV5M_DATA;
2546 authdata_eq(krb5_authdata a1, krb5_authdata a2)
2548 return (a1.ad_type == a2.ad_type
2549 && a1.length == a2.length
2550 && !memcmp(a1.contents, a2.contents, a1.length));
2553 /* Allocate zeroed memory; set *code to 0 on success or ENOMEM on failure. */
2554 static inline void *
2555 k5alloc(size_t len, krb5_error_code *code)
2559 /* Allocate at least one byte since zero-byte allocs may return NULL. */
2560 ptr = calloc((len > 0) ? len : 1, 1);
2561 *code = (ptr == NULL) ? ENOMEM : 0;
2565 krb5_error_code KRB5_CALLCONV
2566 krb5_get_credentials_for_user(krb5_context context, krb5_flags options,
2568 krb5_creds *in_creds,
2570 krb5_creds **out_creds);
2572 krb5_error_code KRB5_CALLCONV
2573 krb5_get_credentials_for_proxy(krb5_context context,
2576 krb5_creds *in_creds,
2577 krb5_ticket *evidence_tkt,
2578 krb5_creds **out_creds);
2580 krb5_error_code KRB5_CALLCONV
2581 krb5int_get_authdata_containee_types(krb5_context context,
2582 const krb5_authdata *container,
2583 unsigned int *nad_types,
2584 krb5_authdatatype **ad_types);
2586 krb5_error_code krb5int_parse_enctype_list(krb5_context context,
2587 const char *profkey, char *profstr,
2588 krb5_enctype *default_list,
2589 krb5_enctype **result);
2591 #ifdef DEBUG_ERROR_LOCATIONS
2592 #define krb5_set_error_message(ctx, code, ...) \
2593 krb5_set_error_message_fl(ctx, code, __FILE__, __LINE__, __VA_ARGS__)
2595 void KRB5_CALLCONV_C
2596 krb5_set_error_message_fl(krb5_context ctx, krb5_error_code code,
2597 const char *file, int line, const char *fmt, ...)
2599 __attribute__((__format__(printf,5,6)))
2603 #ifndef DISABLE_TRACING
2604 /* Do not use these functions directly; see k5-trace.h. */
2605 void krb5int_init_trace(krb5_context context);
2608 #endif /* _KRB5_INT_H */